• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved PVP Arena ( Need 2 player to fight bug)

Ray Rewind

Doctor
Joined
Jun 6, 2009
Messages
1,349
Reaction score
76
Location
Germany
2014-01-08_14h08_48.png

Pvp Arena ain't working

The arena doesn't work it says you need 2 players to duell.

action script

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local firstPlayerPosition = {x = 889, y = 1025, z = 7, stackpos = STACKPOS_TOP_CREATURE}
    local getFirstPlayer = getThingFromPos(firstPlayerPosition)
    local secondPlayerPosition = {x = 889, y = 1027, z = 7, stackpos = STACKPOS_TOP_CREATURE}
    local getSecondPlayer = getThingFromPos(secondPlayerPosition)
    local arenaLevel = 100
    local newFirstPlayerPosition = {x = 881, y = 1025, z = 7}
    local newSecondPlayerPosition = {x = 886, y = 1025, z = 7}
    if(item.uid == 7005) then
        if(getFirstPlayer.itemid > 0 and getSecondPlayer.itemid > 0) then
            if(getPlayerLevel(getFirstPlayer.uid) >= arenaLevel and getPlayerLevel(getSecondPlayer.uid) >= arenaLevel) then
                for arenax = 880, 1022 do
                    for arenay = 887, 1029 do
                        local arenaPosition = {x=arenax, y=arenay, z=7, stackpos=253}
                        local arenaCreature = getThingFromPos(arenaPosition)
                        if(arenaCreature.itemid > 0 and isPlayer(arenaCreature.uid) == FALSE) then
                            if(isMonster(arenaCreature.uid) == TRU[ATTACH=full]23752[/ATTACH] E) then
                                doRemoveCreature(arenaCreature.uid)
                            end
                        elseif(arenaCreature.itemid > 0 and isPlayer(arenaCreature.uid) == TRUE) then
                            doPlayerSendCancel(cid, "Wait for current duel to end.")
                            return TRUE
                        end
                    end
                end
                if(item.itemid == 1945) then
                    doTransformItem(item.uid, 1946)
                elseif(item.itemid == 1946) then
                    doTransformItem(item.uid, 1945)
                end
                doSendMagicEffect(firstPlayerPosition, 2)
                doSendMagicEffect(secondPlayerPosition, 2)
                doTeleportThing(getFirstPlayer.uid, newFirstPlayerPosition)
                doTeleportThing(getSecondPlayer.uid, newSecondPlayerPosition)
                doSendMagicEffect(newFirstPlayerPosition, 10)
                doSendMagicEffect(newSecondPlayerPosition, 10)
                doPlayerSendTextMessage(getFirstPlayer.uid, 18, "FIGHT!")
                doPlayerSendTextMessage(getSecondPlayer.uid, 18, "FIGHT!")
            else
                doPlayerSendCancel(cid, "Both fighters must have level 100.")
            end
        else
            doPlayerSendCancel(cid, "You need 2 players for a duel.")
        end
    end
    return TRUE
end


movements

Code:
function onStepIn(cid, item, fromPosition, itemEx, toPosition)
local playerPosition = getPlayerPosition(cid)
local newPosition = {x=1038, y=988, z=8}
local gethp = getCreatureHealth(cid)
local getmaxhp = getCreatureMaxHealth(cid)
local add = getmaxhp - gethp
    if(item.actionid == 7709) then
        getThingfromPos(playerPosition)
        doSendMagicEffect(playerPosition,2)
        doTeleportThing(cid,newPosition)
        doSendMagicEffect(newPosition,10)
        doCreatureAddHealth(cid, add, TRUE)
        doRemoveCondition(cid, CONDITION_INFIGHT)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have escaped.")
    end
return TRUE
end


Code:
function onStepIn(cid, item, pos)

local tpout = {x=891, y=1026, z=7}
local level = 1

    if isCreature(cid) == TRUE then
        if getPlayerLevel(cid) > level then
            doTeleportThing(cid, tpout)
            doSendMagicEffect(getPlayerPosition(cid), 10)
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You left the arena.")
            return 0
        end
    else
        return 0
    end
return true
end
 
You need to change getFirstPlayer.itemid and getSecondPlayer.itemid to
getFirstPlayer.uid and getSecondPlayer.uid

Then it will work fine.
 
if(getFirstPlayer.itemid > 0 and getSecondPlayer.itemid > 0) then
if(getPlayerLevel(getFirstPlayer.uid) >= arenaLevel and getPlayerLevel(getSecondPlayer.uid) >= arenaLevel) then


Why?
 
if(getFirstPlayer.itemid > 0 and getSecondPlayer.itemid > 0) then
if(getPlayerLevel(getFirstPlayer.uid) >= arenaLevel and getPlayerLevel(getSecondPlayer.uid) >= arenaLevel) then


