• 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.X+ Tried calling a function but it wont update

Mjmackan

Mapper ~ Writer
Premium User
Joined
Jul 18, 2009
Messages
1,425
Solutions
15
Reaction score
178
Location
Sweden
Using tfs 1.3

I added this function into global:

Lua:
function checkEventWaitingRoom()
 if playerAmount == nil or playerAmount > 0 then
    playerAmount = 0
 end
if eventWaitingRoom ~= nil then
for _, s in pairs(eventWaitingRoom) do
 if isPlayer(s) then
    playerAmount = playerAmount + 1
 end
end
end
 return playerAmount
end

And then i'm running this function from an onThink globalevent but it will only update when i /reload global or within restart, how come and how should I do it?

Edit: Forgot to paste the getSpectators inside the function.
 
Last edited:
Using tfs 1.3

I added this function into global:

Lua:
function checkEventWaitingRoom()
 if playerAmount == nil or playerAmount > 0 then
    playerAmount = 0
 end
if eventWaitingRoom ~= nil then
for _, s in pairs(eventWaitingRoom) do
 if isPlayer(s) then
    playerAmount = playerAmount + 1
 end
end
end
 return playerAmount
end

And then i'm running this function from an onThink globalevent but it will only update when i /reload global or within restart, how come and how should I do it?

Edit: Forgot to paste the getSpectators inside the function.
If it's only 'updating' once, then that makes me think that it's only being called once, which is going to be within the script calling this function, not this function itself.

You'd have to show us how the onThink event is setup in xml and lua.
 
If it's only 'updating' once, then that makes me think that it's only being called once, which is going to be within the script calling this function, not this function itself.

You'd have to show us how the onThink event is setup in xml and lua.
It was solved, the issue was that I pasted the getSpectator directory outside of the function which meant it checked from startup only.
 
Back
Top