SA-MP Forums Archive
1 random nearly house(problem with code) - 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: 1 random nearly house(problem with code) (/showthread.php?tid=466300)



1 random nearly house(problem with code) - sianbg - 27.09.2013

Hello, i want to get 1 random nearly houses, but it doesnt work.

The code is:
Код:
	new rand = random(MAX_HOUSES - 1);
	while(!(HouseInfo[rand][hExteriorZ] <= 100 && HouseInfo[rand][hExteriorX] > 2402.6104 && HouseInfo[rand][hExteriorX] < 2498.5225 && HouseInfo[rand][hExteriorY] < 1334.343750 && HouseInfo[rand][hExteriorY] > -1644.7028))
	{
	    rand++;
	    if(rand == 1400) {
	    	rand = 1;
		}
	}
I'm begginner of scripting. Sorry for my english


Re: 1 random nearly house(problem with code) - Accord - 27.09.2013

Well, I'm sorry if I understood you wrong but if you have tried to do what I think, which is getting all the nearly houses around the player so this is the code for you and if you meant something else, please let me know and I'll sort it out already:

PHP код:
for(new 0r  MAXA_HOUSESr++)
    {
        if(!
IsPlayerInRangeOfPoint(playerid30HouseInfo[rand][hExteriorX], HouseInfo[rand][hExterioY], HouseInfo[rand][hExteriorZ)) continue;
        {
            
// what happens
        
}
    } 



Re: 1 random nearly house(problem with code) - sianbg - 27.09.2013

no, I edin my post. I want just 1 random house nearly the player.


Re: 1 random nearly house(problem with code) - Accord - 27.09.2013

PHP код:
new rand;
while(!
IsPlayerInRangeOfPoint(playerid30HouseInfo[rand][hExteriorX], HouseInfo[rand][hExterioY], HouseInfo[rand][hExteriorZ))
{
    
rand random(MAX_HOUSES-1);
}
// What happens.