SA-MP Forums Archive
simple question - 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: simple question (/showthread.php?tid=588714)



simple question - houssam501 - 11.09.2015

is there any way to detect if there is no player on the server have pGamemode=1
Playerid[playerid][ pGamemode ] == 1
?
i need help asap please !


Re: simple question - jlalt - 11.09.2015

try:
PHP код:
CMD:gamemode(playerid,params[])
{
  for(new 
i = 0; i < MAX_PLAYERS; i++) {
     if(
PlayerInfo[i][pGamemode] == 1) {
      new 
pname[32],string[128];
      
GetPlayerName(i,pname,32);
      
SendClientMessage(playerid,-1,"Online Gamemode Members:");
      
format(string,sizeof(string)," %s ,pname");
      
SendClientMessage(playerid,-1,string);
      } else 
SendClientMessage(playerid,-1,"There are no Gamemode Member Online.");
   }
  return 
1;
} 



Re: simple question - houssam501 - 11.09.2015

ik that but i need it to detect if there is no players in the gm to stops maps loading
if you know what i mean


Re: simple question - DarkLored - 11.09.2015

pawn Код:
enum gameinfo
{
       pCounter,
       pCount,
};
new gInfo[gameinfo];
simply use a global variable that is directed to a timer that checks every seconds if their are zero players, not the most efficient way but it does the job.


Re: simple question - jlalt - 11.09.2015

maybe
PHP код:
 for(new i = 0; i < MAX_PLAYERS; i++) { if(!PlayerInfo[i][pGamemode]) return 0; 



Re: simple question - houssam501 - 11.09.2015

Quote:
Originally Posted by DarkLored
Посмотреть сообщение
pawn Код:
enum gameinfo
{
       pCounter,
       pCount,
};
new gInfo[gameinfo];
simply use a global variable that is directed to a timer that checks every seconds if their are zero players, not the most efficient way but it does the job.
can you please write the code you mean as i didn't understand


Re: simple question - DarkLored - 11.09.2015

Alright

pawn Код:
forward ServerVars();

enum gameinfo
{
       pCount,
};
new gInfo[gameinfo];

public OnGamemodeInit()
{
        SetTimer("ServerVars", 1000, true);
        return 1;
}

public OnPlayerConnect(playerid)
{
        pCount += 1;
        return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
         pCount -= 1;
         return 1;
}

public ServerVars()
{
       if(gInfo[pCount] == 0)
       {
            //code here
           return 1;
       }
      return 1;
}
Hopefully this is enough information, if you want to destroy the objects then use a loop inside the if statement.


Re: simple question - houssam501 - 11.09.2015

I guess u didn't understand me
im my gamemode theres is pgamemode 0 wich is the lobby or selection of the gm and 1 is dm race so i want to make when there is no player with pgamemode 1 stop loading map progressformap false because without that the map loadimg and it shows for players in the lobby