SA-MP Forums Archive
Detecting a Timeout/Crash - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Detecting a Timeout/Crash (/showthread.php?tid=565387)



Detecting a Timeout/Crash - Beckett - 27.02.2015

When I want to show the message of the reason he disconnected by that's alright but I want to do something like this and it doesn't work.

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(reason == 0) // Timeout/Crash
    {
        myVar = 1;
    }
    return 1;
}
Does it work like that? I've went on the wiki and it didn't state anything about this.

Cheers.


Re: Detecting a Timeout/Crash - SickAttack - 27.02.2015

Well, assuming it's a global variable, it should work.


Re: Detecting a Timeout/Crash - Beckett - 27.02.2015

------


Re: Detecting a Timeout/Crash - SickAttack - 27.02.2015

It should work too, would you elaborate more and tell me what you're trying to do?

Edit: I got to go to bed, you take too long to respond..


Re: Detecting a Timeout/Crash - CalvinC - 27.02.2015

I'd recommend using a switch
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    switch(reason)
    {
        case 0: // Timeout / Crashed
        case 1: // Left
        case 2: // Kicked / Banned
    }
    return 1;
}
This example will return the correct values.


Re: Detecting a Timeout/Crash - Beckett - 27.02.2015

Figured it out, thanks.


Re: Detecting a Timeout/Crash - Threshold - 27.02.2015

What part of this page doesn't explain 'disconnect reasons'?

https://sampwiki.blast.hk/wiki/OnPlayerDisconnect

It clearly states what each reason stands for...


Re: Detecting a Timeout/Crash - SickAttack - 27.02.2015

Quote:
Originally Posted by Threshold
Посмотреть сообщение
What part of this page doesn't explain 'disconnect reasons'?

https://sampwiki.blast.hk/wiki/OnPlayerDisconnect

It clearly states what each reason stands for...
He said that he wanted to know if resetting/setting a variable under OnPlayerDisconnect would work, and the title of his topic says something else... Could you use a proper title for your topic next time? Thanks. You got us a bit confused here, therefore we responded regarding to the exact same thing "Detecting a Timeout/Crash" (for me, at first).


Re: Detecting a Timeout/Crash - kyriakos587 - 28.02.2015

new string[250];
switch(reason){
case 0: format(string,sizeof(string),"*Player %s(id:%d) has left the server [Leaving]",GetName(playerid),playerid);
case 1: format(string,sizeof(string),"*Player %s(id:%d) has left the server [Timeout]",GetName(playerid),playerid);
case 2: format(string,sizeof(string),"*Player %s(id:%d) has left the server [Kicked/Banned]",GetName(playerid),playerid);}
SendClientMessageToAll(0x696969AA,string);

stock GetName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
return name;
}


Re: Detecting a Timeout/Crash - maramizo - 28.02.2015

Logically, changing variables works anywhere as long as it's within their scope.
Also, always use switch case statements over if statements when you can, as they have a shorter run time.