Cop Team Message
#1

I have a /copmessage command for the cops on my server. I am making that command so the cops can talk to each other in it obviously. But my problem is when I type /copmessage (message), the words in the string get messed up and gets the last 8 letters of COP MESSAGE, as it shows in the picture below:



As you can see above, if I type '/copmessage testing', it will show 'pmessage testing', with the pmessage before the starting of 'testing'.

Here is the code:

pawn Код:
if (strcmp("/copmessage", cmdtext, true, 11) == 0)
    {
        if(strlen(cmdtext) <= 11)
        {
            SendClientMessage(playerid,red,"USAGE: /copmessage (message)  -  Enter A Valid Cop Message.");
            return 1;
        }
        else
        {
            new output[255];
            new pname[24];
            GetPlayerName(playerid, pname, 24);
            strmid(output,cmdtext,3,strlen(cmdtext));
            format(string, sizeof(string), "COP MESSAGE: %s(%d) %s",pname,playerid,output);
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(Team == TEAM_COPS)
                {
                    format(string, sizeof(string), "COP MESSAGE: %s (%d): %s",pname,playerid,output);
                    MessageToCops(blue,string);
                    //SendClientMessage(i,blue,string);
                    return 1;
                }
                else
                {
                    if(isnull(cmdtext)) return SendClientMessage(playerid,red,"You Are Not A Cop. You May Not Use The Cop Radio Device.");
                    SendClientMessage(playerid,red,"You Are Not A Cop. You May Not Use The Cop Radio Device.");
                    return 1;
                }
            }
        }
    }
Here is the stock and forward for MessageToCops:

pawn Код:
forward MessageToCops(color,const string[]);
public MessageToCops(color,const string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        new Team = GetPVarInt(i,"Team");
        if(IsPlayerConnected(i) == 1) if(Team==TEAM_COPS) SendClientMessage(i,color,string);
    }
    return 1;
}
So there is my problem, if anyone knows what I need to add or have done wrong with the code, please let me know.
Reply
#2

Your issue is at strmid, set 3 to 12
Reply
#3

pawn Код:
forward MessageToCops(color,const string[]);
public MessageToCops(color,const string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(GetPVarInt(i,"Team") == TEAM_COPS)
            {
                SendClientMessage(i,color,string);
            }
        }
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by SilentHuntR
Посмотреть сообщение
Your issue is at strmid, set 3 to 12
Wow such an easy thing to miss, thanks a lot.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)