Why is this code causing server 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: Why is this code causing server crash? (
/showthread.php?tid=605725)
Why is this code causing server crash? -
Ritzy2K - 23.04.2016
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).");
}
}*/
Re: Why is this code causing server crash? -
povargek - 23.04.2016
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;
}
Re: Why is this code causing server crash? -
Ritzy2K - 23.04.2016
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