#Locals out of the way

1 messages · Page 1 of 1 (latest)

granite schooner
#

I have watched NoPixel streams for really long time and everytime some racer runs away from cops and hits local's vehicle, that vehicle gets yeet'd away from player's way. So I wanted to create something similar..

granite schooner
#

Here is code if you want to test it out (should not be used at roleplay server)

Common issues:

  • chatgpt "fixed" some issues and replaced some of code so dont expect it to work 100% of time lol
function normalize(vec)
    local length = math.sqrt(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z)
    if length ~= 0 then
        return vector3(vec.x / length, vec.y / length, vec.z / length)
    else
        return vector3(0.0, 0.0, 0.0)
    end
end

AddEventHandler('entityDamaged', function(victim, culprit, weapon, damage)
    if IsPedInAnyVehicle(PlayerPedId()) and GetEntityType(victim) == 2 then
        local playerVehicle = GetVehiclePedIsIn(PlayerPedId(), false)
        local victimVehicle = victim

        local playerCoords = GetEntityCoords(playerVehicle)
        local victimCoords = GetEntityCoords(victimVehicle)

        local forceDirection = (victimCoords - playerCoords) * vector3(1.0, 1.0, 0.0)
        local normalizedForce = normalize(forceDirection)

        local forceMultiplier = 10.0 -- Adjust this value to change force of velocity

        local victimVelocity = GetEntityVelocity(victimVehicle)
        local newVelocity = victimVelocity + normalizedForce * forceMultiplier
        SetEntityVelocity(victimVehicle, newVelocity.x, newVelocity.y, newVelocity.z)
    end
end)
turbid venture
#

where to put?

granite schooner
#

any client file

candid cipher
#

haha nice it’s hilarious to watch

slender ledge
#

good idea, however i think something I would do is make them vanish, could only imagine the police chases with this kek

summer swift
#

all you have to do is turn up the fmass on the vehicles handling metas you want.

granite schooner
whole sun
#

making them vanish would be a lot better IMO

summer swift
granite schooner