Help "local variable"
#1

Код:
\gamemodes\A-Life.pwn(4001) : warning 219: local variable "string" shadows a variable at a preceding level
\gamemodes\A-Life.pwn(4009) : warning 219: local variable "string" shadows a variable at a preceding level
\gamemodes\A-Life.pwn(4020) : warning 219: local variable "string" shadows a variable at a preceding level
\gamemodes\A-Life.pwn(4028) : warning 219: local variable "string" shadows a variable at a preceding level
Код:
		new randenginemask = random(2)+1;
	    if(randenginemask == 1)
	    {
			new string[128];
 			format(string, sizeof(string), "* Stranger %d menyalakan mesin dan berhasil", RandMask[playerid]);
			ProxDetector(30.0, playerid, string,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
			SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
			SendClientMessageEx(playerid, COLOR_WHITE, "Mesin telah hidup, Tekan 'Y' atau ketik '/car engine' untuk mematikan mesin).");
			}
			else
			{
			new string[128];
			format(string, sizeof(string), "* Stranger %d menyalakan mesin, tetapi gagal", RandMask[playerid]);
			ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
			SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
			SendClientMessageEx(playerid, COLOR_WHITE, "Mesin gagal di nyalakan, silahkan putar kunci lagi untuk menyalakan mesin.");
		}
		return 1;
		}
   		new randengine = random(2)+1;
	    if(randengine == 1)
	    {
	    new string[128];
	    format(string, sizeof(string), "* %s mencoba menyalakan mesin dan berhasil", GetPlayerNameEx(playerid));
		ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
		SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
		SendClientMessageEx(playerid, COLOR_WHITE, "Mesin telah hidup, Tekan 'Y' atau ketik '/car engine' untuk mematikan mesin).");
		}
		else
		{
		new string[128];
		format(string, sizeof(string), "* %s mencoba menyalakan mesin, tetapi gagal", GetPlayerNameEx(playerid));
		ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
		SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
		SendClientMessageEx(playerid, COLOR_WHITE, "Mesin gagal di nyalakan, silahkan putar kunci lagi untuk menyalakan mesin.");
		}
How to fix ? i do not no warning , please help!
Reply
#2

"string" is already declared as global and you re-declare it locally. Rename it and also in the code is used below.
Reply
#3

Show me whole more code have you defined the variable string outside of a function,then remove it.
Reply
#4

