mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-06-17 14:57:27 +08:00
114 lines
3.3 KiB
C++
114 lines
3.3 KiB
C++
#pragma once
|
|
#include "entity.hpp"
|
|
#include "natives.hpp"
|
|
#include "pointers.hpp"
|
|
#include "outfit.hpp"
|
|
|
|
namespace big::ped
|
|
{
|
|
inline bool change_player_model(const Hash hash)
|
|
{
|
|
for (uint8_t i = 0; !STREAMING::HAS_MODEL_LOADED(hash) && i < 100; i++)
|
|
{
|
|
STREAMING::REQUEST_MODEL(hash);
|
|
script::get_current()->yield();
|
|
}
|
|
if (!STREAMING::HAS_MODEL_LOADED(hash))
|
|
{
|
|
return false;
|
|
}
|
|
PLAYER::SET_PLAYER_MODEL(self::id, hash);
|
|
self::ped = PLAYER::PLAYER_PED_ID();
|
|
script::get_current()->yield();
|
|
STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(hash);
|
|
for (int i = 0; i < 12; i++)
|
|
{
|
|
PED::SET_PED_COMPONENT_VARIATION(self::ped, i, PED::GET_PED_DRAWABLE_VARIATION(self::ped, i), PED::GET_PED_TEXTURE_VARIATION(self::ped, i), PED::GET_PED_PALETTE_VARIATION(self::ped, i));
|
|
}
|
|
return true;
|
|
}
|
|
|
|
inline bool steal_outfit(const Ped target)
|
|
{
|
|
Ped ped = self::ped;
|
|
|
|
if (ENTITY::GET_ENTITY_MODEL(ped) != ENTITY::GET_ENTITY_MODEL(target))
|
|
{
|
|
return false;
|
|
}
|
|
for (int i = 0; i < 12; i++)
|
|
{
|
|
PED::SET_PED_COMPONENT_VARIATION(ped, i, PED::GET_PED_DRAWABLE_VARIATION(target, i), PED::GET_PED_TEXTURE_VARIATION(target, i), PED::GET_PED_PALETTE_VARIATION(target, i));
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
inline void steal_identity(const Ped target)
|
|
{
|
|
const int max_health = ENTITY::GET_ENTITY_MAX_HEALTH(self::ped);
|
|
const int current_health = ENTITY::GET_ENTITY_HEALTH(self::ped);
|
|
const int current_armor = PED::GET_PED_ARMOUR(self::ped);
|
|
|
|
PLAYER::SET_PLAYER_MODEL(self::id, ENTITY::GET_ENTITY_MODEL(target));
|
|
script::get_current()->yield();
|
|
PED::CLONE_PED_TO_TARGET(target, self::ped);
|
|
ENTITY::SET_ENTITY_MAX_HEALTH(self::ped, max_health);
|
|
ENTITY::SET_ENTITY_HEALTH(self::ped, current_health, 0);
|
|
PED::SET_PED_ARMOUR(self::ped, current_armor);
|
|
}
|
|
|
|
inline void kill_ped(const Ped ped)
|
|
{
|
|
if (entity::take_control_of(ped))
|
|
PED::APPLY_DAMAGE_TO_PED(ped, PED::GET_PED_MAX_HEALTH(ped) * 2, false, 0);
|
|
}
|
|
|
|
inline void kill_ped_by_relation(Ped ped, int relation_id)
|
|
{
|
|
if (PED::GET_RELATIONSHIP_BETWEEN_PEDS(ped, PLAYER::PLAYER_PED_ID()) == relation_id)
|
|
kill_ped(ped);
|
|
}
|
|
|
|
inline Ped spawn(ePedType pedType, Hash hash, Hash clone, Vector3 location, float heading, bool is_networked = true)
|
|
{
|
|
for (uint8_t i = 0; !STREAMING::HAS_MODEL_LOADED(hash) && i < 100; i++)
|
|
{
|
|
STREAMING::REQUEST_MODEL(hash);
|
|
script::get_current()->yield();
|
|
}
|
|
|
|
if (!STREAMING::HAS_MODEL_LOADED(hash))
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
auto ped = PED::CREATE_PED(pedType, hash, location.x, location.y, location.z, heading, is_networked, false);
|
|
|
|
script::get_current()->yield();
|
|
|
|
if (clone)
|
|
{
|
|
PED::CLONE_PED_TO_TARGET(clone, ped);
|
|
}
|
|
|
|
STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(hash);
|
|
|
|
return ped;
|
|
}
|
|
|
|
inline void set_ped_random_component_variation(Ped ped)
|
|
{
|
|
auto range = [](int lower_bound, int upper_bound) -> int {
|
|
return std::rand() % (upper_bound - lower_bound + 1) + lower_bound;
|
|
};
|
|
outfit::components_t components;
|
|
for (auto& item : components.items)
|
|
{
|
|
int drawable_id = range(0, PED::GET_NUMBER_OF_PED_DRAWABLE_VARIATIONS(ped, item.id) - 1);
|
|
int texture_id = range(0, PED::GET_NUMBER_OF_PED_TEXTURE_VARIATIONS(ped, item.id, drawable_id) - 1);
|
|
PED::SET_PED_COMPONENT_VARIATION(ped, item.id, drawable_id, texture_id, PED::GET_PED_PALETTE_VARIATION(ped, item.id));
|
|
}
|
|
}
|
|
}
|