22.08.2009, 22:10
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'. |


. Let me explain why that line is highlighted.