I am trying to pass arguments to another function but I get this error:
Here is my code:
I am also wondering why it executes the player(cid) does not exist, when it does (line 3)
tfs 1.0
Code:
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
data/spells/scripts/test.lua:6: attempt to index local 'oldTarget' (a nil value)
stack traceback:
[C]: in function '__index'
data/spells/scripts/test.lua:6: in function <data/spells/scripts/test.lua:1>
Here is my code:
Lua:
function repeatF(cid, oldTarget, var)
local player = Player(cid)
if not player then
print("Creature no longer exists")
setPlayerStorageValue(oldTarget, 2105, -1)
oldTarget:setNoMove(false)
return
end
print("Creature still exists")
local target = Player(cid):getTarget()
local mana = Player(cid):getMana()
if target and target == oldTarget then
Player(cid):addMana(-50)
addEvent(repeatF, 500)
else
Player(cid):setNoMove(false)
oldTarget:setNoMove(false)
setPlayerStorageValue(cid, 2104, -1)
if oldTarget:isPlayer() then
setPlayerStorageValue(oldTarget, 2105, -1)
end
return true
end
end
function onCastSpell(cid, var)
local oldTarget = Player(cid):getTarget()
if not Player(cid) or not oldTarget then
return
end
Player(cid):setNoMove(true)
oldTarget:setNoMove(true)
repeatF(cid, oldTarget, var)
return doCombat(cid, combat, var)
end
I am also wondering why it executes the player(cid) does not exist, when it does (line 3)
tfs 1.0