Skip to content

Instantly share code, notes, and snippets.

@AndnixSH
Forked from codenulls/main.cpp
Created August 24, 2022 17:08
Show Gist options
  • Save AndnixSH/13cb190c661be1218da32475574dec57 to your computer and use it in GitHub Desktop.
Save AndnixSH/13cb190c661be1218da32475574dec57 to your computer and use it in GitHub Desktop.
A simple GTA:SA ASI mod to restore health of local player by pressing the R key on keyboard.
#include "plugin.h"
#include "common.h"
#include "CHud.h"
#include "CTimer.h"
using namespace plugin;
class RestoreHealthGTASA {
public:
RestoreHealthGTASA() {
// Initialise your plugin here
Events::gameProcessEvent += []
{
CPlayerPed* pLocalPlayer = FindPlayerPed();
if (pLocalPlayer)
{
static unsigned int lastKeyPressedTime = 0;
if (KeyPressed('R') && ( CTimer::m_snTimeInMilliseconds - lastKeyPressedTime > 500))
{
lastKeyPressedTime = CTimer::m_snTimeInMilliseconds;
pLocalPlayer->m_fHealth = pLocalPlayer->m_fMaxHealth;
CHud::SetHelpMessage("Restored Player Health!", true, false, false);
}
}
};
}
} restoreHealthGTASA;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment