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

CreatureEvent Pvp Arena TFS 1.x

Sir Islam

Never Give Up
Joined
Jun 6, 2008
Messages
504
Solutions
1
Reaction score
116
Location
Suez , Egypt
don't register in login and don't forget to remove Pvp tool from arena in map editor

in creaturescripts.xml put this code
Code:
<event type="login" name="Arena_Login" script="Arena_Death.lua"/>
<event type="preparedeath" name="Arena_Death" script="Arena_Death.lua"/>
make file name Arena_Death.lua and put this code
Code:
function onLogin(cid)
cid:registerEvent("Arena_Death")
return true
end

local arena = {
     from = {x=1590, y=1809, z=7}, -- left top corner of  arena
     to = {x=1669, y=1867, z=7}, -- right bottom corner of  arena
     temple = { x = 2000, y = 2000, 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
 
Last edited:
There are something wrong with teleport thing..

Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/events/Arena_Death.lua: onPrepareDeath
attempt to index a nil value
stack traceback:
        [C]: at 0x013f98bb90
        [C]: in function 'teleportTo'
        data/creaturescripts/scripts/events/Arena_Death.lua:17: in function <dat
a/creaturescripts/scripts/events/Arena_Death.lua:12>

---------------------------------------@edit

I've changed this line :

from
Code:
Player(cid):teleportTo(temple, true)

to
Code:
Player(cid):teleportTo(arena.temple, true)

And worked 100% for me (TFS 1.1)!!! THANK YOU


I was trying this script for a month, that is a beatiful one! Great job!

Now I can do a lot of events based on monster, the players can die without worries in a monster arena made by me! I'll release when I finish it. Can I tag you so?
 
Last edited:
Lua Script Error: [CreatureScript Interface] data/creaturescripts/scripts/events/Arena_Death.lua:eek:nPrepareDeath attempt to index a nil value stack traceback: [C]: at 0x013f98bb90 [C]: in function 'teleportTo' data/creaturescripts/scripts/events/Arena_Death.lua:17: in function <dat a/creaturescripts/scripts/events/Arena_Death.lua:12>

yes i forget to change it i fix it now :)
 
don't register in login and don't forget to remove Pvp tool from arena in map editor

in creaturescripts.xml put this code
Code:
<event type="login" name="Arena_Login" script="Arena_Death.lua"/>
<event type="preparedeath" name="Arena_Death" script="Arena_Death.lua"/>
make file name Arena_Death.lua and put this code
Code:
function onLogin(cid)
cid:registerEvent("Arena_Death")
return true
end

local arena = {
     from = {x=1590, y=1809, z=7}, -- left top corner of  arena
     to = {x=1669, y=1867, z=7}, -- right bottom corner of  arena
     temple = { x = 2000, y = 2000, 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
TFS 1.0 Error

sdsdsd.PNG
 
Back
Top