help shadows a variable at a preceding level
#1

(53019) : warning 219: local variable "b" shadows a variable at a preceding level
Код:
CMD:eclose(playerid)
{
    if ( !EvenTStats ) return SendClientMessage ( playerid , 0x00C0FFFF , "The event is already closed." ) ;
    if ( !IsPlayerAdmin ( playerid ) ) return SendClientMessage ( playerid , 0x00C0FFFF , "You can not use this command..") ;
    for ( new v , b = GetMaxPlayers(); v != b; v++ ) it is
    {
        if ( TheEvenT [ v ] )
        {
            TheEvenT [ v ] = true ;
            EvenTStats = false ;
        }
    }
    return 1;
}
Reply
#2

That warning means you have defined the variable "b" twice in the same scope.

Maybe you have a global variable named "b"? or you are not showing the whole cmd.
Reply
#3

I added the system event to my gm is this https://pastebin.com/09ZCW14Y helpme
Reply
#4

Don't use small variables like that, make the variable mean something.

It's highly likely that one of the the includes you are using, use 'b' as a variable and you need to change all your 'b's to proper variable names.. Such as "EventName", or "PlyrName" for a players name.
Reply
#5

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Don't use small variables like that, make the variable mean something.

It's highly likely that one of the the includes you are using, use 'b' as a variable and you need to change all your 'b's to proper variable names.. Such as "EventName", or "PlyrName" for a players name.
thanks bro changing the for b_2 and for solving
Reply
#6

No no no, don't use b_2... Use a proper name for the variable.

Once your script starts getting big, the variables won't mean anything, where they should at least read to be something descriptive. (You'll end up with massive amounts of odd variables that don't make sense when looked at from outside.)


If you do this before you get too far in, then you'll pick this up better, faster and use it more often.

Like CopCars in an array covering all cop cars, or FactionID for the faction you're referencing.

Like the old scripts that have x y z in their scripts.. Should more be something relating to the coords, such as their usage, PickupX,PickupY, PickupZ, or EntranceX EntranceY EntranceZ.


You could instead of b_2, use temp_b so you know that it's a temp value ONLY used to work in a function.

Naming conventions are an underused thing, but have so much potential to make things feel a lot easier.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)