Spawn vehicle in nearest garage
#1

Hello my dealership is based on dialog i have a problem i have more than one dealership so i want to detect the nearest dealership i am buying my car and spawn it there.


this is my buying code:
Код:
if(money < 800) return SendClientMessage(playerid, -1, "You don't have enough money");
if(money > 800)
{
	GivePlayerMoney(playerid, -800);
	SendClientMessage(playerid, -1, "You bought a freeway its parked in the nearest garage.");
	PlayerInfo[playerid][pVehicle1] = 1;
	PlayerInfo[playerid][pVehicle1Model] = 463;
	PlayerInfo[playerid][pVehicle1X] = 1551.4;
	PlayerInfo[playerid][pVehicle1Y] = -31;
	PlayerInfo[playerid][pVehicle1Z] = 21.9;
	PlayerInfo[playerid][pVehicle1C] = 279.998;
	personalcar1[playerid] = CreateVehicle(463,1551.4,-31,21.9,279.998, -1, -1, 99999);
	OnPlayerUpdate(playerid);
}
i need an example cord as i have no idea how to do it thanks
Reply
#2

i found this

Quote:
Originally Posted by w84m3
Посмотреть сообщение
I'd use sth like this:

PHP код:
enum hospital_
{
    
Float:h_X,
    
Float:h_Y,
    
Float:h_Z
};

new 
Hospitals[][hospital_] =
{
    {
0.00.00.0}, // list of hospital coords
    
{123.0456.0789.0},
    {
500.0500.0500.0}
};

stock Float:PlayerDistanceToPoint(playeridFloat:_xFloat:_yFloat:_z)
{
    new 
Float:Coo[3];
    
GetPlayerPos(playerid,Coo[0],Coo[1],Coo[2]);
    return 
floatsqroot(((Coo[0] - _x) * (Coo[0] - _x)) + ((Coo[1] - _y) * (Coo[1] - _y)) + ((Coo[2] - _z) * (Coo[2] - _z)));        
}

stock ClosestHospital(playerid)
{
    new 
hospitalidFloat:closest PlayerDistanceToPoint(playeridHospitals[0][h_X], Hospitals[0][h_Y], Hospitals[0][h_Z];
    for(new 
i=1i<sizeof(Hospitals); i++)
    {
        if(
PlayerDistanceToPoint(playeridHospitals[i][h_X], Hospitals[i][h_Y], Hospitals[i][h_Z]) < closest)
        {
            
closest PlayerDistanceToPoint(playeridHospitals[i][h_X], Hospitals[i][h_Y], Hospitals[i][h_Z]);
            
hospitalid i;
        }
    }
    return 
hospitalid;
}

public 
OnPlayerDeath(playeridkilleridreason)
{
    
SetPVarInt(playerid"Dead"1);
    
SetPVarInt(playerid"Hospital"ClosestHospital(playerid));
}

public 
OnPlayerSpawn(playerid)
{
    if(
GetPVarInt(playerid"Dead"))
    {
        new 
hid GetPVarInt(playerid"Hospital");
        
SetPlayerInterior(playerid0);
        
SetPlayerVirtualWorld(playerid0);
        
SetPlayerPos(playeridHospitals[hid][h_X], Hospitals[hid][h_Y], Hospitals[hid][h_Z]);
        
SetPVarInt(playerid"Dead"0);
    }

Not sure if it works..
But can anyone tell me how to add the angel and implement it into vehicle system?
Reply
#3

Can anyone please try and help coz i really need this done i am tired of searching
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)