How could format() crash the server?
#1

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.
Reply
#2

use crash-detector. show us the result.
Reply
#3

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)