Advertisement
LouNGeR

GTA IV Capturing Headshots

May 6th, 2011
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using System;
  2. using GTA;
  3.  
  4. // CAPTURING HEADSHOTS
  5. // ©2011 LouNGeR
  6. // For http://www.gtaforums.com/index.php?act=ST&t=475837
  7.  
  8. public class HeadshotTest : Script
  9. {
  10.     public HeadshotTest()
  11.     {
  12.         Interval = 250;
  13.         this.Tick += new EventHandler(this.HeadshotTest_Tick);
  14.     }
  15.     private void HeadshotTest_Tick(object sender, EventArgs e)
  16.     {
  17.         GTA.Native.Pointer BonePointer = typeof(Int32);
  18.         GTA.Native.Function.Call("GET_CHAR_LAST_DAMAGE_BONE", Player.Character, BonePointer);
  19.         Int32 iBone = Convert.ToInt32(BonePointer.Value);
  20.  
  21.         // http://www.gtamodding.com/index.php?title=Ped_Bones
  22.         // BONE_NECK: 0x4B4
  23.         // BONE_HEAD: 0x4B5
  24.  
  25.         switch (iBone)
  26.         {
  27.             case 0x4B5:
  28.                 //Game.DisplayText("HEADSHOT!!");                     // Received a headshot
  29.                 Random RNG = new Random((int)DateTime.Now.Ticks);
  30.                 Double RandomNumber = RNG.NextDouble();
  31.                 if (RandomNumber < .7)                              // Let's say Niko has a 70% chance of dying
  32.                     Player.Character.Die();
  33.                 break;
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement