OnPlayerDisconnect stopped working
#1

I don't know why, but this callback doesn't work anymore, but it used to all time ago. Mayby you know the reason?

Код HTML:
public OnPlayerDisconnect(playerid, reason){
    specby[specto[playerid]]=-1;
    specto[playerid]=-1;
    specby[playerid]=-1;
    PlayersCount--;
	Account[playerid][pVotesForKick]=0;
	Account[playerid][pVotesForBan]=0;
    PlayerInVotekick[playerid]=false;
    PlayerInVoteban[playerid]=false;
    KillTimer(VoteKickTimer[player]);
    KillTimer(VoteBanTimer[player]);
 	DestroyObject(myobject[playerid]);
	DestroyObject(myobject2[playerid]);
	DestroyObject(myobject3[playerid]);
	DestroyObject(myobject4[playerid]);
	DestroyObject(myobject5[playerid]);
    for(new i=0;i<MAX_SERVER_PLAYERS;i++){
      MyVoteK[i][playerid]=false;
	  MyVoteB[i][playerid]=false;}
    MyVoteC[playerid]=false;
    new stringa[128],file[256];
    GetPlayerName(playerid, name, sizeof(name));

      switch(reason){
        case 0: format(stringa, sizeof(stringa), "* [CRASH]: %s has left the server. *", name);
        case 1: format(stringa, sizeof(stringa), "* [EXIT]: %s has left the server. *", name);
        case 2:{
	           if(Banned[playerid]==false){
		         format(stringa, sizeof(stringa), "* [KICK]: %s has been kicked. *", name);}
			   if(Banned[playerid]==true){
		         format(stringa, sizeof(stringa), "* [BAN]: %s has been banned!!! *", name);}}}
    if(Options[ConnectMessages]==1){
      SendClientMessageToAll(COLOR_GREY, stringa);}
	print(stringa);
    Banned[playerid]=false;
    GetPlayerName(playerid, pname, sizeof(pname));
    format(file, sizeof(file), UsersFile, pname);
    OnPlayerLogout(playerid);
    Account[playerid][pMuteWarnings]=0;
    Account[playerid][pSpamWarnings]=0;
    Account[playerid][pPingWarnings]=0;
    Account[playerid][pFloodding]=0;
    Account[playerid][pJailed]=false;
    Account[playerid][pFreezed]=false;
    Account[playerid][pMuted]=false;
    Account[playerid][pFlood]=false;
    Account[playerid][pVehicleLocked]=false;
    Account[playerid][pWarning]=0;
    Account[playerid][pBanWarning]=0;
    Account[playerid][pSkin]=0;
    if(Account[playerid][pLoggedin]==1){
	  dini_IntSet(file,"muted",0);
	  dini_IntSet(file,"jailed",0);
	  dini_IntSet(file,"freezed",0);}
    Spawned[playerid]=false;
    GodActive[playerid]=false;
    ResetPlayerWeapons(playerid);
    KillTimer(MuteTimer[playerid]);
    KillTimer(JailTimer[playerid]);
	return 1;}
Reply
#2

Make an debug to show the mistake...
Reply
#3

Quote:
Originally Posted by Viniborn
Посмотреть сообщение
Make an debug to show the mistake...
hmmmm, how to make a debug?
Reply
#4

