-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.lua
116 lines (83 loc) · 3.07 KB
/
functions.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
function Notify(text, type, time)
if time == nil then time = 10000 end
if framework == "QB" then
Core.Functions.Notify(text, type)
elseif framework == "ESX" then
TriggerClientEvent('esx:showNotification', source, text, type, time)
end
end
function math.round(num, numDecimalPlaces)
return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
end
function Title(x,y,z, text)
local onScreen,_x,_y=World3dToScreen2d(x,y,z)
local px,py,pz=table.unpack(GetGameplayCamCoords())
SetTextScale(0.35, 0.35)
SetTextFont(4)
SetTextProportional(1)
SetTextColour(255, 255, 255, 215)
SetTextEntry("STRING")
SetTextCentre(1)
AddTextComponentString(text)
DrawText(_x,_y)
local factor = (string.len(text)) / 370
DrawRect(_x,_y+0.0125, 0.015+ factor, 0.03, 41, 11, 41, 68)
end
function GetRepairPrice1()
local myVehicle = GetVehiclePedIsIn(PlayerPedId(),false)
local EngineHealth = GetVehicleEngineHealth(myVehicle)
local RepairPriceMultiplier = 1
local RepairPrice = math.random(39,49)
EngineHealth = (EngineHealth - 1000)
RepairPriceMultiplier = ((EngineHealth - (EngineHealth* 2)) / 100)
RepairPriceEquals = RepairPrice * RepairPriceMultiplier
RoundedRepairPrice = math.round(RepairPriceEquals)
return RoundedRepairPrice
end
function GetRepairPrice2()
local myVehicle = GetVehiclePedIsIn(PlayerPedId(),false)
local BodyHealth = GetVehicleBodyHealth(myVehicle)
local RepairPriceMultiplier = 1
local RepairPrice = math.random(39,49)
BodyHealth = (BodyHealth - 1000)
RepairPriceMultiplier = ((BodyHealth - (BodyHealth* 2)) / 100)
RepairPriceEquals = RepairPrice * RepairPriceMultiplier
RoundedRepairPrice = math.round(RepairPriceEquals)
return RoundedRepairPrice
end
function EngineRepair()
local plyPed = PlayerPedId()
local plyVeh = GetVehiclePedIsIn(plyPed, false)
local getFuel = GetVehicleFuelLevel(plyVeh)
local RepairPrice = GetRepairPrice1()
TriggerServerEvent('redux_repair:repairpay', RepairPrice + 200)
SetVehicleDirtLevel(plyVeh, 0.0)
SetVehiclePetrolTankHealth(plyVeh, 4000.0)
SetVehicleFuelLevel(plyVeh, getFuel)
SetVehicleEngineHealth(plyVeh, 1000.0)
SetVehicleEngineOn(plyVeh, false, false, true)
Notify("Engine Repaired!", "success")
TriggerEvent('veh.randomDegredation',10,plyVeh,3)
end
function BodyRepair()
local plyPed = PlayerPedId()
local plyVeh = GetVehiclePedIsIn(plyPed, false)
local getFuel = GetVehicleFuelLevel(plyVeh)
local RepairPrice = GetRepairPrice2()
TriggerServerEvent('redux_repair:repairpay', RepairPrice + 200)
SetVehicleDirtLevel(plyVeh, 0.0)
SetVehicleFuelLevel(plyVeh, getFuel)
SetVehicleFixed(plyVeh)
SetVehicleDeformationFixed(plyVeh)
WashDecalsFromVehicle(plyVeh)
SetVehicleBodyHealth(plyVeh, 1000.0)
SetVehicleEngineOn(plyVeh, true, true, true)
Notify("Body Repaired!", "success")
end
function playSoundEffect(soundEffect, volume)
SendNUIMessage({
playSoundEffect = true,
soundEffect = soundEffect,
volume = volume
})
end