Chat & Another Command Interfering
#1

I have two commands, one is a chat command and the other is just a normal command (Not chat).

The chat command is /t
and the command is /top

When i type /t and my message, Example,

[TEAM-CHAT] PlayerName: test

it works but when i do the command /top this happens,

[TEAM-CHAT] PlayerName: op

It basically just thinks when i type /top the first T is refering to the chat command. and it does /t and it types out "op"

Can you please help me out! Thanks! The commands as usual:

pawn Код:
if (strcmp("/t", cmdtext, true, 2) == 0)
    {
        new playername[24];
        GetPlayerName(playerid, playername, 24);
        if(strlen(cmdtext) <= 2)
        {
            SendClientMessage(playerid, COLOR_BLUE, "USAGE: /t (Text)");
            return 1;
        }
        new output[255];
        strmid(output,cmdtext,2,strlen(cmdtext));
        for(new i=0;i<MAX_PLAYERS;i++)
        {
            if(IsPlayerConnected(i))
            {
                format(string, sizeof(string), "[TEAM-CHAT] %s: %s", playername, output);
                SendClientMessage(i, COLOR_BLUE, string);
            }
        }
        return 1;
    }
pawn Код:
// Some parts of command removed. but weren't important.
if (strcmp("/top", cmdtext, true, 10) == 0)
    {
    SendClientMessage(playerid, "You have placed it on the top.");
    return 1;

}
Reply
#2

Quote:
Originally Posted by [HIR]AlbanianSoilder
Посмотреть сообщение
I have two commands, one is a chat command and the other is just a normal command (Not chat).

The chat command is /t
and the command is /top

When i type /t and my message, Example,

[TEAM-CHAT] PlayerName: test

it works but when i do the command /top this happens,

[TEAM-CHAT] PlayerName: op

It basically just thinks when i type /top the first T is refering to the chat command. and it does /t and it types out "op"

Can you please help me out! Thanks! The commands as usual:

pawn Код:
if (strcmp("/t", cmdtext, true, 2) == 0)
    {
        new playername[24];
        GetPlayerName(playerid, playername, 24);
        if(strlen(cmdtext) <= 2)
        {
            SendClientMessage(playerid, COLOR_BLUE, "USAGE: /t (Text)");
            return 1;
        }
        new output[255];
        strmid(output,cmdtext,2,strlen(cmdtext));
        for(new i=0;i<MAX_PLAYERS;i++)
        {
            if(IsPlayerConnected(i))
            {
                format(string, sizeof(string), "[TEAM-CHAT] %s: %s", playername, output);
                SendClientMessage(i, COLOR_BLUE, string);
            }
        }
        return 1;
    }
pawn Код:
// Some parts of command removed. but weren't important.
if (strcmp("/top", cmdtext, true, 10) == 0)
    {
    SendClientMessage(playerid, "You have placed it on the top.");
    return 1;

}
I suggest you use zcmd, or dcmd..
ZCMD Example...
pawn Код:
command(top,playerid,params[])
{
    SendClientMessage(playerid,COLOR_LIGHTRED,"You have placed it on the top.");
}
But.. your problem is..
pawn Код:
if (strcmp("/top", cmdtext, true, 10) == 0)
    {
    SendClientMessage(playerid, "You have placed it on the top.");
    return 1;

}
It should be..
pawn Код:
if (strcmp("/top", cmdtext, true, 10) == 0)
    {
    SendClientMessage(playerid,COLOR, "You have placed it on the top.");
    return 1;

}
Reply
#3

The codes look both the same, or i am just not seeing the difference. please help me out
Reply
#4

Quote:
Originally Posted by [HIR]AlbanianSoilder
Посмотреть сообщение
The codes look both the same, or i am just not seeing the difference. please help me out
In the SendClientMessage .. you forgot the COLOR params.
Reply
#5

Quote:
Originally Posted by 1337connor
Посмотреть сообщение
In the SendClientMessage .. you forgot the COLOR params.
No he didn't..


EDIT:

Oh nvm i was looking at the wrong one, but yes you did forget the color.
Reply
#6

I fixed it but still, i am having trouble with the commands interfering each other, the chat command and normal command (Where not used as a chat.)
Reply
#7

Yo, your string is 255 CELLS BIG, lemme see, you need a string of 128, because max chat string is 128 cells big, read ******'s tutorial.
And this problem, can't be fixed without ZCMD or DCMD, use one of thoose.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)