The code snippets presented here, in no particular order, are coded
for use with LemonUI checkboxes and OnTick. However you can use the
same code without the checkboxes. When you see .Title, it refers to
the checkboxes. For example: StuntJump.Title
Actually ticks are parasitic arachnids, not insects, but let's get back on topic. The OnTick event in ScriptHookVDotNet is like a regular check-in that happens every time the game updates or refreshes its scene, usually many times per second. This event is essential because it allows developers to run specific code—like monitoring a player’s actions—within that brief moment of the game's timeline.
For example, if a game mod wants to keep track of the speed of a player’s car, the OnTick event would be the perfect spot to check the speed continuously and ensure that the game responds to the player’s actions in real-time. This section contains snippets of code that impact the game environments. They are all monitored in the OnTick event.
// The code below toggles Help Display. The titles refer to the LemonUI checkboxes if used.
if (HelpDisplay.Checked) { Function.Call(Hash.HIDE_HELP_TEXT_THIS_FRAME); HelpDisplay.Title = "Help Disabled"; } else { HelpDisplay.Title = "~g~Help Enabled"; }
// Disables Notifcations including SHVDN exception errors.
if (NotificationDisplay.Checked) { Function.Call(Hash.THEFEED_HIDE_THIS_FRAME); NotificationDisplay.Title = "Notifications Disabled"; } else { NotificationDisplay.Title = "~g~Notifications Enabled"; }
// Stunt Jump, two functions, both set to 0 to work.
if (StuntJump.Checked) { Function.Call(Hash.DISABLE_STUNT_JUMP_SET, 0); StuntJump.Title = "Stunt Jumps Disabled"; } else { Function.Call(Hash.ENABLE_STUNT_JUMP_SET, 0); StuntJump.Title = "~g~Stunt Jumps Enabled"; }
// radar - must be enabled (turned On) in game display settings
if (RadarDisplay.Checked)
{
Function.Call(Hash.DISPLAY_RADAR, 0);
RadarDisplay.Title = "Radar Disabled";
}
else
{
Function.Call(Hash.DISPLAY_RADAR, 1);
RadarDisplay.Title = "~g~Radar Enabled";
}
// Phone and Quick Save
if (DisablePhone.Checked) { Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "spcellphone"); Game.DisableControlThisFrame(GTA.Control.Phone); DisablePhone.Title = "~r~Phone and Save Disabled"; } else { DisablePhone.Title = "~w~Phone and Save Enabled"; }
// Reticle Display
if (Game.Player.IsAiming) { if (ReticleDisplay.Checked) { { //GTA.UI.Screen.HideHudComponentThisFrame(14); Function.Call(Hash.HIDE_HUD_COMPONENT_THIS_FRAME, 14); } } else { Function.Call(Hash.SHOW_HUD_COMPONENT_THIS_FRAME, 14); } }
// Player Super Jump
if (JumpState.Checked) { Function.Call(Hash.SET_SUPER_JUMP_THIS_FRAME, Game.Player); }
// Density Multiplier Values: 0.0 = no vehicles on streets, 1.0 = normal vehicles on streets
// There are many options here. Experiment with what works best for your game configuration.
if (DecreaseVehicles.Checked)
{
Function.Call(Hash.SET_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0.0); //float
// Function.Call(Hash.SET_RANDOM_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0.0);//float
Function.Call(Hash.SET_PARKED_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0.0);//float
Function.Call(Hash.SET_VEHICLE_POPULATION_BUDGET, 0); //integer
DecreaseVehicles.Title = "Decrease Vehicle Population";
}
else
{
Function.Call(Hash.SET_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 1.0);
// Function.Call(Hash.SET_RANDOM_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 1.0);
Function.Call(Hash.SET_PARKED_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 1.0);
Function.Call(Hash.SET_VEHICLE_POPULATION_BUDGET, 3); //3 seems to work well
DecreaseVehicles.Title = "~g~Normal Traffic";
}
// Many different options are available. These are just a sampling.
if (DisableCitySounds.Checked)
{
Function.Call(Hash.START_AUDIO_SCENE, "CHARACTER_CHANGE_IN_SKY_SCENE");
Function.Call(Hash.SET_AUDIO_FLAG, "PoliceScannerDisabled", true);
Function.Call(Hash.SET_AUDIO_FLAG, "DisableFlightMusic", true);
}
else
{
}
// Disable the Parachute, doesn't work consistently
if (Game.Player.Character.IsInParachuteFreeFall)
{
Function.Call(Hash.SET_PLAYER_HAS_RESERVE_PARACHUTE, Game.Player, false);
}