• 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:
Ehrm, try this then:
PHP:
local arena = { 
    frompos = {x=120, y=32, z=9}, 
    topos = {x=129, y=39, z=9}, 
    exit = {x=125, y=30, z=9}  
} 

function onPrepareDeath(cid, killer) 
    if isInArea(getCreaturePosition(cid), arena.frompos, arena.topos) then
        doSendMagicEffect(arena.exit, 10) 
        doTeleportThing(cid, arena.exit, FALSE) 
        doCreatureAddHealth(cid, getCreatureMaxHealth(cid)) 
    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

:eek:
 
Last edited:
Code:
local arena = {
    frompos = {x=308, y=227, z=5},
    topos = {x=324, y=232, z=5},
    exit = {x=324, y=232, z=6} 
}

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

function onPrepareDeath(cid, killer)
    if isInArea(getPlayerPosition(cid), arena.frompos, arena.topos) then
        addEvent(exitArena, 100, {cid=cid, exit=arena.exit})
	doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
    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

I'm using this script, it's working normally, unless when you get a HEADSHOT. When it happens, you die after been teleported :S
 
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



I use and debug server.

Use TFS 2.11
 
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

has any1 found a fix to this? this is the code with the problem stated as above which works the best atm, that i know of.

Code:
local arena = {
    frompos = {x=187, y=406, z=10},
    topos = {x=198, y=412, z=10},
    exit = {x=185, y=409, z=9} 
}

local function exitArena(p)
    doSendMagicEffect(p.exit, 10)
    doTeleportThing(p.cid, p.exit, FALSE)
    doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
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
code by colandus
 
If you want it solved, addEvent should not be used... Because it takes 0.1 seconds before it teleports out of the arena!

Idk what's wrong, but it's a really weird error.
 
and i guess you cant use a zero for the time delay in the addevent?

of course you can, but this would be the same as when you write the action without adding an event.
I tryed to script this stuff too..., but I always got the same bug. Player is dead in the temple. I guess it would work if you could manage it to add the health to the player about 100 ms after his "dead".
 
Cant get it to work either, closest i get is player standing with 0 health and wont die it all.
 
Last edited:
if u use tfs 0,3+ its possible to make 100% perfect pvp arena in tfs, ive done it so keep trying :)

tip: heal the player before you tp him, and use FORCE = TRUE in addhealth.

edit: for those who get tfs crash when using colandus script, its cuz u teleport the player when he is "dead". heal him first, then teleport and you are good ;)

PLZZZ REP MI
 
Back
Top