Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Criminal Enterprises
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

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

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

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

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

    2. Support

    3. Suggestions

*DO NOT* SHARE MEDIA OR LINKS TO LEAKED COPYRIGHTED MATERIAL. Discussion is allowed.

Need help with creating a mod


Boooster
 Share

Recommended Posts

If you read my post in the topmost sticky topic, you can skip this - I really want to work on this idea and I feel that if I don't start a new topic it will be buried (and has already started to be) in the other topic... I just want to know if this is possible from an experienced modder so I can start to research how to go about doing this. Here is the idea:

 

 

I have never really modded anything before, but I love this game so much that I wouldn't mind starting to learn to make a mod for personal use (and releasing it if I succeeded). I've started looking up the various tutorials and found I didn't really understand much, and before I start really diving into this I would just like to know that what I want to mod is even possible. I posted about this on the last page but it got swallowed up pretty quickly; here is my idea:

 

To attach a script to each of the traffic lights in the game (or a universal script.. see how much I don't know? smile.gif) where if there is a cop in the radius that would notice you (the same radius that would reset the wanted circle when you try to avoid cops) running a red light you would give one star. This would also apply for pedestrians of course (I'd love to see the cops chase them down for running a red light). That already seems like a daunting task for me, but ideally I would attach a script to the major intersections (Times Square for example) that would automatically give 1 star even if no cops were present - it would work similar to the cameras that are on some intersections that photograph people that run red lights... but I digress.

 

