GetPlayersInZone() returns an indexed table. Thus if you were to print its content (using "for k,v in ipairs(GetPlayersInZone()) do print (k,v) end") you would get the following:
Code:
1 playerdata
2 playerdata
3 playerdata
4 playerdata
Tables in Lua start off with index 1, unlike arrays in C-like languages which start off at 0.
If I were to retrieve the player which is the first in the table I would use GetPlayersInZone()[1]. However, the value returned by GetPlayersInZone() could be nil (as there could be zero players in the zone), thus you'd be better off by assigning the table to a local variable (to avoid polluting the global namespace), then checking if the table contains any playerdata at index 1, and then finally perform an action on the player.
For instance:
Code:
local zonePlayers = GetPlayersInZone(some zone);
if (zonePlayers[1] ~= nil) then
zonePlayers[1]:DoSomething();
end
If you wanted to store the player in another value it is as simple as assigning any other variable, i.e. local player = zonePlayers[1].