Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( data == "button1" ) then
- TriggerEvent( 'Engine' )
- -- Thats from cl_action.lua for the button
- -- This goes at the bottom of cl_action.lua
- RegisterNetEvent('Engine')
- local vehicles = {}
- local State = {}
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(0)
- if GetSeatPedIsTryingToEnter(GetPlayerPed(-1)) == -1 and not table.contains(vehicles, GetVehiclePedIsTryingToEnter(GetPlayerPed(-1))) then
- table.insert(vehicles, GetVehiclePedIsTryingToEnter(GetPlayerPed(-1)))
- table.insert(State, IsVehicleEngineOn(GetVehiclePedIsTryingToEnter(GetPlayerPed(-1))))
- elseif IsPedInAnyVehicle(GetPlayerPed(-1), false) and not table.contains(vehicles, GetVehiclePedIsIn(GetPlayerPed(-1), false)) then
- table.insert(vehicles, GetVehiclePedIsIn(GetPlayerPed(-1), false))
- table.insert(State, IsVehicleEngineOn(GetVehiclePedIsIn(GetPlayerPed(-1), false)))
- end
- for i = 1, tablelength(vehicles) do
- if (GetPedInVehicleSeat(vehicles[i], -1) == GetPlayerPed(-1)) or IsVehicleSeatFree(vehicles[i], -1) then
- SetVehicleEngineOn(vehicles[i], State[i], State[i], State[i])
- end
- end
- end
- end)
- AddEventHandler('Engine', function()
- local veh
- local StateIndex
- for i = 1, tablelength(vehicles) do
- if vehicles[i] == GetVehiclePedIsIn(GetPlayerPed(-1), false) then
- veh = vehicles[i]
- StateIndex = i
- end
- end
- if IsPedInAnyVehicle(GetPlayerPed(-1), false) then
- if (GetPedInVehicleSeat(veh, -1) == GetPlayerPed(-1)) then
- if IsVehicleEngineOn(veh) then
- State[StateIndex] = false
- else
- State[StateIndex] = true
- end
- end
- end
- end)
- function drawNotification(text) --Just Don't Edit!
- SetNotificationTextEntry("STRING")
- AddTextComponentString(text)
- DrawNotification(false, false)
- end
- function tablelength(T) --Just Don't Edit!
- local count = 0
- for _ in pairs(T) do count = count + 1 end
- return count
- end
- function table.contains(table, element)
- for _, value in pairs(table) do
- if value == element then
- return true
- end
- end
- return false
- end
- -- Then add the button in ui.lua and change button 1 to whatever button you are gonna use.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement