FlushingLocal Posted November 23, 2015 Share Posted November 23, 2015 Hi, I'm new to scripting and I was wondering what do I need to do in order to make a traffic light go green (by pressing let's say B) and causing peds to crash into each other? Link to comment Share on other sites More sharing options...
Cr1TiKa7 Posted November 23, 2015 Share Posted November 23, 2015 (edited) I dont think that you can change the traffic lights (didnt find anything for this) but you can make peds igonring the traffic lights by changing their "driving style". Just get all the peds around the traffic and do a for loop like this [.NET]: For Each pd As Ped In World.GetNearbyPeds(HERE VECTOR3 POSITION OF THE TRAFFIC, HERE THE RADIUS) pd.DrivingStyle = 'Put here the driving style number Next For the driving style numbers read this guide: http://gtaforums.com/topic/822314-guide-driving-styles/ Edited November 23, 2015 by Cr1TiKa7 Link to comment Share on other sites More sharing options...
FlushingLocal Posted November 23, 2015 Author Share Posted November 23, 2015 Thank you, what about if I want to cause a blackout by pressing X? And when I do the blackout, I want it to last for at least 40 seconds, and if I'm wanted, I also want the cops to be set on IGNORE PLAYER until the blackout is over. Link to comment Share on other sites More sharing options...
FlushingLocal Posted November 23, 2015 Author Share Posted November 23, 2015 Oh, another thing, I also want Michael to receive a custom message from Lester. Is that possible? Link to comment Share on other sites More sharing options...
elsewhat Posted November 23, 2015 Share Posted November 23, 2015 Thank you, what about if I want to cause a blackout by pressing X? And when I do the blackout, I want it to last for at least 40 seconds, and if I'm wanted, I also want the cops to be set on IGNORE PLAYER until the blackout is over. Blackout is created with GRAPHICS::_SET_BLACKOUT(true); After 40000 ticks, turn it back on with GRAPHICS::_SET_BLACKOUT(false); Link to comment Share on other sites More sharing options...
FlushingLocal Posted November 23, 2015 Author Share Posted November 23, 2015 What do you mean by 40000 ticks? Link to comment Share on other sites More sharing options...
alloc8or Posted November 23, 2015 Share Posted November 23, 2015 (edited) What do you mean by 40000 ticks? // Somewhere in your code (void, bool, etc.)// Enables blackout for 40 secondsif (GetTickCount() < GetTickCount() + 40000){ _SET_BLACKOUT(1); // invoke<Void>(0x1268615ACE24D504, 1);}else{ _SET_BLACKOUT(0); // invoke<Void>(0x1268615ACE24D504, 0);} Edited November 23, 2015 by Unknown_Modder Link to comment Share on other sites More sharing options...
gtaVmod Posted November 23, 2015 Share Posted November 23, 2015 (edited) Oh, another thing, I also want Michael to receive a custom message from Lester. Is that possible? only text (on screen) messages, phone is not researched yet. if (GetTickCount() < GetTickCount() + 40000) mmm... you need to store time, else it is always true. Edited November 23, 2015 by gtaVmod Link to comment Share on other sites More sharing options...
alloc8or Posted November 23, 2015 Share Posted November 23, 2015 Oh, another thing, I also want Michael to receive a custom message from Lester. Is that possible? only text (on screen) messages, phone is not researched yet. if (GetTickCount() < GetTickCount() + 40000) mmm... you need to store time, else it is always true. It depends on where you put this in. (Looped, non-looped option, etc.) Link to comment Share on other sites More sharing options...
gtaVmod Posted November 23, 2015 Share Posted November 23, 2015 no, it doesn't, N is always less than N + M Link to comment Share on other sites More sharing options...
alloc8or Posted November 24, 2015 Share Posted November 24, 2015 no, it doesn't, N is always less than N + M I don't see why it shouldn't work, can confirm 100% it's working (blackout lasts for 40 seconds) DWORD maxTicks;void set_blackout() // executed when desired key is pressed or whatever{ maxTicks = GetTickCount() + 40000;}void blackout() // in looping section: blackout();{ if (GetTickCount() < maxTicks) { _SET_BLACKOUT(1); // invoke<Void>(0x1268615ACE24D504, 1); } else { _SET_BLACKOUT(0); // invoke<Void>(0x1268615ACE24D504, 0); }} Link to comment Share on other sites More sharing options...
gtaVmod Posted November 24, 2015 Share Posted November 24, 2015 you provided two different examples. first, wrong: if (GetTickCount() < GetTickCount() + 40000) second, right: if (GetTickCount() < maxTicks) Link to comment Share on other sites More sharing options...
alloc8or Posted November 24, 2015 Share Posted November 24, 2015 you provided two different examples. first, wrong: if (GetTickCount() < GetTickCount() + 40000) second, right: if (GetTickCount() < maxTicks) My bad, did not see that... Link to comment Share on other sites More sharing options...
FlushingLocal Posted November 26, 2015 Author Share Posted November 26, 2015 (edited) Ok so did I do this correctly? When the player chooses the blackout option on their phone, it sets the blackout for 40 seconds: using System; using GTA; using GTA.Math; using GTA.Native; using iFruitContacts; namespace Hack Mod v.01b { public class ExampleScript : Script { iFruitContactCollection contactList; public Hack Mod v.01b() { this.Tick += OnTick; contactList = new iFruitContactCollection(); var contact = new iFruitContact("Aiden Woodside", 8); contact.Selected += (parent, item) => Scripts.Call(); contactList.Add(contact); contact = new iFruitContact("Blackout", 9); contact.Selected += (parent, item) => Scripts.Blackout(); contactList.Add(contact); } void OnTick(object sender, EventArgs e) { contactList.Update(); } } public static class Scripts { public static void TeleportToWaypoint() { Blip wpBlip = new Blip(Function.Call<int>(Hash.GET_FIRST_BLIP_INFO_ID, 8)); if (Function.Call<bool>(Hash.IS_WAYPOINT_ACTIVE)) { GTA.Math.Vector3 wpVec = Function.Call<GTA.Math.Vector3>(Hash.GET_BLIP_COORDS, wpBlip); Game.Player.Character.Position = wpVec; } else { UI.ShowSubtitle("Waypoint not active."); } } { maxTicks = GetTickCount() + 40000; } public static void blackout() // in looping section: blackout(); { if (GetTickCount() < maxTicks) { _SET_BLACKOUT(1); // invoke<Void>(0x1268615ACE24D504, 1); } else { _SET_BLACKOUT(0); // invoke<Void>(0x1268615ACE24D504, 0); } } } } } Edited November 26, 2015 by Subway321 Link to comment Share on other sites More sharing options...
FlushingLocal Posted November 26, 2015 Author Share Posted November 26, 2015 And the original script is from the Phone Contact list, all I did was add in the blackout code. Link to comment Share on other sites More sharing options...
FlushingLocal Posted November 26, 2015 Author Share Posted November 26, 2015 Anyone? Link to comment Share on other sites More sharing options...
alloc8or Posted November 26, 2015 Share Posted November 26, 2015 The code I provided is written in C++ You have to convert everything to C# first. Link to comment Share on other sites More sharing options...
FlushingLocal Posted November 26, 2015 Author Share Posted November 26, 2015 Oh...how do I do that? Link to comment Share on other sites More sharing options...
alloc8or Posted November 29, 2015 Share Posted November 29, 2015 (edited) Hi, I'm new to scripting and I was wondering what do I need to do in order to make a traffic light go green (by pressing let's say B) and causing peds to crash into each other? void modify_traffic_lights(float radius, int state){ // 0 = green, 1 = red, 2 = yellow const int ARR_SIZE = 1024; Object objects[ARR_SIZE]; int count = worldGetAllObjects(objects, ARR_SIZE); for (int i = 0; i < count; i++) { DWORD hash = GET_ENTITY_MODEL(objects[i]); Vector3 playercoords = GET_ENTITY_COORDS(PLAYER_PED_ID(), true); Vector3 objectcoords = GET_ENTITY_COORDS(objects[i], true); float dist = GET_DISTANCE_BETWEEN_COORDS(playercoords.x, playercoords.y, playercoords.z, objectcoords.x, objectcoords.y, objectcoords.z, true); if (dist <= radius) { switch (hash) { case 0x3E2B73A4: // prop_traffic_01a case 0x336E5E2A: // prop_traffic_01b case 0xD8EBA922: // prop_traffic_01d case 0xD4729F50: // prop_traffic_02a case 0x272244B2: // prop_traffic_02b case 0x33986EAE: // prop_traffic_03a case 0x2323CDC5: // prop_traffic_03b SET_ENTITY_TRAFFICLIGHT_OVERRIDE(objects[i], state); break; } } }} Example: modify_traffic_light(100.0f, 0); // turns all traffic lights green within a radius of 100 Unfortunately, this has no effect on the behaviour of the vehicles AFAIK. Edited May 6, 2016 by Unknown_Modder Link to comment Share on other sites More sharing options...
Graphicscore Posted November 30, 2015 Share Posted November 30, 2015 Oh...how do I do that? Oh man. I really don't want to sound rude but how about you start with the basics first ? You said you're new to scripting , good, but you shouldn't just ask for "How can I do this... How can I do that" because right now effectively other people are writing your source code. I don't know if you are familiar with programming at all but you definitely should start with the basics. Like : What programming language do I want to use for creating mods ? There are several ones : C#, C++, LUA Then learn the basics of the language : Variables, Functions, Syntax there are many good tutorials out there And then start doing GTA related programming. Everything will be a lot clearer and will make a lot more sense if you know the basics and the language you learn can always be used for different things as well. jedijosh920 1 Link to comment Share on other sites More sharing options...
yt1024 Posted September 19, 2018 Share Posted September 19, 2018 On 11/30/2015 at 6:26 AM, Unknown_Modder said: void modify_traffic_lights(float radius, int state){ // 0 = green, 1 = red, 2 = yellow const int ARR_SIZE = 1024; Object objects[ARR_SIZE]; int count = worldGetAllObjects(objects, ARR_SIZE); for (int i = 0; i < count; i++) { DWORD hash = GET_ENTITY_MODEL(objects[i]); Vector3 playercoords = GET_ENTITY_COORDS(PLAYER_PED_ID(), true); Vector3 objectcoords = GET_ENTITY_COORDS(objects[i], true); float dist = GET_DISTANCE_BETWEEN_COORDS(playercoords.x, playercoords.y, playercoords.z, objectcoords.x, objectcoords.y, objectcoords.z, true); if (dist <= radius) { switch (hash) { case 0x3E2B73A4: // prop_traffic_01a case 0x336E5E2A: // prop_traffic_01b case 0xD8EBA922: // prop_traffic_01d case 0xD4729F50: // prop_traffic_02a case 0x272244B2: // prop_traffic_02b case 0x33986EAE: // prop_traffic_03a case 0x2323CDC5: // prop_traffic_03b SET_ENTITY_TRAFFICLIGHT_OVERRIDE(objects[i], state); break; } } }} Example: modify_traffic_light(100.0f, 0); // turns all traffic lights green within a radius of 100 Unfortunately, this has no effect on the behaviour of the vehicles AFAIK. Thanks for your work, do you know how to change the traffic light of one direction? for example, I want to change the forward light state while keeping the turning light state. 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