SA-MP Forums Archive
local variable "Random" shadows a variable at a preceding level - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: local variable "Random" shadows a variable at a preceding level (/showthread.php?tid=631641)



local variable "Random" shadows a variable at a preceding level - Pachino - 02.04.2017

I have this problem...

Код:
new Random = random(3);
		if(Random == 0)
		{
			SetPlayerAttachedObject(playerid, 1, 2844, 6, 0.728, -0.0619, -0.320, -106.100, -2.299, 151.300);
		}
		if(Random == 1)
		{
			SetPlayerAttachedObject(playerid, 1, 2819, 6, 0.777, 0.000, 0.00, -105.099, -0.799, 101.6999);
		}
		if(Random == 2)
		{
			SetPlayerAttachedObject(playerid, 1, 2843, 6, -0.516, 0.137, 0.186, -116.5, -4.899, -7.7999);
		}
		HoldingObject[playerid] = 2844;
		SendClientMessage(playerid, WHITE, "Operite prljavo rublje u masini za ves.");
	}
	else
	{
		SendClientMessage(playerid, WHITE, "Niste blizu prljavog rublja.");
	}
EVERYWHERE WHERE IS IN EXAMPLE: new Random = random(20);
Is warning..


Re: local variable "Random" shadows a variable at a preceding level - GoldenLion - 02.04.2017

There's probably a global variable or a function called "Random". Just change the name of the variable.


Re: local variable "Random" shadows a variable at a preceding level - xTURBOx - 02.04.2017

Код:
new Rd = random(3);
		if(Rd == 0)
		{
			SetPlayerAttachedObject(playerid, 1, 2844, 6, 0.728, -0.0619, -0.320, -106.100, -2.299, 151.300);
		}
		if(Rd == 1)
		{
			SetPlayerAttachedObject(playerid, 1, 2819, 6, 0.777, 0.000, 0.00, -105.099, -0.799, 101.6999);
		}
		if(Rd == 2)
		{
			SetPlayerAttachedObject(playerid, 1, 2843, 6, -0.516, 0.137, 0.186, -116.5, -4.899, -7.7999);
		}
		HoldingObject[playerid] = 2844;
		SendClientMessage(playerid, WHITE, "Operite prljavo rublje u masini za ves.");
	}
	else
	{
		SendClientMessage(playerid, WHITE, "Niste blizu prljavog rublja.");
	}