Quantcast

Jump to content

» «
Photo

Check if player is armed

No replies to this topic
Yorpie
  • Yorpie

    I fought the law and the law lost.

  • Members
  • Joined: 09 Feb 2011
  • None

#1

Posted 29 December 2013 - 04:07 AM Edited by Yorpie, 29 December 2013 - 04:31 AM.

Hello,

 

I need some help with something.

I have downloaded a script by 'hippiecommunist' which allows the police to give you a ticket instead of arresting you at a 1 star wanted level.

Now I would like to improve this scripts a bit but my own attempts have failed, since I'm unexperienced with script modding.

 

 

The thing I want to change is pretty simple

I used to want something different but I made up my mind, so thats why the topic title is not what I am requesting here, sorry about that.

 

From the moment I receive a 1 star wanted level I want the script to give me 3 seconds to let a cop come to me and hand me a ticket. If there, between the moment I receive a 1 star wanted level and the 3 seconds have passed, hasn't come a cop to me to give me a ticket, I want the script to make the cops act as usual, by which I mean they try to arrest you.

(If you're wondering, I have installed this mod called 'arrest warrant' mod. When you commit a traffic felony you get pulled over and a cop comes to you to ask for your ID. After a few seconds you then receive a 1 star wanted level and you get busted. So I want to receive a ticket if I commit a traffic felony and I decide to pull over instead of getting busted at gunpoint. Since the cop is standing right in front of you, 3 seconds is more then enough for him to start writing the ticket.)

 

 

 

Here is the script:

using System;
using System.Windows.Forms;
using GTA;

// ### when player has 1 wanted star, the police will only fine the player instead of 
// ### arresting him (only if the player has enough cash and the player is idle) 
// ### the cop who gives you the fine will carry your money, in case you'll want it back
// ### press and hold F8 to surrender and get arrested (hold until arrested)

namespace Ticket
{

    public class Ticket : Script
    {



        public Ticket()
        {


            this.Tick += new EventHandler(this.ScriptCommunicationExample1_Tick);

            Wait(0);

        }


        private int RN(int min, int max)
        {
            Random random = new Random();
            return random.Next(min, max);
        }

        Vehicle v = null;
        float spd;
        int w;
        bool sur = false;

        private void ScriptCommunicationExample1_Tick(object sender, EventArgs e)
        {
            {



                Wait(0);



                if (Player.WantedLevel == 1)
                {



                    {
                        AnimationSet anims = new AnimationSet("[email protected]_hold");
                        AnimationSet animz = new AnimationSet("[email protected]");
                        AnimationFlags animflags = AnimationFlags.Unknown12 | AnimationFlags.Unknown11 | AnimationFlags.Unknown09;

                        int B = RN(5000, 14000);
                        float vx = Player.Character.Velocity.X, vy = Player.Character.Velocity.Y;
                        vx = vx * vx; vy = vy * vy;
                        if (Player.Character.isSittingInVehicle() && !Player.Character.isDead)
                        {
                            v = Player.Character.CurrentVehicle;
                            Wait(0);
                            if (v.Exists())
                            {

                                spd = v.Speed;

                            }
                        }

                        GTA.Ped[] pedArray = GTA.World.GetPeds(Player.Character.Position.Around(2.0f), 1.7f, 2);

                        foreach (GTA.Ped Pede in pedArray)
                        {
                            if (sur == true || vx > 0.001F || vy > 0.001F || spd > 2.0F || !Pede.Exists() || (Player.Money < 1000) || GTA.Native.Function.Call<bool>("IS_CHAR_GETTING_UP", Pede) || Pede.isSittingInVehicle()

||

GTA.Native.Function.Call<bool>("IS_GROUP_MEMBER", Pede, Player.Group) || (!Pede.isAliveAndWell) || Pede == Player.Character || Pede.RelationshipGroup == RelationshipGroup.Player || Pede.isRagdoll ||

((Pede.Model.ToString() != "0xF5148AB2") && (Pede.Model.ToString() != "0xE9EC3678") && (Pede.Model.ToString() !=

"0xFAAD5B99")
                           && (Pede.Model.ToString() != "0xE9EC3678") && (Pede.Model.ToString() != "0xC41C88BE") && (Pede.Model.ToString() != "0xC46CBC16")))	//|| Pede.isRagdoll
                            {
                                continue;
                            }
                        Group gr;
                        gr = Player.Group;
                            Wait(0);

                            GTA.Native.Function.Call("REQUEST_MODEL", "amb_clipboard");
                            Pede.Task.AimAt(Player.Character.Position, 1500);
                            Game.DisplayText("LCPD: Freeze!");


                            GTA.Native.Function.Call("SWITCH_PED_TO_ANIMATED", Player.Character, 1);

                            Player.Character.Task.ClearAll();
                            Player.Character.FreezePosition = true;
                            GTA.Native.Function.Call("SET_CAMERA_CONTROLS_DISABLED_WITH_PLAYER_CONTROLS", 0);
                            Player.CanControlCharacter = false;
                            Pede.Health += 50;
                            GTA.Native.Function.Call("CANCEL_OVERRIDE_RESTART");
                            Player.Character.Task.ClearAll();
                            Player.Character.FreezePosition = false;
                            //Wait(800);
                            GTA.Native.Function.Call("SET_MAX_WANTED_LEVEL", 0);
                            if (Pede.isSittingInVehicle()) { Wait(2500); }
                            GTA.Native.Function.Call("REQUEST_MODEL", "amb_clipboard");

                            GTA.Object clipB = World.CreateObject("amb_clipboard", Player.Character.Position.Around(9.0F));

                            Vector3 sx = Player.Character.GetOffsetPosition(new Vector3(0.0f, 0.5f, 0.0f));
                            GTA.Native.Function.Call("CLEAR_WANTED_LEVEL", Player);
                            Player.Character.Task.TurnTo(Pede);
                            if (Player.Character.isSittingInVehicle()) { Wait(1500); }

                            GTA.Native.Function.Call("CLEAR_WANTED_LEVEL", Player);
                            GTA.Native.Function.Call("SET_POLICE_IGNORE_PLAYER", Player, 1);
                            Player.Character.Task.TurnTo(Pede);
                            Wait(1000);

                            if (Player.Character.Weapons.CurrentType != 0)
                            {
                                Game.DisplayText("LCPD: Suspect is Armed, Confiscating Weapon"); B += 3500; Player.Character.Weapons.Current.Ammo -=

Player.Character.Weapons.Current.Ammo;
                            }
                            GTA.Native.Function.Call("SET_CURRENT_CHAR_WEAPON", Player.Character, 0, 1);

                            GTA.Native.Function.Call("SET_CURRENT_CHAR_WEAPON", Pede, 0, 1);
                            GTA.Native.Function.Call("SWITCH_PED_TO_ANIMATED", Pede, 1);
                            Pede.Task.ClearAll();
                            Player.Character.Task.TurnTo(Pede);
                            Pede.DuckWhenAimedAtByGroupMember = false;
                        Pede.ChangeRelationship(RelationshipGroup.Player, Relationship.Companion);
                        gr.AddMember(Pede);

                            Player.Character.Task.TurnTo(Pede);
                            Wait(700);
                            GTA.Native.Function.Call("SET_CURRENT_CHAR_WEAPON", Pede, 0, 1);
                            GTA.Native.Function.Call("SWITCH_PED_TO_ANIMATED", Player.Character, 0);
                            GTA.Native.Function.Call("SET_CURRENT_CHAR_WEAPON", Pede, 0, 1);
                            GTA.Native.Function.Call("SET_EVERYONE_IGNORE_PLAYER", Player, 1);
                            Wait(10);
                            GTA.Native.Function.Call("SET_CURRENT_CHAR_WEAPON", Pede, 0, 1);
                            GTA.Native.Function.Call("SWITCH_PED_TO_ANIMATED", Pede, 1);


                            int W = (int)(Pede.Position.DistanceTo(Player.Character.Position) * 70.0f);
                            Wait(W);
                            GTA.Native.Function.Call("SWITCH_PED_TO_ANIMATED", Pede, 1);
                            GTA.Native.Function.Call("CLEAR_WANTED_LEVEL", Player);
                            Player.Character.Task.TurnTo(Pede); //Wait(700);
                            Pede.Task.TurnTo(Player.Character);

                            if (clipB != null && clipB.Exists()) { GTA.Native.Function.Call("ATTACH_OBJECT_TO_PED", clipB, Pede, 1232, -0.025f, 0.085f, -0.021f, 0.0f, 0.0f, -0.5f, 0); }

                            Player.Character.Task.PlayAnimation(animz, "how", 6.4F);
                            Pede.Task.PlayAnimation(anims, "walk_hold", 6.4F, animflags);
                            Wait(500);
                            Player.Character.Task.ClearAll();
                            Pede.Task.TurnTo(Player.Character);

                            Wait(3500);
                            Pede.SayAmbientSpeech("INTIMIDATE");
	           gr.RemoveMember(Pede);
                            Pede.Task.ClearAll();

                            if (clipB != null && clipB.Exists()) { clipB.Delete(); }
                            Player.CanControlCharacter = true;
                            GTA.Native.Function.Call("SET_CAMERA_CONTROLS_DISABLED_WITH_PLAYER_CONTROLS", 1);
                            GTA.Native.Function.Call("SET_POLICE_IGNORE_PLAYER", Player, 0);
                            GTA.Native.Function.Call("SET_MAX_WANTED_LEVEL", 6);
                            GTA.Native.Function.Call("SET_EVERYONE_IGNORE_PLAYER", Player, 0);
                            if (Player.Money > B)
                            {
                                Player.Money -= B;
                            }
                            else { B = Player.Money; }
                            Pede.Money += B;
                            Player.Money -= B; Game.DisplayText("LCPD: your were fined with: " + B + "$");
                            Pede.RelationshipGroup = RelationshipGroup.Cop;

                            GTA.Native.Function.Call("CANCEL_OVERRIDE_RESTART");
                            Player.Character.FreezePosition = false;
                            sur = false;
                            //  GTA.Native.Function.Call("ALTER_WANTED_LEVEL", Player, 1);
                            // GTA.Native.Function.Call("APPLY_WANTED_LEVEL_CHANGE_NOW", Player);
                            if (Pede.Exists())
                            {
                                GTA.Native.Function.Call("SET_CHAR_AS_MISSION_CHAR", Pede, 0);
		 if (Pede.isInGroup) { gr.RemoveMember(Pede); }
                                Pede.NoLongerNeeded();
                            }
                        }
                        if (sur == true && !GTA.Native.Function.Call<bool>("IS_CHAR_PLAYING_ANIM", Player.Character, "ped", "handsup"))
                        {
                            animz = new AnimationSet("ped");

                            Wait(0);
                            if (isKeyPressed(Settings.GetValueKey("Key", Keys.F8)) && !GTA.Native.Function.Call<bool>("PLAYER_HAS_GREYED_OUT_STARS", Player))
                            {
                                if (!GTA.Native.Function.Call<bool>("IS_CHAR_PLAYING_ANIM", Player.Character, "ped", "handsup"))
                                {
                                    Player.Character.Task.PlayAnimation(animz, "handsup", 15.4F);
                                }

                            }
                            Wait(600);
                            if (!GTA.Native.Function.Call<bool>("IS_CHAR_PLAYING_ANIM", Player.Character, "ped", "handsup"))
                            {
                                Player.WantedLevel = w;
                                sur = false;
                            }
                        }

                    }
                }
                else if ((Player.WantedLevel >= 1) && Player.Character.isAlive && !Player.Character.isRagdoll)//&&!Player.Character.isGettingUp&& sur == false
                {
                    if (isKeyPressed(Settings.GetValueKey("Key", Keys.F8))  && !GTA.Native.Function.Call<bool>("IS_PLAYER_BEING_ARRESTED", Player) && !GTA.Native.Function.Call<bool>("PLAYER_HAS_GREYED_OUT_STARS", Player))
                    {

                        sur = true;
                        w = Player.WantedLevel;
                        AnimationSet animz = new AnimationSet("ped");
                        if (!GTA.Native.Function.Call<bool>("IS_CHAR_PLAYING_ANIM", Player.Character, "ped", "handsup"))
                        {
                            Player.Character.Task.PlayAnimation(animz, "handsup", 15.4F);
                        }

                        Player.WantedLevel = 1;
                        Player.Character.Weapons.Current.Ammo = 0;
                        Player.Character.DropCurrentWeapon();
                        GTA.Native.Function.Call("SET_CURRENT_CHAR_WEAPON", Player.Character, 0, 1);
                        Wait(100);
                        if (GTA.Native.Function.Call<bool>("IS_CHAR_PLAYING_ANIM", Player.Character, "ped", "handsup"))
                        {
                            Wait(0);

                        }
                        else
                        {
                            Wait(0);
                            Player.WantedLevel = w;
                            sur = false;
                        }

                    }

                }


            }
        }

    }


}




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users