Little strtok problem on /report command
#1

Well, yesterday I started making mAdmin (MeanAdmin) and I have done 1k lines already, but I got a little problem with my /report command:
pawn Код:
dcmd_report(playerid, params[])
{
    new tmp[256];
    new tmp2[256];
    new Index;
    tmp = strtok(params, Index);
    tmp2 = strtok(params, Index);
    new id = strval(tmp);
    new reason = strval(tmp2);
    new string[128];
    new reporter[MAX_PLAYER_NAME], reported[MAX_PLAYER_NAME];
    GetPlayerName(playerid, reporter, MAX_PLAYER_NAME);
    GetPlayerName(id, reported, MAX_PLAYER_NAME);
    format(string, 128, "[REPORT] [%d]%s reported [%d]%s || reason: %d", playerid, reporter, id, reported, reason);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PInfo[i][Level] >= 1)
        {
            SendClientMessage(i, LIGHTBLUE, string);
        }
    }
    return 1;
}
And my reason says: reason: 0
Asking for help
Reply
#2

Try adding continue; after the sendclientmessage
Reply
#3

Nope, still doesn't work.
Reply
#4

pawn Код:
dcmd_report(playerid, params[])
{
    new tmp[256];
    new tmp2[256];
    new Index;
    tmp = strtok(params, Index);
    tmp2 = strtok(params, Index);
    new id = strval(tmp);
    new reason = strval(tmp2);
    new string[128];
    new reporter[MAX_PLAYER_NAME], reported[MAX_PLAYER_NAME];
    GetPlayerName(playerid, reporter, MAX_PLAYER_NAME);
    GetPlayerName(id, reported, MAX_PLAYER_NAME);
    format(string, 128, "[REPORT] [%d]%s reported [%d]%s || reason: %s", playerid, reporter, id, reported, reason);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PInfo[i][Level] >= 1)
        {
            SendClientMessage(i, LIGHTBLUE, string);
        }
    }
    return 1;
}
pawn Код:
reason: %s
You had it as an integer "%d" should be "%s"
Reply
#5

Nope, Kaylux. It is an integer, as much as I know, while using %s, it doesn't show anything, just
reason:
It doesn't say anything in the reason. Just:
Код:
reason:
Reason is blank
Reply
#6

Try a %f
Reply
#7

lawl, %f is a float! It shows as:
Код:
reason: 0.000000
-.-
Anyone knows a fix?
Reply
#8

So your usage is like: /report [id] [reason]
So i would use it like: /report 0 Just testing?
Reply
#9

I ment %z it's a special one. I used it for my report command a while ago. Worked fine
Reply
#10

If the reason is blank then your code is wrong. Why would "Reason" not be a string?.
And why don't you use sscanf?

pawn Код:
dcmd_report(playerid, params[])
{
    new giveplayer, reason[24], string[64], player[MAX_PLAYER_NAME];;
    if (sscanf(params, "us", giveplayer, reason)) return SendClientMessage(playerid, COLOR_YELLOW, "[ERROR] Right Usage: /report [ID/Part of Name] [Reason]");
    else
    {
        GetPlayerName(playerid, player, sizeof(player));
        format(string, 128, "[REPORT] [%d]%s reported [%d]%s || reason: %s", playerid, player, giveplayer, giveplayer, reason);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(PInfo[i][Level] >= 1)
            {
                SendClientMessage(i, LIGHTBLUE, string);
            }
        }
        return 1;
    }
}
This makes alot more sense.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)