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

[REQUEST]Arena lever + Teleporter kick

nips

Da.Nb
Joined
Oct 15, 2009
Messages
152
Reaction score
0
Location
Germany
hi all,

This is my standart mini arena.

1. Player pos 1
2. Player pos 2
3. Looser kick pos
4. Winner exit pos



Can somebody create a scipt for my teleporter ?
it is stressfull to fight in arena and while you have to watch that u dont step on TP(pos 4).

Now i need a scipt that let the teleporter(pos 4) appear when one of two players got kicked ...

something like:

IF player 1 or player 2 kicked out of arena
Then playce teleporter on X,Y,Z.
IF player 1 or player 2 moved into teleporter on pos X,Y,Z
Then remove teleporter
Return.

Here are my Codes:

Server/actions

<action actionid="7667" script="arenalever.lua" />
<action uniqueid="7667" script="arenalever.lua" />
arenalever.lua
Code:
  local arenas = {
        [7667] = {
                fromPos ={
                        {x = 119, y = 38, z = 9},    --player 1 start pos
                        {x = 132, y = 38, z = 9}             --player 2 start pos
                                                                                        --you can add how much you want, there are no limits
                },
                toPos = {
                        {x = 122, y = 38, z = 9},    --player 1 teleport position
                        {x = 129, y = 38, z = 9}             --player 2 teleport position
                                                                                        --you can add how much you want, there are no limits
                }
        }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
        if(item.itemid == 1946) then
                doTransformItem(item.uid, 1945)
                return TRUE
        end

        local arena = arenas[item.uid]
        if(not arena) then
                return FALSE
        end

        local players = {}
        for _, pos in pairs(arena.fromPos) do
                pos.stackpos = STACKPOS_TOP_CREATURE
                local tmp = getThingfromPos(pos).uid
                if(tmp > 0 and isCreature(tmp) == TRUE) then
                        table.insert(players, tmp)
                end
        end

        if(table.maxn(players) < table.maxn(arena.fromPos)) then
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need more creatures for duel.")
                return TRUE
        end

        for i, pid in pairs(players) do
                doSendMagicEffect(arena.fromPos[i], CONST_ME_POFF)
                doTeleportThing(pid, arena.toPos[i])
                doSendMagicEffect(arena.toPos[i], CONST_ME_TELEPORT)
                doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, "FIGHT!")
        end

        return TRUE
end


Server/globalevents

<event type="preparedeath" name="Arena3" script="arena3.lua"/>
arena3.lua


Code:
  local arena = {
frompos = {x=121, y=35, z=9}, -- Top Left Corner
topos = {x=131, y=42, z=9}, -- Bottom Right Corner
exit = {x=126, y=33, z=9} -- Exit
}

function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
        if isPlayer(cid) == TRUE then
                if isInArea(getCreaturePosition(cid), arena.frompos, arena.topos) then
                        doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid), TRUE)
                        doTeleportThing(cid, arena.exit)
                        doSendMagicEffect(arena.exit, 10)
                        doPlayerSendTextMessage(mostDamageKiller,MESSAGE_STATUS_CONSOLE_ORANGE,'[ARENA] You have defeated '..getCreatureName(cid)..'!')
                        doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_RED,'[ARENA] You where defeated by '..getCreatureName(mostDamageKiller)..'!')
                end
                return true
        end
end


I hope somebody can help me.

Yours Nips
 
I also look for arena like this. I mean for script, to kick the player which die's not to "kill him" and I would like to enter more than 2 people to arena.
 
I modified your script:

If player1(or2) wins then both player get their full health back
and both player get portet out of the arena to the starting
positions.

Lua:
local arena = {
frompos = {x=121, y=35, z=9}, -- Top Left Corner
topos = {x=131, y=42, z=9}, -- Bottom Right Corner
player1pos = {x = 119, y = 38, z = 9}, --Starting/teleport pos player1
player2pos = {x = 132, y = 38, z = 9}  --Starting/teleport pos player2
}