Why?
Now change for first line too.

Because you are searching for a player not item, using itemid when searching creature stack position will always return 0
 
here

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local firstPlayerPosition = {x = 889, y = 1025, z = 7, stackpos = STACKPOS_TOP_CREATURE}
    local getFirstPlayer = getThingFromPos(firstPlayerPosition)
    local secondPlayerPosition = {x = 889, y = 1027, z = 7, stackpos = STACKPOS_TOP_CREATURE}
    local getSecondPlayer = getThingFromPos(secondPlayerPosition)
    local arenaLevel = 100
    local newFirstPlayerPosition = {x = 881, y = 1025, z = 7}
    local newSecondPlayerPosition = {x = 886, y = 1025, z = 7}
    if(item.uid == 7005) then
        if(getFirstPlayer.uid > 0 and getSecondPlayer.uid > 0) then
            if(getPlayerLevel(getFirstPlayer.uid) >= arenaLevel and getPlayerLevel(getSecondPlayer.uid) >= arenaLevel) then
                for arenax = 880, 1022 do
                    for arenay = 887, 1029 do
                        local arenaPosition = {x=arenax, y=arenay, z=7, stackpos=253}
                        local arenaCreature = getThingFromPos(arenaPosition)
                        if(arenaCreature.uid > 0 and isPlayer(arenaCreature.uid) == FALSE) then
                            if(isMonster(arenaCreature.uid) == TRUE) then
                                doRemoveCreature(arenaCreature.uid)
                            end
                        elseif(arenaCreature.uid > 0 and isPlayer(arenaCreature.uid) == TRUE) then
                            doPlayerSendCancel(cid, "Wait for current duel to end.")
                            return TRUE
                        end
                    end
                end
                if(item.itemid == 1945) then
                    doTransformItem(item.uid, 1946)
                elseif(item.itemid == 1946) then
                    doTransformItem(item.uid, 1945)
                end
                doSendMagicEffect(firstPlayerPosition, 2)
                doSendMagicEffect(secondPlayerPosition, 2)
                doTeleportThing(getFirstPlayer.uid, newFirstPlayerPosition)
                doTeleportThing(getSecondPlayer.uid, newSecondPlayerPosition)
                doSendMagicEffect(newFirstPlayerPosition, 10)
                doSendMagicEffect(newSecondPlayerPosition, 10)
                doPlayerSendTextMessage(getFirstPlayer.uid, 18, "FIGHT!")
                doPlayerSendTextMessage(getSecondPlayer.uid, 18, "FIGHT!")
            else
                doPlayerSendCancel(cid, "Both fighters must have level 100.")
            end
        else
            doPlayerSendCancel(cid, "You need 2 players for a duel.")
        end
    end
    return TRUE
end


changed all .itemid to uid except for where it actually uses item such as 1945. and 1946
 
[27/01/2014 06:39:44] [Error - LuaScriptInterface::loadFile] data/actions/scripts/pvparena/arenalever.lua:17: ']' expected near '='
[27/01/2014 06:39:44] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/pvparena/arenalever.lua)
[27/01/2014 06:39:44] data/actions/scripts/pvparena/arenalever.lua:17: ']' expected near '='
 
Now
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local firstPlayerPosition = {x = 889, y = 1025, z = 7, stackpos = STACKPOS_TOP_CREATURE}
    local getFirstPlayer = getThingFromPos(firstPlayerPosition)
    local secondPlayerPosition = {x = 889, y = 1027, z = 7, stackpos = STACKPOS_TOP_CREATURE}
    local getSecondPlayer = getThingFromPos(secondPlayerPosition)
    local arenaLevel = 100
    local newFirstPlayerPosition = {x = 881, y = 1025, z = 7}
    local newSecondPlayerPosition = {x = 886, y = 1025, z = 7}
    if(item.uid == 7005) then
        if(getFirstPlayer.uid > 0 and getSecondPlayer.uid > 0) then
            if(getPlayerLevel(getFirstPlayer.uid) >= arenaLevel and getPlayerLevel(getSecondPlayer.uid) >= arenaLevel) then
                for arenax = 880, 1022 do
                    for arenay = 887, 1029 do
                        local arenaPosition = {x=arenax, y=arenay, z=7, stackpos=253}
                        local arenaCreature = getThingFromPos(arenaPosition)
                        if(arenaCreature.uid > 0) then
                            if(isMonster(arenaCreature.uid)) then
                                doRemoveCreature(arenaCreature.uid)
                            end
                            if(arenaCreature.uid > 0 and isPlayer(arenaCreature.uid)) then
                                doPlayerSendCancel(cid, "Wait for current duel to end.")
                                return TRUE
                            end
                        end
                    end
                end
                if(item.itemid == 1945) then
                    doTransformItem(item.uid, 1946)
                elseif(item.itemid == 1946) then
                    doTransformItem(item.uid, 1945)
                end
                doSendMagicEffect(firstPlayerPosition, 2)
                doSendMagicEffect(secondPlayerPosition, 2)
                doTeleportThing(getFirstPlayer.uid, newFirstPlayerPosition)
                doTeleportThing(getSecondPlayer.uid, newSecondPlayerPosition)
                doSendMagicEffect(newFirstPlayerPosition, 10)
                doSendMagicEffect(newSecondPlayerPosition, 10)
                doPlayerSendTextMessage(getFirstPlayer.uid, 18, "FIGHT!")
                doPlayerSendTextMessage(getSecondPlayer.uid, 18, "FIGHT!")
            else
                doPlayerSendCancel(cid, "Both fighters must have level 100.")
            end
        else
            doPlayerSendCancel(cid, "You need 2 players for a duel.")
        end
    end
    return TRUE
