OnPlayerNativeItem
The player’s game made an item of its own - return true to adopt it, false to have it removed.
In multiplayer the server gives every item the player carries, but the game still makes a few itself: a craft, a butchering, a
loot, a die, a tool’s work, the vial a drink leaves. The server has no record behind such an item; this callback is asked
first, as the item arrives (in observe too - there the answer only changes what the log says). kind names the producer:
craft- alchemy, cooking, drying, preparing;butcher- an animal butchered;loot- an animal looted;tool- what a lockpick, a blade or a shovel makes;dice- the dice game’s own dice;eat- what a meal leaves, an empty vial or a core;wear- the broken twin a destroyed weapon is swapped for (the server pairs it with the item that broke, so this reaches the mode only when it cannot);script- made by the game’s own Lua, which a cheat tool’s items arrive as too;setitems- the game’s own dressing of a spawn outfit (credited without asking inside the spawn’s first seconds);unmapped- made by a part of the game the server has no name for, which is where most unmodelled game code lands;foreign_inv- moved in from an inventory that is not the player’s;smith- what the player forged at an anvil: an item one of the game’s smithing recipes makes, arriving while the player’s smithing session is open (from the anvil’s start until half an hour after its start or its last product), with that recipe’s materials gone from the player’s bag in the session;herbis named for completeness: herbs picked in the world arrive as a take from the level (OnPlayerTakeWorldItem).
Return true to adopt the item (the records take it, as if the server had given it, whatever its class and number), false
to have it removed, or nothing to leave it to the server’s rule. The rule: an item the game made and no mode adopted is
accepted when it is an ordinary item, no more than 100 at once, within a limit of value a minute - a bigger limit for a
producer that really makes that kind of item (a craft makes food, herbs and alchemy, a butchering food and materials), a tight
one for the rest, so a normal craft passes and a flood does not; it is refused for the guarded categories
([audit] guarded_categories: weapons, armour, ammunition, money) until a mode adopts them here; and everything made by a
script of the game is refused while story quests are off. Items made by code outside the game are never asked about: they are
a foreign_call hint and are never credited, so under enforce they are removed. A smith item is accepted, a forged sword
or a horseshoe too, two pieces a minute at most - unless you return false (only the town’s smiths may forge, say). The
materials it was forged from are spent with it; an item made at the anvil while none of its recipes’ materials left the bag is
not the smith’s (a line in the log says so) and is judged like any other. The anvil’s hammer and tongs, which the game puts in
the player’s bag while they forge and takes back after, are the anvil’s during the session too. What the recipes make and take
comes from the game tables export; with an export made before it (the server’s log says so at the start) a melee weapon or a
horseshoe made at an anvil counts as forged and no materials are checked.
Syntax
Section titled “Syntax”function OnPlayerNativeItem(pid, kind, class, amount) -- ...end| Parameter | Type | |
|---|---|---|
pid |
number | the player |
kind |
string | the producer - craft, butcher, herb, loot, dice, tool, eat, wear, smith, script, setitems, unmapped or foreign_inv |
class |
string | the item class GUID (GetItemName names it) |
amount |
number | how many were made |
Returns
Section titled “Returns”true adopts the item, false has it removed, nothing (or nil) leaves it to the server’s rule
Example
Section titled “Example”function OnPlayerNativeItem(pid, kind, class, amount) -- only the town's blacksmiths may forge: anyone else's work at an anvil is taken away if kind == "smith" and not GetPlayerData(pid, "blacksmith") then return false end if kind == "loot" then return false end -- this server lets nothing be looted by the gameendSee also
Section titled “See also”OnPlayerAuditViolation · OnPlayerCheatDetected · GivePlayerItem · GetItemInfo · the Accounts, admins, bans and the audit group of the index
