SA-MP Forums Archive
Apply this command when everybody leaves? - 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: Apply this command when everybody leaves? (/showthread.php?tid=645719)



Apply this command when everybody leaves? - insus100 - 02.12.2017

Ok guys, so I want the server to call
PHP код:
EventLoad 
every time the server gets empty, due to bugs after logging again.

Here is the command I have to put manually:
PHP код:
CMD:stopgame(playerid) {
    
EventLoad 0;
    return 
1;

Thank you!!!!


Re: Apply this command when everybody leaves? - H4bdel - 02.12.2017

PHP код:
new PlayersOnline 0;
public 
OnPlayerConnect(playerid)
{
PlayersOnline PlayersOnline+1;
return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
PlayersOnline PlayersOnline-1;
if(
PlayersOnline == 0)
{
EventLoad 0;
}
return 
1;




Re: Apply this command when everybody leaves? - Lucases - 02.12.2017

Use foreach, download it from here:
https://github.com/karimcambridge/SA....1/foreach.inc

pawn Код:
#include <foreach>

pawn Код:
public OnPlayerDisconnect(playerid)
{
         if(Iter_Random(player) == -1)  //This checks for a random value in the player's iterator,
          {           //if it's empty means no one is online
                    // no players online
          }
          return 1;
}



Re: Apply this command when everybody leaves? - insus100 - 02.12.2017

Thanks a lot it works +rep


Re: Apply this command when everybody leaves? - m4karow - 03.12.2017

Код:
if(!Iter_Count(Players))
{
   EventLoaded = 0;
}
better than iter_random...