Fix: Request control (#1226)
This commit is contained in:
parent
31d2db48df
commit
cc5a154bdb
@ -72,37 +72,26 @@ namespace big::entity
|
|||||||
|
|
||||||
inline bool take_control_of(Entity ent, int timeout = 300)
|
inline bool take_control_of(Entity ent, int timeout = 300)
|
||||||
{
|
{
|
||||||
if (auto hnd = g_pointers->m_handle_to_ptr(ent))
|
auto hnd = g_pointers->m_handle_to_ptr(ent);
|
||||||
{
|
|
||||||
if (!*g_pointers->m_is_session_started || !hnd->m_net_object || network_has_control_of_entity(hnd->m_net_object))
|
if (!hnd || !hnd->m_net_object || !*g_pointers->m_is_session_started)
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
if (network_has_control_of_entity(hnd->m_net_object))
|
||||||
|
return true;
|
||||||
|
|
||||||
for (int i = 0; i < timeout; i++)
|
for (int i = 0; i < timeout; i++)
|
||||||
{
|
{
|
||||||
auto hnd = g_pointers->m_handle_to_ptr(ent);
|
|
||||||
|
|
||||||
if (!hnd || !hnd->m_net_object)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
g_pointers->m_request_control(hnd->m_net_object);
|
g_pointers->m_request_control(hnd->m_net_object);
|
||||||
|
|
||||||
|
if (network_has_control_of_entity(hnd->m_net_object))
|
||||||
|
return true;
|
||||||
|
|
||||||
if (timeout != 0)
|
if (timeout != 0)
|
||||||
script::get_current()->yield();
|
script::get_current()->yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto hnd = g_pointers->m_handle_to_ptr(ent);
|
|
||||||
if (!hnd || !hnd->m_net_object || !network_has_control_of_entity(hnd->m_net_object))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int netHandle = NETWORK::NETWORK_GET_NETWORK_ID_FROM_ENTITY(ent);
|
|
||||||
NETWORK::SET_NETWORK_ID_CAN_MIGRATE(netHandle, true);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::vector<Entity> get_entities(bool vehicles, bool peds)
|
inline std::vector<Entity> get_entities(bool vehicles, bool peds)
|
||||||
@ -205,7 +194,6 @@ namespace big::entity
|
|||||||
|
|
||||||
inline Entity get_entity_closest_to_middle_of_screen()
|
inline Entity get_entity_closest_to_middle_of_screen()
|
||||||
{
|
{
|
||||||
|
|
||||||
Entity closest_entity{};
|
Entity closest_entity{};
|
||||||
float distance = 1;
|
float distance = 1;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user