Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using GTA; // This is a reference that is needed! do not edit this
- using GTA.Native; // This is a reference that is needed! do not edit this
- using GTA.Math; // This is a reference that is needed! do not edit this
- using System; // This is a reference that is needed! do not edit this
- using System.Windows.Forms; // This is a reference that is needed! do not edit this
- namespace scriptname
- {
- public class scriptname : Script // declare Modname as a script
- {
- Ped player;
- public scriptname() // main function
- {
- Tick += this.OnTick;
- KeyDown += this.OnKeyDown;
- KeyUp += this.OnKeyUp;
- Interval = 0;
- }
- void OnTick(object sender, EventArgs e) // This is where most of your script goes
- {
- player = Game.Player.Character;
- if (Function.Call<bool>(Hash.IS_PED_ARMED, player, 1)) //if player is holding any melee weapon
- {
- //you can get the position of your current weapon by using "getWeaponPosition()". For example:
- //Here, we check if the distance between your weapon and a certain ped is less than or equal to 0.8 units.
- if (World.GetDistance(getWeaponPosition(), Ped.Position) <= 0.8f) //replace "Ped" with any ped you would like to apply the damage pack to.
- {
- //Apply damage pack to ped.
- Function.Call(Hash.APPLY_PED_DAMAGE_PACK, Ped, "HOSPITAL_0", 1.0f, 1.0f); //again, replace "Ped" with the ped you would like to apply the damage pack to.
- }
- }
- }
- Vector3 getWeaponPosition()
- {
- Entity currentWeapon = Function.Call<Entity>(Hash.GET_CURRENT_PED_WEAPON_ENTITY_INDEX, player); //get current weapon as an Entity
- return currentWeapon.Position; //return position of current weapon.
- }
- void OnKeyDown(object sender, KeyEventArgs e)
- {
- }
- void OnKeyUp(object sender, KeyEventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement