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

problem function

Prince Mego

New Member
Joined
Feb 11, 2016
Messages
20
Reaction score
1
I have a problem in my script and i need help
this is my error
Untitled.jpg

and this is my line function
Code:
function teleporttoarea()
local players = {}
 for x = frome.x, toe.x do
        for y = frome.y, toe.y do
            for z = frome.z, toe.z do
                local pos = {x = x, y = y, z = z, stackpos = 253}
                local v = getThingfromPos(pos).uid
                if isPlayer(v) then
                table.insert(players,v)
                if #players >= min then
                doTeleportThing(v,teleportto)
                doBroadcastMessage("The guild War Event Started With "..tonumber(#players).." Players", MESSAGE_EVENT_ADVANCE)
                else
                doBroadcastMessage("The guild War Event Didn't Start Because Of Low Players", MESSAGE_EVENT_ADVANCE)
                end
                end
            end
        end
    end
return true
end
please help and sorry for my english
 
Last edited by a moderator:
Code:
doTeleportThing(v,teleportto)

Is the var teleportto defined?

Weird, looks like v, which was previously validated as a player is the problem.
Perhaps try to return getThingfromPos(pos) instead of its unique id.
 
Code:
doTeleportThing(v,teleportto)

Is the var teleportto defined?

Weird, looks like v, which was previously validated as a player is the problem.
Perhaps try to return getThingfromPos(pos) instead of its unique id.

i added new line in config
Code:
local templearena = {x = 31938, y = 32137, z = 7}

i edit this code
Code:
doTeleportThing(v,teleportto)
to
Code:
doTeleportThing(v,templearena)

and i removed the min player line and now my function is

Code:
function teleporttoarea()
local players = {}
 for x = frome.x, toe.x do
        for y = frome.y, toe.y do
            for z = frome.z, toe.z do
                local pos = {x = x, y = y, z = z, stackpos = 255}
                local v = getThingfromPos(pos).uid
                if isPlayer(v) then
                doTeleportThing(v,templearena)
                doBroadcastMessage("Top Guild War Event Started Go Go Go!", MESSAGE_EVENT_ADVANCE)
                end
            end
        end
    end
return true
end

and i test it and the problem teleport is fixed thanks

but we have 1 more problem if 2 player stand in 1 tile just 1 only from the 2 player teleport to the arena
and when event start get error in tfs in doBroadcastMessage and the message is repeated 5 times in server logs
sorry for my english and thank's
 
Last edited by a moderator:
To avoid looping of doBroadcastMessage, place it under the end of the for loops. If you only want it to broadcast if at least one player is found, create a boolean check that you set to true after the isPlayer condition.
The stackpos attribute in your pos value tells the script to only select whatever is at stack position 255. If there are 2 players on the same sqm, it is likely that they have different stackpos values.
 
Back
Top