Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
      4. Frontier Pursuits
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Diamond Casino & Resort
      2. DLC
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA 6

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA IV Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA SA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA VC Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA III Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. News

    2. Forum Support

    3. Site Suggestions

RoosterArmament

Police Officers Behavior Mod

Recommended Posts

RoosterArmament

Hi everyone,

 

I'm new in modding GTA IV and so far I only made/converted weapons for the game.

 

What I would like to do is to change the Police Officers behavior in the streets as follow:

 

1) I want the police officers to have AK47 instead of handgun.

 

2) I want the police officers to start shooting at people in the streets, all the time and targeting everyone.

 

How can I do that, what files do I need to modify and is it hard to achieve ?

 

Thanks a lot !

 

 

Share this post


Link to post
Share on other sites
ch3y3zze

 

using System;using GTA;public class CrazyCops : Script{   public CrazyCops()   {       Tick += CrazyCops_Tick;   }   void CrazyCops_Tick(object sender, EventArgs e)   {       foreach (Ped ped in World.GetAllPeds())       {           if (ped.isAliveAndWell && ped.PedType == PedType.Cop && ped.Weapons.AssaultRifle_AK47.Ammo == 0)           {               ped.Weapons.RemoveAll();               ped.Weapons.AssaultRifle_AK47.Ammo = 500;           }       }   }}

 

 

ill add the killer cops later, open notepad paste the code and save as ilovechunkyfunkymonkey.cs and install to scripts

Share this post


Link to post
Share on other sites
RoosterArmament

To install as a Script, what do I need??? Scripthook and/or ASIloader???

 

Thanks a lot mate, I really appreciate it !!!

 

Take your time for the second part, I'm really grateful.

 

EDIT: Do you think it would be possible to make the NOOSE appear after a certain time (few minutes IRL) and randomly shoot at people as well?

It might be a lot of coding though...

Edited by RoosterArmament

Share this post


Link to post
Share on other sites
ch3y3zze

yes make sure u r using scripthook c++ 0.5.1 and scripthookdotnet 1.7.1.7 beta on gta iv 1.0.7 or eflc whatever version is newest

 

AsiLoader: dsound.dll (asi loader by alexander blade) if u want online, but u wont be able to use other people's save files or xlive.dll (called xliveless by listener) this will let u use other people's saved games but no online

 

then yes place in the scripts folder u created when installing the shdontnet

 

and yes everything u said is possible, i can have hookers appear if u want or old grandmas with shotguns too lol

Edited by ch3y3zze

Share this post


Link to post
Share on other sites
RoosterArmament

It's is working perfectly, thank you !!! Exactly what I wanted, no bugs. colgate.gif

 

I'll be patient for the Killer Cops and Killer Noose, in the meantime could you increase the number of police officers in the street by 2 or 3 times the original rockstar game number ?

 

After this, I won't bother you again biggrin.gif

Share this post


Link to post
Share on other sites
ch3y3zze

Well it would be easier to increase the number of cops spawned by editing the dat file that controls that. If i spawn more cops and game reaches it's limits on peds, then they wont spawn. Increasing number of cops running around would probably lead to stability issues, but go ahead and check out the popcyc.dat, i think that is where u can set number of peds spawned by the game

Share this post


Link to post
Share on other sites
ch3y3zze

 

