127 lines
4.1 KiB
Lua
127 lines
4.1 KiB
Lua
EXTERNAL_EVENTS_NAMES = {
|
|
["esx:getSharedObject"] = nil, -- This is nil because it will be found automatically, change it to your one ONLY in the case it can't be found
|
|
}
|
|
|
|
INTERACTION_POINTS_REFRESH = 1000
|
|
|
|
--[[
|
|
You can edit this function if you want to add second jobs or anything like that (editing this function is down to you)
|
|
If you edit this, you WILL have also to edit the function in sv_integrations.lua file
|
|
]]
|
|
function isAllowedForJobs(allowedJobs)
|
|
if(not allowedJobs) then return true end
|
|
|
|
local playerJob = Framework.getPlayerJob()
|
|
|
|
if(allowedJobs[playerJob] == true) then
|
|
return true
|
|
elseif(allowedJobs[playerJob]) then
|
|
local playerJobGrade = tostring( Framework.getPlayerJobGrade() )
|
|
|
|
return allowedJobs[playerJob] and allowedJobs[playerJob][playerJobGrade]
|
|
else
|
|
return false
|
|
end
|
|
end
|
|
|
|
-- Key to interact (for example with plants). Default is E (38)
|
|
KEY_TO_INTERACT = 38
|
|
|
|
-- Key to burn the plant. Default is G (47)
|
|
KEY_TO_BURN = 47
|
|
|
|
-- Enable or disable the smoke effect when burning plants
|
|
BURN_PLANTS_SMOKE_EFFECT = true
|
|
|
|
-- How many seconds the blip for police alerts will remain in the map
|
|
BLIP_TIME_AFTER_POLICE_ALERT = 120
|
|
|
|
--[[
|
|
Default progressbar color (must be a hex code). Examples:
|
|
"#0fffef" - Light blue
|
|
"#ff0f0f" - Red
|
|
"#0f0fff" - Blue
|
|
]]
|
|
DEFAULT_PROGRESSBAR_COLOR = "#47ff33"
|
|
|
|
|
|
RegisterNetEvent("farming_creator:framework:ready", function()
|
|
exports["farming_creator"]:disableScriptEvent("farming_creator:internalProgressBar")
|
|
end)
|
|
|
|
|
|
-- ================================================================
|
|
-- MercyV | Farming mit X abbrechen
|
|
-- ================================================================
|
|
|
|
local isFarming = false
|
|
local cancelFlag = false -- Signal für den Unfreeze-Loop
|
|
|
|
local function stopHexBar()
|
|
pcall(function() exports['hex_4_hud']:StopProgressbar() end)
|
|
pcall(function() exports['hex_4_hud']:CancelProgressbar() end)
|
|
pcall(function() exports['hex_4_hud']:HideProgressbar() end)
|
|
pcall(function() exports['hex_4_hud']:StopProgress() end)
|
|
pcall(function() exports['hex_4_hud']:CancelProgress() end)
|
|
pcall(function() exports['hex_4_hud']:stopProgressbar() end)
|
|
pcall(function() exports['hex_4_hud']:cancelProgressbar() end)
|
|
end
|
|
|
|
RegisterNetEvent("farming_creator:internalProgressBar", function(time, text)
|
|
if isFarming then return end
|
|
isFarming = true
|
|
cancelFlag = false
|
|
|
|
-- X-Taste überwachen
|
|
CreateThread(function()
|
|
local elapsed = 0
|
|
while elapsed < time and isFarming do
|
|
Wait(0)
|
|
|
|
if IsDisabledControlJustPressed(0, 73) or IsControlJustPressed(0, 73) then
|
|
isFarming = false
|
|
cancelFlag = true
|
|
|
|
-- 1) hex_4_hud Bar sofort stoppen
|
|
stopHexBar()
|
|
|
|
-- 2) Animation abbrechen
|
|
ClearPedTasksImmediately(PlayerPedId())
|
|
|
|
-- 3) farming_creator hat ~2 Sek. eigenes Cleanup nach dem Abbruch
|
|
-- → jeden Frame entfrosten bis farming_creator fertig ist
|
|
CreateThread(function()
|
|
local ped = PlayerPedId()
|
|
local playerId = PlayerId()
|
|
local start = GetGameTimer()
|
|
|
|
while GetGameTimer() - start < 3000 do
|
|
FreezeEntityPosition(ped, false)
|
|
SetPlayerControl(playerId, true, 0)
|
|
ClearPedTasks(ped)
|
|
Wait(0)
|
|
end
|
|
|
|
-- Finaler Reset
|
|
FreezeEntityPosition(ped, false)
|
|
SetPlayerControl(playerId, true, 0)
|
|
cancelFlag = false
|
|
end)
|
|
|
|
BeginTextCommandDisplayHelp('STRING')
|
|
AddTextComponentSubstringPlayerName('~r~Aktion abgebrochen.')
|
|
EndTextCommandDisplayHelp(0, false, true, 3000)
|
|
|
|
return
|
|
end
|
|
|
|
elapsed = elapsed + 16
|
|
Wait(16)
|
|
end
|
|
|
|
isFarming = false
|
|
end)
|
|
|
|
exports['hex_4_hud']:StartProgressbar(time, text)
|
|
end)
|