-
Notifications
You must be signed in to change notification settings - Fork 2
/
client.lua
160 lines (158 loc) · 5.2 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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
local vehicle = nil
local isDriver = false
local fTractionLossMult = nil
local isModed = false
local class = nil
local isBlacklisted = false
local classMod = {
[0]= 2.51, -- Compacts
[1] = 2.51, --Sedans
[2] = 1.01, --SUVs
[3] = 2.51, --Coupes
[4] = 2.501, --Muscle
[5] = 2.51, --Sports Classics
[6] = 2.51, --Sports
[7] = 2.51, --Super
[8] = 1.51, --Motorcycles
[9] = 0, --Off-road
[10] = 0, --Industrial
[11] = 0, --Utility
[12] = 2.21, --Vans
[13] = 0, --Cycles
[14] = 0, --Boats
[15] = 0, --Helicopters
[16] = 0, --Planes
[17] = 0, --Service
[18] = 2.21, --Emergency
[19] = 0, --Military
[20] = 2.21, --Commercial
[21] = 0 --Trains
}
local blackListed = {
788045382, --"sanchez"
-1453280962,--"sanchez2"
1753414259, --"enduro"
2035069708,--"esskey"
86520421,--"bf400"
-488123221,--"predator"
-1536924937,--"policeold1"
-1647941228,--"fbi2"
353883353,--"polmav"
469291905,--"lguard"
1475773103, --Rumpo3
1977528411, --Scoutpol
1570619963, --ktm policia
610904671, -- insurgency
-561505450, --scpd4
-1286617882, --scpd5
-271532569, --scpd7
-879194100, --umkscout
}
Citizen.CreateThread(function()
while true do
local ped = GetPlayerPed(-1)
if IsPedInAnyVehicle(ped, false) then
if vehicle == nil then
vehicle = GetVehiclePedIsUsing(ped)
if GetPedInVehicleSeat(vehicle, -1) == ped then
isDriver = true
if DecorExistOn(vehicle, 'fTractionLossMult') then
fTractionLossMult = DecorGetFloat(vehicle, 'fTractionLossMult')
print("Existe um valor padrão: "..fTractionLossMult)
else
fTractionLossMult = GetVehicleHandlingFloat(vehicle, 'CHandlingData', 'fTractionLossMult')
DecorRegister('fTractionLossMult', 1)
DecorSetFloat(vehicle,'fTractionLossMult', fTractionLossMult)
print("O valor padrão é criado: "..fTractionLossMult)
end
class = GetVehicleClass(vehicle)
isBlacklisted = isModelBlacklisted(GetEntityModel(vehicle))
end
end
else
if vehicle ~= nil then
if DoesEntityExist(vehicle) then
setTractionLost (fTractionLossMult)
end
Citizen.Wait(1000)
vehicle = nil
isDriver = false
fTractionLossMult = nil
isModed = false
class = nil
isBlacklisted = false
end
end
Citizen.Wait(2000)
end
end)
Citizen.CreateThread(function()
while true do
if isBlacklisted == false then
if vehicle ~= nil and isDriver == true then
local speed = GetEntitySpeed(vehicle)*3.6
if not pointingRoad(vehicle) then
if groundAsphalt() or speed <= 35.0 then
if isModed == true then
isModed = false
setTractionLost (fTractionLossMult)
end
else
if isModed == false and speed > 35.0 then
isModed = true
setTractionLost (fTractionLossMult + classMod[class])
end
end
else
if isModed == true then
isModed = false
setTractionLost (fTractionLossMult)
end
end
end
end
Citizen.Wait(500)
end
end)
function setTractionLost (value)
if isBlacklisted == false and vehicle ~= nil and value ~= nil then
SetVehicleHandlingFloat(vehicle, 'CHandlingData', 'fTractionLossMult', value)
print("fTractionLossMult: "..value)
end
end
function isModelBlacklisted(model)
local found = false
for i = 1, #blackListed do
if blackListed[i] == model then
found = true
break
end
end
return found
end
function groundAsphalt()
local ped = PlayerPedId()
local playerCoord = GetEntityCoords(ped)
local target = GetOffsetFromEntityInWorldCoords(ped, vector3(0,2,-3))
local testRay = StartShapeTestRay(playerCoord, target, 17, ped, 7) -- This 7 is entirely cargo cult. No idea what it does.
local _, hit, hitLocation, surfaceNormal, material, _ = GetShapeTestResultEx(testRay)
if hit and material == 282940568 then
return true
end
return false
end
function pointingRoad(veh)
local pos = GetEntityCoords(veh, true)
if IsPointOnRoad(pos.x,pos.y,pos.z-1,false) then
return true
end
local pos2 = GetOffsetFromEntityInWorldCoords(veh, 1.5, 0, 0)
local pos3 = GetOffsetFromEntityInWorldCoords(veh, -1.5, 0, 0)
if IsPointOnRoad(pos2.x,pos2.y,pos2.z-1,false) then
return true
end
if IsPointOnRoad(pos3.x,pos3.y,pos3.z,false) then
return true
end
return false
end