#1

Okay My /o command is bugged but I cannot see anything wrong :/



pawn Код:
if (strcmp("/o", cmdtext, true, 3) == 0)
    {
        if(!strlen(cmdtext)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /o [chat]");
        new str[256];
        GetPlayerName(playerid, str, sizeof(str));
        format(str, sizeof(str), "[OOC] %s: %s", str, cmdtext);
        SendClientMessageToAll(COLOR_GREEN, str);
        return 1;
    }
When I type /o it just does what is does in the Picture
Reply
#2

Quote:
Originally Posted by Luis the Lobster
Посмотреть сообщение
Okay My /o command is bugged but I cannot see anything wrong :/



pawn Код:
if (strcmp("/o", cmdtext, true, 3) == 0)
    {
        if(!strlen(cmdtext)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /o [chat]");
        new str[256];
        GetPlayerName(playerid, str, sizeof(str));
        format(str, sizeof(str), "[OOC] %s: %s", str, cmdtext);
        SendClientMessageToAll(COLOR_GREEN, str);
        return 1;
    }
When I type /o it just does what is does in the Picture
you need strtok, which is a small snippet that will get a string/result after space example.
/o' 'message.... ' ' is the space and strtok will get the message after it.
Reply
#3

First of all, don't use str[256], view ******' post about code optimizations for more info.

Код:
if (strcmp("/o", cmdtext, true, 2) == 0)
    {
        if(!strlen(cmdtext)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /o [chat]");
        new str[128];
        GetPlayerName(playerid, str, sizeof(str));
        format(str, sizeof(str), "[OOC] %s: %s", str, cmdtext[4]);
        SendClientMessageToAll(COLOR_GREEN, str);
        return 1;
    }
Try that.
Reply
#4

I used Faith code but now it says Luis_Geramia: n123, ?
Reply
#5

Try this:

pawn Код:
if(!strcmp("/o", cmdtext, true, 2))
{
    if(!strlen(cmdtext)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /o [chat]");
    new str[128], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(str, sizeof(str), "[OOC] %s: %s", pName, cmdtext[2]);
    SendClientMessageToAll(COLOR_GREEN, str);
    return 1;
}
Reply
#6

Thanks Pothead
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)