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

TFS 1.2 Game.getSpectators

lazarus321

Member
Joined
May 8, 2017
Messages
209
Reaction score
20
Hi all,

I have a doubt, if I want to identify only 3 targets (can be player or show or both), within that table below how would I do?

local spectators = Game.getSpectators(Position(100, 100, 7), false, false, 5, 5, 5, 5)
for i = 1, #spectators do
local spectator = spectators
spectator:say(spectator:getName(), TALKTYPE_SAY)
end
 
Solution
you can break the loop or using another kind of loop

Lua:
local spectators = Game.getSpectators(Position(100, 100, 7), false, false, 5, 5, 5, 5)
for i = 1, #spectators do
    local spectator = spectators[i]
    spectator:say(spectator:getName(), TALKTYPE_SAY)
    if i == 3 then
        break
    end
end
you can break the loop or using another kind of loop

Lua:
local spectators = Game.getSpectators(Position(100, 100, 7), false, false, 5, 5, 5, 5)
for i = 1, #spectators do
    local spectator = spectators[i]
    spectator:say(spectator:getName(), TALKTYPE_SAY)
    if i == 3 then
        break
    end
end
 
Solution
Back
Top