Help with warning and /eject command? -
DeltaAirlines12 - 11.12.2009
How do I fix this warning?
Код:
C:\Users\Dustin\Desktop\WW3 v0.3 Edition\gamemodes\WW3.pwn(1523) : warning 219: local variable "PlayerName" shadows a variable at a preceding level
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Warning.
And how would I make it so if a player typed /eject, it would kick the player out of the car?
Thanks
Re: Help with warning and /eject command? -
LarzI - 11.12.2009
1.You have defined (new varName) the variable "PlayerName" more than 1 time in your script (1 global and 1 local)
2. RemovePlayerFromVehicle
Re: Help with warning and /eject command? -
DeltaAirlines12 - 11.12.2009
Quote:
Originally Posted by lrZ^ aka LarzI
1.You have defined (new varName) the variable "PlayerName" more than 1 time in your script (1 global and 1 local)
2. RemovePlayerFromVehicle
|
Umm...? So where should I type what? (to fix the warning) Sorry, I am kinda noobish with scripting sometime....
Re: Help with warning and /eject command? -
LarzI - 12.12.2009
just delete the variable you've created inside a function/callback called "PlayerName" and keep the global one
Re: Help with warning and /eject command? -
DeltaAirlines12 - 12.12.2009
Quote:
Originally Posted by lrZ^ aka LarzI
just delete the variable you've created inside a function/callback called "PlayerName" and keep the global one
|
I don't really understand your "high roller" talk, lol, sorry
can you explain a lil more with a lil more detail? Sorry for my noobish-ness
Re: Help with warning and /eject command? -
LarzI - 12.12.2009
I'll give you an example:
pawn Код:
new PlayerName[24];
//As you can see, this line is all by itself, not inside any braces ( { and } )
public OnPlayerConnect(playerid)
{
new PlayerName[24];
/*This line is "making" the warning. Since we already have
defined "PlayerName" global (as I said, not inside any braces)
and we're trying to define it again inside a function. This is not
necesarry, since when you define a variable "global" all callbacks
and functions will "use" that variable, so you don't have to make a new one.*/
return true;
}
So to fix, delete the PlayerName vars (new PlayerName[MAX_PLAYER_NAME]; or w/e you have defined it as) which is inside { and } and leave the global one ( whichi isn't inside any braces), since that's the one you "need"
Re: Help with warning and /eject command? -
DeltaAirlines12 - 12.12.2009
Quote:
Originally Posted by lrZ^ aka LarzI
I'll give you an example:
pawn Код:
new PlayerName[24]; //As you can see, this line is all by itself, not inside any braces ( { and } )
public OnPlayerConnect(playerid) { new PlayerName[24]; /*This line is "making" the warning. Since we already have defined "PlayerName" global (as I said, not inside any braces) and we're trying to define it again inside a function. This is not necesarry, since when you define a variable "global" all callbacks and functions will "use" that variable, so you don't have to make a new one.*/ return true; }
So to fix, delete the PlayerName vars (new PlayerName[MAX_PLAYER_NAME]; or w/e you have defined it as) which is inside { and } and leave the global one ( whichi isn't inside any braces), since that's the one you "need"
|
Ohhhh! I get it! Thanks!
Re: Help with warning and /eject command? -
LarzI - 12.12.2009
NP :P
And for the command..
Simple Example:
pawn Код:
if( !strcmp( cmdtext, "/eject", true ))
{
if( GetPlayerState( playerid ) != PLAYER_STATE_DRIVER )
return SendClientMessage( playerid, 0xFF0000FF, "**[ERROR]You must be the driver of a vehicle to use this command" );
RemovePlayerFromVehicle( playerid );
return true;
}
Easy as pie :P
NOTE: This is for ejecting the driver (which also is the one who types the command)
This can easily be edited for seatids, for other players etc, etc.