Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Class1 : Script
- {
- bool bSmoking = false;
- GTA.Object spliff;
- GTA.Timer timer = new GTA.Timer(); // the timer will always show the elapsed gametime since the last Start()
- AnimationSet anims = new AnimationSet("amb@smoking_spliff");
- AnimationFlags animflags = AnimationFlags.Unknown12 | AnimationFlags.Unknown11 | AnimationFlags.Unknown09;
- public Class1()
- {
- Interval = 1000;
- this.KeyDown += new GTA.KeyEventHandler(this.AnimationExample_KeyDown);
- this.Tick += new EventHandler(this.AnimationExample_Tick);
- }
- private void AnimationExample_KeyDown(object sender, GTA.KeyEventArgs e)
- {
- if (e.Key != Keys.J) return;
- if (bSmoking)
- StopSmoking();
- else
- StartSmoking();
- }
- private void StartSmoking()
- {
- if (bSmoking) return;
- bSmoking = true;
- Player.Character.Weapons.Unarmed.Select();
- Player.Character.Animation.Play(anims, "create_spliff", 8.0F, animflags);
- Wait(1600);
- spliff = World.CreateObject(0xD130ADEF, Player.Character.Position);
- spliff.AttachToPed(Player.Character, Bone.RightHand, new Vector3(0.14F, 0.03F, 0.04F), new Vector3(2.21F, -0.12F, 0.0F));
- Player.Character.Animation.WaitUntilFinished(anims, "create_spliff");
- timer.Start();
- }
- private void StopSmoking()
- {
- if (!bSmoking) return;
- bSmoking = false;
- if (spliff == null) return;
- spliff.Detach();
- spliff.NoLongerNeeded();
- }
- private void AnimationExample_Tick(object sender, EventArgs e)
- {
- if (bSmoking)
- {
- if (Player.Character.Weapons.CurrentType != Weapon.Unarmed)
- {
- StopSmoking();
- }
- else if ((timer.ElapsedTime > 10000) && (Player.Character.isIdle))
- {
- if (Player.Character.isInVehicle())
- Player.Character.Task.PlayAnimation(anims, "partial_smoke_car", 8.0F, animflags);
- else
- Player.Character.Task.PlayAnimation(anims, "partial_smoke", 8.0F, animflags);
- timer.Start();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement