SA-MP Forums Archive
How to exclude player from location? - 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: How to exclude player from location? (/showthread.php?tid=600414)



How to exclude player from location? - Agiss100 - 07.02.2016

Hello. I have the following code.

As you can see i check if player is near a point, and randomly assign another one to drive to.
But how to exclude the pickup location as dropoff location?

Код:
			if(IsPlayerInRangeOfPoint(playerid, 5, Destinations[j][LoadX], Destinations[j][LoadY], Destinations[j][LoadZ]))
			{
				PlayerCache[playerid][pMissionStatus] = 1;
				new rand = random(sizeof(Destinations));
				SetPlayerMapIcon(playerid, MapIcon[playerid], Destinations[rand][LoadX], Destinations[rand][LoadY], Destinations[rand][LoadZ], 51, 0, MAPICON_GLOBAL_CHECKPOINT);



Re: How to exclude player from location? - Vince - 07.02.2016

PHP код:
new rand;
do 
{
    
rand random(sizeof(Destinations));
}
while(
rand == j); 



Re: How to exclude player from location? - Joron - 07.02.2016

Nvrm..Delete this..


Re: How to exclude player from location? - AbyssMorgan - 07.02.2016

PHP код:
if(IsPlayerInRangeOfPoint(playerid5Destinations[j][LoadX], Destinations[j][LoadY], Destinations[j][LoadZ]))
            {
                
PlayerCache[playerid][pMissionStatus] = 1;
                
                new 
rand;
                
FindNextDestination:
                
rand random(sizeof(Destinations));
                if(
rand == j) goto FindNextDestination//new id == old id ?
                
                
SetPlayerMapIcon(playeridMapIcon[playerid], Destinations[rand][LoadX], Destinations[rand][LoadY], Destinations[rand][LoadZ], 510MAPICON_GLOBAL_CHECKPOINT); 



Re: How to exclude player from location? - Vince - 07.02.2016

^ Yeah, that's why do-while exists. It differs from the traditional while loop in that it always gets executed at least one.