SA-MP Forums Archive
Little strtok problem on /report command - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Little strtok problem on /report command (/showthread.php?tid=207601)



Little strtok problem on /report command - Mean - 06.01.2011

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


Re: Little strtok problem on /report command - Kyle - 06.01.2011

Try adding continue; after the sendclientmessage


Re: Little strtok problem on /report command - Mean - 06.01.2011

Nope, still doesn't work.


Re: Little strtok problem on /report command - Kaylux - 06.01.2011

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"


Re: Little strtok problem on /report command - Mean - 06.01.2011

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


Re: Little strtok problem on /report command - bartje01 - 06.01.2011

Try a %f


Re: Little strtok problem on /report command - Mean - 06.01.2011

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


Re: Little strtok problem on /report command - Ash. - 06.01.2011

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


Re: Little strtok problem on /report command - bartje01 - 06.01.2011

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


Re: Little strtok problem on /report command - Kaylux - 06.01.2011

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.