/me command ???
#1

Код:
}
	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
Reply
#2

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
Reply
#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
#4

Wow thanks it works now
Reply
#5

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

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

Quote:
Originally Posted by Abernethy
lmao it is aswell lol
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)