No problem. Just be aware that I also use mythic_notify, so there is an export in there for the notification upon completion of repair. You may need to change that if you are still going to display notifications.
Curious to why you would not just do the stuff you want to do after the event finishes … in the finish callback which allows for checking if they cancelled it.
That code you can cancel the event instantly and wait 20 seconds and it’ll still work.
It’s not my coding. That is the stock coding from the person that created the script. They never incorporated anything into it for canceling. I’m not a coder at all for LUA, and I wouldn’t know where to start for canceling something like that. I just knew where to place the progress bar, so figured I’d help them out with the location of where it goes.
Hello,
I try the Progbar, so install in my job system, that as soon as you press the E or X button presses the Progbar, but do not quite understand how to cancel the Progbar …
? When the progress bar is going, you can press delete to cancel it. Can change it in the client script if you want it to be something else.
If an action is cancelled, the callback will still be called but the parameter passed to it will be true so you can do anything you need to in the event of a cancelled action.
-- CLIENTSIDED
-- Registers a network event
RegisterNetEvent('EngineToggle:Engine')
RegisterNetEvent('EngineToggle:RPDamage')
local vehicles = {}; RPWorking = true
function notify(string)
SetNotificationTextEntry("STRING")
AddTextComponentString(string)
DrawNotification(true, false)
end
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if UseKey and ToggleKey then
if IsControlJustReleased(1, ToggleKey) then
TriggerEvent('EngineToggle:Engine')
end
end
if GetSeatPedIsTryingToEnter(GetPlayerPed(-1)) == -1 and not table.contains(vehicles, GetVehiclePedIsTryingToEnter(GetPlayerPed(-1))) then
table.insert(vehicles, {GetVehiclePedIsTryingToEnter(GetPlayerPed(-1)), 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), IsVehicleEngineOn(GetVehiclePedIsIn(GetPlayerPed(-1), false))})
end
for i, vehicle in ipairs(vehicles) do
if DoesEntityExist(vehicle[1]) then
if (GetPedInVehicleSeat(vehicle[1], -1) == GetPlayerPed(-1)) or IsVehicleSeatFree(vehicle[1], -1) then
if RPWorking then
SetVehicleEngineOn(vehicle[1], vehicle[2], true, false)
SetVehicleJetEngineOn(vehicle[1], vehicle[2])
if not IsPedInAnyVehicle(GetPlayerPed(-1), false) or (IsPedInAnyVehicle(GetPlayerPed(-1), false) and vehicle[1]~= GetVehiclePedIsIn(GetPlayerPed(-1), false)) then
if IsThisModelAHeli(GetEntityModel(vehicle[1])) or IsThisModelAPlane(GetEntityModel(vehicle[1])) then
if vehicle[2] then
SetHeliBladesFullSpeed(vehicle[1])
end
end
end
end
end
else
table.remove(vehicles, i)
end
end
end
end)
AddEventHandler('EngineToggle:Engine', function()
local veh
local StateIndex
for i, vehicle in ipairs(vehicles) do
if vehicle[1] == GetVehiclePedIsIn(GetPlayerPed(-1), false) then
veh = vehicle[1]
StateIndex = i
end
end
Citizen.Wait(1500)
if IsPedInAnyVehicle(GetPlayerPed(-1), false) then
if (GetPedInVehicleSeat(veh, -1) == GetPlayerPed(-1)) then
vehicles[StateIndex][2] = not GetIsVehicleEngineRunning(veh)
if vehicles[StateIndex][2] then
notify('~y~Silnik włączony!')
else
notify('~y~Silnik wyłączony!')
end
end
end
end)
AddEventHandler('EngineToggle:RPDamage', function(State)
RPWorking = State
end)
if OnAtEnter then
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if GetSeatPedIsTryingToEnter(GetPlayerPed(-1)) == -1 then
for i, vehicle in ipairs(vehicles) do
if vehicle[1] == GetVehiclePedIsTryingToEnter(GetPlayerPed(-1)) and not vehicle[2] then
Citizen.Wait(2000)
vehicle[2] = true
notify('~y~Silnik włączony!')
end
end
end
end
end)
end
function table.contains(table, element)
for _, value in pairs(table) do
if value[1] == element then
return true
end
end
return false
end
Hello im having a problem with the bar, i run a VRP server and installed the bar with badgerbank robberies and it works but the process is done it does not stop the action and i cant use delete or anything to get out of it…i would like to know how to fix!? thank you.