#include "plugin.h"
#include "CWorld.h"
#include "CCamera.h"
#include "extensions/ScriptCommands.h"
using namespace plugin;
class Project5 {
public:
std::unordered_map<std::uint8_t, std::vector<std::uint8_t>> vKeys = {
{49, {31, 30}},
{50, {22, 23, 24, 91}},
{51, {25, 27, 26}},
{52, {29}},
{53, {34, 33}}
};
Project5() {
Events::drawingEvent += [this] {
if (!isPlayerPlaying() || isInputActive())
return;
for (const auto& [key, weapons] : vKeys) {
if (KeyPressed(key)) {
printf("Key: %d\n", key);
CPed* pPed = CWorld::Players[CWorld::PlayerInFocus].m_pPed;
std::uint32_t nHandle = CPools::GetPedRef(pPed);
for (std::uint8_t nWeapon : weapons) {
printf("Weapon: %d\n", nWeapon);
if (Command<Commands::HAS_CHAR_GOT_WEAPON>(nHandle, nWeapon)) {
Command<Commands::SET_CURRENT_CHAR_WEAPON>(nHandle, 0);
Command<Commands::SET_CURRENT_CHAR_WEAPON>(nHandle, nWeapon);
break;
}
}
}
}
};
}
bool isPlayerPlaying() {
return CWorld::Players[CWorld::PlayerInFocus].m_pPed != nullptr;
}
bool isInputActive() {
CPed* pPed = CWorld::Players[CWorld::PlayerInFocus].m_pPed;
return (pPed && pPed->m_pVehicle);
}
} Project5Plugin;