Help with command
#1

Hi friends, when a user places / report, the command works, but when put / report id reason, says ERROR: Unknown Command.

Command code:

PHP код:
CMD:reportar(playerid, params[])
{
    new 
target, reason[98];
    if(
sscanf(params, "us[98]", target, reason)) return SendClientMessage(playerid, X11_THISTLE_1, "USA: /reportar [jugador] [razon]");
    if(
strlen(reason) < 1) return SendClientMessage(playerid, X11_FIREBRICK, "ERROR: La longitud del reporte debe ser mayor a 1.");
    if(! 
IsPlayerConnected(target)) return SendClientMessage(playerid, X11_FIREBRICK, "ERROR: El jugador especifico no esta conectado.");
    if(
target == playerid) return SendClientMessage(playerid, X11_FIREBRICK, "ERROR: No puedes reportarte ati mismo.");
    new 
hour, minute, second;
    
gettime(hour, minute, second);
    for(new 
i = (sizeof(gReportLog) - 1); i > -1; i++) gReportLog[i+1] = gReportLog[i];
    new 
string[145];
    
format(string, sizeof(string), "%02d:%02d | El jugador %s[%i] fue reportado por %s[%i] | Razon: %s", hour, minute, ReturnPlayerName(playerid), playerid, ReturnPlayerName(target), target, reason);
    
gReportLog[0] = string;
    
SendClientMessageForAdmins(X11_YELLOW_2, string);
    foreach(new 
i : Player)
    {
        if(
gUser[i][u_admin] > 0)
           {
            
PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0);
            
#if defined REPORT_TEXTDRAW
                
TextDrawSetStringf(gReportTD, "~b~~h~~h~~h~~h~%s(%i) ~b~~h~~h~~h~fue reportado por ~b~~h~~h~~h~~h~%s(%i) ~b~~h~~h~~h~Razon: ~b~~h~~h~~h~~h~%s", ReturnPlayerName(playerid), playerid, ReturnPlayerName(target), target, reason);
                
TextDrawShowForPlayer(i, gReportTD);
                
SetTimerEx("HideTD", 10 * 1000, false, "i", i);
            
#endif
        
}
    }
    
SendClientMessagef(playerid, X11_YELLOW_1, "Tu reporte hacia %s[%i] fue enviado a los administradores.", ReturnPlayerName(target), target);
    return 
1;
}
#if defined REPORT_TEXTDRAW
    
forward HideTD(playerid);
    public 
HideTD(playerid) return TextDrawHideForPlayer(playerid, gReportTD);
#endif 
Reply
#2

The unknown command message is given because run time error 4 occurs in this line:
pawn Код:
for(new i = (sizeof(gReportLog) - 1); i > -1; i++) gReportLog[i+1] = gReportLog[i];
You made the loop to go backwards so that would be "i--" and not "i+". This part is also wrong:
pawn Код:
gReportLog[i+1] = gReportLog[i];
as on the last iterator will still give run time error and I guess gReportLog is a string so you cannot copy strings like that (use strcat -> strcpy) and neither this line:
pawn Код:
gReportLog[0] = string;
If I were you, I'd just add the latest report at the first free slot so I wouldn't have to "move" the rest.
Reply
#3

Hi how to Add Commands
Reply
#4

thanks Konstantinos for the answer, I resolved the error.

may close.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)