Skip to content

OnPlayerItemWear

One of the player’s items wore down or was mended.

The player’s game changed the condition of an item in their bag by at least a whole percent: a blow, a block or a shot wore it (after is lower), or a smith, a whetstone or a repair kit mended it (after is higher). Both are the percent the game’s inventory shows, 0..100 (GetPlayerItemHealth). How fast items wear at all is SetItemWear’s; this is where a mode decides about one change: return nothing to let it be, false to keep the item as it was (their game is set back), or a number to set the condition to (their game is set to it). An item that arrives (a give, a pickup, a chest’s) and the mode’s own SetPlayerItemHealth are no wear and do not come here; nor does a horse’s saddlebags’ item. A worn piece’s new condition reaches the other players’ screens with it, at most once a second.

Repair kits. A kit’s repair comes here twice: the repaired item’s mend (after higher) and the kit’s own loss - a kit’s charge is its condition (its category is "Ointment"). To undo a repair, keep both: false for the item’s mend and for the kit’s loss. The grindstone’s sharpening is a mend too.

function OnPlayerItemWear(pid, class, before, after)
-- ...
end
Parameter Type
pid number the player
class string the item class GUID
before number the condition before, 0..100
after number the condition their game holds now, 0..100

nil to let it be, false to keep before, or a number - the condition the item should have

-- a sparring yard: nothing wears inside it
function OnPlayerItemWear(pid, class, before, after)
if after < before and IsPlayerInZone(pid, yard) then return false end
end

SetItemWear · GetPlayerItemHealth · SetPlayerItemHealth · the Items and inventory group of the index