This for me would step up the realism by so much - Ideally it would work for driving down one way streets the wrong way too, but I doubt that is possible - at least with the traffic lights you can attach a script to it... although now that I think about it, I can see it being complex detecing which direction you are passing the light from (so it won't flag you running red light when you passing a green). I think playing the story mode missions with this challenge as well make the game much more interesting and actually make you think instead of holding down the accelerate to get to point A as quickly as possible... I can see using bikes much more intense too - weaving in and out of traffic to escape cops chasing you much easier than cars can!

 

I've been reminded by another poster that cops do flash you their siren when you do break the law (run a red light. drive the wrong way in a one way street), so there must be some way to attach a script that for every time that occurs you wil get one star.. It would seem the easiest way to go about doing it.

 

The bottom line (because I will keep going): I would like to learn this but I want to know from an experienced modder first - is this even possible with the tools we have? And is this something extremely complex for someone who has never modded before? I've always been an idea person more than a modder, so any insight into this would be great. Thanks for reading!

Edited by Boooster
Link to comment
Share on other sites

Well, its not like we (the modders), know everything... You just need to try out things and see if it works. Thats what i do. You create PoC's (Proof of Concepts), for every 'element' of the mod. For ex. first you try to get the trafficlight state (red,green etc), then you try to spawn a cop car. See what i mean?

 

But i dont think its that easy to get the trafficlight state... I didnt notice any function that deal with trafficlights... I think you would have to dig into the memory of the game itself.

Link to comment
Share on other sites

Thanks for the reply! I realize that you modders don't know everything, but you certainly know more than me, and you definately have a better idea of whether or not this is even possible. Could you kindly forward me to a good relevant guide that could get me started on this? I don't know if this is coding, scripting, etc. Yes, I am a total n00b smile.gif

Link to comment
Share on other sites

Well, i suggest downloading Visual Studio Express edition (C# or VB), and the .NET ScriptHook smile.gif Then look through some example scripts that come with the hook. It gives you a nice start. After that just look thought the function of the hook and see whats possible.

 

http://www.microsoft.com/express/

 

And i know ive seen some tutorials on the forum, but i cant find them :S

Edited by Intosia
Link to comment
Share on other sites

I would suggest sending a PM to the creator of this mod. In some of the taxi missions(the ones requiring you to drive safely), you get flagged for running red lights and driving on the wrong side of the road.

 

Examples of this:

user posted image

user posted image

 

I hope this helps you out, as I'd be very interested to see how this goes smile.gif

Link to comment
Share on other sites

Woaaaaaah thank you so much!!! That would make my work like 100x times easier! since it seems that someone has already figured out the necessary code/script that needs to be changed. Thank you for the link, I am PMing the creator now! smile.gif

Link to comment
Share on other sites

I would suggest sending a PM to the creator of this mod. In some of the taxi missions(the ones requiring you to drive safely), you get flagged for running red lights and driving on the wrong side of the road.

 

Examples of this:

user posted image

user posted image

 

I hope this helps you out, as I'd be very interested to see how this goes smile.gif

Wow that wud bring in... MOAR REALIZIZIZM! happy.gif

Link to comment
Share on other sites

GET_TIME_SINCE_PLAYER_DROVE_AGAINST_TRAFFIC

GET_TIME_SINCE_PLAYER_DROVE_ON_PAVEMENT

GET_TIME_SINCE_PLAYER_HIT_BUILDING

GET_TIME_SINCE_PLAYER_HIT_CAR

GET_TIME_SINCE_PLAYER_HIT_OBJECT

GET_TIME_SINCE_PLAYER_HIT_PED

GET_TIME_SINCE_PLAYER_RAN_LIGHT

 

all of those natives take one argument (player) and returns another (time since last event in miliseconds; -1 if no event happened so far)

 

EDIT:

I let my self make small script smile.gif Feel free to use it

It will give you one wanted star everytime when you break the law and cop car is in range (see maxRadius). It's written in c# and can be run using .net scripthook

and I removed checking if player hit building since it returns true everytime you hit kerb and if player hit object because it returns true even if you touch cofee cup

 

using System;using GTA;using GTA.Native;namespace LawMod{   public class LawMod : Script   {       public LawMod()       {           Interval = 250;           Tick += new EventHandler(LawMod_Tick);       }       void LawMod_Tick(object sender, EventArgs e)       {           //there is no purpose for checking if player is breaking the law if he/she is           //currently being chased by police           if (Player.WantedLevel == 0 && isPlayerBreakingLaw && isCopCarInRange)           {               Player.WantedLevel = 1;           }       }       bool isPlayerBreakingLaw       {           get           {               Vehicle veh = Player.Character.CurrentVehicle;               if (veh == null || veh.Speed <= 3f) //if player is not in vehicle or if speed is too low (otherwise cops will chase you even if you only touch ped or scratch car)               {                   return false;               }               int againstTraffic = Function.Call<int>("GET_TIME_SINCE_PLAYER_DROVE_AGAINST_TRAFFIC", Player);                int pavement = Function.Call<int>("GET_TIME_SINCE_PLAYER_DROVE_ON_PAVEMENT", Player);               int car = Function.Call<int>("GET_TIME_SINCE_PLAYER_HIT_CAR", Player);               int ped = Function.Call<int>("GET_TIME_SINCE_PLAYER_HIT_PED", Player);               int redLight = Function.Call<int>("GET_TIME_SINCE_PLAYER_RAN_LIGHT", Player);               return (IsLastTimeInCurrentTick(againstTraffic)|| IsLastTimeInCurrentTick(pavement) || IsLastTimeInCurrentTick(car) || IsLastTimeInCurrentTick(ped) || IsLastTimeInCurrentTick(redLight)); //if any of those are commited return true; otherwise false           }       }       bool isCopCarInRange       {           get           {               //note this will look only for basic cop cars, if you drive against traffic               //next to Noose enforcer they will do nothing               float maxRadius = 25f; //maximum distance for cops to spot breaking the law               Vector3 samplePos = Player.Character.Position; //player's pos               Vehicle[] vehicles = World.GetAllVehicles(); //get all vehicles in game                               foreach (Vehicle veh in vehicles) //loop through vehicles               {                   bool isSirenOn = Function.Call<bool>("IS_CAR_SIREN_ON", veh); //maybe they are chasing someone else?                   bool isEmpty = veh.isSeatFree(VehicleSeat.Driver); //checks if police car is empty (we assume that no one else can drive police car than cops)                   if (samplePos.DistanceTo(veh.Position) > maxRadius || isSirenOn || isEmpty) //don't bother going any further when distance is grater than maxRadius, cops are currently chasing someone else or there is no driver                    {                       continue;                   }                   if (veh.Model == "police" || veh.Model == "police2") //if vehicle's model is a police one return true                   {                       return true;                   }               }               return false; //if no vehicle in array was police return false           }       }       bool IsLastTimeInCurrentTick(int lastTime)       {           //this function will check if given "lastTime" (result of calling           //one of "GET_TIME_SINCE...") has happened within this tick           //           //lastTime grater then Interval means that breaking the law happened before           //this tick and has been handled (by previous tick)           //           // lastTime less than 0 (-1) means that event hasn't happened so far           return lastTime <= Interval && lastTime >= 0;       }   }}

 

Edited by _hax
Link to comment
Share on other sites

Thats pretty cool, but rather then one star straight away for running redlight, have it so that it you only get wanted stars when the police in the area.

Link to comment
Share on other sites

Thats pretty cool, but rather then one star straight away for running redlight, have it so that it you only get wanted stars when the police in the area.

I don't understand you.

Do you want to get wanted level when police is in area or not? In this code example you get wanted level only if cop car is in area but you can change it removing checking wether isCopCarInRange is true in Tick event (cops will be dispatched even if no in area)

Link to comment
Share on other sites

  • 1 month later...

Hey, is there any chance someone could compile that script up there and post the file? I can't compile stuff. I don't have the software or the knowledge.

Link to comment
Share on other sites

Hi, just copy & paste _hax's code into Notepad and save as 'LawMod.cs'. Put this file in the .NET scripthook's 'scripts' folder.

Link to comment
Share on other sites

 

Hi, just copy & paste _hax's code into Notepad and save as 'LawMod.cs'. Put this file in the .NET scripthook's 'scripts' folder.

Thanks! Let's hope this mod works.

 

EDIT: Nope, it just gives me a little error saying "Error in script" and it doesn't do what it's supposed to do.

 

OHH, it preserved the stupid word wrapping. so comments were not being commented out.

 

EDIT: Nope, same deal. Doesn't work and it says "Error in script LawMod.LawMod"

 

the error in the log:

 

 

2009-10-18 01:10:39 - Error during Tick in script 'LawMod.LawMod':                     System.Exception: RemoteEvent 'NativeInvoke' threw a System.AccessViolationException: Attempted to read or write protected memory during remote call to native function 'GET_DRIVER_OF_CAR'!                        at unmanaged.NativeContext3.Invoke(SByte* name, NativeContext3* cxt)                        at GTA.Vehicle.isSeatFree(VehicleSeat Seat)                        at LawMod.LawMod.get_isCopCarInRange()                        at LawMod.LawMod.LawMod_Tick(Object sender, EventArgs e)                        at GTA.Script.TryTick()                        at GTA.Script.DoTick()                        at GTA.ScriptThread.OnTick()

 

Edited by Kitteh
Link to comment
Share on other sites

 

Hi, just copy & paste _hax's code into Notepad and save as 'LawMod.cs'. Put this file in the .NET scripthook's 'scripts' folder.

Thanks! Let's hope this mod works.

 

EDIT: Nope, it just gives me a little error saying "Error in script" and it doesn't do what it's supposed to do.

 

OHH, it preserved the stupid word wrapping. so comments were not being commented out.

 

EDIT: Nope, same deal. Doesn't work and it says "Error in script LawMod.LawMod"

 

the error in the log:

 

 

2009-10-18 01:10:39 - Error during Tick in script 'LawMod.LawMod':                     System.Exception: RemoteEvent 'NativeInvoke' threw a System.AccessViolationException: Attempted to read or write protected memory during remote call to native function 'GET_DRIVER_OF_CAR'!                        at unmanaged.NativeContext3.Invoke(SByte* name, NativeContext3* cxt)                        at GTA.Vehicle.isSeatFree(VehicleSeat Seat)                        at LawMod.LawMod.get_isCopCarInRange()                        at LawMod.LawMod.LawMod_Tick(Object sender, EventArgs e)                        at GTA.Script.TryTick()                        at GTA.Script.DoTick()                        at GTA.ScriptThread.OnTick()

 

The 'veh' var can be null/non existent. Its a bug in the GetAllVehicles() method. Always check if it exists.

 

Exist(veh) && veh != NULL

Link to comment
Share on other sites

 

Hi, just copy & paste _hax's code into Notepad and save as 'LawMod.cs'. Put this file in the .NET scripthook's 'scripts' folder.

Thanks! Let's hope this mod works.

 

EDIT: Nope, it just gives me a little error saying "Error in script" and it doesn't do what it's supposed to do.

 

OHH, it preserved the stupid word wrapping. so comments were not being commented out.

 

EDIT: Nope, same deal. Doesn't work and it says "Error in script LawMod.LawMod"

 

the error in the log:

 

 

2009-10-18 01:10:39 - Error during Tick in script 'LawMod.LawMod':                     System.Exception: RemoteEvent 'NativeInvoke' threw a System.AccessViolationException: Attempted to read or write protected memory during remote call to native function 'GET_DRIVER_OF_CAR'!                        at unmanaged.NativeContext3.Invoke(SByte* name, NativeContext3* cxt)                        at GTA.Vehicle.isSeatFree(VehicleSeat Seat)                        at LawMod.LawMod.get_isCopCarInRange()                        at LawMod.LawMod.LawMod_Tick(Object sender, EventArgs e)                        at GTA.Script.TryTick()                        at GTA.Script.DoTick()                        at GTA.ScriptThread.OnTick()

 

The 'veh' var can be null/non existent. Its a bug in the GetAllVehicles() method. Always check if it exists.

 

Exist(veh) && veh != NULL

where do I add that in?

 

EDIT: ah, figured it out. Seems to work... kind of.

Edited by Kitteh
Link to comment
Share on other sites

  • 1 month later...

 

EDIT: ah, figured it out. Seems to work... kind of.

Sounds you are absolut euphoric about the script...

Are there any results or did the run-over-red-lights-idea went down the tubes/ into the garbage can?

Edited by AVVvU
Link to comment
Share on other sites

  • 3 weeks later...

Hi, since I too am very interested in this sort of mod, and haven't seen anyone actually complete the script so that you can plug it in as usual, here's the edited code where I added that check for the veh variable as instructed a few posts above. The script seems to work fine, so far cops chased me for running red lights and going the wrong way. I experienced slight stutter when I am commiting traffic violations, but nothing bad or consistent.

 

So anyway, here's the code:

 

 

using System;using GTA;using GTA.Native;namespace LawMod{  public class LawMod : Script  {      public LawMod()      {          Interval = 250;          Tick += new EventHandler(LawMod_Tick);      }      void LawMod_Tick(object sender, EventArgs e)      {          //there is no purpose for checking if player is breaking the law if he/she is          //currently being chased by police          if (Player.WantedLevel == 0 && isPlayerBreakingLaw && isCopCarInRange)          {              Player.WantedLevel = 1;          }      }      bool isPlayerBreakingLaw      {          get          {              Vehicle veh = Player.Character.CurrentVehicle;              if (veh == null || veh.Speed <= 3f) //if player is not in vehicle or if speed is too low (otherwise cops will chase you even if you only touch ped or scratch car)              {                  return false;              }              int againstTraffic = Function.Call<int>("GET_TIME_SINCE_PLAYER_DROVE_AGAINST_TRAFFIC", Player);               int pavement = Function.Call<int>("GET_TIME_SINCE_PLAYER_DROVE_ON_PAVEMENT", Player);              int car = Function.Call<int>("GET_TIME_SINCE_PLAYER_HIT_CAR", Player);              int ped = Function.Call<int>("GET_TIME_SINCE_PLAYER_HIT_PED", Player);              int redLight = Function.Call<int>("GET_TIME_SINCE_PLAYER_RAN_LIGHT", Player);              return (IsLastTimeInCurrentTick(againstTraffic)|| IsLastTimeInCurrentTick(pavement) || IsLastTimeInCurrentTick(car) || IsLastTimeInCurrentTick(ped) || IsLastTimeInCurrentTick(redLight)); //if any of those are commited return true; otherwise false          }      }      bool isCopCarInRange      {          get          {              //note this will look only for basic cop cars, if you drive against traffic              //next to Noose enforcer they will do nothing              float maxRadius = 25f; //maximum distance for cops to spot breaking the law              Vector3 samplePos = Player.Character.Position; //player's pos              Vehicle[] vehicles = World.GetAllVehicles(); //get all vehicles in game                              foreach (Vehicle veh in vehicles) //loop through vehicles              {if (Exists(veh) && veh != null){                  bool isSirenOn = Function.Call<bool>("IS_CAR_SIREN_ON", veh); //maybe they are chasing someone else?                  bool isEmpty = veh.isSeatFree(VehicleSeat.Driver); //checks if police car is empty (we assume that no one else can drive police car than cops)                  if (samplePos.DistanceTo(veh.Position) > maxRadius || isSirenOn || isEmpty) //don't bother going any further when distance is grater than maxRadius, cops are currently chasing someone else or there is no driver                   {                      continue;                  }                  if (veh.Model == "police" || veh.Model == "police2") //if vehicle's model is a police one return true                  {                      return true;                  }}               }              return false; //if no vehicle in array was police return false          }      }      bool IsLastTimeInCurrentTick(int lastTime)      {          //this function will check if given "lastTime" (result of calling          //one of "GET_TIME_SINCE...") has happened within this tick          //          //lastTime grater then Interval means that breaking the law happened before          //this tick and has been handled (by previous tick)          //          // lastTime less than 0 (-1) means that event hasn't happened so far          return lastTime <= Interval && lastTime >= 0;      }  }}

 

 

I suck at coding actually, took me two days to figure this one out. tounge.gif So if anyone wants to flesh out this, or the original author is still on it, looking forward to official releases! smile.gif

Cheers!

Link to comment
Share on other sites

Wow! Is anyone able to re-code this as a C++ script (or .asi or something) and compile? I have 1.0.0.4 and the .NET scripthook doesn't work with it yet... I'd se soooo grateful!

 

EDIT: and maybe also make it so that it checks whether cop peds are nearby as well (not just cars), and checks whether they 'see' Niko, rather than just a simple radius (I'm assuming there's a function to test whether they 'see' Niko, since the engine allows you to hide from cops in alleyways and such).

Edited by Yangster
Link to comment
Share on other sites

You can already use the script (I don't know how to compile it either), just copy/paste the code into notepad and name the file with the .cs extension. It would probably be more optimized if compiled - maybe that's the source of the occasional stutter.

 

Not sure if the ped cop giving you wanted stars is a good idea - they're everywhere, unlike cop cars. Like this you have a good chance of running into a cop car and having to bolt, but it isn't a problem during missions if you need to speed up - this script as is adds a great deal of realism to the cops ingame, no more going crazy behind the wheel in their plain sight with them ignoring you. And the best thing is, its not at all annoying! I highly reccomend it!

 

I imagine finishing street races with this mod will be a tad more difficult now... wink.gif

Link to comment
Share on other sites

  • 3 weeks later...

somebody should keep this thing alive!as i see the scripts is already done can anyone make this as a mod for 1.0.4.0 version? icon14.gif

Link to comment
Share on other sites

  • 2 weeks later...
GET_TIME_SINCE_PLAYER_DROVE_AGAINST_TRAFFIC

GET_TIME_SINCE_PLAYER_DROVE_ON_PAVEMENT

GET_TIME_SINCE_PLAYER_HIT_BUILDING

GET_TIME_SINCE_PLAYER_HIT_CAR

GET_TIME_SINCE_PLAYER_HIT_OBJECT

GET_TIME_SINCE_PLAYER_HIT_PED

GET_TIME_SINCE_PLAYER_RAN_LIGHT

 

 

Finally R* scripters have created such opcodes =)

Link to comment
Share on other sites

  • 3 weeks later...

This isn't working at all for me. I have ManSh00ter's revision of the script as "LawMod.cs" in GTA4/scripts, yet nothing is different. I'm running the latest patch with the .NET scripthook and asi loader.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 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.