using System;using System.Collections.Generic;using GTA;public class CrazyCops : Script{    GTA.Timer nooseSpawnTimer;    List<Vehicle> vehiclesSpawned;    List<Ped> pedsSpawned;    public CrazyCops()    {        vehiclesSpawned = new List<Vehicle>();        pedsSpawned = new List<Ped>();        nooseSpawnTimer = new Timer(120000);        nooseSpawnTimer.Tick += new EventHandler(nooseSpawnTimer_Tick);        nooseSpawnTimer.Start();                Tick += CrazyCops_Tick;        Interval = 1000;    }    void Cleanup()    {        for (int i = pedsSpawned.Count - 1; i >= 0; i--)        {            if (!Game.Exists(pedsSpawned[i])) pedsSpawned.RemoveAt(i);        }        foreach (Ped ped in pedsSpawned)        {            try            {                if (!ped.isAliveAndWell && !ped.isOnScreen && Game.LocalPlayer.Character.Position.DistanceTo(ped.Position) > 25)                {                    ped.Delete();                }            }            catch (Exception) { }        }        for (int i = vehiclesSpawned.Count - 1; i >= 0; i--)        {            if (!Game.Exists(vehiclesSpawned[i])) vehiclesSpawned.RemoveAt(i);        }        foreach (Vehicle vehicle in vehiclesSpawned)        {            if ((!vehicle.isAlive || !vehicle.isDriveable) && !vehicle.isOnScreen && Game.LocalPlayer.Character.Position.DistanceTo(vehicle.Position) > 25)            {                vehicle.Delete();            }        }    }    void nooseSpawnTimer_Tick(object sender, EventArgs e)    {        Vehicle swatVan;        try        {            Vector3 vehPos = World.GetNextPositionOnStreet(World.GetPositionAround(Game.LocalPlayer.Character.Position, 50));            swatVan = World.CreateVehicle(new Model("NSTOCKADE"), vehPos);            swatVan.isRequiredForMission = true;            vehiclesSpawned.Add(swatVan);        }        catch (Exception ex) { Game.Console.Print("Crazy Cops Error: " + ex.ToString()); Game.DisplayText("Noose Spawn Failed, Check Console >_<"); return; }        VehicleSeat[] seats = new VehicleSeat[] { VehicleSeat.Driver, VehicleSeat.RightFront, VehicleSeat.LeftRear, VehicleSeat.RightRear };        Model swatPedModel = new Model("M_Y_SWAT");        Ped[] cops = new Ped[4];        try        {            for (int i = 0; i < 4; i++)            {                cops[i] = swatVan.CreatePedOnSeat(seats[i], swatPedModel);                cops[i].RelationshipGroup = RelationshipGroup.Cop;                cops[i].BecomeMissionCharacter();                pedsSpawned.Add(cops[i]);            }        }        catch (Exception ex) { Game.Console.Print("Crazy Cops Error: " + ex.ToString()); Game.DisplayText("Noose Spawn Failed, Check Console >_<"); if (Game.Exists(swatVan)) { swatVan.Delete(); } return; }    }    void CrazyCops_Tick(object sender, EventArgs e)    {        Cleanup();        foreach (Ped ped in World.GetAllPeds())        {            if (Game.Exists(ped) && ped.isAliveAndWell && ped.PedType == PedType.Cop)            {                if (ped.Weapons.AssaultRifle_AK47.Ammo == 0)                {                    ped.ChangeRelationship(RelationshipGroup.Bum, Relationship.Hate);                    ped.ChangeRelationship(RelationshipGroup.Civillian_Female, Relationship.Hate);                    ped.ChangeRelationship(RelationshipGroup.Civillian_Male, Relationship.Hate);                    ped.ChangeRelationship(RelationshipGroup.Criminal, Relationship.Hate);                    ped.ChangeRelationship(RelationshipGroup.Dealer, Relationship.Hate);                    ped.ChangeRelationship(RelationshipGroup.Fireman, Relationship.Hate);                    ped.ChangeRelationship(RelationshipGroup.Gang_AfricanAmerican, Relationship.Hate);                    ped.ChangeRelationship(RelationshipGroup.Gang_Albanian, Relationship.Hate);                    ped.ChangeRelationship(RelationshipGroup.Gang_Biker1, Relationship.Hate);                    ped.ChangeRelationship(RelationshipGroup.Gang_Biker2, Relationship.Hate);                    ped.ChangeRelationship(RelationshipGroup.Gang_ChineseJapanese, Relationship.Hate);                    ped.ChangeRelationship(RelationshipGroup.Gang_Irish, Relationship.Hate);                    ped.ChangeRelationship(RelationshipGroup.Gang_Italian, Relationship.Hate);                    ped.ChangeRelationship(RelationshipGroup.Gang_Jamaican, Relationship.Hate);                    ped.ChangeRelationship(RelationshipGroup.Gang_Korean, Relationship.Hate);                    ped.ChangeRelationship(RelationshipGroup.Gang_PuertoRican, Relationship.Hate);                    ped.ChangeRelationship(RelationshipGroup.Gang_Russian1, Relationship.Hate);                    ped.ChangeRelationship(RelationshipGroup.Gang_Russian2, Relationship.Hate);                    ped.ChangeRelationship(RelationshipGroup.Medic, Relationship.Hate);                    ped.ChangeRelationship(RelationshipGroup.Player, Relationship.Hate);                    ped.ChangeRelationship(RelationshipGroup.Prostitute, Relationship.Hate);                    ped.Weapons.RemoveAll();                    ped.Weapons.AssaultRifle_AK47.Ammo = 500;                }                if (ped.isIdle && !ped.isInCombat && !ped.isShooting)                {                    ped.Task.FightAgainstHatedTargets(20f);                }            }        }    }}

 

 

