/report cmd make crash the server
#1

This /report command, when someone does a long report like /report 1 using cheats like hh and infinite ammo bla bla, makes crash the server and i dont know why..

pawn Код:
CMD:report(playerid,params[])
{
    if(pInfo[playerid][Logged] == 0) return SCM(playerid,0x0080C0FF,"Please login before using this command.");
    if(GetPVarInt(playerid,"RepTime")>GetTickCount())return SCM(playerid,0xFF0000FF,"Please wait 10 seconds before reporting a player again.");
    new Target;
    new Reason[128];
    new string2[250];
    if(!sscanf(params, "u[24]s[250]",Target, Reason))
    {
            if(Target == playerid) return SCM(playerid, COLOR_RED, "You can't report yourself.");
            if(strlen(params) > 128) return SCM(playerid, COLOR_RED, "Your report can't be more than 128 characters long.");
            if(!IsPlayerConnected(Target))
            return SCM(playerid, COLOR_RED, "Player is not connected!");

            new tname[MAX_PLAYER_NAME];
            new pname[MAX_PLAYER_NAME];
            GetPlayerName(Target,tname,sizeof(tname));
            GetPlayerName(playerid,pname,sizeof(pname));
            new astring[250];
            new Year, Month, Day, Hour, Minute, Second;
            getdate(Year, Month, Day);
            gettime(Hour, Minute, Second);

            SCM(playerid, COLOR_RED, "> Player reported to online admins.");
            new rstring[200];
            format(rstring,sizeof(rstring),"** %s (%d) reported %s (%d) - (%s) - %02d/%02d/%02d - %02d:%02d:%02d -", pname,playerid,tname,Target,Reason,Day,Month,Year,Hour,Minute,Second);
            format(astring,sizeof(astring),"[REPORT] %s (%d) reported %s (%d) - (%s)", pname,playerid,tname,Target,Reason);
            SendMessageToAdmins(0x33AA33FF,astring);
           
            ReportLog(rstring);
            format(string2, sizeof(string2), "04,2[REPORT]: %s (%d) reported %s (%d) - (Reason: %s) - %02d/%02d/%02d - %02d:%02d:%02d -", pname,playerid,tname,Target,Reason,Day,Month,Year,Hour,Minute,Second);
            IRC_GroupSay(gGroupID, IRC_ACHANNEL, string2);
            IRC_GroupSay(gGroupID, IRC_CHANNEL, string2);

            SetPVarInt(playerid,"RepTime",GetTickCount()+10000);
        }
        else return SCM(playerid, -1, "{F70505}Usage: {FFFFFF}/report <playerid> <reason>");
    return 1;
}
The admins get reports ingame and an irc, whats the problem then?
Reply
#2

i'm pretty sure you get sscanf warnings in your console.
Reply
#3

Nope, tested now.
Reply
#4

Run the crashdetect plugin.
Reply
#5

Check if the plugins load properly.
Reply
#6

Not sure if this will cause a crash but I've found a problem in the first few lines:

PHP код:
new Target;
    new 
Reason[128];
    new 
string2[250];
    if(!
sscanf(params"u[24]s[250]",TargetReason)) //You have "s" set to a length of 250 but Reason is only 128. So you need to change s[250 to s[128]. Also, "u" does not need a length. Just do "us[128]" 
Also, string2 seems to never be used unless I'm just missing it and all your strings are pretty big. 128 should be a perfect length for all of them since that is the max the SA:MP client can show in one line.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)