Server crashing when flooding in a cmd
#1

Hello guys,im having a problem with commands example when they have variables like on/off...when i type example /name aaaaaaaaaaaaa spam it till the last word the server gets crashed,it also works with the other commands so please do you have any idea of getting rid of this bug? Drop down a reply with the code if you can help me on the OnPlayerCommandPerformed! Thank you

Код:
COMMAND:name(playerid, params[])
{
	if(PlayerInfo[playerid][admin] || PlayerInfo[playerid][premium] || PlayerInfo[playerid][playerteam]==HITMAN || PlayerInfo[playerid][playerteam]==FBI || PlayerInfo[playerid][playerleve]>= 10)
	{
		new tmp[5];
		if(sscanf(params, "s", tmp)) return SCP(playerid, "[on/off]");
		if(strcmp(tmp,"on",true)==0)
		{
			PlayerTemp[playerid][hname]=0;
			GameTextForPlayer(playerid,"~g~ShowName ON",1000,1);
			PlayerLoop(i) ShowPlayerNameTagForPlayer(i,playerid,1);
		}
		else if(strcmp(tmp,"off",true)==0)
		{
			PlayerTemp[playerid][hname]=1;
			GameTextForPlayer(playerid,"~r~ShowName OFF",1000,1);
			PlayerLoop(i) if(!PlayerInfo[i][power]) ShowPlayerNameTagForPlayer(i,playerid,0);
		}
		else return SCP(playerid, "[on/off]");
	}
	else return SendClientError(playerid, CANT_USE_CMD);
	return 1;
}
Reply
#2

Should be
if(sscanf(params, "s[5]", tmp))
but you don't need sscanf for 1 option your 'params' is same as tmp

pawn Код:
COMMAND:name(playerid, params[])
{
    if(PlayerInfo[playerid][admin] || PlayerInfo[playerid][premium] || PlayerInfo[playerid][playerteam]==HITMAN || PlayerInfo[playerid][playerteam]==FBI || PlayerInfo[playerid][playerleve]>= 10)
    {
        if(isnull(params)) SCP(playerid, "[on/off]");
        else if(strcmp(params,"on",true)==0)
        {
            PlayerTemp[playerid][hname]=0;
            GameTextForPlayer(playerid,"~g~ShowName ON",1000,1);
            PlayerLoop(i) ShowPlayerNameTagForPlayer(i,playerid,1);
        }
        else if(strcmp(params,"off",true)==0)
        {
            PlayerTemp[playerid][hname]=1;
            GameTextForPlayer(playerid,"~r~ShowName OFF",1000,1);
            PlayerLoop(i) if(!PlayerInfo[i][power]) ShowPlayerNameTagForPlayer(i,playerid,0);
        }
        else SCP(playerid, "[on/off]");
    }
    else SendClientError(playerid, CANT_USE_CMD);
    return 1;
}
Reply
#3

What does the s[5] identify?
Do you have any line of script wich i can paste it at the OnPlayerCommandPerformed to not be able to write more than 15 words at those commands wich include some variables
Reply
#4

Parameter size really shouldn't be crashing your server (Unless you're using some variable to do with string length in an array, causing an out of bounds error). Have you tried installing crashdetect to see what's causing your server to crash?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)