refactor(VehicleUtil): Optimised bring vehicle
This commit is contained in:
parent
abdfa503a5
commit
ea4d1cd30b
@ -27,8 +27,6 @@ namespace big
|
|||||||
|
|
||||||
location = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), true);
|
location = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), true);
|
||||||
|
|
||||||
entity::take_control_of(veh);
|
|
||||||
|
|
||||||
vehicle::bring(veh, location);
|
vehicle::bring(veh, location);
|
||||||
}QUEUE_JOB_END_CLAUSE
|
}QUEUE_JOB_END_CLAUSE
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "entity.hpp"
|
||||||
#include "gta/joaat.hpp"
|
#include "gta/joaat.hpp"
|
||||||
|
#include "math.hpp"
|
||||||
#include "natives.hpp"
|
#include "natives.hpp"
|
||||||
#include "notify.hpp"
|
#include "notify.hpp"
|
||||||
#include "pointers.hpp"
|
#include "pointers.hpp"
|
||||||
@ -9,11 +11,15 @@ namespace big::vehicle
|
|||||||
{
|
{
|
||||||
inline void bring(Vehicle veh, Vector3 location, bool put_in = true)
|
inline void bring(Vehicle veh, Vector3 location, bool put_in = true)
|
||||||
{
|
{
|
||||||
|
entity::take_control_of(veh);
|
||||||
|
|
||||||
ENTITY::SET_ENTITY_COORDS(veh, location.x, location.y, location.z + 1.f, 0, 0, 0, 1);
|
ENTITY::SET_ENTITY_COORDS(veh, location.x, location.y, location.z + 1.f, 0, 0, 0, 1);
|
||||||
|
|
||||||
if (put_in)
|
if (put_in)
|
||||||
{
|
{
|
||||||
script::get_current()->yield(100ms);
|
for (size_t i = 0; i < 100 && math::distance_between_vectors(location, ENTITY::GET_ENTITY_COORDS(veh, true)) > 10; i++)
|
||||||
|
script::get_current()->yield();
|
||||||
|
|
||||||
PED::SET_PED_INTO_VEHICLE(PLAYER::PLAYER_PED_ID(), veh, -1);
|
PED::SET_PED_INTO_VEHICLE(PLAYER::PLAYER_PED_ID(), veh, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user