[HELP] How to check server empty? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP] How to check server empty? (
/showthread.php?tid=656715)
[HELP] How to check server empty? -
Charisma - 22.07.2018
How to check empty servers by loop?
https://pastebin.com/T7gqBfUJ
Re: [HELP] How to check server empty? -
SyS - 22.07.2018
If you are using y_iterate you can use Iter_Count(Player) to get number of online players and check if it is zero
Re: [HELP] How to check server empty? -
grymtn - 22.07.2018
or if you dontwant to use iterators you can just create a global variable like below.
Код:
new myonlineplayers=0;
Then under OnPlayerConnect:
Then ofcourse OnPlayerDisconnect:
After that you just need a command that will tell you the number that your variable holds.
If you really want to use a loop you can create an array* variable for max players and when they disconnect you can turn it to 0 and ofcourse on login you can do switching it to 1. so your loop would be like:
Код:
new mycount=0;
for(new i=0; i<MAX_PLAYERS; i++)
{
if(myonlineplayers[i]==1)
{
mycount++;
}
}
Then you can print that mycount variable to your screen if you want or do whatever you need with it. But it would be the same thing as using iterators because thats basically an iterator.
Edit: fixed wrong spelled word.
Re: [HELP] How to check server empty? -
Banditul18 - 22.07.2018
Quote:
Код:
new mycount=0;
for(new i=0; i<MAX_PLAYERS; i++)
{
if(myonlineplayers[i]==1)
{
mycount++;
}
}
|
Wut? In your example myonlineplayers keep the connected players already, why did you make this loop? Its useless and it have an error already, myonlineplayers its not an array and definetly its not a per player array.
Re: [HELP] How to check server empty? -
grymtn - 22.07.2018
Quote:
Originally Posted by Banditul18
Wut? In your example myonlineplayers keep the connected players already, why did you make this loop? Its useless and it have an error already, myonlineplayers its not an array and definetly its not a per player array.
|
i told him to change it to an array there. i didnt specify with my coding. i turned it in to a loop because check what he asked. HE WANTED A LOOP. So i gave him a loop if he changes it in to an array. the first one i do keeps the online count. the loop with array keeps which ids are online, which is what he asks and what he gave example of in pastebin. Is it really that hard to see it there?