Hi, I wanted to add multiple positions and a number that will change (0/1) for specific player to the table and after few seconds remove it. Code so far:
1. global.lua
2. spells\mySpell.lua
3. actions\spellClick.lua
This is what happens when you execute spell first time and then click on item:
This is what happens when you execute spell second time and then click on item: (as you can see, the table increased)
And this is how the table is structured I guess:
GLOBAL_INFO = {
21732837 = {0, {{X, Y, Z}, {X, Y, Z}, {X, Y, Z}}}
}
/Edit
Not even this helps in myFunction:
GLOBAL_TRIGGERED = {}
1. global.lua
Lua:
GLOBAL_MYINFO = {}
2. spells\mySpell.lua
Lua:
local createdItemsPos =
{
Position(targetPos.x - 1, targetPos.y, targetPos.z), -- left
Position(targetPos.x + 1, targetPos.y, targetPos.z), -- right
Position(targetPos.x, targetPos.y + 1, targetPos.z), -- top
Position(targetPos.x, targetPos.y - 1, targetPos.z), -- bottom
}
local function myFunction(cid)
local player = Player(cid)
local target = player:getTarget()
for tableId, tableTrigger in pairs(GLOBAL_MYINFO) do
if tableId == target:getId() then
if tableTrigger[1] == 1 then
print("triggered")
GLOBAL_MYINFO[target:getId()] = nil -- this should clear tables
end
end
end
end
function onCastSpell(cid, var)
local player = Player(cid)
local target = player:getTarget()
local targetPos = target:getPosition()
GLOBAL_MYINFO[target:getId()] = {0, createdItemsPos}
addEvent(myFunction, 8000, cid)
return true
end
3. actions\spellClick.lua
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local creature = Creature(cid)
print("\nNEW LINE---")
for tableId, tableTrigger in pairs(GLOBAL_MYINFO) do
if creature:getId() ~= tableId then -- if creature ID is not in the table then stop execution
return false
end
for k, v in pairs(tableTrigger[2]) do
print(k, v)
end
tableTrigger[1] = 1 -- trigger
end
return true
end
This is what happens when you execute spell first time and then click on item:
This is what happens when you execute spell second time and then click on item: (as you can see, the table increased)
And this is how the table is structured I guess:
GLOBAL_INFO = {
21732837 = {0, {{X, Y, Z}, {X, Y, Z}, {X, Y, Z}}}
}
/Edit
Not even this helps in myFunction:
GLOBAL_TRIGGERED = {}
Last edited: