How to exclude player from location?
#1

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);
Reply
#2

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

Nvrm..Delete this..
Reply
#4

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); 
Reply
#5

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


Forum Jump:


Users browsing this thread: 1 Guest(s)