11.08.2010, 04:54
script so when all players die atleast once (1) the game mode restarts and it says all players have died restarting now all help appreciated!
forward Restart();
public OnPlayerDeath(playerid, killerid, reason)
{
SetPVarInt(playerid, "HasDied", 1);
if(DeadPlayers == TotalPlayers)
{
SetTimer("Restart", 5000, 0);
SendClientMessageToAll(0xFFFAFA, "All the players have died, server will restart in 5 seconds!");
}
return 1;
}
public Restart()
{
SendRconCommand("gmx");
return 1;
}
stock DeadPlayers()
{
new deadplayers;
for(new x=0; x<MAX_PLAYERS; x++)
{
if(GetPVarInt(x, "HasDied") == 1)
{
deadplayers++;
}
}
return deadplayers;
}
stock TotalPlayers()
{
new players;
for(new x=0; x<MAX_PLAYERS; x++)
{
players++;
}
return players;
}
pawn Код:
|
forward Restart(); public OnPlayerDeath(playerid, killerid, reason) { SetPVarInt(playerid, "HasDied", 1); new dead = DeadPlayers(); new total = TotalPlayers(); if(dead == total) { SetTimer("Restart", 5000, 0); SendClientMessageToAll(0xFFFAFA, "All the players have died, server will restart in 5 seconds!"); } return 1; } public Restart() { SendRconCommand("gmx"); return 1; } stock DeadPlayers() { new deadplayers; for(new x=0; x<MAX_PLAYERS; x++) { if(GetPVarInt(x, "HasDied") == 1) deadplayers++; } return deadplayers; } stock TotalPlayers() { new players; for(new x=0; x<MAX_PLAYERS; x++) { if(IsPlayerConnected(x)) players++; } return players; }
Код:
forward Restart(); public OnPlayerDeath(playerid, killerid, reason) { SetPVarInt(playerid, "HasDied", 1); new dead = DeadPlayers(); new total = TotalPlayers(); if(dead == total) { SetTimer("Restart", 5000, 0); SendClientMessageToAll(0xFFFAFA, "All the players have died, server will restart in 5 seconds!"); } return 1; } public Restart() { SendRconCommand("gmx"); return 1; } stock DeadPlayers() { new deadplayers; for(new x=0; x<MAX_PLAYERS; x++) { if(GetPVarInt(x, "HasDied") == 1) deadplayers++; } return deadplayers; } stock TotalPlayers() { new players; for(new x=0; x<MAX_PLAYERS; x++) { if(IsPlayerConnected(x)) players++; } return players; } |
forward RestartCheck();
OnGameModeInit()
{
SetTimer("RestartCheck" 5000, true);
}
public RestartCheck()
{
new x;
for(new i;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if(PUT YOUR FUNCTION HERE TO CHECK TEAM(i) == TEAM_HIDER) x++
}
}
if(x == 0) SendRconCommand("gmx");
}