SetItemUseCheck
Decide before the game uses an item - a book read, a letter opened, food eaten.
Names an item class, a category of the item list or every item ("*") whose use waits for the
mode: when a player uses such an item from their bag, their game holds the use and asks, and OnPlayerUseItem decides -
false refuses it (nothing is read, eaten or applied; the item stays), anything else lets the game go on as usual. The
categories that have a use: "Document" (books, letters, maps, recipes), "Food", "Herb", "Ointment" (bandages; a
repair kit’s repair is no use - OnPlayerItemWear hears it and may undo it), "Poison". on = false takes a name back. A
use waits for the round trip to the server, so name what the mode means to judge, not every item.
Syntax
Section titled “Syntax”SetItemUseCheck(item [, on])| Parameter | Type | |
|---|---|---|
item |
string | an item (name, id or GUID), a category ("Document", "Food" …), or "*" for every item |
on |
boolean | true (the default) to decide first, false to take it back (optional) |
Returns
Section titled “Returns”boolean - false for an item or category the catalogue does not know
Example
Section titled “Example”-- the guild's recipes are learned only by its membersfunction OnGameModeInit() SetItemUseCheck("Document", true)endfunction OnPlayerUseItem(pid, class, health, buff) local info = GetItemInfo(class) if info and info.name:find("^recipe_") and not guildMember[pid] then ShowNotification(pid, "Only the guild may learn this.") return false endendSee also
Section titled “See also”OnPlayerUseItem · IsItemUseChecked · GetItemInfo · the Items and inventory group of the index
