SA-MP Forums Archive
CMD doesnt work.. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: CMD doesnt work.. (/showthread.php?tid=380921)



CMD doesnt work.. - xMCx - 27.09.2012

pawn Код:
CMD:report(playerid,params[])
{
    new id, reason[35], string[128], sendername[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME];
    if(sscanf(params,"uz", id, reason)) return SendClientMessage(playerid, lb,"USAGE: /report [playerid/partofname] [reason]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, red,"Invalid player ID");
    else
    {
        GetPlayerName(id, name,sizeof(name));
        GetPlayerName(playerid, sendername, sizeof(sendername));
        sendername[strfind(sendername,"_")] = ' ';
        format(string, sizeof(string), "[ID:%d] %s has reported %s: %s.", playerid, sendername, name, reason);
        ABroadCast(yel,string,1);
        format(string, sizeof(string), "Use /markfalse [id] or /acceptreport [id]");
        ABroadCast(yel,string,1);
        format(string, sizeof(string), "Your report was just send to the online admins, please wait for a reply");
        SendClientMessage(playerid,COLOR_ORANGE,string);
        PlayerNeedsHelp[playerid] = 1;
        return 1;
    }
}
it just says unkown command.


Re: CMD doesnt work.. - Jarnu - 27.09.2012

EDIT: I was wrong.. solution already posted below.


Re: CMD doesnt work.. - West X - 27.09.2012

pawn Код:
CMD:report(playerid,params[])
{
    new id, reason[35], string[128], sendername[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME];
    if(sscanf(params,"uz", id, reason)) return SendClientMessage(playerid, lb,"USAGE: /report [playerid/partofname] [reason]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, red,"Invalid player ID");
    GetPlayerName(id, name,sizeof(name));
    GetPlayerName(playerid, sendername, sizeof(sendername));
    sendername[strfind(sendername,"_")] = ' ';
    format(string, sizeof(string), "[ID:%d] %s has reported %s: %s.", playerid, sendername, name, reason);
    ABroadCast(yel,string,1);
    format(string, sizeof(string), "Use /markfalse [id] or /acceptreport [id]");
    ABroadCast(yel,string,1);
    format(string, sizeof(string), "Your report was just send to the online admins, please wait for a reply");
    SendClientMessage(playerid,COLOR_ORANGE,string);
    PlayerNeedsHelp[playerid] = 1;
    return 1;
}



Re: CMD doesnt work.. - Kirollos - 27.09.2012

pawn Код:
CMD:report(playerid,params[])
{
    new id, reason[35], string[128], sendername[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME];
    if(sscanf(params,"uz", id, reason)) return SendClientMessage(playerid, lb,"USAGE: /report [playerid/partofname] [reason]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, red,"Invalid player ID");
    else
    {
        GetPlayerName(id, name,sizeof(name));
        GetPlayerName(playerid, sendername, sizeof(sendername));
        sendername[strfind(sendername,"_")] = ' ';
        format(string, sizeof(string), "[ID:%d] %s has reported %s: %s.", playerid, sendername, name, reason);
        ABroadCast(yel,string,1);
        format(string, sizeof(string), "Use /markfalse [id] or /acceptreport [id]");
        ABroadCast(yel,string,1);
        format(string, sizeof(string), "Your report was just send to the online admins, please wait for a reply");
        SendClientMessage(playerid,COLOR_ORANGE,string);
        PlayerNeedsHelp[playerid] = 1;
        return 1;
    }
    return 1;
}
That will work i believe

EDIT: i guess i am late to post, the above poster wrote the correct code


Re: CMD doesnt work.. - xMCx - 27.09.2012

can u tell me what was the problem please?


Re: CMD doesnt work.. - Jarnu - 27.09.2012

The problem was...
You didn't returned the value of command.
pawn Код:
return 1;
Read the green text
pawn Код:
CMD:report(playerid,params[])
{
    new id, reason[35], string[128], sendername[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME];
    if(sscanf(params,"uz", id, reason)) return SendClientMessage(playerid, lb,"USAGE: /report [playerid/partofname] [reason]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, red,"Invalid player ID");
    else
    {
        GetPlayerName(id, name,sizeof(name));
        GetPlayerName(playerid, sendername, sizeof(sendername));
        sendername[strfind(sendername,"_")] = ' ';
        format(string, sizeof(string), "[ID:%d] %s has reported %s: %s.", playerid, sendername, name, reason);
        ABroadCast(yel,string,1);
        format(string, sizeof(string), "Use /markfalse [id] or /acceptreport [id]");
        ABroadCast(yel,string,1);
        format(string, sizeof(string), "Your report was just send to the online admins, please wait for a reply");
        SendClientMessage(playerid,COLOR_ORANGE,string);
        PlayerNeedsHelp[playerid] = 1;
        return 1; //You just returned the value of above code.. not WHOLE command so,
    }
   return 1; //You need to put 'return 1;' 1 = true here before 1 ending brace
}



Re: CMD doesnt work.. - xMCx - 27.09.2012

thanks ! +rep


Re: CMD doesnt work.. - xMCx - 27.09.2012

ahh damn .. i tryed the 2 options and it still doesnt work ..


Re: CMD doesnt work.. - Jarnu - 27.09.2012

Well.. dude.. i got your problem then ..

Do you have sscanf plugin? . .show me your server_log.txt


Re: CMD doesnt work.. - xMCx - 27.09.2012

Код:
[18:06:55] sscanf warning: 'z' is deprecated, consider using 'S' instead.
[18:06:55] sscanf warning: No default value found.
[18:06:55] sscanf warning: Strings without a length are deprecated, please add a destination size.
[18:07:01] sscanf warning: 'z' is deprecated, consider using 'S' instead.
[18:07:01] sscanf warning: No default value found.
[18:07:01] sscanf warning: Strings without a length are deprecated, please add a destination size.
[18:07:05] sscanf warning: 'z' is deprecated, consider using 'S' instead.
[18:07:05] sscanf warning: No default value found.
[18:07:05] sscanf warning: Strings without a length are deprecated, please add a destination size.
change z to s?