pName Shadows a variable
#1

Hello I'm having some trouble so recently I wanted to make my own anti-cheat on my script which would ban players who would spawn a jetpack and aren't admins and I keep getting this error
Код:
(337) : warning 219: local variable "pName" shadows a variable at a preceding level
this is the command
Код:
CMD:jetpack(playerid, params[])
{
	if(User[playerid][USER_ADMIN] >= 4)
	{
	    new string[90],pName[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, pName, sizeof(pName));
	    format(string, sizeof(string), "%s has spawned jetpack", pName);
	    SendClientMessageToAll(-1, string);
	    SetPlayerSpecialAction(playerid, 2);
	}
	return 1;
}
line 337:
Код:
new string[90],pName[MAX_PLAYER_NAME];
Please help me out
Reply
#2

You don't need to make a variable,

use

GetPlayerName(playerid);

instead.
Reply
#3

Because pName is already declared in the global scope.

pawn Код:
CMD:jetpack(playerid, params[])
{
    if(User[playerid][USER_ADMIN] >= 4)
    {
        new string[64], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "%s has spawned jetpack", name);
        SendClientMessageToAll(-1, string);
        SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USEJETPACK);
    }
    return 1;
}
Reply
#4

How to I make it disappear after I'm done using it?
Reply
#5

Press the enter button
Reply
#6

no but after I press it I want it to be gone so no one else can use it
Reply
#7

Just make it so that when you press enter it c;clears the animation. For example:

Код:
if(GetPlayerSpecialAction(playerid)==2){
ClearAnimations(playerid);
}
That should remove the Jetpack from the player, rather than dropping it. You'd need to tweak it a little bit to make sure people don't fall to the ground and such.
Reply
#8

SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
Reply
#9

Quote:
Originally Posted by Kar
Посмотреть сообщение
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
Where should I be adding this?
Reply
#10

*BUMP*
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)