Quote:
Originally Posted by rockhopper
Посмотреть сообщение
Show me whole more code have you defined the variable string outside of a function,then remove it.
this code
Код:
forward SetVehicleEngine(vehicleid, playerid);
public SetVehicleEngine(vehicleid, playerid)
{
	new string[128];
	new engine,lights,alarm,doors,bonnet,boot,objective;
    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
    if(engine == VEHICLE_PARAMS_ON)
	{
		SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
		SendClientMessageEx(playerid, COLOR_WHITE, "Engine has been turn off.");
		DeletePVar(playerid, "fuelonoff");
		DestroyProgressBar(FuelBar[playerid]);
		textdrawscount--;
		FuelBar[playerid] = INVALID_BAR_ID;
		arr_Engine{vehicleid} = 0;
	}
    else if(engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET)
	{
		new Float: f_vHealth;
		GetVehicleHealth(vehicleid, f_vHealth);
		if(f_vHealth < 350.0) return SendClientMessageEx(playerid, COLOR_RED, "Mesin tidak dapat menyala - rusak!");
	    if(VehicleFuel[vehicleid] <= 0.0) return SendClientMessageEx(playerid, COLOR_RED, "Mesin tidak dapat menyala - bensin habis!");
	    if(PlayerInfo[playerid][pMaskuse] == 1)
		{
		new randenginemask = random(2)+1;
	    if(randenginemask == 1)
	    {
			new string[128];
 			format(string, sizeof(string), "* Stranger %d menyalakan mesin dan berhasil", RandMask[playerid]);
			ProxDetector(30.0, playerid, string,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
			SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
			SendClientMessageEx(playerid, COLOR_WHITE, "Mesin telah hidup, Tekan 'Y' atau ketik '/car engine' untuk mematikan mesin).");
			}
			else
			{
			new string[128];
			format(string, sizeof(string), "* Stranger %d menyalakan mesin, tetapi gagal", RandMask[playerid]);
			ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
			SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
			SendClientMessageEx(playerid, COLOR_WHITE, "Mesin gagal di nyalakan, silahkan putar kunci lagi untuk menyalakan mesin.");
		}
		return 1;
		}
   		new randengine = random(2)+1;
	    if(randengine == 1)
	    {
	    new string[128];
	    format(string, sizeof(string), "* %s mencoba menyalakan mesin dan berhasil", GetPlayerNameEx(playerid));
		ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
		SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
		SendClientMessageEx(playerid, COLOR_WHITE, "Mesin telah hidup, Tekan 'Y' atau ketik '/car engine' untuk mematikan mesin).");
		}
		else
		{
		new string[128];
		format(string, sizeof(string), "* %s mencoba menyalakan mesin, tetapi gagal", GetPlayerNameEx(playerid));
		ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
		SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
		SendClientMessageEx(playerid, COLOR_WHITE, "Mesin gagal di nyalakan, silahkan putar kunci lagi untuk menyalakan mesin.");
		}
		arr_Engine{vehicleid} = 1;
		if(GetChased[playerid] < 999 && VehicleBomb[vehicleid] == 1)
		{
			if(PlayerInfo[playerid][pHeadValue] >= 1)
			{
				if(PlayerInfo[GetChased[playerid]][pMember] == 8 || PlayerInfo[GetChased[playerid]][pLeader] == 8)
				{
					new Float:boomx, Float:boomy, Float:boomz;
					GetPlayerPos(playerid,boomx, boomy, boomz);
					CreateExplosion(boomx, boomy , boomz, 7, 1);
					VehicleBomb[vehicleid] = 0;
					PlacedVehicleBomb[GetChased[playerid]] = INVALID_VEHICLE_ID;
					new takemoney = PlayerInfo[playerid][pHeadValue] / 4 * 2;
					GivePlayerCash(GetChased[playerid], takemoney);
					GivePlayerCash(playerid, -takemoney);
					format(string,sizeof(string),"Hitman %s telah menandatangani kontrak %s dan mendapatkan $%d.",GetPlayerNameEx(GetChased[playerid]),GetPlayerNameEx(playerid),PlayerInfo[playerid][pHeadValue] / 4 * 2);
					SendFamilyMessage(8, COLOR_YELLOW, string);
					format(string,sizeof(string),"Anda telah dilukai oleh seorang hitman dan kehilangan $%d!",takemoney);
					ResetPlayerWeaponsEx(playerid);
					// SpawnPlayer(playerid);
					SendClientMessageEx(playerid, COLOR_YELLOW, string);
					PlayerInfo[playerid][pHeadValue] = 0;
					PlayerInfo[GetChased[playerid]][pCHits] += 1;
					SetPlayerHealth(playerid, 0.0);
					// KillEMSQueue(playerid);
					GoChase[GetChased[playerid]] = 999;
					PlayerInfo[GetChased[playerid]][pC4Used] = 0;
					PlayerInfo[GetChased[playerid]][pC4] = 0;
					GotHit[playerid] = 0;
					GetChased[playerid] = 999;
					return 1;
				}
			}
		}

		SetPVarInt(playerid, "fuelonoff", 1);
	 	FuelBar[playerid] = CreateProgressBar(548.00, 26.00, 57.50, 3.20, 866792447, 100.0);
	 	textdrawscount++;
	  	SetProgressBarValue(FuelBar[playerid], VehicleFuel[vehicleid]);
		ShowProgressBarForPlayer(playerid, FuelBar[playerid]);
	}
	return 1;
}
Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
"string" is already declared as global and you re-declare it locally. Rename it and also in the code is used below.
I have changed the name but still like it
Reply
#5

You dotn need to make a string everytime you want to use it, you need to make it only once inside the function.
http://pastebin.com/pxYAMTb5
Reply
#6

Quote:
Originally Posted by TwinkiDaBoss
Посмотреть сообщение
You dotn need to make a string everytime you want to use it, you need to make it only once inside the function.
http://pastebin.com/pxYAMTb5
Код:
\gamemodes\A-Life.pwn(4051) : error 017: undefined symbol "string"
\gamemodes\A-Life.pwn(4051) : error 017: undefined symbol "string"
\gamemodes\A-Life.pwn(4051) : error 029: invalid expression, assumed zero
\gamemodes\A-Life.pwn(4051) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
now found 4 error from your code
Reply
#7

Quote:
Originally Posted by Shinta307
Посмотреть сообщение
Код:
\gamemodes\A-Life.pwn(4051) : error 017: undefined symbol "string"
\gamemodes\A-Life.pwn(4051) : error 017: undefined symbol "string"
\gamemodes\A-Life.pwn(4051) : error 029: invalid expression, assumed zero
\gamemodes\A-Life.pwn(4051) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
now found 4 error from your code
Added wrong paste sorry
http://pastebin.com/KeD6Mwcg
Reply
#8

http://pastebin.com/sYekfDqU

EDIT: he did it quickly :/
Reply
#9

Quote:
Originally Posted by TwinkiDaBoss
Посмотреть сообщение
Added wrong paste sorry
http://pastebin.com/KeD6Mwcg
Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)