Help with function call after the player diconnects -
SlonCHL - 25.11.2013
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
Re: Help with function call after the player diconnects -
Spydah - 25.11.2013
Explain what you want and show what you got from now.
Re: Help with function call after the player diconnects -
ikkentim - 25.11.2013
Put your code under OnPlayerDisconnect.
https://sampwiki.blast.hk/wiki/OnPlayerDisconnect
Re: Help with function call after the player diconnects -
SlonCHL - 25.11.2013
I have got nothing now, OnPlayerDiconnect calls when the player is still in the server, cause I have a team player count, if the one opponent team is empty then the other team wins.
Re: Help with function call after the player diconnects -
Spydah - 25.11.2013
Give the script of when you win/loose.
Re: Help with function call after the player diconnects -
erminpr0 - 25.11.2013
You're right, use Timer
pawn Код:
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;
}
Re: Help with function call after the player diconnects -
SlonCHL - 25.11.2013
I tried, set the timer to 1500ms, it didn't work, trying 5000 now
Re: Help with function call after the player diconnects -
Spydah - 25.11.2013
Slon did you connect that script too your variables?
Re: Help with function call after the player diconnects -
SlonCHL - 25.11.2013
What variables?
Код:
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;
}
Timer didn't work
Seems like isplayerconnected function is malfunctioning
Re: Help with function call after the player diconnects -
Spydah - 25.11.2013
Under Variables will fall in your script:
Код:
HumanCount
ZombieBossCount
SafeCount
You got a script, does it work now?