Ok this is untested so I suppose I expect some bugs, let me know wink.gif

Share this post


Link to post
Share on other sites
RoosterArmament

OMG!!! Ch3y3zze this coding is SO GREAT thank you a lot, man!!!

 

Tested it for about 15min, no "bugs" whatsoever. Here are some requests/suggestion:

 

1) Could you make the Noose to have M4 ???(they have AK47 as well, dont change the Police though)

 

2) Could you spawn more Noose (like 2 or 3 trucks at the same time) ?

 

3) Could you make Police and Noose to IGNORE the player (engage him only if there are police stars level)

 

Otherwise this is exactly what I wanted, this is so fun!!! The Police doesn't kill people but arrest them, the Noose kill them but I guess I'll keep it that way it's really cool.

 

Thank you !!!

Share this post


Link to post
Share on other sites
ch3y3zze

oh nice, glad it's working the way it is supposed to, yeah just check back later, ill give noose M4's and try to spawn a 2nd and 3rd vehicle, the one problem i usually have with gta is spawning stuff, sometimes causes instabilty but it's worth giving it a shot, ill make a setting at the top of the script where u can write, spawnNoose = 1 or 2 or 3 and then u test how many u can spawn with out issues wink.gif

 

and ill make them ignore player unless u have wanted level

 

ok just check back later, maybe i can edit today

Edited by ch3y3zze

Share this post


Link to post
Share on other sites
RoosterArmament

Take your time, I can enjoy what you already done at the moment, it is already cool enough!

Share this post


Link to post
Share on other sites
ch3y3zze

 

