filipus
Member
- Joined
- Dec 31, 2010
- Messages
- 229
- Reaction score
- 12
So I'm using the isInArea function. I don't know why but it doesn't seem to be working.
Here is my code:
For some reason the getPlayerPosition(cid) doesn't seem to be returning any value.
This is the error:
Can anyone help?
Still trying to learn
Here is my code:
Code:
local arena = {
frompos = {x=32389, y=32188, z=7},
topos = {x=32403, y=32201, z=7},
exit = {x=32404, y=32204, z=7}
}
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
if isPlayer(cid) == TRUE then
if isInArea(getPlayerPosition(cid), arena.frompos, arena.topos) then
if doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid), TRUE) == TRUE then
if doTeleportThing(cid, arena.exit) == TRUE then
doSendMagicEffect(arena.exit, 10)
doPlayerSendTextMessage(mostDamageKiller,MESSAGE_STATUS_CONSOLE_BLUE,'[ARENA] You have defeated '..getPlayerName(cid)..'!')
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'[ARENA] You are defeated by '..getPlayerName(mostDamageKiller)..'!')
return FALSE
end
end
end
end
return TRUE
end
For some reason the getPlayerPosition(cid) doesn't seem to be returning any value.
This is the error:
Code:
[05/04/2014 13:25:14] [Error - CreatureScript Interface]
[05/04/2014 13:25:14] data/creaturescripts/scripts/arena.lua:onPrepareDeath
[05/04/2014 13:25:14] Description:
[05/04/2014 13:25:14] data/lib/032-position.lua:2: attempt to index global 'position' (a nil value)
[05/04/2014 13:25:14] stack traceback:
[05/04/2014 13:25:14] data/lib/032-position.lua:2: in function 'isInArea'
[05/04/2014 13:25:14] data/creaturescripts/scripts/arena.lua:11: in function <data/creaturescripts/scripts/arena.lua:9>
Can anyone help?
Still trying to learn