2424exports (' GetVehicleWithPlate' , MSK .GetVehicleWithPlate )
2525
2626MSK .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 )
3928
4029 if DoesEntityExist (entity ) then
4130 local entityCoords = GetEntityCoords (entity )
42- return entity , entityCoords , (' %.2f' ):format (# (playerCoords - entityCoords ))
31+ return entity , entityCoords , (' %.2f' ):format (# (MSK . Player . coords - entityCoords ))
4332 end
4433
4534 return entity
@@ -48,8 +37,10 @@ MSK.GetVehicleInFront = MSK.GetVehicleInDirection
4837exports (' GetVehicleInDirection' , MSK .GetVehicleInDirection )
4938
5039MSK .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
5344
5445 for i = - 1 , 16 do
5546 if GetPedInVehicleSeat (vehicle , i ) == playerPed then
@@ -85,7 +76,7 @@ MSK.GetVehicleLabel = function(vehicle, model)
8576 vehicleModel = GetEntityModel (vehicle )
8677 end
8778
88- if model then
79+ if model and not vehicleModel then
8980 if not IsModelValid (model ) then
9081 return ' Unknown' , error ((' The Model does not exist on function MSK.GetVehicleLabel (reveived %s)' ):format (model ))
9182 end
@@ -132,9 +123,9 @@ local isInVehicle, isEnteringVehicle = false, false
132123CreateThread (function ()
133124 while true do
134125 local sleep = 200
135- local playerPed = PlayerPedId ()
126+ local playerPed = MSK . Player . ped
136127
137- if not isInVehicle and not IsPlayerDead (PlayerId () ) then
128+ if not isInVehicle and not IsPlayerDead (MSK . Player . clientId ) then
138129 if DoesEntityExist (GetVehiclePedIsTryingToEnter (playerPed )) and not isEnteringVehicle then
139130 local vehicle = GetVehiclePedIsTryingToEnter (playerPed )
140131 local plate = GetVehicleNumberPlateText (vehicle )
@@ -162,7 +153,7 @@ CreateThread(function()
162153 TriggerServerEvent (' msk_core:enteredVehicle' , currentVehicle .plate , currentVehicle .seat , currentVehicle .netId , currentVehicle .isEngineOn , currentVehicle .isDamaged )
163154 end
164155 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
166157 isInVehicle = false
167158 TriggerEvent (' msk_core:exitedVehicle' , currentVehicle .vehicle , currentVehicle .plate , currentVehicle .seat , currentVehicle .netId , currentVehicle .isEngineOn , currentVehicle .isDamaged )
168159 TriggerServerEvent (' msk_core:exitedVehicle' , currentVehicle .plate , currentVehicle .seat , currentVehicle .netId , currentVehicle .isEngineOn , currentVehicle .isDamaged )
0 commit comments