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

PVP Arena

Cosmotonio

New Member
Joined
Nov 26, 2007
Messages
142
Reaction score
0
I make this scrip, but is not inished yet.
If you kill a player with summon the server will crash.
If the hit is bigger than your life you are dead or the server will crash.

creaturescripts.xml
Code:
<event type="preparedeath" name="Arena" script="Arena.lua" />

arena.lua
Code:
local arenapos = {fromx=120, fromy=32, tox=129, toy=39, z=9} 
local exit = {x=125, y=30, z=9}

function onPrepareDeath(cid, killer)
    for i = arenapos.fromx, arenapos.tox do 
        for j = arenapos.fromy, arenapos.toy do 
            local pos = {x=i, y=j, z=arenapos.z, stackpos=253} 
            local getThing = getThingfromPos(pos).uid 
            if isPlayer(getThing) == 1 then
 			doTeleportThing(cid, exit, TRUE)
			doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
            end 
        end 
    end 
    return FALSE 
end

Please help me to fix
 
Last edited:
I don't understand your code... Why do you wanna check the whole area if you already got the uid of the player? :S

Wouldn't this do it?
PHP:
local arenapos = {fromx=120, fromy=32, tox=129, toy=39, z=9} 
local exit = {x=125, y=30, z=9}

function onPrepareDeath(cid, killer)
    for x=arenapos.fromx, arenapos.tox do 
        for y=arenapos.fromy, arenapos.toy do 
            if comparePos(getPlayerPosition(cid), {x=x, y=y, z=arenapos.z}) then
                doTeleportThing(cid, exit, TRUE)
                doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
                return TRUE
            end 
        end 
    end 
    return FALSE 
end
 
I don't understand your code... Why do you wanna check the whole area if you already got the uid of the player? :S

Wouldn't this do it?
PHP:
local arenapos = {fromx=120, fromy=32, tox=129, toy=39, z=9} 
local exit = {x=125, y=30, z=9}

function onPrepareDeath(cid, killer)
    for x=arenapos.fromx, arenapos.tox do 
        for y=arenapos.fromy, arenapos.toy do 
            if comparePos(getPlayerPosition(cid), {x=x, y=y, z=arenapos.z}) then
                doTeleportThing(cid, exit, TRUE)
                doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
                return TRUE
            end 
        end 
    end 
    return FALSE 
end




Work in TFS 2.11???
 
Alright, what about this one?
PHP:
local arena = {
	frompos = {x=120, y=32, z=9},
	topos = {x=129, y=39, z=9},
	exit = {x=125, y=30, z=9} 
}

local function exitArena(p)
    doSendMagicEffect(p.exit, 10)
    doTeleportThing(p.cid, p.exit, FALSE)
end

function onPrepareDeath(cid, killer)
    if isInArea(getPlayerPosition(cid), arena.frompos, arena.topos) then
        doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
        addEvent(exitArena, 100, {cid=cid, exit=arena.exit})
    end
    return FALSE
end

function isInArea(pos, fromPos, toPos)
    if pos.x >= fromPos.x and pos.x <= toPos.x then
        if pos.y >= fromPos.y and pos.y <= toPos.y then
            if pos.z >= fromPos.z and pos.z <= toPos.z then
                return true
            end
        end
    end
    return false
end
 
Last edited:
Code:
local arena = {
    frompos = {x=308, y=227, z=5},
    topos = {x=324, y=232, z=5},
    exit = {x=316, y=225, z=5}
}

function onPrepareDeath(cid, killer)
    if isInArea(getPlayerPosition(cid), area.frompos, area.topos) then
        doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
        doSendMagicEffect(arena.exit, 10)
        doTeleportThing(cid, arena.exit, TRUE)
    end
    return FALSE
end

function isInArea(pos, fromPos, toPos)
    if pos.x >= fromPos.x and pos.x <= toPos.x then
        if pos.y >= fromPos.y and pos.y <= toPos.y then
            if pos.z >= fromPos.z and pos.z <= toPos.z then
                return true
            end
        end
    end
    return false
end

Colandus, I'm using your script, but in the end, the player is not teleported to the "Exit Area", but to his temple... and in the console appears an error at the line 8, saying something about "global area"

please fix it ^^
 
The server is still crashing... The bug is when you put "if isInArea(getPlayerPosition(cid), arena.frompos, arena.topos) then", cause yesterday I was testing with "area", and the server didn't crash, but didn't teleport the player to the "Exit" after his 'death', but to his temple (Btw, teleporting the player to his temple don't means that he is dead)


EDIT> I took off these 2 lines:
Code:
        doSendMagicEffect(arena.exit, 10)
        doTeleportThing(cid, arena.exit, FALSE)
and the server is not crashing anymore, and is not showing any errors on the console. When I "kill" the player, his life back to the green, and he is not teleported (of course). So, the bug is on these 2 lines :p
 
Last edited:
Yes, I knew that already... Just that I don't know what causes it ^.-

But you could try adding an event (will update the last script with it)...
 
Now it's working ok.. only 1 little problem: If the "killer kills the killed" :)P) by a headshot, the other player is teleported to the outside of the arena as dead. Example:

you have 310 of life, and I hit 300 with my sd... I will SD you twice, and you will be teleported to the outside of the arena, everything ok...
but...
you have 310 of life, and I hit 320 with my sd... I will SD you once, and you will be teleported to the outside of the arena as dead :S
 
Back
Top