Trouble with Global Values
#1

So, i have this global value outside all functions to make it a global one

Code:
new carguyid;
And some codes to get the carguy's position and set players positions to there when they spawn:

Code:
if (GetPlayerTeam(playerid) == 2)
	{
		new Float:x;
		new Float:y;
		new Float:z;
	    GetPlayerPos(carguyid,x,y,z);
	    SetPlayerPos(playerid,x,y,z + 100);
		SendClientMessage(playerid,COLOR_WHITE,"You are now skidiving over the Carguy, do /Getcar when you want your vehicle!");
	}
Which are fine. I also have a code to set the value of that global var so my server works propperly:

Code:
if (GetPlayerTeam(playerid) == 1)
	{
	    new carguyid = playerid;
               .....................
But pawno gives me these warnings:

Code:
C:\Users\Henrique\Desktop\SAMP - The Project\Dir\gamemodes\Carguy.pwn(204) : warning 219: local variable "carguyid" shadows a variable at a preceding level
C:\Users\Henrique\Desktop\SAMP - The Project\Dir\gamemodes\Carguy.pwn(204) : warning 204: symbol is assigned a value that is never used: "carguyid"
Problem: I dont want the carguyid to be a local var when i do "new carguyid = playerid", i want it to set the value of the global var i created back there to the playerid value.

So... little help here?
Reply
#2

Remove the new in front of it? Or am I missing something?
Reply
#3

Change

Code:
new carguyid = playerid;
to

Code:
carguyid = playerid;
and you have to use the carguyid variable somewhere for it to stop the second warning or add

Code:
#pragma unused carguyid
at the bottom of your script.
Reply
#4

Quote:
Originally Posted by andrew4699
View Post
Change

Code:
new carguyid = playerid;
to

Code:
carguyid = playerid;
and you have to use the carguyid variable somewhere for it to stop the second warning or add

Code:
#pragma unused carguyid
at the bottom of your script.
Uh, I think Vince just explained that.
Reply
#5

Thanks all ^^ givin reps.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)