24
24
exports (' GetVehicleWithPlate' , MSK .GetVehicleWithPlate )
25
25
26
26
MSK .GetVehicleInDirection = function (distance )
27
- local playerPed = PlayerPedId ()
28
- local playerCoords = GetEntityCoords (playerPed )
29
- local destination = GetOffsetFromEntityInWorldCoords (playerPed , 0.0 , distance or 5.0 , 0.0 )
30
- local handle = StartShapeTestCapsule (playerCoords , destination , distance or 5.0 , 2 , playerPed , 4 )
31
-
32
- local entity = MSK .Timeout .Await (1000 , function ()
33
- local retval , hit , endCoords , surfaceNormal , entityHit = GetShapeTestResult (handle )
34
-
35
- if retval ~= 1 and hit then
36
- return entityHit ~= 0 and entityHit
37
- end
38
- end , " No result received from GetShapeTestResult on function GetVehicleInFront" )
27
+ local entity = MSK .Request .Raycast (distance , 2 )
39
28
40
29
if DoesEntityExist (entity ) then
41
30
local entityCoords = GetEntityCoords (entity )
42
- return entity , entityCoords , (' %.2f' ):format (# (playerCoords - entityCoords ))
31
+ return entity , entityCoords , (' %.2f' ):format (# (MSK . Player . coords - entityCoords ))
43
32
end
44
33
45
34
return entity
@@ -48,8 +37,10 @@ MSK.GetVehicleInFront = MSK.GetVehicleInDirection
48
37
exports (' GetVehicleInDirection' , MSK .GetVehicleInDirection )
49
38
50
39
MSK .GetPedVehicleSeat = function (playerPed , vehicle )
51
- if not playerPed then playerPed = PlayerPedId () end
52
- if not vehicle then GetVehiclePedIsIn (playerPed , false ) end
40
+ if not playerPed then playerPed = MSK .Player .ped end
41
+ if not vehicle then vehicle = MSK .Player .vehicle end
42
+
43
+ if not DoesEntityExist (vehicle ) then return false end
53
44
54
45
for i = - 1 , 16 do
55
46
if GetPedInVehicleSeat (vehicle , i ) == playerPed then
@@ -85,7 +76,7 @@ MSK.GetVehicleLabel = function(vehicle, model)
85
76
vehicleModel = GetEntityModel (vehicle )
86
77
end
87
78
88
- if model then
79
+ if model and not vehicleModel then
89
80
if not IsModelValid (model ) then
90
81
return ' Unknown' , error ((' The Model does not exist on function MSK.GetVehicleLabel (reveived %s)' ):format (model ))
91
82
end
@@ -132,9 +123,9 @@ local isInVehicle, isEnteringVehicle = false, false
132
123
CreateThread (function ()
133
124
while true do
134
125
local sleep = 200
135
- local playerPed = PlayerPedId ()
126
+ local playerPed = MSK . Player . ped
136
127
137
- if not isInVehicle and not IsPlayerDead (PlayerId () ) then
128
+ if not isInVehicle and not IsPlayerDead (MSK . Player . clientId ) then
138
129
if DoesEntityExist (GetVehiclePedIsTryingToEnter (playerPed )) and not isEnteringVehicle then
139
130
local vehicle = GetVehiclePedIsTryingToEnter (playerPed )
140
131
local plate = GetVehicleNumberPlateText (vehicle )
@@ -162,7 +153,7 @@ CreateThread(function()
162
153
TriggerServerEvent (' msk_core:enteredVehicle' , currentVehicle .plate , currentVehicle .seat , currentVehicle .netId , currentVehicle .isEngineOn , currentVehicle .isDamaged )
163
154
end
164
155
elseif isInVehicle then
165
- if not IsPedInAnyVehicle (playerPed , false ) or IsPlayerDead (PlayerId () ) then
156
+ if not IsPedInAnyVehicle (playerPed , false ) or IsPlayerDead (MSK . Player . clientId ) then
166
157
isInVehicle = false
167
158
TriggerEvent (' msk_core:exitedVehicle' , currentVehicle .vehicle , currentVehicle .plate , currentVehicle .seat , currentVehicle .netId , currentVehicle .isEngineOn , currentVehicle .isDamaged )
168
159
TriggerServerEvent (' msk_core:exitedVehicle' , currentVehicle .plate , currentVehicle .seat , currentVehicle .netId , currentVehicle .isEngineOn , currentVehicle .isDamaged )
0 commit comments