• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Server] How to check if you have a vehicle in position
#1
Hello guys, I have a problem. I'm making a garage system and I would like to know if there are any vehicles parked.





I tried that way, but the vehicle is created in the same position in the second wave, the system works perfectly until the second wave, the third time the truck is created on top of the other.



My English is bad, for a better interpretation of the problem, watch the video:?https://youtu.be/QOKytHFMVQQ

Code:
enum VacancyInfo

{

? ? Float:posX,

? ? Float:posY,

? ? Float:posZ,

? ? Float:posA

}

new TruckerVacancy[MAX_TRUCKER_VACANCY][VacancyInfo] =

{

? ? {2788.3999000,-2484.7000000,14.8000000,90.0000000},

? ? {2788.3999000,-2474.3999000,14.8000000,90.0000000},

? ? {2788.3999000,-2464.1001000,14.8000000,90.0000000},

? ? {2788.3999000,-2453.8000000,14.8000000,90.0000000},

? ? {2788.3999000,-2443.5000000,14.8000000,90.0000000},

? ? {2788.3999000,-2433.2000000,14.8000000,90.0000000},

? ? {2788.3999000,-2422.8999000,14.8000000,90.0000000}

};



#define IsVehicleInRangeOfPoint(%0,%1,%2,%3,%4)\

? ? (%1 >= GetVehicleDistanceFromPoint(%0, %2, %3, %4))



stock IsVehicleFromRangePointEx(Float:range, Float:x, Float:y, Float:z)

{

? ? foreach(new i: Vehicle)

? ? {

? ? ? ? return IsVehicleInRangeOfPoint(i, range, x, y, z);

? ? }

? ? return 0;

}



CMD:etruck(playerid, params[])

{

? ? for(new i; i < MAX_TRUCKER_VACANCY; i)

? ? {

? ? ? ? if(!IsVehicleFromRangePointEx(5.0, TruckerVacancy[i][posX],TruckerVacancy[i][posY],TruckerVacancy[i][posZ]))

? ? ? ? {

? ? ? ? ? ? CreateVehicleEx(403, TruckerVacancy[i][posX],TruckerVacancy[i][posY],TruckerVacancy[i][posZ],TruckerVacancy[i][posA], 0, 0);

? ? ? ? ? ? return 1;

? ? ? ? }

? ? }

? ? return 1;

}
  Reply


Messages In This Thread
How to check if you have a vehicle in position - by Frajola - 2020-12-09, 01:37 AM

Forum Jump: