Shout command
#1

Hey I have problem with Shout command, I can't make it work, so problem is when I write /shout "a" it says "USAGE: /shout [text]" when I do /shout AAAAAaaaaaaaAAAAA it says me same thing "USAGE:...." if I write /shout (a lot of mixed letters) it will show only last letters for example: iagnslfhwrshnaskdbngh it will show: "(name) shouts: bngh"
What is wrong?

pawn Код:
if(strcmp(cmd, "/shout", true) == 0)
    {
        //if(IsDown[playerid] == 1 || IsDown[playerid] == 2) { return SendClientMessage(playerid,0xFF0000AA,"You can't shout while incapacitated."); }
        if(IsPlayerConnected(playerid))
        {
            GetPlayerName(playerid, Name, sizeof(Name));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[256];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            if(!strlen(result))
            {
                SendClientMessage(playerid, 0xffffffff, "USAGE: /shout [text]");
                return 1;
            }
            format(Str, sizeof(Str), "%s shouts: %s", Name, result);
            SendClientMessage(playerid, 0xffffffff, Str);
            //ProxDetector(30.0, playerid, string,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF);
            printf("- /shout: %s", Str);
        }
        return 1;
    }
    return 0;
}
this is also what I have current OnPlayerCommandText:
pawn Код:
new cmd[256];
    new tmp[256];
    new idx;
    cmd = strtok(cmdtext, idx);
    tmp = strtok(cmdtext, idx);
    new id = strval(tmp);
    new Float:x;
    new Float:y;
    new Float:z;
    new Str[256];
And I'm using strtok also..
pawn Код:
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
I think I showed you everything I need :P thanks for help in advance
Reply


Messages In This Thread
Shout command - by Lajko1 - 26.10.2013, 22:22
Re: Shout command - by Pottus - 26.10.2013, 22:26
Re: Shout command - by Lajko1 - 26.10.2013, 22:30
Re: Shout command - by Pottus - 26.10.2013, 22:46
Re: Shout command - by Mattakil - 26.10.2013, 23:41
Re: Shout command - by Lajko1 - 27.10.2013, 05:33
Re: Shout command - by -CaRRoT - 27.10.2013, 05:45
Re: Shout command - by Lajko1 - 27.10.2013, 07:45
Re: Shout command - by Tomix - 27.10.2013, 09:49
Re: Shout command - by Lajko1 - 27.10.2013, 13:54

Forum Jump:


Users browsing this thread: 1 Guest(s)