/say command error
#1

I have this code:

Код:
	if (strcmp(cmdtext, "/say", true) == 0)
	{
	if(Admin[playerid] == true)
	{
	if(sscanf(params,"s", Text)) return SendClientMessage(playerid, 0xF00000FF, "Use /say [Text]");
	format(string2, 128, "[Admin] %s: %s",PlayerName(playerid), Text);
	SendClientMessageToAll(0x10F441AA, string2);
	}
	else if(VIP[playerid] == true)
	{
	if(sscanf(params,"s", Text)) return SendClientMessage(playerid, 0xF00000FF, "Use /say [Text]");
	format(string2, 128, "[VIP] %s: %s",PlayerName(playerid), Text);
	SendClientMessageToAll(0x10F441AA, string2);
	}
	return 1;
But i getting this:

Код:
error 017: undefined symbol "PlayerName"
error 017: undefined symbol "PlayerName"
How i can fix it?
Reply
#2

Do you even have the stock 'PlayerName'?
Reply
#3

Код:
stock PlayerName(playerid) {
	new PlayerName[MAX_PLAYER_NAME];
	GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
	return name;
}
	if (strcmp(cmdtext, "/say", true) == 0)
	{
	if(Admin[playerid] == true)
	{
	if(sscanf(params,"s", Text)) return SendClientMessage(playerid, 0xF00000FF, "Use /say [Text]");
	format(string2, 128, "[Admin] %s: %s",PlayerName(playerid), Text);
	SendClientMessageToAll(0x10F441AA, string2);
	}
	else if(VIP[playerid] == true)
	{
	if(sscanf(params,"s", Text)) return SendClientMessage(playerid, 0xF00000FF, "Use /say [Text]");
	format(string2, 128, "[VIP] %s: %s",PlayerName(playerid), Text);
	SendClientMessageToAll(0x10F441AA, string2);
	}
	return 1;
Reply
#4

gamemodes\mygm.pwn(3193) : warning 219: local variable "PlayerName" shadows a variable at a preceding level
gamemodes\mygm.pwn(3195) : error 017: undefined symbol "name"

Now i getting this.
Reply
#5

Try with
PHP код:
stock PlayerNameEx(playerid)
{
    new 
PlayerName[MAX_PLAYER_NAME];
    
GetPlayerName(playeridPlayerNamesizeof(PlayerName));
    return 
PlayerName;
}
if (
strcmp(cmdtext"/say"true) == 0)
{
    if(
Admin[playerid] == true)
    {
        if(
sscanf(params,"s"Text)) return SendClientMessage(playerid0xF00000FF"Use /say [Text]");
        
format(string2128"[Admin] %s: %s",PlayerNameEx(playerid), Text);
        
SendClientMessageToAll(0x10F441AAstring2);
    }
    else if(
VIP[playerid] == true)
    {
        if(
sscanf(params,"s"Text)) return SendClientMessage(playerid0xF00000FF"Use /say [Text]");
        
format(string2128"[VIP] %s: %s",PlayerNameEx(playerid), Text);
        
SendClientMessageToAll(0x10F441AAstring2);
    }
    return 
1;

Rep + ?
Reply
#6

Add this one above it:
pawn Код:
stock PlayerName(playerid) {
    new name[24];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
Reply
#7

@Berlovan I've corrected the error, if you look closely at my code.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)