end
 
It's the coordinate for
Code:
for arenax = TOPLEFTX, BOTTOMRIGHTX do
for arenax = TOPLEFTY, BOTTOMRIGHTY do

Use that format for the arena and make sure that if it's on a seperate floor for z you set the z position in local arenaPosition.
 
alright then follow that format I showed above, you have the coordinates set wrong, the coordinates say that it will check the tiles the players are standing in when they pull the lever. so the coordinates are wrong.
 
Okay I forgot that pic was there, that clearly shows the coordinates are incorrect. If you look at the format I said to you, you are using.

for arenax = left X, top Y do
for arenay = right X, bottom Y do

so it is scanning from 880 - 1022 X instead of 880 - 888 x
and scanning from 887 - 1029 Y instead of 1022 - 1030
so you were basically scanning a line of squares not even an area.

you should be using.

for arenax = left X, right X do
for arenay = top Y, bottom Y do

Hopefully this will help you understand for if you make another script like this. =)

here is fixed script with coordinates.
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local firstPlayerPosition = {x = 889, y = 1025, z = 7, stackpos = STACKPOS_TOP_CREATURE}
    local getFirstPlayer = getThingFromPos(firstPlayerPosition)
    local secondPlayerPosition = {x = 889, y = 1027, z = 7, stackpos = STACKPOS_TOP_CREATURE}
    local getSecondPlayer = getThingFromPos(secondPlayerPosition)
    local arenaLevel = 100
    local newFirstPlayerPosition = {x = 881, y = 1025, z = 7}
    local newSecondPlayerPosition = {x = 886, y = 1025, z = 7}
    if(item.uid == 7005) then
        if(getFirstPlayer.uid > 0 and getSecondPlayer.uid > 0) then
            if(getPlayerLevel(getFirstPlayer.uid) >= arenaLevel and getPlayerLevel(getSecondPlayer.uid) >= arenaLevel) then
                for arenax = 880, 888 do
                    for arenay = 1022, 1030 do
                        local arenaPosition = {x=arenax, y=arenay, z=7, stackpos=253}
                        local arenaCreature = getThingFromPos(arenaPosition)
                        if(arenaCreature.uid > 0) then
                            if(isMonster(arenaCreature.uid)) then
                                doRemoveCreature(arenaCreature.uid)
                            end
                            if(arenaCreature.uid > 0 and isPlayer(arenaCreature.uid)) then
                                doPlayerSendCancel(cid, "Wait for current duel to end.")
                                return TRUE
                            end
                        end
                    end
                end
                if(item.itemid == 1945) then
                    doTransformItem(item.uid, 1946)
                elseif(item.itemid == 1946) then
                    doTransformItem(item.uid, 1945)
                end
                doSendMagicEffect(firstPlayerPosition, 2)
                doSendMagicEffect(secondPlayerPosition, 2)
                doTeleportThing(getFirstPlayer.uid, newFirstPlayerPosition)
                doTeleportThing(getSecondPlayer.uid, newSecondPlayerPosition)
                doSendMagicEffect(newFirstPlayerPosition, 10)
                doSendMagicEffect(newSecondPlayerPosition, 10)
                doPlayerSendTextMessage(getFirstPlayer.uid, 18, "FIGHT!")
                doPlayerSendTextMessage(getSecondPlayer.uid, 18, "FIGHT!")
            else
                doPlayerSendCancel(cid, "Both fighters must have level 100.")
            end
        else
            doPlayerSendCancel(cid, "You need 2 players for a duel.")
        end
    end
    return TRUE
end
 
Last edited:
Back
Top