Okay now its all starting to come together. Thanks for your help and advice, I'll make it so it would only repair the vehicle, because as you previously said pressing the button defeats the purpose for a Tick, and i'm trying to make a standalone menu mod. I appreciate your patience
GoDz_GodHasFaith
View profile on GTA5-Mods.com »
Posts made by GoDz_GodHasFaith
-
RE: Invincible Vehicle [C#] Helpposted in General Modding Discussion
-
RE: Invincible Vehicle [C#] Helpposted in General Modding Discussion
I'm a little confused with the line of code you gave me. Do you mind explaining a little more in depth what it does?
-
RE: Invincible Vehicle [C#] Helpposted in General Modding Discussion
Hmm... Well the reason why I wanted the Tick was because I wanted the car.Repair(); line to run every second...
Basically I this is the button now:void VehicleRepair() { vehicleMenu.AddItem(vehicleRepair); vehicleMenu.OnItemSelect += (sender, item, index) => { isVehicleRepaired = !isVehicleRepaired; Ped playerPed = Game.Player.Character; if (playerPed == null || !playerPed.Exists() || playerPed.IsDead) return; if (!playerPed.IsInVehicle()) return; Vehicle car = playerPed.CurrentVehicle; if (car == null || !car.Exists()) return; if (Game.GameTime > GameTimeReference) { car.IsInvincible = true; car.Repair(); GameTimeReference = Game.GameTime + 1000; } }; }Now when I press the button in game, it fixes the car. But what i want it to do is run that car.Repair(); line every second but i have no clue how to do that without the Tick..
-
RE: Invincible Vehicle [C#] Helpposted in General Modding Discussion
Whats the issue with moving Tick += Class1_Tick; to the button press code?
-
RE: Invincible Vehicle [C#] Helpposted in General Modding Discussion
Yes! Thank you so much, I edited your script a little to fit more of what I would like it to do, instead of the tick running all the time, could I make it so that whenever the Invincible Vehicle button is pressed in the menu, it would run the Tick?
-
RE: Invincible Vehicle [C#] Helpposted in General Modding Discussion
I have the if statement:
if (Function.Call<bool>(Hash.IS_PED_IN_ANY_VEHICLE, Game.Player.Character, false))
inside of the Tick, How could i make Vehicle car; into a local variable (if I even change it to a local variable) -
RE: Invincible Vehicle [C#] Helpposted in General Modding Discussion
Yes, i figured out the problem but in game it pops up a error as soon as the menu loads. The error is in the beginning of the Tick. But in visual studio there are no issues, so i have to fiddle around with the tick to see what works. Still is very confusing to me lmao, thanks for your help, i hope im not asking any stupid questions (:
-
RE: Invincible Vehicle [C#] Helpposted in General Modding Discussion
oh wow, thank you. I completely jumped over that lmao
Now all i have to figure out is whats wrong with the code, because it pops a error in game when I press the button.
Edit:
Also, could you help me figure out how to make the Invincible Vehicle button when pressed, run the Tick? All is appreciated -
RE: Invincible Vehicle [C#] Helpposted in General Modding Discussion
Thank you both for your responses
So the code I put up wasn't working... as in it didn't even repair the vehicle. So setting it to be invincible didn't work either.
so I've changed around some code, but i'm still having trouble understanding. I have figured out a few things, and I took the advice of JitNaught and Ben, so heres what i have:private void Class1_Tick(object sender, EventArgs e) { if (isVehicleRepaired) { car.Repair(); car.IsInvincible = true; GameTimeReference = Game.GameTime + 1000; vehicleRepair.Text = "Invincible Vehicle: " + true.ToString(); } else { car.IsInvincible = false; vehicleRepair.Text = "Invincible Vehicle: " + false.ToString(); } } void VehicleRepair() { vehicleRepair = new UIMenuItem("Invincible Vehicle: " + isVehicleRepaired.ToString()); vehicleMenu.AddItem(vehicleRepair); playerMenu.OnItemSelect += (sender, item, index) => { if (item == vehicleRepair) { isVehicleRepaired = !isVehicleRepaired; if (isVehicleRepaired) { car.IsInvincible = true; } } }; }my question is inside the brackets of this line of code:
if (isVehicleRepaired)
{
car.IsInvincible = true;
}do i have to make it run the Tick that I just made? Basically on the button press, it would run the Tick. But i have 0 clue on how to do that.
-
Invincible Vehicle [C#] Helpposted in General Modding Discussion
Hello! I'm very new with modding in C# and I've been stuck trying to get this Invincible Vehicle code into my GTA 5 trainer menu. I have the code, but it was originally made as a standalone script, so I've been trying to fit the code to work inside of my trainer and I have a little bit of a idea on what to do, but still need a little help to be pointed in the right direction. Once the menu loads in, all features work fine. But whenever I get to the Invincible Car button, it does nothing. I'm 100% sure its the code, but I've been trying for the past couple hours to fix it but cant find the problem. I've put a OnTick because I want the code to run every second after the button is pressed. Here's my code:
////BUTTON CODE BELOW:
void VehicleRepair() { vehicleRepair = new UIMenuItem("Invincible Vehicle: " + isVehicleRepaired.ToString()); vehicleMenu.AddItem(vehicleRepair); playerMenu.OnItemSelect += (sender, item, index) => { if (item == vehicleRepair) { isVehicleRepaired = !isVehicleRepaired; if (isVehicleRepaired) { void OnTick(object EventArgs) { if (isVehicleRepaired) { if (Game.GameTime > GameTimeReference) { if (Function.Call<bool>(Hash.IS_PED_IN_ANY_VEHICLE, Game.Player.Character, false)) { car.Repair(); int GameTimeReference = Game.GameTime + 1000; vehicleRepair.Text = "Invincible Car: " + true.ToString(); } } } } } } }; }/////END
This code is under public class Class1 : Script
Vehicle car;
int GameTimeReference = Game.GameTime + 1000;bool isVehicleRepaired;
/////Any help would be greatly appreciated please go easy on me