• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved Help with player:addItem

LeOnArd0

Member
Joined
Jan 24, 2010
Messages
76
Reaction score
14
Hello guys!

I needed a light with a function to add the item to the player when completing a task.

My script is in extendopcode with integration in the client (it does the action through the window).

Here's a part of the script, if you need the whole let me know.

Lua:
                    player:addItem(task.item)  -- Here, if I add the direct ID of an item it delivers, however, it is not recognizing the call to task.item.

Tks for help!!

Greetings,
Leo
 
Last edited:
Lua:
print("Task Item: " .. task.item) --- lets see what it returns
task.item = tonumber(task.item) --- convert to number (sometimes table values are not recognized as number as default)
player:addItem(task.item)
 
@Dakos

this error appeared in the console
Lua:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/extendedopcode.lua:onExtendedOpcode
...rdo\Desktop\Drakens\Servidor\data\scripts\taskSystem.lua:217: attempt to concatenate field 'item' (a table value)
stack traceback:
        [C]: in function '__concat'
        ...rdo\Desktop\Drakens\Servidor\data\scripts\taskSystem.lua:217: in function 'onAction'
        data/creaturescripts/scripts/extendedopcode.lua:11: in function <data/creaturescripts/scripts/extendedopcode.lua:3>

This is line 11:
Code:
        TaskSystem.onAction(player, json.decode(buffer))
 
task.item not returning an id, its just return a table,

Lua:
for _, id in pairs(task.item) do
    player:addItem(id)
end

or just change
Lua:
itemRewards = {2646}
to
itemRewards = 2646
 
Back
Top