-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathclient.lua
56 lines (48 loc) · 1.92 KB
/
client.lua
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Main = {
ped = PlayerPedId
}
RegisterNetEvent('bbv-repair:usekit',function()
if IsPedInAnyVehicle(PlayerPedId(), true) then Wrapper:Notify('You need to exit the car first') return end
local ped = Main.ped()
local ped_pos = GetEntityCoords(ped)
Main.veh,Main.dist = Wrapper:GetClosesVeh(ped_pos)
if Main.dist < Config.Settings.Distance then
Main:RepairCam()
else
Wrapper:Notify(Config.Button.NoVeh,'error',6000)
end
end)
function Main:RepairCam()
Main.Cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", 1)
RenderScriptCams(true, 1, 1500, true, true)
self:processCamera(Main.Cam)
Wait(1500)
exports['bbv-interactbutton']:button(Config.Button.FirstText,Config.Button.EndText,Config.Button.Event,Config.Button.Time)
end
function Main:processCamera(cam)
SetVehicleDoorOpen(Main.veh, 4, false, false)
local vehpos = GetEntityCoords(Main.veh)
local vehfront = GetEntityForwardVector(Main.veh)
local vehfrontpos = vector3(vehpos.x + (vehfront.x * 3),vehpos.y + (vehfront.y * 3) ,vehpos.z + (vehfront.z * 2) )
local rotx, roty, rotz = table.unpack(GetEntityRotation(PlayerPedId()))
local camX, camY, camZ = table.unpack(GetGameplayCamCoord())
local camRX, camRY, camRZ = GetGameplayCamRelativePitch(), 0.0, GetGameplayCamRelativeHeading()
local camF = GetGameplayCamFov()
local camRZ = (rotz+camRZ)
SetCamCoord(cam, vehfrontpos.x, vehfrontpos.y, vehfrontpos.z + 1.5)
PointCamAtCoord(cam, vehpos.x,vehpos.y,vehpos.z - 1)
SetCamFov(cam, camF)
end
RegisterCommand(Config.Settings.Command, function()
if Config.Settings.Framework == 'ST' then
TriggerEvent('bbv-repair:usekit')
end
end)
RegisterNetEvent('bbv-repair:repair',function()
Wrapper:RemoveItem(Config.Settings.ItemName,1)
SetVehicleEngineHealth(Main.veh, 1000)
SetVehicleEngineOn( Main.veh, true, true )
SetVehicleFixed(Main.veh)
RenderScriptCams(false, 1, 1500, false, false)
Main.veh = nil
end)