Hello guys, i'm an problem with tables.
This is a code of LIB
This code make two items in game and add two values in table called (CACHE_GAMEEVENTS), with values (UID and Event ID), but when i call this function in actions, the table return 0 values.
But if i try print the value of table in talkactions, work.
Sorry by the bad english.
This is a code of LIB
Code:
Event_Lightberear = {
CACHE_GAMEEVENTS = {},
}
local function transformItem(pos, id, newId)
return doTransformItem(getTileItemById(pos, id).uid, newId)
end
Event_Lightberear.createEvent = function ()
for _, pos in ipairs(Lightberear_Configurations.Torchs_Positions) do
local newTorch = doCreateItem(1234, 1, pos)
doItemSetAttribute(newTorch, "Torch_ID", newTorch)
local event = addEvent(transformItem, 10, pos, 1234, 4321)
table.insert(Event_Lightberear.CACHE_GAMEEVENTS, {uid = newTorch, eid = event})
end
return true
end
This code make two items in game and add two values in table called (CACHE_GAMEEVENTS), with values (UID and Event ID), but when i call this function in actions, the table return 0 values.
Code:
function onUse(cid, item, frompos, item2, topos)
print("[Action] Table Value: ".. #Event_Lightberear.CACHE_GAMEEVENTS)
return true
end
But if i try print the value of table in talkactions, work.
Code:
function onSay(cid, words, param, channel)
if param == "1" then
Event_Lightberear.createEvent()
else
print("[Talkaction] Table Value: ".. #Event_Lightberear.CACHE_GAMEEVENTS)
end
return true
end
Sorry by the bad english.
Last edited: