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. DLC
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
      7. The Diamond Casino Heist
    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

FlushingLocal

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

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?

Share this post


Link to post
Share on other sites
Cr1TiKa7

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
FlushingLocal

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

Share this post


Link to post
Share on other sites
elsewhat

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);

Share this post


Link to post
Share on other sites
FlushingLocal

What do you mean by 40000 ticks?

Share this post


Link to post
Share on other sites
alloc8or

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

Share this post


Link to post
Share on other sites
gtaVmod

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

Share this post


Link to post
Share on other sites
alloc8or

 

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

Share this post


Link to post
Share on other sites
gtaVmod

no, it doesn't, N is always less than N + M

Share this post


Link to post
Share on other sites
alloc8or

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);	}}

Share this post


Link to post
Share on other sites
gtaVmod

you provided two different examples.

 

 

first, wrong:

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

second, right:

if (GetTickCount() < maxTicks)

Share this post


Link to post
Share on other sites
alloc8or

 

you provided two different examples.

 

 

first, wrong:

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

second, right:

if (GetTickCount() < maxTicks)

My bad, did not see that...

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
FlushingLocal

And the original script is from the Phone Contact list, all I did was add in the blackout code.

Share this post


Link to post
Share on other sites
FlushingLocal

Anyone?

Share this post


Link to post
Share on other sites
alloc8or

The code I provided is written in C++

You have to convert everything to C# first.

Share this post


Link to post
Share on other sites
FlushingLocal

Oh...how do I do that?

Share this post


Link to post
Share on other sites
alloc8or

 

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

Share this post


Link to post
Share on other sites
Graphicscore

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.

Share this post


Link to post
Share on other sites
yt1024
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.

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.