} if(strcmp(cmdtext, "/me", true, 3)==0) { new pname[24], string[256]; GetPlayerName(playerid, pname, 24); format(string, 256, "* %s %s", pname, cmdtext[4]); SendClientMessageToAll(0xFFFFFFAA , string); return 1;
C:\Documents and Settings\Administrator\Desktop\Stunt-server\gamemodes\StuntWorld.pwn(597) : warning 219: local variable "pname" shadows a variable at a preceding level
}
if(strcmp(cmdtext, "/me", true, 3)==0) {
new pname1[24], string[256];
GetPlayerName(playerid, pname1, 24);
format(string, 256, "* %s %s", pname1, cmdtext[4]);
SendClientMessageToAll(0xFFFFFFAA , string);
return 1;
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'. |
Originally Posted by MB@
Wow thanks it works now
|
Originally Posted by Abernethy
Copied from https://sampwiki.blast.hk/wiki/Using_strcmp()
|