• 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]lever scipt

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
 
my scripts works 100%
but i want to include that the teleportet appears after
player 1 or player 2 got kicked !!
(teleporter appears for 20 seconds)
 
First Script: Edit

Code:
local tpPos = {x=100, y=100, z=7}
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!")
    doRemoveItem(getTileItemById(1387,tpPos).uid)
    return TRUE
end

Second Script: Add
Code:
local tele = {x=100, y=100, z=7} -- Create Here
local exit = {x=100, y=100, z=7} -- Where Tele Takes You
doCreateTeleport(1387, exit, tele)
 
in wich lines do i have to add ??

now my scipts looks like this:

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
}

  local tele = {
  local tele = {x=126, y=35, z=9} -- Create Here
local exit = {x=126, y=33, z=9} -- Where Tele Takes You
doCreateTeleport(1387, exit, tele)
}

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

and:
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
                }
        }
}

  local tpPos = {
	local tpPos = {x=126, y=35, z=9}
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!")
    doRemoveItem(getTileItemById(1387,tpPos).uid)
    return TRUE
end
}

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


but now it works anymore :(
 
Last edited:
Edit the positions.

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} -- Where loser goes
}

local tele = {x=100, y=100, z=7} -- Create Teleport Here
local exit = {x=126, y=33, z=9} -- Where Tele Takes You
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(1387, exit, tele)
                        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

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

        local tpPos = {x=100, y=100, z=7}
        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!")
		doRemoveItem(getTileItemById(1387,tpPos).uid)
		return TRUE
	end
end
 
Back
Top