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;herbandsmithare named for completeness: the server has no producer under either name yet, so herbs picked in the world arrive as a take from the level (OnPlayerTakeWorldItem) and smithing, which is not among the producers the server knows, should arrive asunmapped- theunmappedlines in the log, which name where the item came from, show it.
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) - smithing a sword included - 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 mode that wants smithing to work adopts the
classes it chooses of smith and unmapped, by the class’s category (GetItemInfo) and the player’s role - and checks
with observe first which kind its smiths’ work arrives as.
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) local info = GetItemInfo(class) -- a blacksmith's own work is theirs (observe first shows which kind the game's smithing arrives as) if (kind == "smith" or kind == "unmapped") and info and info.category == "MeleeWeapon" and GetPlayerData(pid, "blacksmith") then return true 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
