SA-MP Forums Archive
/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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /me command ??? (/showthread.php?tid=92985)



/me command ??? - MB@ - 22.08.2009

Код:
}
	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
Please help


Re: /me command ??? - shady91 - 22.08.2009

it means your useing new pname twice make it

pawn Код:
}
    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;
or delete one of the new pname


Re: /me command ??? - Zafire1410 - 22.08.2009

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


Re: /me command ??? - MB@ - 22.08.2009

Wow thanks it works now


Re: /me command ??? - shady91 - 22.08.2009

Quote:
Originally Posted by MB@
Wow thanks it works now
np


Re: /me command ??? - Abernethy - 22.08.2009

Copied from https://sampwiki.blast.hk/wiki/Using_strcmp()


Re: /me command ??? - shady91 - 22.08.2009

Quote:
Originally Posted by Abernethy
lmao it is aswell lol