SA-MP Forums Archive
Need help with /me command. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need help with /me command. (/showthread.php?tid=333507)



Need help with /me command. - Gytis0 - 11.04.2012

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.


Re: Need help with /me command. - The__ - 11.04.2012

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.


Re: Need help with /me command. - Gytis0 - 11.04.2012

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.


Re: Need help with /me command. - The__ - 11.04.2012

No problem.


Re: Need help with /me command. - ricardo178 - 11.04.2012

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