PHP код:
public OnPlayerDisconnect(playeridreason){
    
specby[specto[playerid]]=-1;
    
specto[playerid]=-1;
    
specby[playerid]=-1;
    
PlayersCount--;
    
Account[playerid][pVotesForKick]=0;
    
Account[playerid][pVotesForBan]=0;
    
PlayerInVotekick[playerid]=false;
    
PlayerInVoteban[playerid]=false;
    
KillTimer(VoteKickTimer[player]);
    
KillTimer(VoteBanTimer[player]);
     
DestroyObject(myobject[playerid]);
    
DestroyObject(myobject2[playerid]);
    
DestroyObject(myobject3[playerid]);
    
DestroyObject(myobject4[playerid]);
    
DestroyObject(myobject5[playerid]);
    for(new 
i=0;i<MAX_SERVER_PLAYERS;i++){
      
MyVoteK[i][playerid]=false;
      
MyVoteB[i][playerid]=false;}
    
MyVoteC[playerid]=false;
    new 
stringa[128],file[256];
    
GetPlayerName(playeridnamesizeof(name));

      switch(
reason){
        case 
0format(stringasizeof(stringa), "* [CRASH]: %s has left the server. *"name);
        case 
1format(stringasizeof(stringa), "* [EXIT]: %s has left the server. *"name);
        case 
2:{
               if(
Banned[playerid]==false){
                 
format(stringasizeof(stringa), "* [KICK]: %s has been kicked. *"name);}
               if(
Banned[playerid]==true){
                 
format(stringasizeof(stringa), "* [BAN]: %s has been banned!!! *"name);}}}
    if(
Options[ConnectMessages]==1){
      
SendClientMessageToAll(COLOR_GREYstringa);}
    print(
stringa);
    
Banned[playerid]=false;
    
GetPlayerName(playeridpnamesizeof(pname));
    
format(filesizeof(file), UsersFilepname);
    
OnPlayerLogout(playerid);
    
Account[playerid][pMuteWarnings]=0;
    
Account[playerid][pSpamWarnings]=0;
    
Account[playerid][pPingWarnings]=0;
    
Account[playerid][pFloodding]=0;
    
Account[playerid][pJailed]=false;
    
Account[playerid][pFreezed]=false;
    
Account[playerid][pMuted]=false;
    
Account[playerid][pFlood]=false;
    
Account[playerid][pVehicleLocked]=false;
    
Account[playerid][pWarning]=0;
    
Account[playerid][pBanWarning]=0;
    
Account[playerid][pSkin]=0;
    if(
Account[playerid][pLoggedin]==1){
      
dini_IntSet(file,"muted",0);
      
dini_IntSet(file,"jailed",0);
      
dini_IntSet(file,"freezed",0);}
    
Spawned[playerid]=false;
    
GodActive[playerid]=false;
    
ResetPlayerWeapons(playerid);
    
KillTimer(MuteTimer[playerid]);
    
KillTimer(JailTimer[playerid]);
    return 
1;

Reply
#5

i believe the callback crashes when its get called. happened to me before.

use crashdetect plugin and compile with the more params thingy and then look on the console, you will be able to fix it
Reply
#6

Quote:
Originally Posted by kirollos
Посмотреть сообщение
i believe the callback crashes when its get called. happened to me before.

use crashdetect plugin and compile with the more params thingy and then look on the console, you will be able to fix it
The problem that he putted the "}" in someplace wrong anyway my code that I posted will fix that problem .
Reply
#7

Quote:
Originally Posted by James_Nick
Посмотреть сообщение
The problem that he putted the "}" in someplace wrong anyway my code that I posted will fix that problem .
it didn't. No changes yet. Also, you made a mistake and closed the public with ) instead of }
Reply
#8

Like Viniborn said, make a debug to make a debug print something (even random message), if it prints out in the console it means the callback is working, if it's not, the callback has causing some problems.

Here is an example of debug code

PHP код:
public OnPlayerDisconnect(playeridreason)
{
     print(
"[debug] OnPlayerDisconnect called!");
     return 
1;

Reply
#9

Quote:
Originally Posted by Romel
Посмотреть сообщение
Like Viniborn said, make a debug to make a debug print something (even random message), if it prints out in the console it means the callback is working, if it's not, the callback has causing some problems.

Here is an example of debug code

PHP код:
public OnPlayerDisconnect(playeridreason)
{
     print(
"[debug] OnPlayerDisconnect called!");
     return 
1;

its not working
Reply
#10

Maybe because you want to save ALOT of stuff when the player disconnects, with Dini. Of course you know what Dini does:

Open save entry close, open save entry close..etc.

Try to use YINI and see, it might work.

Or try to remove some stuff like the saving of the jailed, Float X...etc and see.

I might not be correct for why it's not getting called.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)