using System;using System.Collections.Generic;using GTA;public class CrazyCops : Script{   const int NOOSE_SPAWN_COUNT = 3;   GTA.Timer nooseSpawnTimer;   List<Vehicle> vehiclesSpawned;   List<Ped> pedsSpawned;   Model swatPedModel = new Model("M_Y_SWAT");   public CrazyCops()   {       vehiclesSpawned = new List<Vehicle>();       pedsSpawned = new List<Ped>();       nooseSpawnTimer = new Timer(120000);       nooseSpawnTimer.Tick += new EventHandler(nooseSpawnTimer_Tick);       nooseSpawnTimer.Start();       Tick += CrazyCops_Tick;       Interval = 1000;   }   void Cleanup()   {       for (int i = pedsSpawned.Count - 1; i >= 0; i--)       {           if (!Game.Exists(pedsSpawned[i])) pedsSpawned.RemoveAt(i);       }       foreach (Ped ped in pedsSpawned)       {           try           {               if (!ped.isAliveAndWell && !ped.isOnScreen && Game.LocalPlayer.Character.Position.DistanceTo(ped.Position) > 25)               {                   ped.Delete();               }           }           catch (Exception) { }       }       for (int i = vehiclesSpawned.Count - 1; i >= 0; i--)       {           if (!Game.Exists(vehiclesSpawned[i])) vehiclesSpawned.RemoveAt(i);       }       foreach (Vehicle vehicle in vehiclesSpawned)       {           if ((!vehicle.isAlive || !vehicle.isDriveable) && !vehicle.isOnScreen && Game.LocalPlayer.Character.Position.DistanceTo(vehicle.Position) > 25)           {               vehicle.Delete();           }       }   }   void nooseSpawnTimer_Tick(object sender, EventArgs e)   {       for (int i = 0; i < NOOSE_SPAWN_COUNT; i++)       {           Vehicle swatVan;           try           {               Vector3 vehPos = World.GetNextPositionOnStreet(World.GetPositionAround(Game.LocalPlayer.Character.Position, i * 10 + 50));               swatVan = World.CreateVehicle(new Model("NSTOCKADE"), vehPos);               swatVan.isRequiredForMission = true;               vehiclesSpawned.Add(swatVan);           }           catch (Exception ex) { Game.Console.Print("Crazy Cops Error: " + ex.ToString()); Game.DisplayText("Noose Spawn Failed, Check Console >_<"); return; }           VehicleSeat[] seats = new VehicleSeat[] { VehicleSeat.Driver, VehicleSeat.RightFront, VehicleSeat.LeftRear, VehicleSeat.RightRear };           Ped[] cops = new Ped[4];           try           {               for (int i2 = 0; i2 < 4; i2++)               {                   cops[i2] = swatVan.CreatePedOnSeat(seats[i2], swatPedModel);                   cops[i2].RelationshipGroup = RelationshipGroup.Cop;                   cops[i2].BecomeMissionCharacter();                   pedsSpawned.Add(cops[i2]);               }           }           catch (Exception ex) { Game.Console.Print("Crazy Cops Error: " + ex.ToString()); Game.DisplayText("Noose Spawn Failed, Check Console >_<"); if (Game.Exists(swatVan)) { swatVan.Delete(); } return; }       }   }   void CrazyCops_Tick(object sender, EventArgs e)   {       Cleanup();       foreach (Ped ped in World.GetAllPeds())       {           if (Game.Exists(ped) && ped.isAliveAndWell && ped.PedType == PedType.Cop)           {               if (ped.Weapons.AssaultRifle_AK47.Ammo == 0 && ped.Weapons.AssaultRifle_M4.Ammo == 0)               {                   ped.ChangeRelationship(RelationshipGroup.Bum, Relationship.Hate);                   ped.ChangeRelationship(RelationshipGroup.Civillian_Female, Relationship.Hate);                   ped.ChangeRelationship(RelationshipGroup.Civillian_Male, Relationship.Hate);                   ped.ChangeRelationship(RelationshipGroup.Criminal, Relationship.Hate);                   ped.ChangeRelationship(RelationshipGroup.Dealer, Relationship.Hate);                   ped.ChangeRelationship(RelationshipGroup.Fireman, Relationship.Hate);                   ped.ChangeRelationship(RelationshipGroup.Gang_AfricanAmerican, Relationship.Hate);                   ped.ChangeRelationship(RelationshipGroup.Gang_Albanian, Relationship.Hate);                   ped.ChangeRelationship(RelationshipGroup.Gang_Biker1, Relationship.Hate);                   ped.ChangeRelationship(RelationshipGroup.Gang_Biker2, Relationship.Hate);                   ped.ChangeRelationship(RelationshipGroup.Gang_ChineseJapanese, Relationship.Hate);                   ped.ChangeRelationship(RelationshipGroup.Gang_Irish, Relationship.Hate);                   ped.ChangeRelationship(RelationshipGroup.Gang_Italian, Relationship.Hate);                   ped.ChangeRelationship(RelationshipGroup.Gang_Jamaican, Relationship.Hate);                   ped.ChangeRelationship(RelationshipGroup.Gang_Korean, Relationship.Hate);                   ped.ChangeRelationship(RelationshipGroup.Gang_PuertoRican, Relationship.Hate);                   ped.ChangeRelationship(RelationshipGroup.Gang_Russian1, Relationship.Hate);                   ped.ChangeRelationship(RelationshipGroup.Gang_Russian2, Relationship.Hate);                   ped.ChangeRelationship(RelationshipGroup.Medic, Relationship.Hate);                   //ped.ChangeRelationship(RelationshipGroup.Player, Relationship.Hate);                   ped.ChangeRelationship(RelationshipGroup.Prostitute, Relationship.Hate);                   ped.Weapons.RemoveAll();                   if (ped.Model == swatPedModel) { ped.Weapons.AssaultRifle_M4.Ammo = 500; } else { ped.Weapons.AssaultRifle_AK47.Ammo = 500; }               }               if (ped.isIdle && !ped.isInCombat && !ped.isShooting)               {                   ped.Task.FightAgainstHatedTargets(20f);               }           }       }   }}

 

 

ok that will give M4s to Noose now, and set the number of noose vans to spawn at top, also now, they wont go after the player until u have a wanted level, if u notice where i wrote the "//" where it says to hate the player, just delete the "//" if u want them to go after the player again

Edited by ch3y3zze

Share this post


Link to post
Share on other sites
gpcguy1

This is cool. What would you put if you want the cops using shotguns or smgs?

Share this post


Link to post
Share on other sites
ch3y3zze

 

This is cool. What would you put if you want the cops using shotguns or smgs?

just replace where its says "AssaultRifle_AK47" with any of these:

 

 

  public Weapon RocketLauncher public Weapon SniperRifle_M40A1 public Weapon BasicSniperRifle public Weapon AssaultRifle_M4 public Weapon AssaultRifle_AK47 public Weapon MP5 public Weapon Uzi public Weapon BarettaShotgun public Weapon BasicShotgun public Weapon DesertEagle public Weapon Glock public Weapon MolotovCocktails public Weapon Grenades public Weapon Knife public Weapon BaseballBat public Weapon Unarmed

 

 

this is from the WeaponCollection clss in shdn

Share this post


Link to post
Share on other sites
gpcguy1

is there a character selection to make other peds like this?

Share this post


Link to post
Share on other sites
ch3y3zze

This script is affecting Cop PedType's so u can change the ped type for other peds to be affected

 

edit: just tested the multiple noose trucks and my game was swarming with noose, it was awesome lol

Edited by ch3y3zze

Share this post


Link to post
Share on other sites
gpcguy1

I changed the ped type but none of them work except the cops.

Share this post


Link to post
Share on other sites
ch3y3zze

well if ur changing the pedtype u wont want that pedtype to hate itself, so remove the line of code that sets the ped to hate that relationshipgroup for whatever ur adding, PedTypes and Rel groups pretty much lineup, and u will want to add cops to one of the relationship group's being hated

 

not sure it will work but at least test with those changes

Share this post


Link to post
Share on other sites
gpcguy1

I have done that before you told me and it didn't work.

Share this post


Link to post
Share on other sites
ch3y3zze

ah cool ur smarter than the average bear wink.gif

 

yeah something to do with other ped types being less aggressive or something

Share this post


Link to post
Share on other sites
gpcguy1

 

ah cool ur smarter than the average bear wink.gif

 

yeah something to do with other ped types being less aggressive or something

Im checking ways to make the ped group more aggressive

Edit: Couldn't make anything work

Civilians are too coward

Edited by gpcguy1

Share this post


Link to post
Share on other sites
gpcguy1

No pedtype worked besides cops. But when I spawned a Gang_AfricanAmerican via trainer it had them attack everyone like the the script told. But the ones that are on the street don't. Seems to be the relationship for peds.

Share this post


Link to post
Share on other sites
RoosterArmament

@Ch3y3zze: I didn't get the time to THANK YOU. This is just PERFECT. Now I can have alot of fun!!!

 

I do have the feeling that the script is preventing "normal / unscripted" Noose trucks to appear, but I dont really care.

 

No other bugs noticed.

 

Thank you so much !!!

Share this post


Link to post
Share on other sites
ch3y3zze

No problem , I'm glad u enjoy it wink.gif

Share this post


Link to post
Share on other sites
lemonwire

This script is amazing, would it be possible to enable gang wars with similar scripting as well?

Share this post


Link to post
Share on other sites
JokersWild

oh that ch3y3zze he is such a character xD

 

ch3y3zze wrote an awesome drugwars mod with gang battles already, maybe ill ask him to upload it if people want to download it

Edited by JokersWild

Share this post


Link to post
Share on other sites
lemonwire
oh that ch3y3zze he is such a character xD

 

ch3y3zze wrote an awesome drugwars mod with gang battles already, maybe ill ask him to upload it if people want to download it

Thanks for the reply,

 

Yes, I'd like to download it, thanks!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.