SRB2 Message Board  

Go Back   SRB2 Message Board > Sonic Robo Blast 2 > Editing > Editing Help

Reply
 
Thread Tools Search this Thread
Old 07-22-2018   #1
Lion Sora
SRB2 Freeplay Owner
 
Lion Sora's Avatar
Default Network Variables?

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
__________________
Creator of SRB2 FreePlay, the SRB2 server for anyone and everyone
Mod is being publicly tested
Lion Sora is offline   Reply With Quote
Old 07-22-2018   #2
"Lat'"
Stop it
 
"Lat'"'s Avatar
Default

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 :/
__________________
Quote:
Originally Posted by Bronydude2k5 View Post
If you make me a Sash Lilac wad, I'll make you a sonic sprite hack of any choice.
"Lat'" is offline   Reply With Quote
Old 07-22-2018   #3
Lion Sora
SRB2 Freeplay Owner
 
Lion Sora's Avatar
Default

how do i get the max players though? as in the max players a server has
__________________
Creator of SRB2 FreePlay, the SRB2 server for anyone and everyone
Mod is being publicly tested
Lion Sora is offline   Reply With Quote
Old 07-22-2018   #4
Rapidgame7
Rookie modder
 
Rapidgame7's Avatar
Default

The max players variable is a (vanilla) CVar. You cannot retrieve (vanilla) CVar values with Lua.

Spoiler: Slightly less related
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.
__________________
Ever tried to start a project until you find out it's too complicated then you abandon it

Last edited by Rapidgame7; 07-22-2018 at 09:23 PM. Reason: taxt
Rapidgame7 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:28 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.