Advertisement
Guest User

InvincibleRagdoll.cs

a guest
Jul 12th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 KB | None | 0 0
  1. using GTA; // This is a reference that is needed! do not edit this
  2. using GTA.Math;
  3. using GTA.Native; // This is a reference that is needed! do not edit this
  4. using System; // This is a reference that is needed! do not edit this
  5. using System.Windows.Forms; // This is a reference that is needed! do not edit this
  6.  
  7. namespace InvincibleRagdoll
  8. {
  9.     public class InvincibleRagdoll : Script // declare Modname as a script
  10.     {
  11.         bool invincible = false;
  12.  
  13.         public InvincibleRagdoll() // main function
  14.         {
  15.             Tick += this.OnTick;
  16.             KeyDown += this.OnKeyDown;
  17.             KeyUp += this.OnKeyUp;
  18.         }
  19.  
  20.         void OnTick(object sender, EventArgs e) // This is where most of your script goes
  21.         {
  22.             Ped player = Game.Player.Character; // player variable
  23.  
  24.             if (player.IsRagdoll)
  25.             {
  26.                 player.Health = player.MaxHealth;
  27.                 player.Armor = 100;
  28.                 Function.Call(Hash.SET_PED_SUFFERS_CRITICAL_HITS, player, false);
  29.                 player.AlwaysDiesOnLowHealth = false;
  30.                 invincible = true;
  31.             }
  32.             else
  33.             {
  34.                 if (invincible) //to make the following code only run once, we check the "invincible" boolean
  35.                 {
  36.                     Function.Call(Hash.SET_PED_SUFFERS_CRITICAL_HITS, player, true);
  37.                     //player.AlwaysDiesOnLowHealth = true; //not sure if needed, so leaving it out.
  38.                     invincible = false;
  39.                 }
  40.             }
  41.         }
  42.        
  43.         void OnKeyDown(object sender, KeyEventArgs e)
  44.         {
  45.         }
  46.  
  47.         void OnKeyUp(object sender, KeyEventArgs e)
  48.         {
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement