-
Notifications
You must be signed in to change notification settings - Fork 14
/
client.lua
63 lines (61 loc) · 2.44 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
Settings = {
KeepEngineOn = true, ---Keeps The engine on after leaving the vehicle if the engine is on,
NPCCheck = true --- Adds NPC Check to the code(Checks if there is any ped inside vehicle or not)
}
CreateThread(function()
local dist, index,ped
while true do
if IsControlJustPressed(0, 75) then
ped = PlayerPedId()
if IsPedInAnyVehicle(ped) then
if Settings.KeepEngineOn then
local veh = GetVehiclePedIsIn(ped)
if GetIsVehicleEngineRunning(veh) then
TaskLeaveVehicle(ped, veh, 0)
Wait(1000)
SetVehicleEngineOn(veh, true, true, true)
end
end
else
local veh = GetVehiclePedIsTryingToEnter(ped)
if veh ~= 0 then
if CanSit(veh) then
local coords = GetEntityCoords(ped)
if #(coords - GetEntityCoords(veh)) <= 3.5 then
ClearPedTasks(ped)
ClearPedSecondaryTask(ped)
for i = 0, GetNumberOfVehicleDoors(veh), 1 do
local coord = GetEntryPositionOfDoor(veh, i)
if (IsVehicleSeatFree(veh, i - 1) and
GetVehicleDoorLockStatus(veh) ~= 2) then
if dist == nil then
dist = #(coords - coord)
index = i
end
if #(coords - coord) < dist then
dist = #(coords - coord)
index = i
end
end
end
if index then
TaskEnterVehicle(ped, veh, 10000, index - 1,1.0, 1, 0)
end
index, dist = nil, nil
end
end
end
end
end
Wait(1)
end
end)
CanSit = function(veh)
if not Settings.NPCCheck then
return true
end
for i = -1, 15 do
if IsEntityAPed(GetPedInVehicleSeat(veh, i)) then return false end
end
return true
end