SHARE
TWEET

Get last weapon damage

Eddlm Apr 11th, 2016 142 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using GTA;
  2. using GTA.Native;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Windows.Forms;
  6.  
  7.  
  8. public class ScriptTest : Script
  9. {
  10.     public ScriptTest()
  11.     {
  12.         Tick += OnTick;
  13.         KeyDown += OnKeyDown;
  14.         KeyUp += OnKeyUp;
  15.  
  16.     }
  17.     List<WeaponHash> Guns = new List<WeaponHash> {WeaponHash.Pistol,WeaponHash.PumpShotgun };
  18.     void OnTick(object sender, EventArgs e)
  19.     {
  20.         Ped Player = Game.Player.Character;
  21.         WeaponHash Weapon = WeaponHash.Unarmed;
  22.  
  23.         foreach (WeaponHash gun in Guns)
  24.         {
  25.             if (Function.Call<bool>(Hash.HAS_PED_BEEN_DAMAGED_BY_WEAPON, Player, (int)gun))
  26.             {
  27.                 Weapon = gun;
  28.                 break;
  29.             }
  30.         }
  31.         DisplayHelpTextThisFrame("Player last damaged by "+ Weapon.ToString());
  32.     }
  33.     void OnKeyDown(object sender, KeyEventArgs e)
  34.     {
  35.  
  36.     }
  37.     void OnKeyUp(object sender, KeyEventArgs e)
  38.     {
  39.  
  40.     }
  41.  
  42.     public static void DisplayHelpTextThisFrame(string text)
  43.     {
  44.         Function.Call(Hash._SET_TEXT_COMPONENT_FORMAT, "STRING");
  45.         Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text);
  46.         Function.Call(Hash._DISPLAY_HELP_TEXT_FROM_STRING_LABEL, 0, false, true, -1);
  47.     }
  48. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top