stock PrepararPartida(playerid)
{
if(!IsPlayerNPC(playerid))
{
FilaPartida ++;
PlayerInfo[playerid][pJogando] = true;
SendClientMessage(playerid, COLOR_LIGHTBLUE, "|AVISO| Aguardando mais jogadores...");
do{return 0;} while(PlayerInfo[playerid][pJogando] == false && FilaPartida < 2);
AguardarPartida(playerid);
PlayerInfo[playerid][pEmPartida] = true;
}
return 1;
}
stock AguardarPartida(playerid)
{
if(!IsPlayerNPC(playerid) && PlayerInfo[playerid][pEmPartida] == true)
{
new string[128];
PlayerInfo[playerid][pPodeSair] = false;
format(string, sizeof string, "|AVISO| A partida irб iniciar em 10 segundos!!!");
MessageToMatch(COLOR_LIGHTBLUE, string);
TimerPartida = SetTimer("Partida", segundos(10), false);
}
return 1;
}
SendClientMessage(playerid, COLOR_LIGHTBLUE, "|AVISO| Aguardando mais jogadores...");
while(FilaPartida < 10) {
SendClientMessage(playerid, -1, "A partida sу pode comeзar quando tiver 10 jogadores.");
}
|
PHP код:
While = enquanto. |
|
Faзa um timer de um segundo que checa se hб a quantidade estipulada de players no evento para inicia-lo.
|
SetTimer("iniciarPartida", 1000 * 5, true);
new pTimer;
pTimer = SetTimer("iniciarPartida", 1000, true);
forward iniciarPartida(playerid);
public iniciarPartida(playerid)
{
if(FilaPartida >= 10)
{
Killtimer(pTimer);
//cуdigo para comeзar
}
else {//mensagem que ainda nгo tem player suficiente}
return 1;
}