Network Variables?

Status
Not open for further replies.

MikeTheDigiFloof

Creator of Online+
Are there any variables like to get how many players are on a server and the max players the server has? i also want to know how to get the server name as a variable too, this is for my status script i am working on
 
You can count players by using a players.iterate loop and counting from there. (#players will always return the maximum possible numbers of players since arrays in the source code are of fixed length unlike Lua's tables.)
But reguardless it'd look like that or so;
Code:
local counter = 0
for p in players.iterate do
	counter = $+1
end
(Invalid players aren't returned so it will only count players in the game, which should be what you're aiming for)

However you can't retrieve the server name since Lua has no access to CVars it didn't create :/
 
The max players variable is a (vanilla) CVar. You cannot retrieve (vanilla) CVar values with Lua.

An exception to this is when you create a new CVar in Lua and you assign it to a variable within the same script, that way you can check what's that CVar's value. But you can't overwrite maxplayers with your own CVar either, therefore there's no way for you to be able to get a server's maximum player slots.
 
Last edited:
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top