[SCRIPT] Automatic turnlights
-
Should be simple. When the GPS tells me to turn left or right on the next intersection by showing an arrow in the lower left corner of the minimap, also activate the corresponding blinker. Would add a lot to the immersion.
-
No need to be a dick towards people, okay? Yes I tried doing it myself, but I couldn't find the way to read the direction of that arrow. Still, there are much more skilled scripters than me on this site, so I think they will be able to do it easily. If they want to, that is.
-
Oh, thank you. Didn't know I could mention other members to attract their attention. I really hope someone makes it real, it would be so awesome.
-
@Claude_Lib I'm thinking about it.
-
Wow, awesome, thank you!
-
i have automatic turn lights but i don't know which mod is causing it
-
You too, thank you.
-
Sorry to bother you, but did you look into it?
-
@Claude_Lib I haven't yet, sorry.
-
Maybe I should ask Eddlm? He did make a similar mod, so he probably knows how to do this.
-
@Claude_Lib If you'd like.
-
@Eddlm, could you please look into this?
-
@Claude_Lib I looked into this and got it to work with the GPS using GENERATE_DIRECTIONS_TO_COORD. But the GPS and the waypoint route dont always match. Sometimes it shows to turn. But the route shows to keep going to the next intersection and then turn. The arrow in the mini map also is incorrect. So unless there is a different way. I think thats the best you can hope fore. Also it only works if you set a waypoint. If no one else wants to do this and this is acceptable to you i will upload it.
-
So I assume it's just not possible to read where the arrow is pointing? Did you do it in CS? I'd like to look into the code, maybe I'll learn something.
-
@Claude_Lib Yes you can. Thats the problem. The arrow is not matching. Here is the code. You can un comment out //UI.ShowSubtitle(directions.ToString()); to see what its returning. 3 = left 4 = right ext.
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using GTA;
using GTA.Native;
using GTA.Math;
using Font = GTA.Font;
using System.Linq;public class AutoTurnSignals : Script
{bool LeftTurnSignalOn = false; bool RightTurnSignalOn = false; int Timer = 0; public AutoTurnSignals() { Tick += OnTick; Timer = (int)Game.GameTime; } public void OnTick(object o, EventArgs e) { unsafe { int directions = -1; float poop = 0; float distance = 0; if (Game.Player.Character.CurrentVehicle != null) { if (Game.IsWaypointActive) { var blip = World.GetActiveBlips().FirstOrDefault(b => b.Type == 4 && b.Sprite == BlipSprite.Waypoint); Function.Call(Hash.GENERATE_DIRECTIONS_TO_COORD, blip.Position.X, blip.Position.Y, blip.Position.Z, 0, &directions, &poop, &distance); //UI.ShowSubtitle(directions.ToString()); if (!Game.Player.Character.IsInVehicle(Game.Player.Character.CurrentVehicle) || Timer < (int)Game.GameTime) { LeftTurnSignalOn = false; RightTurnSignalOn = false; Function.Call<int>(Hash.SET_VEHICLE_INDICATOR_LIGHTS, Game.Player.Character.CurrentVehicle, 1, false); Function.Call<int>(Hash.SET_VEHICLE_INDICATOR_LIGHTS, Game.Player.Character.CurrentVehicle, 0, false); } if (directions == 3) { Timer = (int)Game.GameTime + 2000; Function.Call<int>(Hash.SET_VEHICLE_INDICATOR_LIGHTS, Game.Player.Character.CurrentVehicle, 0, false); if (!LeftTurnSignalOn) { Function.Call<int>(Hash.SET_VEHICLE_INDICATOR_LIGHTS, Game.Player.Character.CurrentVehicle, 1, true); Function.Call<int>(Hash.SET_VEHICLE_INDICATOR_LIGHTS, Game.Player.Character.CurrentVehicle, 0, false); Game.Player.Character.CurrentVehicle.RightIndicatorLightOn = true; LeftTurnSignalOn = true; RightTurnSignalOn = false; } } if (directions == 4) { Timer = (int)Game.GameTime + 2000; Function.Call<int>(Hash.SET_VEHICLE_INDICATOR_LIGHTS, Game.Player.Character.CurrentVehicle, 1, false); if (!RightTurnSignalOn) { Game.Player.Character.CurrentVehicle.LeftIndicatorLightOn = true; Function.Call<int>(Hash.SET_VEHICLE_INDICATOR_LIGHTS, Game.Player.Character.CurrentVehicle, 0, true); Function.Call<int>(Hash.SET_VEHICLE_INDICATOR_LIGHTS, Game.Player.Character.CurrentVehicle, 1, false); RightTurnSignalOn = true; LeftTurnSignalOn = false; } } } if (!Game.IsWaypointActive) { Function.Call<int>(Hash.SET_VEHICLE_INDICATOR_LIGHTS, Game.Player.Character.CurrentVehicle, 1, false); Function.Call<int>(Hash.SET_VEHICLE_INDICATOR_LIGHTS, Game.Player.Character.CurrentVehicle, 0, false); } } } }
}
-
Thank you! I will try it out when I get home.
-
The script I coded didn't take into account GPS, so I'm afraid I can't help.
Only thing I can think of, that can help, is looking into @ImNotMentaL 's Voice Navigation script and see how it figures out the next turn the player would have to make.
NPCs can activate the car turning signals by themselves when they know they have to make a turn, but I don't know how to translate this to the player.
-
@Grofarator That's not what he's looking for. That script does exactly what @Eddlm's does.
-
@aimless' script does exactly what I wanted. Thank you again, man! I modified it a bit, though, to suit my needs.
I'll never play the game without it anymore.
-
@Claude_Lib
@stillhere@aimless You guys should release this on the main site
-
@Claude_Lib Nice. I never thought to check the distance. And you should release this.
-
@Jitnaught Think you meant to tag aimless, not me
-
@stillhere You're right, sorry about that
-
@aimless Why don't you release it yourself? You created it after all, you're the original author.
-
@Claude_Lib Yes but you made work correctly. I just got you started. So its your mod.