Help with function call after the player diconnects
#1

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
Reply
#2

Explain what you want and show what you got from now.
Reply
#3

Put your code under OnPlayerDisconnect.

https://sampwiki.blast.hk/wiki/OnPlayerDisconnect
Reply
#4

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.
Reply
#5

Give the script of when you win/loose.
Reply
#6

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;
}
Reply
#7

I tried, set the timer to 1500ms, it didn't work, trying 5000 now
Reply
#8

Slon did you connect that script too your variables?
Reply
#9

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
Reply
#10

Under Variables will fall in your script:
Код:
HumanCount
ZombieBossCount
SafeCount
You got a script, does it work now?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)