• 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!

Problem with one creaturescripts

BugaS

Donżuan
Joined
Mar 12, 2009
Messages
1,219
Reaction score
9
Location
NYC
Hey guys!

I've got:
Lua:
function onLogin(cid)

return true
end
local arena = {
     from = {x = 459, y = 15, z = 7}, -- left top corner of  arena
     to = {x = 470, y = 18, z = 7}, -- right bottom corner of  arena
     temple = { x = 472, y = 11, z = 7 } -- change it to temple pos
}
function onPrepareDeath(cid, killer)
    if isInRange(getPlayerPosition(cid), arena.from,arena.to) then
        if isPlayer(cid) then
            Player(cid):addHealth(Player(cid):getMaxHealth())
            Player(cid):addMana(Player(cid):getMaxMana())
            Player(cid):teleportTo(arena.temple, true)
            return false
        end
    end
   return true
end
function isInRange(pos, fromPos, toPos)
   return pos.x >= fromPos.x and pos.y >= fromPos.y and pos.z >= fromPos.z and pos.x <= toPos.x and pos.y <= toPos.y and pos.z <= toPos.z
end

And on death there I'm getting this error and standing without HP:
Code:
1:28:38.785] [Error - CreatureScript Interface]
[1:28:38.785] data/creaturescripts/scripts/Arena_Ups.lua:onPrepareDeath
[1:28:38.785] Description:
[1:28:38.785] data/creaturescripts/scripts/Arena_Ups.lua:15: attempt to call global 'Player' (a nil value)
[1:28:38.786] stack traceback:
[1:28:38.786]   data/creaturescripts/scripts/Arena_Ups.lua:15: in function <data/creaturescripts/scripts/Arena_Ups.lua:12>

[1:28:39.293] [Error - CreatureScript Interface]
[1:28:39.293] data/creaturescripts/scripts/Arena_Ups.lua:onPrepareDeath

Where is the problem? I think, that this is script for 1.x but i need it for 0.4
 
its simple
dont use Player(cid)
turn the function names into doCreatureXXXX
example:
Player(cid):addHealth(Player(cid):getMaxHealth())
to
doCreatureAddHealth(cid, getCreatureMaxHealth(cid)
 
its simple
dont use Player(cid)
turn the function names into doCreatureXXXX
example:
Player(cid):addHealth(Player(cid):getMaxHealth())
to
doCreatureAddHealth(cid, getCreatureMaxHealth(cid)
Thanks!

Is it okay?
Lua:
function onLogin(cid)
return true
end
local arena = {
     from = {x = 459, y = 15, z = 7}, -- left top corner of  arena
     to = {x = 470, y = 18, z = 7}, -- right bottom corner of  arena
     temple = { x = 472, y = 11, z = 7 } -- change it to temple pos
}
function onPrepareDeath(cid, killer)
    if isInRange(getPlayerPosition(cid), arena.from,arena.to) then
        if isPlayer(cid) then
            doCreatureAddHealth(cid, getCreatureMaxHealth(cid)
            doCreatureAddMana(cid, getCreatureMaxMana(cid)
            doTeleportThing(arena.temple, true)
            return false
        end
    end
   return true
end
function isInRange(pos, fromPos, toPos)
   return pos.x >= fromPos.x and pos.y >= fromPos.y and pos.z >= fromPos.z and pos.x <= toPos.x and pos.y <= toPos.y and pos.z <= toPos.z
end

#EDIT

I'm getting:

Code:
[10:2:56.476] [Error - CreatureScript Interface]
[10:2:56.476] data/creaturescripts/scripts/Arena_Ups.lua:onPrepareDeath
[10:2:56.476] Description:
[10:2:56.476] (luaDoTeleportThing) Thing not found
@Xeraphus
 
Last edited:
Back
Top