Need help with /me command.
#1

I'm trying to make the /me command for my RP server. So when I type in /me walks up to the table; it should print out "Gytis0 walks up to the table". But my problem is, I made the command, but it only prints out one word. So when I type in "/me walks up to the table" it prints out just "Gytis0 walks".

Here's the code.
pawn Код:
if(strcmp(cmd, "/me",true)==0)
    {
        new string[128];
        string = strtok(cmdtext, idx);

        if(strlen(string)==0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /me [action]");

        format(string, sizeof(string), "%s %s ", RPName( playerid ), string);
        printf("%s", string);
        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        return 1;
        }
Please help me fix this. And please, don't tell me to convert to ZCMD, it may be more efficient, but I already made too many commands to convert to ZCMD.
Reply
#2

pawn Код:
if(strcmp(cmd, "/me", true) == 0)// Command name
    {// opening bracket
        new length = strlen(cmdtext);// forgot how to explain this
        while ((idx < length) && (cmdtext[idx] <= ' ')) {//forgot this part =D
            idx++;
        }
        new offset = idx;
        new result[128];
        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) {
            result[idx - offset] = cmdtext[idx];
            idx++;
        }
        result[idx - offset] = EOS;// untill here :)
        if(!strlen(result)) { // if he wrote nothing infront of /me
            SendClientMessage(playerid, 0xFFFFFFFF, " /me [action]");// sending a message
            return 1;// returning 'true'
        }
        format(string, sizeof(string), "* %s %s", sendername, result);// formatting the message
        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);//sending the message to nearby players
        return 1;// returning 'true'
    }//closing bracket
Took it from my GM, if you need any further help or any explantion on this function, PM me.
Reply
#3

Quote:
Originally Posted by The__
Посмотреть сообщение
pawn Код:
if(strcmp(cmd, "/me", true) == 0)// Command name
    {// opening bracket
        new length = strlen(cmdtext);// forgot how to explain this
        while ((idx < length) && (cmdtext[idx] <= ' ')) {//forgot this part =D
            idx++;
        }
        new offset = idx;
        new result[128];
        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) {
            result[idx - offset] = cmdtext[idx];
            idx++;
        }
        result[idx - offset] = EOS;// untill here :)
        if(!strlen(result)) { // if he wrote nothing infront of /me
            SendClientMessage(playerid, 0xFFFFFFFF, " /me [action]");// sending a message
            return 1;// returning 'true'
        }
        format(string, sizeof(string), "* %s %s", sendername, result);// formatting the message
        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);//sending the message to nearby players
        return 1;// returning 'true'
    }//closing bracket
Took it from my GM, if you need any further help or any explantion on this function, PM me.
Thanks alot man . I owe you one.
Reply
#4

No problem.
Reply
#5

As far as you already have an answer, here my suggestion.

Start by using a Role-Play name yourself if you are opening a Role-Play comunity. xD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)