C++ onAddItem Event Function

zxmatzx

Intermediate OT User
Joined
Dec 1, 2010
Messages
96
Reaction score
23
Hello,
I want a event function: onAddItem() that will be called when functions:
Lua:
Container:addItem()
Container:addItemEx()
Player:addItem()
Player:addItemEx()
I have some ideas how to do, but all forms involve C++, that i don't know.
What i realy need is: When i add a item to player or container, check if item.itemid is in table, and give a actionId to the item.
I know, i can do:
Lua:
player:addItem(8000, 1):setActionId(1000)
But this way, i always will have to set it manualy in each script that add the itens that is in the table.
The itens in table, will be unique itens, that can't be droped, moved, traded, i blocked this action on events, looking for the actionId in itens and returning false if have it.
With the table, i can do it automatically, just need to add new itens to table, and the function will give the actionId by itself.
I tryed look how events work, but realy don't know C++...
I think this will be a great function to the community, opening possibilities to new Scripts.
Thanks for attencion.
 
OP
Z

zxmatzx

Intermediate OT User
Joined
Dec 1, 2010
Messages
96
Reaction score
23
Bump
How can i send this sugestion on TFS github?
 

Stigma

Veteran OT User
Joined
Feb 14, 2015
Messages
4,587
Reaction score
2,147
Why do you specifically need an action id to make unique items that aren't discard-able? You can just check if a specific item id matches an id inside a list of ids you don't want players to be able to discard.
 
OP
Z

zxmatzx

Intermediate OT User
Joined
Dec 1, 2010
Messages
96
Reaction score
23
Why do you specifically need an action id to make unique items that aren't discard-able? You can just check if a specific item id matches an id inside a list of ids you don't want players to be able to discard.
Hello, thanks for answer.
I already did this, i have a global table with the itens that belongs to quests and can't be discarted. onStartup read this table and put all itemId inside a global array, when player try move or trade the events check if the itemId is in this array. My system already working. I just think this event will be a great contribution. I have unique itens and quest itens, both works in same way, but if i have this function, i can do:
Lua:
function onAddItem(item) --onAddItem Event. Could have more variables...
    if contains(GLOBAL_ARRAY_QUEST_ITENS, item.itemid) then --Check if item is a quest item
        item:setActionId(UNIQUE_ITEM_ACTION_ID) --Give unique item actionId to it
    end
end
And in my onMoveItem event, i need only check if the item have this actionId, and not the itemIds again.
Like i said, im don't needing this, but think will be great have it.
Thanks.
 
Top