Why is this code causing server crash?
#1

I recently added "disconnect" reason to my server under OnPlayerDisconnect; But when i restart the server using /restart command, it crashes the server. I finally solved why my server was crashing on restarting with crash detect; and this was the reason, i commented this code and then the restart command works absolutely fine.

Can someone figure out what's the issue in this code? Thanks a lot!

Код:
/*switch(reason)
	{
	case 0:
	{
	        SendClientMessageToAllEx(-1, "{C0C0C0}%s(%d) Has Left ZCNR (Timeout / Crash).");
     	}
     	case 1:
     	{
     	    SendClientMessageToAllEx(-1, "{C0C0C0}%s(%d) Has Left ZCNR (Leaving / Quit).");
     	}
     	case 2:
     	{
     	    SendClientMessageToAllEx(-1, "{C0C0C0}%s(%d) Has Left ZCNR (Kicked / Banned).");
     	}
	}*/
Reply
#2

Try:

Код:
public OnPlayerDisconnect(playerid, reason)
{
	new userName[MAX_PLAYER_NAME];
	GetPlayerName(playerid, userName, sizeof(userName));
	
	switch(reason)
	{
		case 0:
		{
			SendClientMessageToAllEx(-1, "{C0C0C0}%s(%d) Has Left ZCNR (Timeout / Crash).", userName, playerid);
		}
		case 1:
		{
			SendClientMessageToAllEx(-1, "{C0C0C0}%s(%d) Has Left ZCNR (Leaving / Quit).", userName, playerid);
		}
		case 2:
		{
			SendClientMessageToAllEx(-1, "{C0C0C0}%s(%d) Has Left ZCNR (Kicked / Banned).", userName, playerid);
		}
	}
	
	return 1;
}
Reply
#3

But the stock ReturnName i use everywhere else is like, just the same how you retireve the name above and store in the string. It works fine everywhere else.

EDIT: IM FUCKING STUPID, I FORGOT TO PUT RETURNNAME AND PLAYER ID. OH MY GOD.

Thank you for pointing out my silly mistake, + rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)