[FREE] Qubit's Driving Shake


Qubit’s Driving Shake Code Snippet

when you start driving, your game camera will shake when you hit it according to your vehicle speed!

🎉 Full Features

:sparkles: 0.01 Resmon value ( optimized by @YvaneOficial & @bitc0de )

:sparkles: 7/24 Support with any questions

🍩 FREE DOWNLOAD

DOWNLOAD FROM TEBEX

📸 Video Preview

If embed video not work ? Watch on Streamable

⚙️ OTHER WORKS

Code is accessible Yes
Subscription-based No
Lines (approximately) 20 +
Requirements none
Support Yes
25 Likes

I want to know how to get that map in the clip tho

Here are the improvements I made:

I changed the name of the lastdamage and curdamage variables to lastDamage and curDamage, following the naming conventions in Lua.
Remove the curspeed variable as it was not being used in the code.
I removed the local line veh2 = GetVehiclePedIsIn(PlayerPedId(), false), as it was not being used.
Fixed the call GetVehiclePedIsIn(PlayerPedId(-1, false) to GetVehiclePedIsIn(PlayerPedId(), false) since you are already getting the current player with PlayerPedId().
I changed GetVehiclePedIsIn(GetPlayerPed(-1)) to GetVehiclePedIsIn(playerPed) since playerPed is the current player.
I checked that the vehicle variable is different from nil and 0 before waiting with damage and judder checks.
I used GetEntitySpeed(vehicle) instead of GetEntitySpeed(veh) to get the current vehicle speed.
I increased the readability of the code by adding proper spacing and indentation.
Keep in mind that these are code organization and style improvements only. I didn’t change the logic of the program itself, so if there are other possible problems in your original code, they are not addressed here.

local lastDamage = 0.0
local curDamage = 0.0
local vehicle = nil

Citizen.CreateThread(function()
while true do
local playerPed = PlayerPedId()
local vehicle = GetVehiclePedIsIn(playerPed, false)

    if DoesEntityExist(vehicle) then
        local shakeRate = GetEntitySpeed(vehicle) / 250.0

        if vehicle ~= nil and vehicle ~= 0 then
            local curHealth = GetVehicleBodyHealth(vehicle)
            if curHealth ~= lastDamage then
                ShakeGameplayCam("MEDIUM_EXPLOSION_SHAKE", shakeRate)
            end
            lastDamage = curHealth
        end
    end

    Citizen.Wait(0)
end

end)

2 Likes

Hello @YvaneOficial, I detect the collision by checking the vehicle damage every milisecond while inside the car, in terms of performance it may not be a very good method, tomorrow I’ll share an improved version, thanks for resmon stats

1 Like

Pushed to github, thanks for the optimization :smiling_face_with_three_hearts:

2 Likes

You’re welcome, now it’s consuming 0.01 :slight_smile:

I just made you a pull request optimizing your code and consuming 0.00 in resmon

imagen

Regards

5 Likes

Circle map is fh4map script, I can’t share map design because this is a private work, maybe I can share it in the future, sorry :frowning_face:

1 Like

Merged on github, thanks for the optimization :partying_face:

2 Likes

This seems really sick but sadly it does not work for me in my server, bummer.

I probably fixed your problem, can you download and try again?

Ya for sure

No luck unfortunately, I might have something conflicting with it maybe

Maybe any drug or alcohol script running StopGameplayCamShaking() or anything, thanks for try :innocent:

Very successful creation :clap: :clap:

1 Like

very good script

1 Like

nice work bro

1 Like

amazing work mate! Keep going!

1 Like

Works great, thanks yo!