feat(Self): Added model change

This commit is contained in:
Yimura 2021-11-11 01:15:27 +01:00
parent 9c0d7179cf
commit af58184844

View File

@ -2,7 +2,9 @@
#include "fiber_pool.hpp"
#include "script.hpp"
#include "script_global.hpp"
#include "util/entity.hpp"
#include "util/player.hpp"
#include "util/notify.hpp"
namespace big
{
@ -37,6 +39,47 @@ namespace big
ImGui::TreePop();
}
if (ImGui::TreeNode("Player Model"))
{
static char model[32];
QUEUE_JOB_BEGIN_CLAUSE()
{
PAD::DISABLE_ALL_CONTROL_ACTIONS(0);
}QUEUE_JOB_END_CLAUSE
if (
ImGui::InputText("Model Name###player_ped_model", model, sizeof(model), ImGuiInputTextFlags_EnterReturnsTrue) ||
ImGui::Button("Set Player Model###spawn_player_ped_model")
)
{
QUEUE_JOB_BEGIN_CLAUSE(= )
{
Hash hash = rage::joaat(model);
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))
{
notify::above_map("~r~Failed to spawn model, did you give an incorrect model?");
return;
}
PLAYER::SET_PLAYER_MODEL(PLAYER::GET_PLAYER_INDEX(), hash);
PED::SET_PED_DEFAULT_COMPONENT_VARIATION(PLAYER::PLAYER_PED_ID());
script::get_current()->yield();
STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(hash);
}QUEUE_JOB_END_CLAUSE
}
ImGui::TreePop();
}
if (ImGui::TreeNode("Police"))
{
ImGui::Checkbox("Never Wanted", &g.self.never_wanted);