• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

Arena 1v1 [LUA] Errors Help Me

Status
Not open for further replies.

Aquilla

Enthusiast
I found one arena 1v1 script lua (Eluna 3.3.5) on pastebin

Link : http://pastebin.com/QNTmKspX#

But have some errors in the script (On Join in logests maps the arena 1v1 is cancelled and more errors)

Haves the Spectator and also has the spectator arena 1v1

Please Help's Me
 

Rochet2

Moderator / Eluna Dev
The error and big mistake in your code is this:
table.insert(OvO.plrQue, player) -- Insert into players with value player

You should NOT save a player somewhere and access it later.
Saving a player is the same as saving a pointer with no guarantee of the object existing and still trying to use it later.
Additionally, a new player object is created when he relogs, so the old object will be invalid and no code links to it anymore.
Do Not Save Object Over Time.

Instead, you should try saving the player guid.
Example:
Code:
local Players = {}

local function IsInQue(guid)
    for i = 1, #Players do
        if (Players[i] == guid) then
            return true
        end
    end
    return false
end

local function onSelect(event, player, creature, sender, intid, code)
    local guid = player:GetGUID()
    if (IsInQue(guid)) then
        player:SendNotification("Already in queue")
    else
        table.insert(Players, guid)
        player:SendAreaTriggerMessage("You are now in queue")
        
        if (#Players >= 10) then -- has enough players?
            for i = 1, #Players do
                local plr = GetPlayerByGUID(Players[i])
                if (plr) then
                    plr:Teleport(map, x, y, z, o)
                end
            end
        end
    end
end

See for example this function for getting the player by his guid:
http://eluna.emudevs.com/Global/GetPlayerByGUID.html
It returns nil if player is not found. And yes, it requires the GUID. GetGUIDLow is not working.

The above code is currently flawed in a way that it teleports players even though some had logged off.
You should run a check on them all to see if there are enough in list and if they are all logged in when going to take action.
 
Last edited:
Status
Not open for further replies.
Top