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(playeridparams[])
{
    new 
targetreason[98];
    if(
sscanf(params"us[98]"targetreason)) return SendClientMessage(playeridX11_THISTLE_1"USA: /reportar [jugador] [razon]");
    if(
strlen(reason) < 1) return SendClientMessage(playeridX11_FIREBRICK"ERROR: La longitud del reporte debe ser mayor a 1.");
    if(! 
IsPlayerConnected(target)) return SendClientMessage(playeridX11_FIREBRICK"ERROR: El jugador especifico no esta conectado.");
    if(
target == playerid) return SendClientMessage(playeridX11_FIREBRICK"ERROR: No puedes reportarte ati mismo.");
    new 
hourminutesecond;
    
gettime(hourminutesecond);
    for(new 
= (sizeof(gReportLog) - 1); > -1i++) gReportLog[i+1] = gReportLog[i];
    new 
string[145];
    
format(stringsizeof(string), "%02d:%02d | El jugador %s[%i] fue reportado por %s[%i] | Razon: %s"hourminuteReturnPlayerName(playerid), playeridReturnPlayerName(target), targetreason);
    
gReportLog[0] = string;
    
SendClientMessageForAdmins(X11_YELLOW_2string);
    foreach(new 
Player)
    {
        if(
gUser[i][u_admin] > 0)
           {
            
PlayerPlaySound(i10850.00.00.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), playeridReturnPlayerName(target), targetreason);
                
TextDrawShowForPlayer(igReportTD);
                
SetTimerEx("HideTD"10 1000false"i"i);
            
#endif
        
}
    }
    
SendClientMessagef(playeridX11_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(playeridgReportTD);
#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: 2 Guest(s)