Boooster Posted August 20, 2009 Share Posted August 20, 2009 (edited) 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 August 20, 2009 by Boooster Link to comment Share on other sites More sharing options...
Intosia Posted August 20, 2009 Share Posted August 20, 2009 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 More sharing options...
Boooster Posted August 20, 2009 Author Share Posted August 20, 2009 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 Link to comment Share on other sites More sharing options...
Intosia Posted August 20, 2009 Share Posted August 20, 2009 (edited) Well, i suggest downloading Visual Studio Express edition (C# or VB), and the .NET ScriptHook 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 August 20, 2009 by Intosia Link to comment Share on other sites More sharing options...
Gokaic Posted August 21, 2009 Share Posted August 21, 2009 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: I hope this helps you out, as I'd be very interested to see how this goes Link to comment Share on other sites More sharing options...
Boooster Posted August 21, 2009 Author Share Posted August 21, 2009 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! Link to comment Share on other sites More sharing options...
Symbiote Posted August 21, 2009 Share Posted August 21, 2009 If this mod pans out it'll be awesome. Link to comment Share on other sites More sharing options...
Nillus Posted August 21, 2009 Share Posted August 21, 2009 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: I hope this helps you out, as I'd be very interested to see how this goes Wow that wud bring in... MOAR REALIZIZIZM! Link to comment Share on other sites More sharing options...
HitZoor Posted August 23, 2009 Share Posted August 23, 2009 Definately a supporter of this mod! Link to comment Share on other sites More sharing options...
jeryslo Posted August 23, 2009 Share Posted August 23, 2009 Good idea, I hope you get a reply from that guy and create this mod. Link to comment Share on other sites More sharing options...
ZZCOOL Posted August 25, 2009 Share Posted August 25, 2009 would be a great mod seeing cops doing some work for once Link to comment Share on other sites More sharing options...
_hax Posted August 30, 2009 Share Posted August 30, 2009 (edited) 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 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 August 30, 2009 by _hax Link to comment Share on other sites More sharing options...
notspectre Posted August 30, 2009 Share Posted August 30, 2009 Woah, nice hax - gives me ideas for my mod Link to comment Share on other sites More sharing options...
Andrew Posted August 31, 2009 Share Posted August 31, 2009 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 More sharing options...
_hax Posted August 31, 2009 Share Posted August 31, 2009 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 More sharing options...
zinklesmesh Posted October 17, 2009 Share Posted October 17, 2009 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 More sharing options...
Symbiote Posted October 17, 2009 Share Posted October 17, 2009 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 More sharing options...
zinklesmesh Posted October 18, 2009 Share Posted October 18, 2009 (edited) 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 October 18, 2009 by Kitteh Link to comment Share on other sites More sharing options...
Intosia Posted October 18, 2009 Share Posted October 18, 2009 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 More sharing options...
zinklesmesh Posted October 19, 2009 Share Posted October 19, 2009 (edited) 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 October 20, 2009 by Kitteh Link to comment Share on other sites More sharing options...
AVVvU Posted December 6, 2009 Share Posted December 6, 2009 (edited) 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 December 6, 2009 by AVVvU Link to comment Share on other sites More sharing options...
ManSh00ter Posted December 21, 2009 Share Posted December 21, 2009 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. So if anyone wants to flesh out this, or the original author is still on it, looking forward to official releases! Cheers! Link to comment Share on other sites More sharing options...
Yangster Posted December 21, 2009 Share Posted December 21, 2009 (edited) 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 December 22, 2009 by Yangster Link to comment Share on other sites More sharing options...
ManSh00ter Posted December 22, 2009 Share Posted December 22, 2009 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... Link to comment Share on other sites More sharing options...
manu90mala Posted January 7, 2010 Share Posted January 7, 2010 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? Link to comment Share on other sites More sharing options...
madforce2k Posted January 8, 2010 Share Posted January 8, 2010 I second that. Very nice. I like where this is going, did it die already or still workable? Link to comment Share on other sites More sharing options...
Crossz0r Posted January 18, 2010 Share Posted January 18, 2010 GET_TIME_SINCE_PLAYER_DROVE_AGAINST_TRAFFICGET_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 More sharing options...
carcols.dat Posted February 6, 2010 Share Posted February 6, 2010 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 More sharing options...
Symbiote Posted February 6, 2010 Share Posted February 6, 2010 HippieCommunist has made a working Traffic Felony mod. http://www.gtaforums.com/index.php?showtopic=438616 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now