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

Lua getPlayersInArea 100%

milbradt

New Member
Joined
Dec 25, 2011
Messages
177
Solutions
1
Reaction score
4
SOLVED



Code:
function getPlayersInArea(fromPos, toPos)local players ={}
      for _, pid in ipairs(getPlayersOnline())do
          if isInRange(getPlayerPosition(pid), fromPos, toPos)then
             table.insert(players, pid)
          end
      end
      return players
end


It is not working.
Does anyone know a solution?

error:
Code:
data/talkactions/scripts/teste.lua:41: attempt to concatenate local 'players' (a table value)
script:
Code:
local players = {}
      for _, pid in pairs(getPlayersOnline()) do
          if isInRange(getPlayerPosition(pid), {x=1028,y=961,z=7}, {x=1033,y=965,z=7}) then
        table.insert(players, pid)
          end
      end
doCreatureSay(cid,""..players.."",19)
 
Last edited:
Obviously that wont work: You cant use a whole table as a single value.

Iterate through the table to get the values or set the storage.

Code:
for i, #players
 setPlayerStorageValue(players[i], storage, value)
end

Something similar, not sure about for iterator now.
 
Back
Top