Problem with my /report command
#1

Hello, I got a problem with my /report command. When i do /report 1 test. It just shows the text when you write /report.

this is the code:

pawn Код:
CMD:report(playerid,params[])
{
    new idx;
    new offset = idx;
    new result[96];
    new string[258];
    new sendername[MAX_PLAYER_NAME];
    new length = strlen(params);
    if(sscanf(params, "ui",playerid,sendername,result))
    return SendClientMessage(playerid, RED, "[LOST:RP] /report [ID] [MESSAGE]");
    if(PlayerInfo[playerid][pRmute] == 1)
    return SendClientMessage(playerid, RED, "[LOST:RP] You are muted from /report, Behave next time");
    {
        GetPlayerName(playerid, sendername, sizeof(sendername));
        while ((idx < length) && (params[idx] <= ' '))
        {
            idx++;
        }
        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
        {
            result[idx - offset] = params[idx];
            idx++;
        }
        result[idx - offset] = EOS;
        if(!strlen(result))
        {
            format(string, sizeof(string), "[LOST:RP] Report from [%d]%s: %s",playerid, sendername, (result));
            aMessage(RED,string,1);
        }
    }
    return 1;
}
Anyone know how to fix this?

Regards, Alex
Reply
#2

a normal report to admins? /report (id) (reason) [EX: /report 1337 Hacker!]

Not tested
pawn Код:
COMMAND:report(playerid, params[])
{
    new targetid, reason[128];
    if(sscanf(params, "us[128]", targetid, reason)) return SendClientMessage(playerid, RED, "[LOST:RP] /report [ID] [MESSAGE]");
    else if(PlayerInfo[playerid][pRmute] == 1) return SendClientMessage(playerid, RED, "[LOST:RP] You are muted from /report, Behave next time");
    {
        new playername[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, sizeof(playername));
        GetPlayerName(targetid, targetname, sizeof(targetname));
       
        new string[128];
        SendClientMessage(playerid, RED, "[LOST:RP] Report sent!");
        format(string, sizeof(string), "[LOST:RP] [%d]%s has reported [%d]%s: %s", playerid, playername, targetid, targetname, reason);
        aMessage(RED,string, 1);
    }
    return 1;
}
Reply
#3

dude what the hell
pawn Код:
if(sscanf(params, "ui",playerid,sendername,result))
you got 3 params and only "ui",okayerid,sendername,result?
Reply
#4

Thanks works fine

Quote:
Originally Posted by Elka_Blazer
Посмотреть сообщение
dude what the hell
pawn Код:
if(sscanf(params, "ui",playerid,sendername,result))
you got 3 params and only "ui",okayerid,sendername,result?
I am new to sscanf.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)