Passing parameters gives warnings
#1

The problem is when I'm using this format :
PHP код:
GiveDrugWithOptions(playerid, .graines dStats[d_coGraines], .type DRUGTYPE_COCAINE); 
Where I add .(parameter) = value - I have those warnings:
Код:
(235) : warning 219: local variable "type" shadows a variable at a preceding level
(472) : warning 219: local variable "type" shadows a variable at a preceding level
(540) : warning 219: local variable "type" shadows a variable at a preceding level
(576) : warning 219: local variable "type" shadows a variable at a preceding level
When I use default format (where each parameter are specified), I don't have any warn.
PHP код:
GiveDrugWithOptions(playerid__dStats[d_coGraines], DRUGTYPE_COCAINE); 
Quote:
Originally Posted by Jeroen52
Посмотреть сообщение
As it says, local variable "type" shadows a variable at a preceding level. Which means that it is already used previously somewhere in the code on a level that is not local.
Either remove the occurrence in the preceding level or change the variable name to something that is not used yet.

And your first post was not descriptive so I wouldn't know what to answer with.
I've "type" 2 times in 2 different functions declared as parameter.
PHP код:
ApplyDrugEffect(playeridFloat:quantitetype
PHP код:
GiveDrugWithOptions(playeridchampid INVALID_DRUG_IDfeuilles 0graines 0type DRUGTYPE_COCAINE
EDIT:
Quote:
Originally Posted by PrO.GameR
Посмотреть сообщение
Are you sure it comes exactly from this line? because pawn compiler is dumb and when you forget to declare a variable somewhere but use it, it throws false shadow warnings of that variable everywhere.

I got a bunch of those single parameter with names and even literally have .playerid=playerid in half dozen parts of my code (streamer related mostly) and there's not a single warning, I advice you to check other places you use type, maybe one of them isn't declared properly.
It's exactly this command which give me warnings.
PHP код:
    else if(!strcmp("/arrestdealer"cmdtexttruestrlen("/arrestdealer")))
    {
        if(!
IsAFDLMember(playerid))
            
SCM(playeridREDPLAYER_UNAUTHORIZED);
        if(
GetNearestDealer(playerid) == INVALID_DRUG_ID)
            return 
SCM(playeridREDNOT_NEAR_DEALER);
        
// SendMessageToRadio(playerid, "%s a arrкte le dealer de drogue.. Le dealer avait %i graines de cannabis & %i graines de cocaine.");
        
DestroyActor(dStats[dID]);
        
SetTimer("CreateDealer"DEALER_HEURE*1000false); // (60*1000)*60*DEALER_HEURE <- Real time
        
DestroyDynamic3DTextLabel(dStats[dLabel]);
        
Me_Auto(playerid"vient d'arrкter le dealer de drogue. On risque pas le voir avant quelques heures.");
        
GiveDrugWithOptions(playerid__dStats[d_coGraines], DRUGTYPE_COCAINE);
        
// GiveDrugWithOptions(playerid, .graines = dStats[d_coGraines], .type = DRUGTYPE_COCAINE);
        
return 1;
    } 
As you can see I've 2 lines with GiveDrugWithOptions. If I switch the commented line from one to the other, it's giving me warnings (Rip English, apologize).
Reply
#2

Then you have a variable elsewhere in your script named 'type'... either change the name of that, or change the name of your parameters to something else.

Eg.
PHP код:
new type// Creating Errors

enum MyEnum
{
    
type// Creating errors
    
value
}; 
Reply
#3

No'p.
Where I declare 'type' are inside command.
PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if(!
strcmp("/planter"cmdtexttruestrlen("/planter")))
    {
        if(!
IsGangMember(playerid))
            return 
SCM(playeridREDPLAYER_UNAUTHORIZED);

        new 
type;
... 
Reply
#4

Just rename it to drug_type, you are wasting a time. "Type" can be even declared in your includes.
Reply
#5

Quote:
Originally Posted by Rdx
Посмотреть сообщение
Just rename it to drug_type, you are wasting a time. "Type" can be even declared in your includes.
Lol, that was that. How can I be stupid like that? x)
Thanks for your help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)