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

Solved Check players

nevix

Tunzodus.net
Joined
Mar 31, 2010
Messages
356
Reaction score
62
Location
Lithuanian
Please help, how to check eg: from x y z to x y z player egzist or no? in specified field

I dont know from what to start :/
 
Code:
    for x = 1000, 2000 do
        for y = 1000, 2000 do
            local t = getThingfromPos({x=x, y=y, z=7, stackpos = STACKPOS_TOP_CREATURE})
            if isPlayer(t.uid) then
                -- blabla
            end
        end
    end
Bad method, use getSpectators instead
 
That is very inefficient though, use getSpectators if your TFS version has that Lua function.
 
Code:
        local spectators = getSpectators(centerPos, 5, 5, false)
        if spectators ~= nil then
                for _, spectator in ipairs(spectators) do
                        if isPlayer(spectator) then
                                -- code
                        end
                end
        end

This will check 5 tiles to west and east from centerPos, and 5 tiles to north and south from centerPos.
 

Similar threads

Back
Top