Skip to content

Instantly share code, notes, and snippets.

@draobrehtom
Created January 2, 2020 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save draobrehtom/118207424778ff129eda38f8243a3008 to your computer and use it in GitHub Desktop.
Save draobrehtom/118207424778ff129eda38f8243a3008 to your computer and use it in GitHub Desktop.
Fivem: JS - Aiming to entity and deleting it
let previousPed;
GiveWeaponToPed(PlayerPedId(), GetHashKey('WEAPON_SNOWBALL'), 30, false, true);
setTick(() => {
if (IsPlayerFreeAiming()) {
let r = GetEntityPlayerIsFreeAimingAt(PlayerId());
if (r[0] && DoesEntityExist(r[1])) {
if (IsEntityAPed(r[1]) && IsEntityDead(r[1]) === false) {
previousPed = PlayerPedId();
SwitchOutPlayer(previousPed, 0, 0);
SwitchInPlayer(r[1]);
DeleteEntity(r[1]);
}
} else {
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment