help need fix for warnings
#1

Quote:

(11174) : warning 219: local variable "color" shadows a variable at a preceding level
(11361) : warning 219: local variable "color" shadows a variable at a preceding level
(11373) : warning 219: local variable "color" shadows a variable at a preceding level
(540) : warning 204: symbol is assigned a value that is never used: "ZONEP"
(541) : warning 204: symbol is assigned a value that is never used: "ZONEP1"
(542) : warning 204: symbol is assigned a value that is never used: "ZONEP2"
(543) : warning 204: symbol is assigned a value that is never used: "ZONEP3"
(544) : warning 204: symbol is assigned a value that is never used: "ZONEP4"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


8 Warnings.

line 540-544
Код:
  ZONEP = CreatePickup(19130,0,405.6122,2437.3101,16.5000, -1); 
    ZONEP1 = CreatePickup(19130,0,108.4016,2438.5852,17.1335, -1); 
    ZONEP2 = CreatePickup(19130,0,115.1133,2551.9019,17.4521, -1); 
    ZONEP3 = CreatePickup(19130,0,233.8716,2231.5603,35.6891, -1); 
    ZONEP4 = CreatePickup(19130,0,-36.4865,2347.7593,24.1406, -1);
line 11174
Код:
stock ShowMessage(playerid, color, msgid)
line 11361
Код:
stock SendToAdmins(color,Message[])
line 11373
Код:
stock AlertToAdmins(playerid,color,Message[])
Reply
#2

You already have a variable called color defined in the scope/level of those functions, simplest fix, call it clr on that scope/level, leave it color on the scope/level above. Or if thats to vague of an explanation, just rename the arguments of those functions to something like other then 'color' to fix the error, and you'll learn this lesson about programming some other day.

The warnings about values that are never used, your saving the pickupid to these ZONEP ZONEP1 etc variables, but then you never do anything else with those variables, so the system warns you that your (most likelly) 'wasting resources', if you have no further plans for those pickups, just remove the 'ZONEP =', 'ZONEP1 =' etc (aswell as any 'new ZONEP, ZONEP1, ZONEP2, ZONEP3, ZONEP4;' you may have defined higher up in that code block)
Reply
#3

zones pickups are in checkpoint when i remove ZONEP=,ZONEP1=... i can't see checkpoints
Reply
#4

Think of all your code as being one big cardboard box, in that box, you have more boxes, in those boxes, you can have more boxes, and so on, these are the levels, the largest box contains all your code, in that you have boxes with your functions, in those you have boxes with your if statements, etc etc.

Pseudo code examples of what i was trying to explain:
Код:
new color; // We start at LEVEL 1 (like, top of file)
...
public exampleFunction(playerid, color) { // We define a function, everything in this function is LEVEL 2
    if(something) { // We define an if statement, everything in this if statement is LEVEL 3
        SendClientMessage(playerid, color, "What color will this have?");
    }
}
In the above example, we start at what we will call 'level 1', its the topmost, our outermost layer of your code, or the largest box if going by that explanation, on 'level 1' we define a variable called color.

Moving down trough the code, we end up at a function, a function is a new box, so 'level 2'. That function allows for an argument, called color.

Just to get the levels across, the example also has a level 3, the if statement box.

But now here's the kicker, each box can look in the bigger box its a part of, so level 3 can see whats in level 2, and level 2 can see whats in level 1. Taking that into consideration, what will happen if you try use the variable color? do you mean to use the color argument of level 2? or the color variable of level 1?

Most code languages will automatically decide to take the variable from the nearest level (so in this case it would use color the argument, from level 2) which most likely is what happens in SA-MP aswell, but its still concidered bad practise, because there can be confusion between you and your code on wich color you meant.

Thats why pawno gives you a warning, local variable "color" shadows a variable at a preceding level, meaning, its not a 100% sure it will use the "color" that you want it too.

Hope that got the message across again, to resolve, simply rename the function argument to "clr" or something thats not "color"
Reply
#5

i changed
now i have problem why i can't see checkpoint for capture zones?
Reply
#6

Re-add the 'ZONEP = ' etc, theres a way to stop Pawno from giving the warnings but so far i cant remember it, you could just live with those warnings. You could maybe do something like the below, paste it after setting the ZONEP etc, so the values are beeing used and pawno is happy, its just a bit silly:

Код:
if((ZONEP == ZONEP1) && (ZONEP2 == ZONEP3) && (ZONEP == ZONEP4)) {
// This if statement is some silly code to stop Pawno giving warnings about the 5 ZONEP variables
print("Wow, the world just exploded?");
}
Reply
#7

ok ok, i fixed warning but why i can't see checkpoints

checkpoints
Quote:

#define CAPZONE 0
#define SNAKE 1//Snakes farm
#define OLD 2
#define Factory 3
#define Town 4

Quote:

CP[SNAKE] = CreateDynamicCP(-36.5458, 2347.6426, 24.1406, 4.0, -1,-1,-1,100.0);

Quote:

CP[OLD] = CreateDynamicCP(234.0314,2231.6675,35.6891, 4.0, -1, -1, -1, 100.0);

and more down...but i can't see cps
Reply
#8

Oh thought you meant checkpoints with the ZONEP stuff, my mistake.

Not really sure why you cant see your checkpoints then, that doesnt seem related to the things we covered in this thread so far.
Maybe make a new thread for the checkpoint issues?
(where possible with a more/all code of the checkpoints, going by what you've shared so far its pretty hard to spot whats causing the checkpoints to not show up)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)