Detecting nearby Andromadas
#1

Hello, I'm trying to make a vehicle transportation system (vehicle goes into an andromada and is then flown to another airport in San Andreas)

The thing that I am having difficulties with, is detecting if there are any Andromadas near, this my code (when the player presses the JUMP key).

Код:
        if(newkeys == KEY_JUMP)
	{
 		for(new i = 0; i < MAX_VEHICLES; i++)
   		{
     		if(GetVehicleModel(i) == 592)
       		{
         		GetVehiclePos(i, Float:ax, Float:ay, Float:az);
			}
		}
		if(IsPlayerInAnyVehicle(playerid))
		{
		    if(!IsAPlane(newcar))
		    {
				if(GetVehicleDistanceFromPoint(newcar, Float:ax, Float:ay, Float:az) < 20)
				{
				    SendClientMessage(playerid, COLOR_GREEN, "IT WORKS!!");
				}
				SendClientMessage(playerid, COLOR_RED, "You are not near an Andromada!");
			}
		}
		SendClientMessage(playerid, COLOR_RED, "You are not in any vehicle!");
	}
Reply
#2

Hey,

pawn Код:
if(newkeys == KEY_JUMP)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new Float:ax,Float:ay,Float:az,Float:px,Float:py,Float:pz, ID=-1, Float:Distance = 20.0; //Max. Distamce to the Adnromada. (Set to 20.0)
        GetPlayerPos(playerid,px,py,pz);
        for(new i = 0; i < MAX_VEHICLES; i++)
        {
            if(GetVehicleModel(i) == 592)
            {
                GetVehiclePos(i, Float:ax, Float:ay, Float:az);
                new Float:tmp=floatsqroot( ( (ax-px)*(ax-px) ) + ( (ay-py)*(ay-py) ) + ( (az-pz)*(az-pz) ) );
                if(Distance>tmp)
                {
                    Distance=tmp;
                    ID=i;
                }
            }
        }
        if(ID != -1) SendClientMessage(playerid, COLOR_GREEN, "IT WORKS!!");
        else SendClientMessage(playerid, COLOR_RED, "You are not near an Andromada!");
        }
    }
    else SendClientMessage(playerid, COLOR_RED, "You are not in any vehicle!");
}
Try this. I use a similar thing for my Property System.

Cheers!
Reply
#3

Hello, I have replaced my piece of code with yours.
But now, when I tried to compile it, the compiler crashed, do you know what may be causing this?
Reply
#4

Never mind, there was a bracket too much.

But, it works, thank you very much! REP+
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)