function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
        if isPlayer(cid) == TRUE then
                if isInArea(getCreaturePosition(cid), arena.frompos, arena.topos) then
                        doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid), TRUE)
                       --Erase the line under if the winner shall have the current HP 
			doCreatureAddHealth(mostDamageKiller, getCreatureMaxHealth(mostDamageKiller) - getCreatureHealth(mostDamageKiller), TRUE)
                        doTeleportThing(cid, arena.player2pos)
			doTeleportThing(mostDamageKiller, arena.player1pos)
                        doSendMagicEffect(arena.player1pos, 10)
			doSendMagicEffect(arena.player2pos, 10)
                        doPlayerSendTextMessage(mostDamageKiller,MESSAGE_STATUS_CONSOLE_ORANGE,'[ARENA] You have defeated '..getCreatureName(cid)..'!')
                        doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_RED,'[ARENA] You where defeated by '..getCreatureName(mostDamageKiller)..'!')
                end
                return true
        end
end

But if you insist on the teleporter than use this script.
The teleporter will reset in 20 seconds.

Lua:
local arena = {
frompos = {x=121, y=35, z=9}, -- Top Left Corner
topos = {x=131, y=42, z=9}, -- Bottom Right Corner
exit = {x=126, y=33, z=9} -- Exit
exitpos = {x=X, y=X, z=X, stackpos=1} -- Where the teleporter appears *Edit it*
teleId = 1387, --ID of the teleporter
telepos = {x=X, y=X, z=X}, --Teleport position of the winner *Edit it*
timetoreset = 20*1000 --Resettime when the teleporter dissapears
}

function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
        if isPlayer(cid) == TRUE then
                if isInArea(getCreaturePosition(cid), arena.frompos, arena.topos) then
                        doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid), TRUE)
                        doTeleportThing(cid, arena.exit)
                        doSendMagicEffect(arena.exit, 10)
			doCreateTeleport(arena.teleId, arena.exitpos, arena.telepos)
                        doPlayerSendTextMessage(mostDamageKiller,MESSAGE_STATUS_CONSOLE_ORANGE,'[ARENA] You have defeated '..getCreatureName(cid)..'!')
                        doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_RED,'[ARENA] You where defeated by '..getCreatureName(mostDamageKiller)..'!')
			addEvent(resetTP, arena.timetoreset)
                end
                return true
        end
end

function resetTP()
doRemoveItem(getThingFromPos(arena.exitpos).uid, 1)
end

If you want the teleporte to dissappear if the player
steps in then you need an "onStepIn" function.
I can write it if you want.

Let me know.
 
Last edited:
Lua:
local arena = {
frompos = {x=121, y=35, z=9}, -- Top Left Corner
topos = {x=131, y=42, z=9}, -- Bottom Right Corner
exit = {x=126, y=33, z=9}, -- Exit
tpId = 1387,
remove = 60, -- time in seconds
tp = {x=x, y=y, z=z}, -- TP Position where will teleport
tp1 = {x=x, y=y, z=z} -- TP Position where will be teleported the player
}

local function removal(position)
    if getThingfromPos(position).itemid == arena.tpId then
        doRemoveItem(getThingfromPos(position).uid)
    end
    return TRUE
end 

function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
        if isPlayer(cid) == TRUE then
                if isInArea(getCreaturePosition(cid), arena.frompos, arena.topos) then
                        doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid), TRUE)
                        doTeleportThing(cid, arena.exit)
                        doSendMagicEffect(arena.exit, 10)
                        doPlayerSendTextMessage(mostDamageKiller,MESSAGE_STATUS_CONSOLE_ORANGE,'[ARENA] You have defeated '..getCreatureName(cid)..'!')
                        doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_RED,'[ARENA] You where defeated by '..getCreatureName(mostDamageKiller)..'!')
						teleport = doCreateTeleport(arena.teleportId, arena.tp1, arena.tp) 
						addEvent(removal, arena.remove * 1000, arena.tp)
				end
                return true
        end
end
 
Back
Top