/me command ???
#3

Quote:

Making a /me command

In this section we are going to make a /me command while NOT using a bunch of strtoks, which is inaccurate. More about strtok in the following section

public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/me", true, 3)) // 3 is the length of /me
{
if(cmdtext[3] == 0) {
SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
return 1;
}
new str[128];
GetPlayerName(playerid, str, sizeof(str));
format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
SendClientMessageToAll(0xFFFF00AA, str);
return 1;
}
return 0;
}

This will produce a /me command which will work perfectly . Let me explain why that line is highlighted.

If I use cmdtext[4] it will in fact cut the first 4 characters off the string. So in my code the string is not '/me blabla' but just 'blabla'.

More easy :P
Reply


Messages In This Thread
/me command ??? - by MB@ - 22.08.2009, 22:06
Re: /me command ??? - by shady91 - 22.08.2009, 22:08
Re: /me command ??? - by Zafire1410 - 22.08.2009, 22:10
Re: /me command ??? - by MB@ - 22.08.2009, 22:13
Re: /me command ??? - by shady91 - 22.08.2009, 22:15
Re: /me command ??? - by Abernethy - 22.08.2009, 22:18
Re: /me command ??? - by shady91 - 22.08.2009, 23:05

Forum Jump:


Users browsing this thread: 1 Guest(s)