[FREE] Antilag/Twostep script


This script makes it possible to have antilag/twostep functionality in your FiveM server!


Preview:

Video


Features:

  • Configurable
  • Command to toggle functionality
  • Custom audio

What’s new:

  • Custom audio added
  • “NPCs” don’t get scared anymore because of the custom audio

Credits

  • Thanks @GoatGeek for helping me with particles

Installation

Download


How to install

  1. Download the zip folder from Github
  2. Extract the zip inside your resources folder
  3. Add it to server.cfg using ensure yorick-antilag

Feature requests and improvements are always welcome :slight_smile:


Code is accessible Yes
Subscription-based No
Lines (approximately) 80
Requirements None
25 Likes

:100::+1::+1::+1::fire::fire:

1 Like

Good release :+1:

1 Like

Threestep when?

1 Like

Proud of you my son, nice way to begin your programming journey.

1 Like

Nice release yorick!

2 Likes

This is not helping with the lag in my server :pleading_face:

5 Likes

sorry man

Nice script! A couple questions:

  1. Is it possible to have it enabled and disabled via command, and work for all vehicles? (So don’t have to manually put every car in the whitelist?) EDIT: I should really read better… I see you have the command to disable it, is it possible to have the option to be disabled for everything unless the command is run first?
  2. Does the ‘explosion’ sound trigger NPCs to flee/become aggressive? I have seen this happen with previous 2step ALS scripts

Hey, yes you can turn off the functionality via the command /antilag. With the same command you can also turn it back on again. Making it work for all vehicles is easily possible editing the following code, just replace the CreateThread part:

CreateThread(function()
    while true do
        local sleep = 1000
        local player = PlayerPedId()
        local veh = GetVehiclePedIsIn(player, false)
        local vehiclePos = GetEntityCoords(veh)
        local delay = math.random(25, Config.explosionSpeed)
        if GetPedInVehicleSeat(GetVehiclePedIsIn(PlayerPedId()), -1) == player and isAntiLagEnabled then
            sleep = 0
            local RPM = GetVehicleCurrentRpm(veh, player)
            local gear = GetVehicleCurrentGear(veh)

            if gear ~= reverse then
                if not IsControlPressed(1, 71) and not IsControlPressed(1, 72) then
                    if RPM > Config.RPM then
                        TriggerServerEvent("flames", VehToNet(veh))
                        AddExplosion(vehiclePos, 61, 0.0, true, true, 0.0, true)
                        Wait(delay)
                    end
                end
            end
        end
        Wait(sleep)
    end
end)

regarding the NPCs running everywhere when the “explosion” happens… That is something that I can look into, good suggestion. Thank you!

1 Like

From memory, I think a previous script creator was looking at using natives to make peds ignore the player while the explosions sounded (probably in your …if RPM > Config.RPM then… section)

1 Like

This looks interesting! Questions:

  1. Is this sync between players?
  2. Is there a way to use different sounds other than the explotion sound. ‘NPC’s don’t like that’

Hi, yeah it syncs between players. I am currently, as we speak, looking into custom sounds!

2 Likes

I can help you with this script if you want :confused:

The code is on github. Feel free to make pull requests :slight_smile:

2 Likes

this will make the peds ignore the sound it is using some ms but will work. nice script i have been using this for weeks now before you even posted it here.

local effectsEnabled = true

function triggerPedestrianEffects()
if effectsEnabled then
print(“Pedestrians are scared away!”)
else
print(“Pedestrians are not affected.”)
end
end

function togglePedestrianEffects()
effectsEnabled = not effectsEnabled
if effectsEnabled then
print(“Pedestrian effects are now enabled.”)
else
print(“Pedestrian effects are now disabled.”)
end
end

while true do
local playerInput = getPlayerInput() – Replace with actual input retrieval logic
if playerInput == “toggle_pedestrian_effects” then
togglePedestrianEffects()
elseif playerInput == “trigger_pedestrian_effects” then
triggerPedestrianEffects()
else
------- Handle other game logic ---------
end
end

With the most recent script update that I did the peds also don’t get scared because of the custom sounds, so the code you posted does not apply anymore for my script :stuck_out_tongue:

1 Like

Great for the car fans of the server!

1 Like

I like it mate keep up the good work. There is one there who trynda sell this script, shame on him, trying to get free scripts that add a lot of joy on servers and try to make profit out of them

Yeah I saw that, tbh im just here to share some nice resources for the community to use and improve my own coding skills. I don’t really want to get involved in that kind of drama. just here for a good time :slight_smile: