25.11.2013, 13:34
How do I execute a line of code after the player have leave the server, I have a team counting script I need to put
new discontime[MAX_PLAYERS];
forward disTim(playerid);
public disTim(playerid)
{
// your code here
KillTimer(discontime[playerid]);
}
public OnPlayerDisconnect(playerid, reason)
{
discontime[playerid] = SetTimerEx("disTim", 1500, false, "i", playerid);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(GetGVarInt("RoundStarted") == 1)
{
new HumanCount = GetPlayersCountInTeam(0);
new ZombieBossCount = CountZombieBoss();
new SafeCount = GetPlayersCountInTeam(2);
if(HumanCount == 0 && SafeCount == 0)
{
SetTimer("ZombieWin", 1, false);
}
else if(ZombieBossCount == 0 && GetGVarInt("HumanInfected") == 1)
{
SetTimer("HumanWin", 1, false);
}
else if(CountConnectedPlayers() == 1)
{
if(HumanCount == 1)
{
SetTimer("HumanWin", 1, false);
}
else if(ZombieBossCount == 1)
{
SetTimer("ZombieWin", 1, false);
}
}
else if(GetGVarInt("EscapeStarted") == 1 && GetGVarInt("RescueInitiated") == 0 && (SafeCount >= 0.8*HumanCount || HumanCount == 0))
{
SetTimer("InitiateRescue", 1, false);
}
}
new MSGString[50+MAX_PLAYER_NAME];
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
switch(reason)
{
case 0: format(MSGString, sizeof(MSGString), "%s have lost connection to the server", PlayerName);
case 1: format(MSGString, sizeof(MSGString), "%s have left the game", PlayerName);
case 2: format(MSGString, sizeof(MSGString), "%s have been kicked out of the server", PlayerName);
}
SendClientMessageToAll(SERVER_MESSAGE_COLOR, MSGString);
return 1;
}
HumanCount ZombieBossCount SafeCount