Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      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

Help with turning lights green and causing peds to crash into each oth


FlushingLocal
 Share

Recommended Posts

FlushingLocal

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

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 by Cr1TiKa7
Link to comment
Share on other sites

FlushingLocal

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

FlushingLocal

Oh, another thing, I also want Michael to receive a custom message from Lester. Is that possible?

Link to comment
Share on other sites

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

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 by Unknown_Modder
Link to comment
Share on other sites

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 by gtaVmod
Link to comment
Share on other sites

 

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

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

you provided two different examples.

 

 

first, wrong:

if (GetTickCount() < GetTickCount() + 40000)

second, right:

if (GetTickCount() < maxTicks)
Link to comment
Share on other sites

 

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

FlushingLocal

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 by Subway321
Link to comment
Share on other sites

FlushingLocal

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

 

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 by Unknown_Modder
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

  • 2 years later...
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

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.