How could format() crash the server? - 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: How could format() crash the server? (
/showthread.php?tid=535149)
How could format() crash the server? [+REP] -
Aasim - 02.09.2014
Hello, my server has crashed twice after using /get, however it does not crash often so my guess would be some nickname is making it crash?
Here's the cmd for /get:
Код:
CMD:get(playerid, params[])
{
if(pInfo[playerid][pAdminLevel] >= 1)
{
new player;
if(sscanf(params, "r", player))
{
SendClientMessage(playerid,CYAN,"Usage: /get <playerid/part of nick>");
return 1;
}
new string[128];
if(IsPlayerConnected(player) && player != INVALID_PLAYER_ID && player != playerid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid,x,y,z);
SetPlayerInterior(player,GetPlayerInterior(playerid));
SetPlayerVirtualWorld(player,GetPlayerVirtualWorld(playerid));
if(GetPlayerState(player) == 2)
{
new VehicleID = GetPlayerVehicleID(player);
SetVehiclePos(VehicleID,x+3,y,z);
LinkVehicleToInterior(VehicleID,GetPlayerInterior(playerid));
SetVehicleVirtualWorld(GetPlayerVehicleID(player),GetPlayerVirtualWorld(playerid));
}
else
{
SetPlayerPos(player,x+2,y,z);
}
format(string,sizeof(string),"You have been teleported to Administrator \"%e's\" location", pName(playerid));
SendClientMessage(player,CYAN,string);
----->This is the line crashing ---> format(string,sizeof(string),"You have teleported \"%e\" to your location", pName(player));
SendClientMessage(playerid,CYAN,string);
return 1;
}
else
{
SendClientMessage(playerid, RED, "Player is not connected or is yourself");
}
}
else
{
return 0;
}
return 1;
}
And here's the pName:
Код:
stock pName(playerid)
{
new gName[MAX_PLAYER_NAME+10];
GetPlayerName( playerid, gName, sizeof gName );
return gName;
}
I added +10 to check if it would fix, but didn't.
Re: How could format() crash the server? -
shourya12 - 02.09.2014
use crash-detector. show us the result.
Re: How could format() crash the server? -
Aasim - 02.09.2014
Quote:
Originally Posted by shourya12
use crash-detector. show us the result.
|
Код:
[03:59:54] [debug] Server crashed while executing AdminSystem.amx
[03:59:54] [debug] AMX backtrace:
[03:59:54] [debug] #0 native format () from samp03svr
[03:59:54] [debug] #1 0001fdf8 in public cmd_get () at E:\samp03\filterscripts\AdminSystem.pwn:2865
[03:59:54] [debug] #2 native CallLocalFunction () from samp03svr
[03:59:54] [debug] #3 000072f8 in public OnPlayerCommandText (playerid=1, cmdtext[]=@0x0012016c "/get 0") at C:\Documents and Settings\B\Desktop\pawno\pawno\include\zcmd.inc:110
[03:59:54] [debug] Native backtrace:
[03:59:54] [debug] #0 b63a193b in _ZN10StackTraceC1EPv () from plugins/crashdetect.so
[03:59:54] [debug] #1 b639a68f in _ZN11CrashDetect20PrintNativeBacktraceERSoPv () from plugins/crashdetect.so
[03:59:54] [debug] #2 b639b85c in _ZN11CrashDetect20PrintNativeBacktraceEPv () from plugins/crashdetect.so
[03:59:54] [debug] #3 b639bca6 in _ZN11CrashDetect11OnExceptionEPv () from plugins/crashdetect.so
I recently changed from %s to %e and haven't had a crash so far, still waiting tho.