-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.lua
More file actions
29 lines (25 loc) · 938 Bytes
/
Copy pathclient.lua
File metadata and controls
29 lines (25 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
-- check the speed of the vehicle
function GetEntitySpeedKmh(entity)
local speed = GetEntitySpeed(entity)
return speed * 3.6 -- Convert from m/s to km/h
end
-- Main thread
Citizen.CreateThread(function()
while true do
Citizen.Wait(0) -- loop
local playerPed = PlayerPedId() -- playerped
if IsPedInAnyVehicle(playerPed, false) then
local vehicle = GetVehiclePedIsIn(playerPed, false)
local speed = GetEntitySpeedKmh(vehicle)
if speed >= 200.0 then
TriggerServerEvent('collision:checkProximity', vehicle)
end
end
end
end)
RegisterNetEvent('collision:setCollision')
AddEventHandler('collision:setCollision', function(targetPed, enable)
local playerPed = PlayerPedId()
local vehicle = GetVehiclePedIsIn(playerPed, false)
SetEntityNoCollisionEntity(vehicle, targetPed, not enable)
end)