From bdb0c685695c1a50317fa6a311edb700309c1168 Mon Sep 17 00:00:00 2001 From: nearbyplayer Date: Fri, 10 Aug 2018 01:07:49 -0400 Subject: [PATCH] Respawn Timer Overhaul & Repo Update * Fixes #64 (Timer related) * Will need Locale translation --- .editorconfig | 6 +- LICENSE.txt => LICENSE | 0 client/main.lua | 1245 +++++++++++++------------- config.lua | 16 +- locales/br.lua | 13 +- locales/de.lua | 12 +- locales/en.lua | 15 +- locales/es.lua | 12 +- locales/fi.lua | 16 +- locales/fr.lua | 12 +- locales/pl.lua | 12 +- locales/sv.lua | 16 +- localization/en_esx_ambulancejob.sql | 16 +- server/main.lua | 107 ++- 14 files changed, 740 insertions(+), 758 deletions(-) rename LICENSE.txt => LICENSE (100%) diff --git a/.editorconfig b/.editorconfig index 41c2aaf2..9b425256 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,9 +1,9 @@ root = true [*] -indent_size = 2 -indent_style = space -end_of_line = lf +indent_size = 4 +indent_style = tab +end_of_line = crlf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE similarity index 100% rename from LICENSE.txt rename to LICENSE diff --git a/client/main.lua b/client/main.lua index 1e2a7f16..08291653 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1,31 +1,30 @@ local Keys = { - ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57, - ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177, - ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18, - ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182, - ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81, - ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70, - ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178, - ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173, - ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118 + ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57, + ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177, + ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18, + ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182, + ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81, + ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70, + ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178, + ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173, + ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118 } -local PlayerData = {} -local FirstSpawn = true -local IsDead = false +local PlayerData = {} +local FirstSpawn = true +local IsDead = false local HasAlreadyEnteredMarker = false -local LastZone = nil -local CurrentAction = nil -local CurrentActionMsg = '' -local CurrentActionData = {} -local IsBusy = false - -ESX = nil +local LastZone = nil +local CurrentAction = nil +local CurrentActionMsg = '' +local CurrentActionData = {} +local IsBusy = false +ESX = nil Citizen.CreateThread(function() while ESX == nil do - TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) - Citizen.Wait(0) + TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) + Citizen.Wait(0) end Citizen.Wait(5000) @@ -47,149 +46,131 @@ AddEventHandler('esx_ambulancejob:heal', function(_type) local playerPed = GetPlayerPed(-1) local maxHealth = GetEntityMaxHealth(playerPed) if _type == 'small' then - local health = GetEntityHealth(playerPed) - local newHealth = math.min(maxHealth , math.floor(health + maxHealth/8)) - SetEntityHealth(playerPed, newHealth) + local health = GetEntityHealth(playerPed) + local newHealth = math.min(maxHealth , math.floor(health + maxHealth/8)) + SetEntityHealth(playerPed, newHealth) elseif _type == 'big' then - SetEntityHealth(playerPed, maxHealth) + SetEntityHealth(playerPed, maxHealth) end ESX.ShowNotification(_U('healed')) end) -function StartRespawnToHospitalMenuTimer() - Citizen.SetTimeout(Config.MenuRespawnToHospitalDelay, function() - if IsDead then - ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'respawn_hospital', - { - title = _U('respawn_at_hospital'), - align = 'bottom-right', - elements = { - {label = _U('no'), value = 'no'}, - {label = _U('yes'), value = 'yes'} - } - }, function(data, menu) - if data.current.value == 'yes' then - RemoveItemsAfterRPDeath() - end - menu.close() - end) - end - end) -end - function StartRespawnTimer() Citizen.SetTimeout(Config.RespawnDelayAfterRPDeath, function() - if IsDead then - RemoveItemsAfterRPDeath() - end + if IsDead then + RemoveItemsAfterRPDeath() + end end) end function StartDistressSignal() Citizen.CreateThread(function() - local timer = Config.RespawnDelayAfterRPDeath + local respawnTimer = Config.RespawnDelayAfterRPDeath - while timer > 0 and IsDead do - Citizen.Wait(2) - timer = timer - 30 + while respawnTimer > 0 and IsDead do + Citizen.Wait(2) + respawnTimer = respawnTimer - 30 - SetTextFont(4) - SetTextProportional(1) - SetTextScale(0.45, 0.45) - SetTextColour(185, 185, 185, 255) - SetTextDropShadow(0, 0, 0, 0, 255) - SetTextEdge(1, 0, 0, 0, 255) - SetTextDropShadow() - SetTextOutline() - BeginTextCommandDisplayText('STRING') - AddTextComponentSubstringPlayerName(_U('distress_send')) - EndTextCommandDisplayText(0.175, 0.805) + SetTextFont(4) + SetTextProportional(1) + SetTextScale(0.45, 0.45) + SetTextColour(185, 185, 185, 255) + SetTextDropShadow(0, 0, 0, 0, 255) + SetTextEdge(1, 0, 0, 0, 255) + SetTextDropShadow() + SetTextOutline() + BeginTextCommandDisplayText('STRING') + AddTextComponentSubstringPlayerName(_U('distress_send')) + EndTextCommandDisplayText(0.175, 0.805) - if IsControlPressed(0, Keys['G']) then - SendDistressSignal() - break - end + if IsControlPressed(0, Keys['G']) then + SendDistressSignal() + break end + end end) end function SendDistressSignal() local playerPed = GetPlayerPed(-1) - local coords = GetEntityCoords(playerPed) + local coords = GetEntityCoords(playerPed) ESX.ShowNotification(_U('distress_sent')) TriggerServerEvent('esx_phone:send', 'ambulance', _U('distress_message'), false, { - x = coords.x, - y = coords.y, - z = coords.z + x = coords.x, + y = coords.y, + z = coords.z }) end -function ShowTimer() - local timer = Config.RespawnDelayAfterRPDeath - - Citizen.CreateThread(function() - while timer > 0 and IsDead do - Citizen.Wait(0) +function ShowDeathTimer() + local respawnTimer = Config.RespawnDelayAfterRPDeath + local allowRespawn = Config.RespawnDelayAfterRPDeath/2 + local fineAmount = Config.EarlyRespawnFineAmount + local payFine = false - raw_seconds = timer/1000 - raw_minutes = raw_seconds/60 - minutes = stringsplit(raw_minutes, ".")[1] - seconds = stringsplit(raw_seconds-(minutes*60), ".")[1] - - SetTextFont(4) - SetTextProportional(0) - SetTextScale(0.0, 0.5) - SetTextColour(255, 255, 255, 255) - SetTextDropshadow(0, 0, 0, 0, 255) - SetTextEdge(1, 0, 0, 0, 255) - SetTextDropShadow() - SetTextOutline() - - local text = _U('please_wait', minutes, seconds) - - if Config.EarlyRespawn then - text = text .. '\n[~b~E~s~]' - end - - SetTextCentre(true) - BeginTextCommandDisplayText("STRING") - AddTextComponentSubstringPlayerName(text) - EndTextCommandDisplayText(0.5, 0.8) - - if Config.EarlyRespawn then - if IsControlPressed(0, Keys['E']) then - RemoveItemsAfterRPDeath() - break - end - end - timer = timer - 15 + if Config.EarlyRespawn and Config.EarlyRespawnFine then + ESX.TriggerServerCallback('esx_ambulancejob:checkBalance', function(finePayable) + if finePayable then + payFine = true + else + payFine = false end + end) + end + + Citizen.CreateThread(function() + while respawnTimer > 0 and IsDead do + Citizen.Wait(0) + + raw_seconds = respawnTimer/1000 + raw_minutes = raw_seconds/60 + minutes = stringsplit(raw_minutes, ".")[1] + seconds = stringsplit(raw_seconds-(minutes*60), ".")[1] + + SetTextFont(4) + SetTextProportional(0) + SetTextScale(0.0, 0.5) + SetTextColour(255, 255, 255, 255) + SetTextDropshadow(0, 0, 0, 0, 255) + SetTextEdge(1, 0, 0, 0, 255) + SetTextDropShadow() + SetTextOutline() + + local text = _U('please_wait', minutes, seconds) if Config.EarlyRespawn then - while timer <= 0 and IsDead do - Citizen.Wait(0) + if not Config.EarlyRespawnFine and respawnTimer <= allowRespawn then + text = text .. _U('press_respawn') + elseif Config.EarlyRespawnFine and respawnTimer <= allowRespawn and payFine then + text = text .. _U('respawn_now_fine', fineAmount) + else + text = text + end + end - SetTextFont(4) - SetTextProportional(0) - SetTextScale(0.0, 0.5) - SetTextColour(255, 255, 255, 255) - SetTextDropshadow(0, 0, 0, 0, 255) - SetTextEdge(1, 0, 0, 0, 255) - SetTextDropShadow() - SetTextOutline() - SetTextCentre(true) + SetTextCentre(true) + SetTextEntry("STRING") + AddTextComponentString(text) + DrawText(0.5, 0.8) - BeginTextCommandDisplayText("STRING") - AddTextComponentSubstringPlayerName(_U('press_respawn')) - EndTextCommandDisplayText(0.5, 0.8) - - if IsControlPressed(0, Keys['E']) then - RemoveItemsAfterRPDeath() - break - end + if Config.EarlyRespawn then + if not Config.EarlyRespawnFine then + if IsControlPressed(0, Keys['E']) then + RemoveItemsAfterRPDeath() + break + end + elseif Config.EarlyRespawnFine then + if respawnTimer <= allowRespawn and payFine then + if IsControlPressed(0, Keys['E']) then + PayFine() + break + end end end + end + respawnTimer = respawnTimer - 15 + end end) end @@ -197,21 +178,27 @@ function RemoveItemsAfterRPDeath() TriggerServerEvent('esx_ambulancejob:setDeathStatus', 0) Citizen.CreateThread(function() - DoScreenFadeOut(800) - while not IsScreenFadedOut() do - Citizen.Wait(10) - end + DoScreenFadeOut(800) + while not IsScreenFadedOut() do + Citizen.Wait(10) + end - ESX.TriggerServerCallback('esx_ambulancejob:removeItemsAfterRPDeath', function() - ESX.SetPlayerData('lastPosition', Config.Zones.HospitalInteriorInside1.Pos) - ESX.SetPlayerData('loadout', {}) + ESX.TriggerServerCallback('esx_ambulancejob:removeItemsAfterRPDeath', function() + ESX.SetPlayerData('lastPosition', Config.Zones.HospitalInteriorInside1.Pos) + ESX.SetPlayerData('loadout', {}) - TriggerServerEvent('esx:updateLastPosition', Config.Zones.HospitalInteriorInside1.Pos) - RespawnPed(GetPlayerPed(-1), Config.Zones.HospitalInteriorInside1.Pos) + TriggerServerEvent('esx:updateLastPosition', Config.Zones.HospitalInteriorInside1.Pos) + RespawnPed(GetPlayerPed(-1), Config.Zones.HospitalInteriorInside1.Pos) - StopScreenEffect('DeathFailOut') - DoScreenFadeIn(800) - end) + StopScreenEffect('DeathFailOut') + DoScreenFadeIn(800) + end) + end) +end + +function PayFine() + ESX.TriggerServerCallback('esx_ambulancejob:payFine', function() + RemoveItemsAfterRPDeath() end) end @@ -219,113 +206,109 @@ function OnPlayerDeath() IsDead = true TriggerServerEvent('esx_ambulancejob:setDeathStatus', 1) - if Config.ShowDeathTimer == true then - ShowTimer() + if Config.ShowDeathTimer then + ShowDeathTimer() end StartRespawnTimer() StartDistressSignal() - if Config.RespawnToHospitalMenuTimer then - StartRespawnToHospitalMenuTimer() - end - ClearPedTasksImmediately(GetPlayerPed(-1)) StartScreenEffect('DeathFailOut', 0, false) end function TeleportFadeEffect(entity, coords) - Citizen.CreateThread(function() + Citizen.CreateThread(function() - DoScreenFadeOut(800) + DoScreenFadeOut(800) - while not IsScreenFadedOut() do - Citizen.Wait(0) - end + while not IsScreenFadedOut() do + Citizen.Wait(0) + end - ESX.Game.Teleport(entity, coords, function() - DoScreenFadeIn(800) - end) + ESX.Game.Teleport(entity, coords, function() + DoScreenFadeIn(800) + end) - end) + end) end function WarpPedInClosestVehicle(ped) - local coords = GetEntityCoords(ped) + local coords = GetEntityCoords(ped) - local vehicle, distance = ESX.Game.GetClosestVehicle({ - x = coords.x, - y = coords.y, - z = coords.z - }) + local vehicle, distance = ESX.Game.GetClosestVehicle({ + x = coords.x, + y = coords.y, + z = coords.z + }) - if distance ~= -1 and distance <= 5.0 then + if distance ~= -1 and distance <= 5.0 then - local maxSeats = GetVehicleMaxNumberOfPassengers(vehicle) - local freeSeat = nil + local maxSeats = GetVehicleMaxNumberOfPassengers(vehicle) + local freeSeat = nil - for i=maxSeats - 1, 0, -1 do - if IsVehicleSeatFree(vehicle, i) then - freeSeat = i - break - end - end + for i=maxSeats - 1, 0, -1 do + if IsVehicleSeatFree(vehicle, i) then + freeSeat = i + break + end + end - if freeSeat ~= nil then - TaskWarpPedIntoVehicle(ped, vehicle, freeSeat) - end + if freeSeat ~= nil then + TaskWarpPedIntoVehicle(ped, vehicle, freeSeat) + end - else - ESX.ShowNotification(_U('no_vehicles')) - end + else + ESX.ShowNotification(_U('no_vehicles')) + end end function OpenAmbulanceActionsMenu() - local elements = { - {label = _U('cloakroom'), value = 'cloakroom'} - } + local elements = { + {label = _U('cloakroom'), value = 'cloakroom'} + } - if Config.EnablePlayerManagement and PlayerData.job.grade_name == 'boss' then - table.insert(elements, {label = _U('boss_actions'), value = 'boss_actions'}) - end + if Config.EnablePlayerManagement and PlayerData.job.grade_name == 'boss' then + table.insert(elements, {label = _U('boss_actions'), value = 'boss_actions'}) + end - ESX.UI.Menu.CloseAll() + ESX.UI.Menu.CloseAll() - ESX.UI.Menu.Open( - 'default', GetCurrentResourceName(), 'ambulance_actions', - { - title = _U('ambulance'), - align = 'top-left', - elements = elements - }, - function(data, menu) + ESX.UI.Menu.Open( + 'default', GetCurrentResourceName(), 'ambulance_actions', + { + title = _U('ambulance'), + align = 'top-left', + elements = elements + }, + function(data, menu) - if data.current.value == 'cloakroom' then - OpenCloakroomMenu() - end + if data.current.value == 'cloakroom' then + OpenCloakroomMenu() + end - if data.current.value == 'boss_actions' then - TriggerEvent('esx_society:openBossMenu', 'ambulance', function(data, menu) - menu.close() - end, {wash = false}) - end + if data.current.value == 'boss_actions' then + TriggerEvent('esx_society:openBossMenu', 'ambulance', function(data, menu) + menu.close() + end, {wash = false}) + end - end, - function(data, menu) + end, + function(data, menu) - menu.close() + menu.close() - CurrentAction = 'ambulance_actions_menu' - CurrentActionMsg = _U('open_menu') - CurrentActionData = {} + CurrentAction = 'ambulance_actions_menu' + CurrentActionMsg = _U('open_menu') + CurrentActionData = {} - end - ) + end + ) end @@ -336,196 +319,196 @@ function OpenMobileAmbulanceActionsMenu() ESX.UI.Menu.Open( 'default', GetCurrentResourceName(), 'mobile_ambulance_actions', { - title = _U('ambulance'), - align = 'top-left', - elements = { - {label = _U('ems_menu'), value = 'citizen_interaction'}, - } + title = _U('ambulance'), + align = 'top-left', + elements = { + {label = _U('ems_menu'), value = 'citizen_interaction'}, + } }, function(data, menu) - if data.current.value == 'citizen_interaction' then - ESX.UI.Menu.Open( - 'default', GetCurrentResourceName(), 'citizen_interaction', - { - title = _U('ems_menu_title'), - align = 'top-left', - elements = { - {label = _U('ems_menu_revive'), value = 'revive'}, - {label = _U('ems_menu_small'), value = 'small'}, - {label = _U('ems_menu_big'), value = 'big'}, - {label = _U('ems_menu_putincar'), value = 'put_in_vehicle'}, - } - }, function(data, menu) - if IsBusy then return end - if data.current.value == 'revive' then -- revive - - local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() - - if closestPlayer == -1 or closestDistance > 3.0 then - ESX.ShowNotification(_U('no_players')) - else - ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(qtty) - if qtty > 0 then - local closestPlayerPed = GetPlayerPed(closestPlayer) - local health = GetEntityHealth(closestPlayerPed) - - if health == 0 then - local playerPed = GetPlayerPed(-1) + if data.current.value == 'citizen_interaction' then + ESX.UI.Menu.Open( + 'default', GetCurrentResourceName(), 'citizen_interaction', + { + title = _U('ems_menu_title'), + align = 'top-left', + elements = { + {label = _U('ems_menu_revive'), value = 'revive'}, + {label = _U('ems_menu_small'), value = 'small'}, + {label = _U('ems_menu_big'), value = 'big'}, + {label = _U('ems_menu_putincar'), value = 'put_in_vehicle'}, + } + }, function(data, menu) + if IsBusy then return end + if data.current.value == 'revive' then -- revive - IsBusy = true - ESX.ShowNotification(_U('revive_inprogress')) - TaskStartScenarioInPlace(playerPed, 'CODE_HUMAN_MEDIC_TEND_TO_DEAD', 0, true) - Citizen.Wait(10000) - ClearPedTasks(playerPed) - - TriggerServerEvent('esx_ambulancejob:removeItem', 'medikit') - TriggerServerEvent('esx_ambulancejob:revive', GetPlayerServerId(closestPlayer)) - IsBusy = false + local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() - -- Show revive award? - if Config.ReviveReward > 0 then - ESX.ShowNotification(_U('revive_complete_award', GetPlayerName(closestPlayer), Config.ReviveReward)) - else - ESX.ShowNotification(_U('revive_complete', GetPlayerName(closestPlayer))) - end - else - ESX.ShowNotification(_U('player_not_unconscious')) - end - else - ESX.ShowNotification(_U('not_enough_medikit')) - end - end, 'medikit') - end - elseif data.current.value == 'small' then - - local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() - if closestPlayer == -1 or closestDistance > 3.0 then - ESX.ShowNotification(_U('no_players')) - else - ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(qtty) - if qtty > 0 then - local closestPlayerPed = GetPlayerPed(closestPlayer) - local health = GetEntityHealth(closestPlayerPed) - - if health > 0 then - local playerPed = GetPlayerPed(-1) + if closestPlayer == -1 or closestDistance > 3.0 then + ESX.ShowNotification(_U('no_players')) + else + ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(qtty) + if qtty > 0 then + local closestPlayerPed = GetPlayerPed(closestPlayer) + local health = GetEntityHealth(closestPlayerPed) - IsBusy = true - ESX.ShowNotification(_U('heal_inprogress')) - TaskStartScenarioInPlace(playerPed, 'CODE_HUMAN_MEDIC_TEND_TO_DEAD', 0, true) - Citizen.Wait(10000) - ClearPedTasks(playerPed) - - TriggerServerEvent('esx_ambulancejob:removeItem', 'bandage') - TriggerServerEvent('esx_ambulancejob:heal', GetPlayerServerId(closestPlayer), 'small') - ESX.ShowNotification(_U('heal_complete', GetPlayerName(closestPlayer))) - IsBusy = false - else - ESX.ShowNotification(_U('player_not_conscious')) - end - else - ESX.ShowNotification(_U('not_enough_bandage')) - end - end, 'bandage') - end - elseif data.current.value == 'big' then - - local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() - if closestPlayer == -1 or closestDistance > 3.0 then - ESX.ShowNotification(_U('no_players')) - else - ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(qtty) - if qtty > 0 then - local closestPlayerPed = GetPlayerPed(closestPlayer) - local health = GetEntityHealth(closestPlayerPed) - - if health > 0 then - local playerPed = GetPlayerPed(-1) + if health == 0 then + local playerPed = GetPlayerPed(-1) - IsBusy = true - ESX.ShowNotification(_U('heal_inprogress')) - TaskStartScenarioInPlace(playerPed, 'CODE_HUMAN_MEDIC_TEND_TO_DEAD', 0, true) - Citizen.Wait(10000) - ClearPedTasks(playerPed) - - TriggerServerEvent('esx_ambulancejob:removeItem', 'medikit') - TriggerServerEvent('esx_ambulancejob:heal', GetPlayerServerId(closestPlayer), 'big') - ESX.ShowNotification(_U('heal_complete', GetPlayerName(closestPlayer))) - IsBusy = false - else - ESX.ShowNotification(_U('player_not_conscious')) - end - else - ESX.ShowNotification(_U('not_enough_medikit')) - end - end, 'medikit') - end - elseif data.current.value == 'put_in_vehicle' then - - local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() - if closestPlayer == -1 or closestDistance > 3.0 then - ESX.ShowNotification(_U('no_vehicles')) + IsBusy = true + ESX.ShowNotification(_U('revive_inprogress')) + TaskStartScenarioInPlace(playerPed, 'CODE_HUMAN_MEDIC_TEND_TO_DEAD', 0, true) + Citizen.Wait(10000) + ClearPedTasks(playerPed) + + TriggerServerEvent('esx_ambulancejob:removeItem', 'medikit') + TriggerServerEvent('esx_ambulancejob:revive', GetPlayerServerId(closestPlayer)) + IsBusy = false + + -- Show revive award? + if Config.ReviveReward > 0 then + ESX.ShowNotification(_U('revive_complete_award', GetPlayerName(closestPlayer), Config.ReviveReward)) else - menu.close() - WarpPedInClosestVehicle(GetPlayerPed(closestPlayer)) + ESX.ShowNotification(_U('revive_complete', GetPlayerName(closestPlayer))) end + else + ESX.ShowNotification(_U('player_not_unconscious')) end - end, function(data, menu) - menu.close() - end) + else + ESX.ShowNotification(_U('not_enough_medikit')) + end + end, 'medikit') + end + elseif data.current.value == 'small' then + + local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() + if closestPlayer == -1 or closestDistance > 3.0 then + ESX.ShowNotification(_U('no_players')) + else + ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(qtty) + if qtty > 0 then + local closestPlayerPed = GetPlayerPed(closestPlayer) + local health = GetEntityHealth(closestPlayerPed) + + if health > 0 then + local playerPed = GetPlayerPed(-1) + + IsBusy = true + ESX.ShowNotification(_U('heal_inprogress')) + TaskStartScenarioInPlace(playerPed, 'CODE_HUMAN_MEDIC_TEND_TO_DEAD', 0, true) + Citizen.Wait(10000) + ClearPedTasks(playerPed) + + TriggerServerEvent('esx_ambulancejob:removeItem', 'bandage') + TriggerServerEvent('esx_ambulancejob:heal', GetPlayerServerId(closestPlayer), 'small') + ESX.ShowNotification(_U('heal_complete', GetPlayerName(closestPlayer))) + IsBusy = false + else + ESX.ShowNotification(_U('player_not_conscious')) + end + else + ESX.ShowNotification(_U('not_enough_bandage')) + end + end, 'bandage') + end + elseif data.current.value == 'big' then + + local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() + if closestPlayer == -1 or closestDistance > 3.0 then + ESX.ShowNotification(_U('no_players')) + else + ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(qtty) + if qtty > 0 then + local closestPlayerPed = GetPlayerPed(closestPlayer) + local health = GetEntityHealth(closestPlayerPed) + + if health > 0 then + local playerPed = GetPlayerPed(-1) + + IsBusy = true + ESX.ShowNotification(_U('heal_inprogress')) + TaskStartScenarioInPlace(playerPed, 'CODE_HUMAN_MEDIC_TEND_TO_DEAD', 0, true) + Citizen.Wait(10000) + ClearPedTasks(playerPed) + + TriggerServerEvent('esx_ambulancejob:removeItem', 'medikit') + TriggerServerEvent('esx_ambulancejob:heal', GetPlayerServerId(closestPlayer), 'big') + ESX.ShowNotification(_U('heal_complete', GetPlayerName(closestPlayer))) + IsBusy = false + else + ESX.ShowNotification(_U('player_not_conscious')) + end + else + ESX.ShowNotification(_U('not_enough_medikit')) + end + end, 'medikit') + end + elseif data.current.value == 'put_in_vehicle' then + + local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() + if closestPlayer == -1 or closestDistance > 3.0 then + ESX.ShowNotification(_U('no_vehicles')) + else + menu.close() + WarpPedInClosestVehicle(GetPlayerPed(closestPlayer)) + end end + end, function(data, menu) + menu.close() + end) + end end, function(data, menu) - menu.close() + menu.close() end) end function OpenCloakroomMenu() - ESX.UI.Menu.Open( - 'default', GetCurrentResourceName(), 'cloakroom', - { - title = _U('cloakroom'), - align = 'top-left', - elements = { - {label = _U('ems_clothes_civil'), value = 'citizen_wear'}, - {label = _U('ems_clothes_ems'), value = 'ambulance_wear'}, - }, - }, - function(data, menu) + ESX.UI.Menu.Open( + 'default', GetCurrentResourceName(), 'cloakroom', + { + title = _U('cloakroom'), + align = 'top-left', + elements = { + {label = _U('ems_clothes_civil'), value = 'citizen_wear'}, + {label = _U('ems_clothes_ems'), value = 'ambulance_wear'}, + }, + }, + function(data, menu) - menu.close() + menu.close() - if data.current.value == 'citizen_wear' then + if data.current.value == 'citizen_wear' then - ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin) - TriggerEvent('skinchanger:loadSkin', skin) - end) + ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin) + TriggerEvent('skinchanger:loadSkin', skin) + end) - end + end - if data.current.value == 'ambulance_wear' then + if data.current.value == 'ambulance_wear' then - ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin) + ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin) - if skin.sex == 0 then - TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_male) - else - TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_female) - end + if skin.sex == 0 then + TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_male) + else + TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_female) + end - end) + end) - end + end - CurrentAction = 'ambulance_actions_menu' - CurrentActionMsg = _U('open_menu') - CurrentActionData = {} + CurrentAction = 'ambulance_actions_menu' + CurrentActionMsg = _U('open_menu') + CurrentActionData = {} - end, - function(data, menu) - menu.close() - end - ) + end, + function(data, menu) + menu.close() + end + ) end @@ -535,61 +518,61 @@ function OpenVehicleSpawnerMenu() if Config.EnableSocietyOwnedVehicles then - local elements = {} + local elements = {} - ESX.TriggerServerCallback('esx_society:getVehiclesInGarage', function(vehicles) + ESX.TriggerServerCallback('esx_society:getVehiclesInGarage', function(vehicles) - for i=1, #vehicles, 1 do - table.insert(elements, {label = GetDisplayNameFromVehicleModel(vehicles[i].model) .. ' [' .. vehicles[i].plate .. ']', value = vehicles[i]}) - end - - ESX.UI.Menu.Open( - 'default', GetCurrentResourceName(), 'vehicle_spawner', - { - title = _U('veh_menu'), - align = 'top-left', - elements = elements, - }, function(data, menu) - menu.close() - - local vehicleProps = data.current.value - ESX.Game.SpawnVehicle(vehicleProps.model, Config.Zones.VehicleSpawnPoint.Pos, 270.0, function(vehicle) - ESX.Game.SetVehicleProperties(vehicle, vehicleProps) - local playerPed = GetPlayerPed(-1) - TaskWarpPedIntoVehicle(playerPed, vehicle, -1) - end) - TriggerServerEvent('esx_society:removeVehicleFromGarage', 'ambulance', vehicleProps) - - end, function(data, menu) - menu.close() - CurrentAction = 'vehicle_spawner_menu' - CurrentActionMsg = _U('veh_spawn') - CurrentActionData = {} - end - ) - end, 'ambulance') - - else -- not society vehicles + for i=1, #vehicles, 1 do + table.insert(elements, {label = GetDisplayNameFromVehicleModel(vehicles[i].model) .. ' [' .. vehicles[i].plate .. ']', value = vehicles[i]}) + end ESX.UI.Menu.Open( 'default', GetCurrentResourceName(), 'vehicle_spawner', { - title = _U('veh_menu'), - align = 'top-left', - elements = Config.AuthorizedVehicles + title = _U('veh_menu'), + align = 'top-left', + elements = elements, }, function(data, menu) - menu.close() - ESX.Game.SpawnVehicle(data.current.model, Config.Zones.VehicleSpawnPoint.Pos, 230.0, function(vehicle) - local playerPed = GetPlayerPed(-1) - TaskWarpPedIntoVehicle(playerPed, vehicle, -1) - end) + menu.close() + + local vehicleProps = data.current.value + ESX.Game.SpawnVehicle(vehicleProps.model, Config.Zones.VehicleSpawnPoint.Pos, 270.0, function(vehicle) + ESX.Game.SetVehicleProperties(vehicle, vehicleProps) + local playerPed = GetPlayerPed(-1) + TaskWarpPedIntoVehicle(playerPed, vehicle, -1) + end) + TriggerServerEvent('esx_society:removeVehicleFromGarage', 'ambulance', vehicleProps) + end, function(data, menu) - menu.close() - CurrentAction = 'vehicle_spawner_menu' - CurrentActionMsg = _U('veh_spawn') - CurrentActionData = {} + menu.close() + CurrentAction = 'vehicle_spawner_menu' + CurrentActionMsg = _U('veh_spawn') + CurrentActionData = {} end ) + end, 'ambulance') + + else -- not society vehicles + + ESX.UI.Menu.Open( + 'default', GetCurrentResourceName(), 'vehicle_spawner', + { + title = _U('veh_menu'), + align = 'top-left', + elements = Config.AuthorizedVehicles + }, function(data, menu) + menu.close() + ESX.Game.SpawnVehicle(data.current.model, Config.Zones.VehicleSpawnPoint.Pos, 230.0, function(vehicle) + local playerPed = GetPlayerPed(-1) + TaskWarpPedIntoVehicle(playerPed, vehicle, -1) + end) + end, function(data, menu) + menu.close() + CurrentAction = 'vehicle_spawner_menu' + CurrentActionMsg = _U('veh_spawn') + CurrentActionData = {} + end + ) end end @@ -599,20 +582,20 @@ function OpenPharmacyMenu() ESX.UI.Menu.Open( 'default', GetCurrentResourceName(), 'pharmacy', { - title = _U('pharmacy_menu_title'), - align = 'top-left', - elements = { - {label = _U('pharmacy_take') .. ' ' .. _('medikit'), value = 'medikit'}, - {label = _U('pharmacy_take') .. ' ' .. _('bandage'), value = 'bandage'} - }, + title = _U('pharmacy_menu_title'), + align = 'top-left', + elements = { + {label = _U('pharmacy_take') .. ' ' .. _('medikit'), value = 'medikit'}, + {label = _U('pharmacy_take') .. ' ' .. _('bandage'), value = 'bandage'} + }, }, function(data, menu) - TriggerServerEvent('esx_ambulancejob:giveItem', data.current.value) - + TriggerServerEvent('esx_ambulancejob:giveItem', data.current.value) + end, function(data, menu) - menu.close() - CurrentAction = 'pharmacy' - CurrentActionMsg = _U('open_pharmacy') - CurrentActionData = {} + menu.close() + CurrentAction = 'pharmacy' + CurrentActionMsg = _U('open_pharmacy') + CurrentActionData = {} end ) end @@ -621,32 +604,32 @@ AddEventHandler('playerSpawned', function() IsDead = false if FirstSpawn then - TriggerServerEvent('esx_ambulancejob:firstSpawn') - exports.spawnmanager:setAutoSpawn(false) -- disable respawn - FirstSpawn = false + TriggerServerEvent('esx_ambulancejob:firstSpawn') + exports.spawnmanager:setAutoSpawn(false) -- disable respawn + FirstSpawn = false end end) RegisterNetEvent('esx:playerLoaded') AddEventHandler('esx:playerLoaded', function(xPlayer) - PlayerData = xPlayer + PlayerData = xPlayer end) RegisterNetEvent('esx:setJob') AddEventHandler('esx:setJob', function(job) - PlayerData.job = job + PlayerData.job = job end) RegisterNetEvent('esx_phone:loaded') AddEventHandler('esx_phone:loaded', function(phoneNumber, contacts) - local specialContact = { - name = 'Ambulance', - number = 'ambulance', - base64Icon = 'data:image/png;base64,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' - } + local specialContact = { + name = 'Ambulance', + number = 'ambulance', + base64Icon = 'data:image/png;base64,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' + } - TriggerEvent('esx_phone:addSpecialContact', specialContact.name, specialContact.number, specialContact.base64Icon) + TriggerEvent('esx_phone:addSpecialContact', specialContact.name, specialContact.number, specialContact.base64Icon) end) @@ -657,269 +640,269 @@ end) RegisterNetEvent('esx_ambulancejob:revive') AddEventHandler('esx_ambulancejob:revive', function() - local playerPed = GetPlayerPed(-1) - local coords = GetEntityCoords(playerPed) - TriggerServerEvent('esx_ambulancejob:setDeathStatus', 0) - - Citizen.CreateThread(function() + local playerPed = GetPlayerPed(-1) + local coords = GetEntityCoords(playerPed) + TriggerServerEvent('esx_ambulancejob:setDeathStatus', 0) - DoScreenFadeOut(800) + Citizen.CreateThread(function() - while not IsScreenFadedOut() do - Citizen.Wait(0) - end + DoScreenFadeOut(800) - ESX.SetPlayerData('lastPosition', { - x = coords.x, - y = coords.y, - z = coords.z - }) + while not IsScreenFadedOut() do + Citizen.Wait(0) + end - TriggerServerEvent('esx:updateLastPosition', { - x = coords.x, - y = coords.y, - z = coords.z - }) + ESX.SetPlayerData('lastPosition', { + x = coords.x, + y = coords.y, + z = coords.z + }) - RespawnPed(playerPed, { - x = coords.x, - y = coords.y, - z = coords.z - }) + TriggerServerEvent('esx:updateLastPosition', { + x = coords.x, + y = coords.y, + z = coords.z + }) - StopScreenEffect('DeathFailOut') + RespawnPed(playerPed, { + x = coords.x, + y = coords.y, + z = coords.z + }) - DoScreenFadeIn(800) + StopScreenEffect('DeathFailOut') - end) + DoScreenFadeIn(800) + + end) end) AddEventHandler('esx_ambulancejob:hasEnteredMarker', function(zone) - if zone == 'HospitalInteriorEntering1' then - TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.HospitalInteriorInside1.Pos) - end + if zone == 'HospitalInteriorEntering1' then + TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.HospitalInteriorInside1.Pos) + end - if zone == 'HospitalInteriorExit1' then - TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.HospitalInteriorOutside1.Pos) - end + if zone == 'HospitalInteriorExit1' then + TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.HospitalInteriorOutside1.Pos) + end - if zone == 'HospitalInteriorEntering2' then - local heli = Config.HelicopterSpawner + if zone == 'HospitalInteriorEntering2' then + local heli = Config.HelicopterSpawner - if not IsAnyVehicleNearPoint(heli.SpawnPoint.x, heli.SpawnPoint.y, heli.SpawnPoint.z, 3.0) - and PlayerData.job ~= nil and PlayerData.job.name == 'ambulance' then - ESX.Game.SpawnVehicle('polmav', { - x = heli.SpawnPoint.x, - y = heli.SpawnPoint.y, - z = heli.SpawnPoint.z - }, heli.Heading, function(vehicle) - SetVehicleModKit(vehicle, 0) - SetVehicleLivery(vehicle, 1) - end) + if not IsAnyVehicleNearPoint(heli.SpawnPoint.x, heli.SpawnPoint.y, heli.SpawnPoint.z, 3.0) + and PlayerData.job ~= nil and PlayerData.job.name == 'ambulance' then + ESX.Game.SpawnVehicle('polmav', { + x = heli.SpawnPoint.x, + y = heli.SpawnPoint.y, + z = heli.SpawnPoint.z + }, heli.Heading, function(vehicle) + SetVehicleModKit(vehicle, 0) + SetVehicleLivery(vehicle, 1) + end) - end - TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.HospitalInteriorInside2.Pos) - end + end + TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.HospitalInteriorInside2.Pos) + end - if zone == 'HospitalInteriorExit2' then - TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.HospitalInteriorOutside2.Pos) - end + if zone == 'HospitalInteriorExit2' then + TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.HospitalInteriorOutside2.Pos) + end - if zone == 'ParkingDoorGoOutInside' then - TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.ParkingDoorGoOutOutside.Pos) - end + if zone == 'ParkingDoorGoOutInside' then + TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.ParkingDoorGoOutOutside.Pos) + end - if zone == 'ParkingDoorGoInOutside' then - TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.ParkingDoorGoInInside.Pos) - end + if zone == 'ParkingDoorGoInOutside' then + TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.ParkingDoorGoInInside.Pos) + end - if zone == 'StairsGoTopBottom' then - CurrentAction = 'fast_travel_goto_top' - CurrentActionMsg = _U('fast_travel') - CurrentActionData = {pos = Config.Zones.StairsGoTopTop.Pos} - end + if zone == 'StairsGoTopBottom' then + CurrentAction = 'fast_travel_goto_top' + CurrentActionMsg = _U('fast_travel') + CurrentActionData = {pos = Config.Zones.StairsGoTopTop.Pos} + end - if zone == 'StairsGoBottomTop' then - CurrentAction = 'fast_travel_goto_bottom' - CurrentActionMsg = _U('fast_travel') - CurrentActionData = {pos = Config.Zones.StairsGoBottomBottom.Pos} - end + if zone == 'StairsGoBottomTop' then + CurrentAction = 'fast_travel_goto_bottom' + CurrentActionMsg = _U('fast_travel') + CurrentActionData = {pos = Config.Zones.StairsGoBottomBottom.Pos} + end - if zone == 'AmbulanceActions' then - CurrentAction = 'ambulance_actions_menu' - CurrentActionMsg = _U('open_menu') - CurrentActionData = {} - end + if zone == 'AmbulanceActions' then + CurrentAction = 'ambulance_actions_menu' + CurrentActionMsg = _U('open_menu') + CurrentActionData = {} + end - if zone == 'VehicleSpawner' then - CurrentAction = 'vehicle_spawner_menu' - CurrentActionMsg = _U('veh_spawn') - CurrentActionData = {} - end + if zone == 'VehicleSpawner' then + CurrentAction = 'vehicle_spawner_menu' + CurrentActionMsg = _U('veh_spawn') + CurrentActionData = {} + end - if zone == 'Pharmacy' then - CurrentAction = 'pharmacy' - CurrentActionMsg = _U('open_pharmacy') - CurrentActionData = {} - end + if zone == 'Pharmacy' then + CurrentAction = 'pharmacy' + CurrentActionMsg = _U('open_pharmacy') + CurrentActionData = {} + end - if zone == 'VehicleDeleter' then + if zone == 'VehicleDeleter' then - local playerPed = GetPlayerPed(-1) - local coords = GetEntityCoords(playerPed) + local playerPed = GetPlayerPed(-1) + local coords = GetEntityCoords(playerPed) - if IsPedInAnyVehicle(playerPed, false) then + if IsPedInAnyVehicle(playerPed, false) then - local vehicle, distance = ESX.Game.GetClosestVehicle({ - x = coords.x, - y = coords.y, - z = coords.z - }) + local vehicle, distance = ESX.Game.GetClosestVehicle({ + x = coords.x, + y = coords.y, + z = coords.z + }) - if distance ~= -1 and distance <= 1.0 then + if distance ~= -1 and distance <= 1.0 then - CurrentAction = 'delete_vehicle' - CurrentActionMsg = _U('store_veh') - CurrentActionData = {vehicle = vehicle} + CurrentAction = 'delete_vehicle' + CurrentActionMsg = _U('store_veh') + CurrentActionData = {vehicle = vehicle} - end + end - end + end - end + end end) function FastTravel(pos) - TeleportFadeEffect(GetPlayerPed(-1), pos) + TeleportFadeEffect(GetPlayerPed(-1), pos) end AddEventHandler('esx_ambulancejob:hasExitedMarker', function(zone) - ESX.UI.Menu.CloseAll() - CurrentAction = nil + ESX.UI.Menu.CloseAll() + CurrentAction = nil end) -- Create blips Citizen.CreateThread(function() - local blip = AddBlipForCoord(Config.Blip.Pos.x, Config.Blip.Pos.y, Config.Blip.Pos.z) + local blip = AddBlipForCoord(Config.Blip.Pos.x, Config.Blip.Pos.y, Config.Blip.Pos.z) - SetBlipSprite (blip, Config.Blip.Sprite) - SetBlipDisplay(blip, Config.Blip.Display) - SetBlipScale (blip, Config.Blip.Scale) - SetBlipColour (blip, Config.Blip.Colour) - SetBlipAsShortRange(blip, true) + SetBlipSprite (blip, Config.Blip.Sprite) + SetBlipDisplay(blip, Config.Blip.Display) + SetBlipScale (blip, Config.Blip.Scale) + SetBlipColour (blip, Config.Blip.Colour) + SetBlipAsShortRange(blip, true) - BeginTextCommandSetBlipName("STRING") - AddTextComponentString(_U('hospital')) - EndTextCommandSetBlipName(blip) + BeginTextCommandSetBlipName("STRING") + AddTextComponentString(_U('hospital')) + EndTextCommandSetBlipName(blip) end) -- Display markers Citizen.CreateThread(function() - while true do - Citizen.Wait(0) + while true do + Citizen.Wait(0) - local coords = GetEntityCoords(GetPlayerPed(-1)) - for k,v in pairs(Config.Zones) do - if(v.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance) then - if PlayerData.job ~= nil and PlayerData.job.name == 'ambulance' then - DrawMarker(v.Type, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false) - elseif k ~= 'AmbulanceActions' and k ~= 'VehicleSpawner' and k ~= 'VehicleDeleter' - and k ~= 'Pharmacy' and k ~= 'StairsGoTopBottom' and k ~= 'StairsGoBottomTop' then - DrawMarker(v.Type, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false) - end - end - end - end + local coords = GetEntityCoords(GetPlayerPed(-1)) + for k,v in pairs(Config.Zones) do + if(v.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance) then + if PlayerData.job ~= nil and PlayerData.job.name == 'ambulance' then + DrawMarker(v.Type, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false) + elseif k ~= 'AmbulanceActions' and k ~= 'VehicleSpawner' and k ~= 'VehicleDeleter' + and k ~= 'Pharmacy' and k ~= 'StairsGoTopBottom' and k ~= 'StairsGoBottomTop' then + DrawMarker(v.Type, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false) + end + end + end + end end) -- Activate menu when player is inside marker Citizen.CreateThread(function() while true do - Citizen.Wait(10) - - local coords = GetEntityCoords(GetPlayerPed(-1)) - local isInMarker = false - local currentZone = nil - for k,v in pairs(Config.Zones) do - if PlayerData.job ~= nil and PlayerData.job.name == 'ambulance' then - if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.MarkerSize.x) then - isInMarker = true - currentZone = k - end - elseif k ~= 'AmbulanceActions' and k ~= 'VehicleSpawner' and k ~= 'VehicleDeleter' and k ~= 'Pharmacy' and k ~= 'StairsGoTopBottom' and k ~= 'StairsGoBottomTop' then - if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.MarkerSize.x) then - isInMarker = true - currentZone = k - end - end + Citizen.Wait(10) + + local coords = GetEntityCoords(GetPlayerPed(-1)) + local isInMarker = false + local currentZone = nil + for k,v in pairs(Config.Zones) do + if PlayerData.job ~= nil and PlayerData.job.name == 'ambulance' then + if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.MarkerSize.x) then + isInMarker = true + currentZone = k end - if isInMarker and not hasAlreadyEnteredMarker then - hasAlreadyEnteredMarker = true - lastZone = currentZone - TriggerEvent('esx_ambulancejob:hasEnteredMarker', currentZone) + elseif k ~= 'AmbulanceActions' and k ~= 'VehicleSpawner' and k ~= 'VehicleDeleter' and k ~= 'Pharmacy' and k ~= 'StairsGoTopBottom' and k ~= 'StairsGoBottomTop' then + if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.MarkerSize.x) then + isInMarker = true + currentZone = k end - - if not isInMarker and hasAlreadyEnteredMarker then - hasAlreadyEnteredMarker = false - TriggerEvent('esx_ambulancejob:hasExitedMarker', lastZone) end end + if isInMarker and not hasAlreadyEnteredMarker then + hasAlreadyEnteredMarker = true + lastZone = currentZone + TriggerEvent('esx_ambulancejob:hasEnteredMarker', currentZone) + end + + if not isInMarker and hasAlreadyEnteredMarker then + hasAlreadyEnteredMarker = false + TriggerEvent('esx_ambulancejob:hasExitedMarker', lastZone) + end + end end) -- Key Controls Citizen.CreateThread(function() - while true do + while true do - Citizen.Wait(10) + Citizen.Wait(10) - if CurrentAction ~= nil then + if CurrentAction ~= nil then - SetTextComponentFormat('STRING') - AddTextComponentString(CurrentActionMsg) - DisplayHelpTextFromStringLabel(0, 0, 1, -1) + SetTextComponentFormat('STRING') + AddTextComponentString(CurrentActionMsg) + DisplayHelpTextFromStringLabel(0, 0, 1, -1) - if IsControlJustReleased(0, Keys['E']) and PlayerData.job ~= nil and PlayerData.job.name == 'ambulance' then + if IsControlJustReleased(0, Keys['E']) and PlayerData.job ~= nil and PlayerData.job.name == 'ambulance' then - if CurrentAction == 'ambulance_actions_menu' then - OpenAmbulanceActionsMenu() - end + if CurrentAction == 'ambulance_actions_menu' then + OpenAmbulanceActionsMenu() + end - if CurrentAction == 'vehicle_spawner_menu' then - OpenVehicleSpawnerMenu() - end + if CurrentAction == 'vehicle_spawner_menu' then + OpenVehicleSpawnerMenu() + end - if CurrentAction == 'pharmacy' then - OpenPharmacyMenu() - end + if CurrentAction == 'pharmacy' then + OpenPharmacyMenu() + end - if CurrentAction == 'fast_travel_goto_top' or CurrentAction == 'fast_travel_goto_bottom' then - FastTravel(CurrentActionData.pos) - end + if CurrentAction == 'fast_travel_goto_top' or CurrentAction == 'fast_travel_goto_bottom' then + FastTravel(CurrentActionData.pos) + end - if CurrentAction == 'delete_vehicle' then - if Config.EnableSocietyOwnedVehicles then - local vehicleProps = ESX.Game.GetVehicleProperties(CurrentActionData.vehicle) - TriggerServerEvent('esx_society:putVehicleInGarage', 'ambulance', vehicleProps) - end - ESX.Game.DeleteVehicle(CurrentActionData.vehicle) - end + if CurrentAction == 'delete_vehicle' then + if Config.EnableSocietyOwnedVehicles then + local vehicleProps = ESX.Game.GetVehicleProperties(CurrentActionData.vehicle) + TriggerServerEvent('esx_society:putVehicleInGarage', 'ambulance', vehicleProps) + end + ESX.Game.DeleteVehicle(CurrentActionData.vehicle) + end - CurrentAction = nil + CurrentAction = nil - end + end - end + end - if IsControlJustReleased(0, Keys['F6']) and PlayerData.job ~= nil and PlayerData.job.name == 'ambulance' and not IsDead then - OpenMobileAmbulanceActionsMenu() - end + if IsControlJustReleased(0, Keys['F6']) and PlayerData.job ~= nil and PlayerData.job.name == 'ambulance' and not IsDead then + OpenMobileAmbulanceActionsMenu() + end - end + end end) RegisterNetEvent('esx_ambulancejob:requestDeath') @@ -936,18 +919,18 @@ if Config.LoadIpl then LoadMpDlcMaps() EnableMpDlcMaps(true) RequestIpl('Coroner_Int_on') -- Morgue - end) + end) end -- String string function stringsplit(inputstr, sep) - if sep == nil then - sep = "%s" - end - local t={} ; i=1 - for str in string.gmatch(inputstr, "([^"..sep.."]+)") do - t[i] = str - i = i + 1 - end - return t + if sep == nil then + sep = "%s" + end + local t={} ; i=1 + for str in string.gmatch(inputstr, "([^"..sep.."]+)") do + t[i] = str + i = i + 1 + end + return t end diff --git a/config.lua b/config.lua index 622bcd6a..313ac88a 100644 --- a/config.lua +++ b/config.lua @@ -14,12 +14,6 @@ local minute = 60 * second -- How much time before auto respawn at hospital Config.RespawnDelayAfterRPDeath = 10 * minute --- How much time before a menu opens to ask the player if he wants to respawn at hospital now --- The player is not obliged to select YES, but he will be auto respawn --- at the end of RespawnDelayAfterRPDeath just above. -Config.RespawnToHospitalMenuTimer = true -Config.MenuRespawnToHospitalDelay = 5 * minute - Config.EnablePlayerManagement = false Config.EnableSocietyOwnedVehicles = false @@ -27,14 +21,14 @@ Config.RemoveWeaponsAfterRPDeath = true Config.RemoveCashAfterRPDeath = true Config.RemoveItemsAfterRPDeath = true --- Will display a timer that shows RespawnDelayAfterRPDeath time remaining +-- Will display a timer that shows RespawnDelayAfterRPDeath as a countdown Config.ShowDeathTimer = true --- Will allow to respawn at any time, don't use with RespawnToHospitalMenuTimer enabled! +-- Will allow respawn after half of RespawnDelayAfterRPDeath has elapsed. Config.EarlyRespawn = false --- The player can have a fine (on bank account) -Config.RespawnFine = false -Config.RespawnFineAmount = 500 +-- The player will be fined for respawning early (on bank account) +Config.EarlyRespawnFine = false +Config.EarlyRespawnFineAmount = 500 Config.Blip = { Pos = { x = 307.76, y = -1433.47, z = 28.97 }, diff --git a/locales/br.lua b/locales/br.lua index 672bbc45..4ffcc83c 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -46,13 +46,11 @@ Locales['br'] = { -- Phone ['alert_ambulance'] = 'Alerta Socorro', -- Death - ['respawn_at_hospital'] = 'Você quer ser transportado para o hospital ?', - ['yes'] = 'Sim', - ['no'] = 'no', - ['please_wait'] = 'Você será automaticamente transportado para o hospital em ~b~%s minutos %s segundos~s~', - ['press_respawn'] = 'Aperte [~b~E~w~] para renascer.', - ['respawn_fine'] = 'you paid ~r~$%s~s~ for respawning.', - ['distress_send'] = 'press ~b~[G]~s~ to send distress signal', + ['please_wait'] = 'you will bleed out in ~b~%s minutes %s seconds~s~\n', + ['press_respawn'] = 'press [~b~E~w~] to respawn.', + ['respawn_now_fine'] = 'respawn now for ~g~$%s ~w~[Press ~b~E~w~]', + ['respawn_fine'] = 'you paid ~r~$%s~s~ to respawn.', + ['distress_send'] = 'press [~b~G~s~] to send distress signal', ['distress_sent'] = 'distress signal has been sent to available units!', ['distress_message'] = 'medical attention required: unconscious citizen!', -- Revive @@ -63,5 +61,4 @@ Locales['br'] = { ['not_enough_medikit'] = 'Você não tem ~b~Seringa~w~.', ['not_enough_bandage'] = 'Você não tem ~b~Vendagem~w~.', ['healed'] = 'Você foi tratado.', - -- Misc } diff --git a/locales/de.lua b/locales/de.lua index 7180521d..38b46ab1 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -37,13 +37,11 @@ Locales['de'] = { -- Phone ['alert_ambulance'] = 'Notdienst anrufen', -- Death - ['respawn_at_hospital'] = 'Willst du ins Krankenhaus gebracht werden?', - ['yes'] = 'ja', - ['no'] = 'no', - ['please_wait'] = 'bitte warte ~b~%s minuten %s sekunden~s~ bis zum respawn', - ['press_respawn'] = 'Drücke [~b~E~w~] zum respawnen.', - ['respawn_fine'] = 'you paid ~r~$%s~s~ for respawning.', - ['distress_send'] = 'press ~b~[G]~s~ to send distress signal', + ['please_wait'] = 'you will bleed out in ~b~%s minutes %s seconds~s~\n', + ['press_respawn'] = 'press [~b~E~w~] to respawn.', + ['respawn_now_fine'] = 'respawn now for ~g~$%s ~w~[Press ~b~E~w~]', + ['respawn_fine'] = 'you paid ~r~$%s~s~ to respawn.', + ['distress_send'] = 'press [~b~G~s~] to send distress signal', ['distress_sent'] = 'distress signal has been sent to available units!', ['distress_message'] = 'medical attention required: unconscious citizen!', -- Revive diff --git a/locales/en.lua b/locales/en.lua index 603b80e1..287033f0 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -46,22 +46,19 @@ Locales['en'] = { -- Phone ['alert_ambulance'] = 'alert Ambulance', -- Death - ['respawn_at_hospital'] = 'do you want to force respawn and spawn in the hospital?', - ['yes'] = 'yes', - ['no'] = 'no', - ['please_wait'] = 'you are unconscious and will bleed out in ~b~%s minutes and %s seconds~s~', + ['please_wait'] = 'you will bleed out in ~b~%s minutes %s seconds~s~\n', ['press_respawn'] = 'press [~b~E~w~] to respawn.', - ['respawn_fine'] = 'you paid ~r~$%s~s~ for respawning.', - ['distress_send'] = 'press ~b~[G]~s~ to send distress signal', + ['respawn_now_fine'] = 'respawn now for ~g~$%s ~w~[Press ~b~E~w~]', + ['respawn_fine'] = 'you paid ~r~$%s~s~ to respawn.', + ['distress_send'] = 'press [~b~G~s~] to send distress signal', ['distress_sent'] = 'distress signal has been sent to available units!', ['distress_message'] = 'medical attention required: unconscious citizen!', -- Revive ['revive_help'] = 'revive a player', -- Item - ['used_medikit'] = 'You have used 1x medikit', - ['used_bandage'] = 'You have used 1x bandage', + ['used_medikit'] = 'You have used ~y~1x~s~ medikit', + ['used_bandage'] = 'You have used ~y~1x~s~ bandage', ['not_enough_medikit'] = 'You do not have ~b~medikit~w~.', ['not_enough_bandage'] = 'You do not have ~b~bandage~w~.', ['healed'] = 'you have been treated.', - -- Misc } diff --git a/locales/es.lua b/locales/es.lua index 92c02650..ba4f7011 100644 --- a/locales/es.lua +++ b/locales/es.lua @@ -36,13 +36,11 @@ Locales['es'] = { -- Phone ['alert_ambulance'] = 'Alerta de ambulancia', -- Death - ['respawn_at_hospital'] = '¿Quieres ser transportado al hospital?', - ['yes'] = 'oui', - ['no'] = 'no', - ['please_wait'] = 's\'por favor, espere ~b~%s minutos %s segundos para reparecer~s~', - ['press_respawn'] = 'presione [~b~E~w~] para reparecer.', - ['respawn_fine'] = 'you paid ~r~$%s~s~ for respawning.', - ['distress_send'] = 'press ~b~[G]~s~ to send distress signal', + ['please_wait'] = 'you will bleed out in ~b~%s minutes %s seconds~s~\n', + ['press_respawn'] = 'press [~b~E~w~] to respawn.', + ['respawn_now_fine'] = 'respawn now for ~g~$%s ~w~[Press ~b~E~w~]', + ['respawn_fine'] = 'you paid ~r~$%s~s~ to respawn.', + ['distress_send'] = 'press [~b~G~s~] to send distress signal', ['distress_sent'] = 'distress signal has been sent to available units!', ['distress_message'] = 'medical attention required: unconscious citizen!', -- Revive diff --git a/locales/fi.lua b/locales/fi.lua index 4f49482c..cfa5b6b6 100644 --- a/locales/fi.lua +++ b/locales/fi.lua @@ -46,15 +46,13 @@ Locales['fi'] = { -- Phone ['alert_ambulance'] = 'hälyytys Ensihoidolle', -- Death - ['respawn_at_hospital'] = 'haluatko respawnata sairaalalle heti ?', - ['yes'] = 'kyllä', - ['no'] = 'ei', - ['please_wait'] = 'olet tajuton, vuodat kuiviin ~b~%s minuutin ja %s sekunnin~s~ kuluttua', - ['press_respawn'] = 'paina [~b~E~w~] respawnataksesi.', - ['respawn_fine'] = 'sinä maksoit ~r~$%s~s~ respawnaamisesta.', - ['distress_send'] = 'paina ~b~[G]~s~ lähettääksesi hätäsignaalin', - ['distress_sent'] = 'hätäsignaali lähetetty vapailla yksiköille.', - ['distress_message'] = 'tarvittava ensihoitoa: tajuton kansalainen!', + ['please_wait'] = 'you will bleed out in ~b~%s minutes %s seconds~s~\n', + ['press_respawn'] = 'press [~b~E~w~] to respawn.', + ['respawn_now_fine'] = 'respawn now for ~g~$%s ~w~[Press ~b~E~w~]', + ['respawn_fine'] = 'you paid ~r~$%s~s~ to respawn.', + ['distress_send'] = 'press [~b~G~s~] to send distress signal', + ['distress_sent'] = 'distress signal has been sent to available units!', + ['distress_message'] = 'medical attention required: unconscious citizen!', -- Revive ['revive_help'] = 'elvytä pelaaja', -- Item diff --git a/locales/fr.lua b/locales/fr.lua index 355a37a3..073193d4 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -46,13 +46,11 @@ Locales['fr'] = { -- Phone ['alert_ambulance'] = 'alerte Ambulance', -- Death - ['respawn_at_hospital'] = 'voulez-vous être transporté à l\'hôpital ?', - ['yes'] = 'oui', - ['no'] = 'no', - ['please_wait'] = 'Vous serez automatiquement transporté à l\'hôpital dans ~b~%s minutes %s secondes~s~', - ['press_respawn'] = 'appuyez sur [~b~E~w~] pour réapparaître.', - ['respawn_fine'] = 'vous avez payer ~r~$%s~s~ pour réapparaître.', - ['distress_send'] = 'press ~b~[G]~s~ to send distress signal', + ['please_wait'] = 'you will bleed out in ~b~%s minutes %s seconds~s~\n', + ['press_respawn'] = 'press [~b~E~w~] to respawn.', + ['respawn_now_fine'] = 'respawn now for ~g~$%s ~w~[Press ~b~E~w~]', + ['respawn_fine'] = 'you paid ~r~$%s~s~ to respawn.', + ['distress_send'] = 'press [~b~G~s~] to send distress signal', ['distress_sent'] = 'distress signal has been sent to available units!', ['distress_message'] = 'medical attention required: unconscious citizen!', -- Revive diff --git a/locales/pl.lua b/locales/pl.lua index 1e8b1663..aca5f6f5 100644 --- a/locales/pl.lua +++ b/locales/pl.lua @@ -46,11 +46,13 @@ Locales['pl'] = { -- Phone ['alert_ambulance'] = 'wezwij ambulans', -- Death - ['respawn_at_hospital'] = 'czy chcesz odrodzić się w szpitalu?', - ['yes'] = 'tak', - ['please_wait'] = 'jesteś nieprzytomny i będziesz się wykrwawiał ~b~%s minut i %s sekund~s~', - ['press_respawn'] = 'naciśnij [~b~E~w~] aby się odrodzić.', - ['respawn_fine'] = 'zapłaciłeś ~r~$%s~s~ za odrodzenie.', + ['please_wait'] = 'you will bleed out in ~b~%s minutes %s seconds~s~\n', + ['press_respawn'] = 'press [~b~E~w~] to respawn.', + ['respawn_now_fine'] = 'respawn now for ~g~$%s ~w~[Press ~b~E~w~]', + ['respawn_fine'] = 'you paid ~r~$%s~s~ to respawn.', + ['distress_send'] = 'press [~b~G~s~] to send distress signal', + ['distress_sent'] = 'distress signal has been sent to available units!', + ['distress_message'] = 'medical attention required: unconscious citizen!', -- Revive ['revive_help'] = 'ożyw gracza', -- Item diff --git a/locales/sv.lua b/locales/sv.lua index 9f607914..b60946d2 100644 --- a/locales/sv.lua +++ b/locales/sv.lua @@ -46,15 +46,13 @@ Locales['sv'] = { -- Phone ['alert_ambulance'] = 'Ring ambulansen', -- Death - ['respawn_at_hospital'] = 'Vill du snabbresa till sjukhuset?', - ['yes'] = 'ja', - ['no'] = 'nej', - ['please_wait'] = 'du är medvetslös och kommer att dö om ~b~%s minuter och %s sekunder~s~', - ['press_respawn'] = 'tryck [~b~E~w~] för att respawna.', - ['respawn_fine'] = 'du betalade ~r~$%s~s~ för att respawna.', - ['distress_send'] = 'tryck ~b~[G]~s~ för att skicka nödsignal', - ['distress_sent'] = 'nödsignal har skickats till samtliga enheter!', - ['distress_message'] = 'läkarvård krävs: medvetslös medborgare!', + ['please_wait'] = 'you will bleed out in ~b~%s minutes %s seconds~s~\n', + ['press_respawn'] = 'press [~b~E~w~] to respawn.', + ['respawn_now_fine'] = 'respawn now for ~g~$%s ~w~[Press ~b~E~w~]', + ['respawn_fine'] = 'you paid ~r~$%s~s~ to respawn.', + ['distress_send'] = 'press [~b~G~s~] to send distress signal', + ['distress_sent'] = 'distress signal has been sent to available units!', + ['distress_message'] = 'medical attention required: unconscious citizen!', -- Revive ['revive_help'] = 'Återuppliva en spelare', -- Item diff --git a/localization/en_esx_ambulancejob.sql b/localization/en_esx_ambulancejob.sql index 87c43e10..8ba7a87a 100644 --- a/localization/en_esx_ambulancejob.sql +++ b/localization/en_esx_ambulancejob.sql @@ -1,27 +1,27 @@ USE `essentialmode`; INSERT INTO `addon_account` (name, label, shared) VALUES - ('society_ambulance', 'Ambulance', 1) + ('society_ambulance', 'EMS', 1) ; INSERT INTO `addon_inventory` (name, label, shared) VALUES - ('society_ambulance', 'Ambulance', 1) + ('society_ambulance', 'EMS', 1) ; INSERT INTO `datastore` (name, label, shared) VALUES - ('society_ambulance', 'Ambulance', 1) + ('society_ambulance', 'EMS', 1) ; INSERT INTO `job_grades` (job_name, grade, name, label, salary, skin_male, skin_female) VALUES - ('ambulance',0,'ambulance','Ambulance',20,'{\"tshirt_2\":0,\"hair_color_1\":5,\"glasses_2\":3,\"shoes\":9,\"torso_2\":3,\"hair_color_2\":0,\"pants_1\":24,\"glasses_1\":4,\"hair_1\":2,\"sex\":0,\"decals_2\":0,\"tshirt_1\":15,\"helmet_1\":8,\"helmet_2\":0,\"arms\":92,\"face\":19,\"decals_1\":60,\"torso_1\":13,\"hair_2\":0,\"skin\":34,\"pants_2\":5}','{\"tshirt_2\":3,\"decals_2\":0,\"glasses\":0,\"hair_1\":2,\"torso_1\":73,\"shoes\":1,\"hair_color_2\":0,\"glasses_1\":19,\"skin\":13,\"face\":6,\"pants_2\":5,\"tshirt_1\":75,\"pants_1\":37,\"helmet_1\":57,\"torso_2\":0,\"arms\":14,\"sex\":1,\"glasses_2\":0,\"decals_1\":0,\"hair_2\":0,\"helmet_2\":0,\"hair_color_1\":0}'), - ('ambulance',1,'doctor','Doctor',40,'{\"tshirt_2\":0,\"hair_color_1\":5,\"glasses_2\":3,\"shoes\":9,\"torso_2\":3,\"hair_color_2\":0,\"pants_1\":24,\"glasses_1\":4,\"hair_1\":2,\"sex\":0,\"decals_2\":0,\"tshirt_1\":15,\"helmet_1\":8,\"helmet_2\":0,\"arms\":92,\"face\":19,\"decals_1\":60,\"torso_1\":13,\"hair_2\":0,\"skin\":34,\"pants_2\":5}','{\"tshirt_2\":3,\"decals_2\":0,\"glasses\":0,\"hair_1\":2,\"torso_1\":73,\"shoes\":1,\"hair_color_2\":0,\"glasses_1\":19,\"skin\":13,\"face\":6,\"pants_2\":5,\"tshirt_1\":75,\"pants_1\":37,\"helmet_1\":57,\"torso_2\":0,\"arms\":14,\"sex\":1,\"glasses_2\":0,\"decals_1\":0,\"hair_2\":0,\"helmet_2\":0,\"hair_color_1\":0}'), - ('ambulance',2,'chief_doctor','Chief doctor',60,'{\"tshirt_2\":0,\"hair_color_1\":5,\"glasses_2\":3,\"shoes\":9,\"torso_2\":3,\"hair_color_2\":0,\"pants_1\":24,\"glasses_1\":4,\"hair_1\":2,\"sex\":0,\"decals_2\":0,\"tshirt_1\":15,\"helmet_1\":8,\"helmet_2\":0,\"arms\":92,\"face\":19,\"decals_1\":60,\"torso_1\":13,\"hair_2\":0,\"skin\":34,\"pants_2\":5}','{\"tshirt_2\":3,\"decals_2\":0,\"glasses\":0,\"hair_1\":2,\"torso_1\":73,\"shoes\":1,\"hair_color_2\":0,\"glasses_1\":19,\"skin\":13,\"face\":6,\"pants_2\":5,\"tshirt_1\":75,\"pants_1\":37,\"helmet_1\":57,\"torso_2\":0,\"arms\":14,\"sex\":1,\"glasses_2\":0,\"decals_1\":0,\"hair_2\":0,\"helmet_2\":0,\"hair_color_1\":0}'), - ('ambulance',3,'boss','Surgeon',80,'{\"tshirt_2\":0,\"hair_color_1\":5,\"glasses_2\":3,\"shoes\":9,\"torso_2\":3,\"hair_color_2\":0,\"pants_1\":24,\"glasses_1\":4,\"hair_1\":2,\"sex\":0,\"decals_2\":0,\"tshirt_1\":15,\"helmet_1\":8,\"helmet_2\":0,\"arms\":92,\"face\":19,\"decals_1\":60,\"torso_1\":13,\"hair_2\":0,\"skin\":34,\"pants_2\":5}','{\"tshirt_2\":3,\"decals_2\":0,\"glasses\":0,\"hair_1\":2,\"torso_1\":73,\"shoes\":1,\"hair_color_2\":0,\"glasses_1\":19,\"skin\":13,\"face\":6,\"pants_2\":5,\"tshirt_1\":75,\"pants_1\":37,\"helmet_1\":57,\"torso_2\":0,\"arms\":14,\"sex\":1,\"glasses_2\":0,\"decals_1\":0,\"hair_2\":0,\"helmet_2\":0,\"hair_color_1\":0}') + ('ambulance',0,'ambulance','Jr. EMT',20,'{\"tshirt_2\":0,\"hair_color_1\":5,\"glasses_2\":3,\"shoes\":9,\"torso_2\":3,\"hair_color_2\":0,\"pants_1\":24,\"glasses_1\":4,\"hair_1\":2,\"sex\":0,\"decals_2\":0,\"tshirt_1\":15,\"helmet_1\":8,\"helmet_2\":0,\"arms\":92,\"face\":19,\"decals_1\":60,\"torso_1\":13,\"hair_2\":0,\"skin\":34,\"pants_2\":5}','{\"tshirt_2\":3,\"decals_2\":0,\"glasses\":0,\"hair_1\":2,\"torso_1\":73,\"shoes\":1,\"hair_color_2\":0,\"glasses_1\":19,\"skin\":13,\"face\":6,\"pants_2\":5,\"tshirt_1\":75,\"pants_1\":37,\"helmet_1\":57,\"torso_2\":0,\"arms\":14,\"sex\":1,\"glasses_2\":0,\"decals_1\":0,\"hair_2\":0,\"helmet_2\":0,\"hair_color_1\":0}'), + ('ambulance',1,'doctor','EMT',40,'{\"tshirt_2\":0,\"hair_color_1\":5,\"glasses_2\":3,\"shoes\":9,\"torso_2\":3,\"hair_color_2\":0,\"pants_1\":24,\"glasses_1\":4,\"hair_1\":2,\"sex\":0,\"decals_2\":0,\"tshirt_1\":15,\"helmet_1\":8,\"helmet_2\":0,\"arms\":92,\"face\":19,\"decals_1\":60,\"torso_1\":13,\"hair_2\":0,\"skin\":34,\"pants_2\":5}','{\"tshirt_2\":3,\"decals_2\":0,\"glasses\":0,\"hair_1\":2,\"torso_1\":73,\"shoes\":1,\"hair_color_2\":0,\"glasses_1\":19,\"skin\":13,\"face\":6,\"pants_2\":5,\"tshirt_1\":75,\"pants_1\":37,\"helmet_1\":57,\"torso_2\":0,\"arms\":14,\"sex\":1,\"glasses_2\":0,\"decals_1\":0,\"hair_2\":0,\"helmet_2\":0,\"hair_color_1\":0}'), + ('ambulance',2,'chief_doctor','Sr. EMT',60,'{\"tshirt_2\":0,\"hair_color_1\":5,\"glasses_2\":3,\"shoes\":9,\"torso_2\":3,\"hair_color_2\":0,\"pants_1\":24,\"glasses_1\":4,\"hair_1\":2,\"sex\":0,\"decals_2\":0,\"tshirt_1\":15,\"helmet_1\":8,\"helmet_2\":0,\"arms\":92,\"face\":19,\"decals_1\":60,\"torso_1\":13,\"hair_2\":0,\"skin\":34,\"pants_2\":5}','{\"tshirt_2\":3,\"decals_2\":0,\"glasses\":0,\"hair_1\":2,\"torso_1\":73,\"shoes\":1,\"hair_color_2\":0,\"glasses_1\":19,\"skin\":13,\"face\":6,\"pants_2\":5,\"tshirt_1\":75,\"pants_1\":37,\"helmet_1\":57,\"torso_2\":0,\"arms\":14,\"sex\":1,\"glasses_2\":0,\"decals_1\":0,\"hair_2\":0,\"helmet_2\":0,\"hair_color_1\":0}'), + ('ambulance',3,'boss','EMT Supervisor',80,'{\"tshirt_2\":0,\"hair_color_1\":5,\"glasses_2\":3,\"shoes\":9,\"torso_2\":3,\"hair_color_2\":0,\"pants_1\":24,\"glasses_1\":4,\"hair_1\":2,\"sex\":0,\"decals_2\":0,\"tshirt_1\":15,\"helmet_1\":8,\"helmet_2\":0,\"arms\":92,\"face\":19,\"decals_1\":60,\"torso_1\":13,\"hair_2\":0,\"skin\":34,\"pants_2\":5}','{\"tshirt_2\":3,\"decals_2\":0,\"glasses\":0,\"hair_1\":2,\"torso_1\":73,\"shoes\":1,\"hair_color_2\":0,\"glasses_1\":19,\"skin\":13,\"face\":6,\"pants_2\":5,\"tshirt_1\":75,\"pants_1\":37,\"helmet_1\":57,\"torso_2\":0,\"arms\":14,\"sex\":1,\"glasses_2\":0,\"decals_1\":0,\"hair_2\":0,\"helmet_2\":0,\"hair_color_1\":0}') ; INSERT INTO `jobs` (name, label) VALUES - ('ambulance','Ambulance') + ('ambulance','EMS') ; INSERT INTO `items` (name, label, `limit`) VALUES diff --git a/server/main.lua b/server/main.lua index 4f72535e..5a2f52f2 100644 --- a/server/main.lua +++ b/server/main.lua @@ -6,14 +6,14 @@ RegisterServerEvent('esx_ambulancejob:revive') AddEventHandler('esx_ambulancejob:revive', function(target) local _source = source local xPlayer = ESX.GetPlayerFromId(_source) - + xPlayer.addMoney(Config.ReviveReward) TriggerClientEvent('esx_ambulancejob:revive', target) end) RegisterServerEvent('esx_ambulancejob:heal') AddEventHandler('esx_ambulancejob:heal', function(target, type) - TriggerClientEvent('esx_ambulancejob:heal', target, type) + TriggerClientEvent('esx_ambulancejob:heal', target, type) end) TriggerEvent('esx_phone:registerNumber', 'ambulance', _U('alert_ambulance'), true, true) @@ -62,47 +62,66 @@ ESX.RegisterServerCallback('esx_ambulancejob:removeItemsAfterRPDeath', function( end) end - if Config.RespawnFine then - TriggerClientEvent('esx:showNotification', xPlayer.source, _U('respawn_fine', Config.RespawnFineAmount)) - xPlayer.removeAccountMoney('bank', Config.RespawnFineAmount) - end - cb() end) +if Config.EarlyRespawn and Config.EarlyRespawnFine then + ESX.RegisterServerCallback('esx_ambulancejob:checkBalance', function(source, cb) + + local xPlayer = ESX.GetPlayerFromId(source) + local bankBalance = xPlayer.getAccount('bank').money + local finePayable = false + + if bankBalance >= Config.EarlyRespawnFineAmount then + finePayable = true + else + finePayable = false + end + + cb(finePayable) + end) + + ESX.RegisterServerCallback('esx_ambulancejob:payFine', function(source, cb) + local xPlayer = ESX.GetPlayerFromId(source) + TriggerClientEvent('esx:showNotification', xPlayer.source, _U('respawn_fine', Config.EarlyRespawnFineAmount)) + xPlayer.removeAccountMoney('bank', Config.EarlyRespawnFineAmount) + cb() + end) +end + ESX.RegisterServerCallback('esx_ambulancejob:getItemAmount', function(source, cb, item) - local xPlayer = ESX.GetPlayerFromId(source) - local qtty = xPlayer.getInventoryItem(item).count - cb(qtty) + local xPlayer = ESX.GetPlayerFromId(source) + local qtty = xPlayer.getInventoryItem(item).count + cb(qtty) end) RegisterServerEvent('esx_ambulancejob:removeItem') AddEventHandler('esx_ambulancejob:removeItem', function(item) - local _source = source - local xPlayer = ESX.GetPlayerFromId(_source) - xPlayer.removeInventoryItem(item, 1) - if item == 'bandage' then - TriggerClientEvent('esx:showNotification', _source, _U('used_bandage')) - elseif item == 'medikit' then - TriggerClientEvent('esx:showNotification', _source, _U('used_medikit')) - end + local _source = source + local xPlayer = ESX.GetPlayerFromId(_source) + xPlayer.removeInventoryItem(item, 1) + if item == 'bandage' then + TriggerClientEvent('esx:showNotification', _source, _U('used_bandage')) + elseif item == 'medikit' then + TriggerClientEvent('esx:showNotification', _source, _U('used_medikit')) + end end) RegisterServerEvent('esx_ambulancejob:giveItem') AddEventHandler('esx_ambulancejob:giveItem', function(item) - local _source = source - local xPlayer = ESX.GetPlayerFromId(_source) - local limit = xPlayer.getInventoryItem(item).limit - local delta = 1 - local qtty = xPlayer.getInventoryItem(item).count - if limit ~= -1 then - delta = limit - qtty - end - if qtty < limit then - xPlayer.addInventoryItem(item, delta) - else - TriggerClientEvent('esx:showNotification', _source, _U('max_item')) - end + local _source = source + local xPlayer = ESX.GetPlayerFromId(_source) + local limit = xPlayer.getInventoryItem(item).limit + local delta = 1 + local qtty = xPlayer.getInventoryItem(item).count + if limit ~= -1 then + delta = limit - qtty + end + if qtty < limit then + xPlayer.addInventoryItem(item, delta) + else + TriggerClientEvent('esx:showNotification', _source, _U('max_item')) + end end) TriggerEvent('es:addGroupCommand', 'revive', 'admin', function(source, args, user) @@ -115,23 +134,23 @@ TriggerEvent('es:addGroupCommand', 'revive', 'admin', function(source, args, use TriggerClientEvent('esx_ambulancejob:revive', source) end end, function(source, args, user) - TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient Permissions.") -end, {help = _U('revive_help'), params = {{name = 'id'}}}) + TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) +end, { help = _U('revive_help'), params = { { name = 'id' } } }) ESX.RegisterUsableItem('medikit', function(source) - local _source = source - local xPlayer = ESX.GetPlayerFromId(_source) - xPlayer.removeInventoryItem('medikit', 1) - TriggerClientEvent('esx_ambulancejob:heal', _source, 'big') - TriggerClientEvent('esx:showNotification', _source, _U('used_medikit')) + local _source = source + local xPlayer = ESX.GetPlayerFromId(_source) + xPlayer.removeInventoryItem('medikit', 1) + TriggerClientEvent('esx_ambulancejob:heal', _source, 'big') + TriggerClientEvent('esx:showNotification', _source, _U('used_medikit')) end) ESX.RegisterUsableItem('bandage', function(source) - local _source = source - local xPlayer = ESX.GetPlayerFromId(_source) - xPlayer.removeInventoryItem('bandage', 1) - TriggerClientEvent('esx_ambulancejob:heal', _source, 'small') - TriggerClientEvent('esx:showNotification', _source, _U('used_bandage')) + local _source = source + local xPlayer = ESX.GetPlayerFromId(_source) + xPlayer.removeInventoryItem('bandage', 1) + TriggerClientEvent('esx_ambulancejob:heal', _source, 'small') + TriggerClientEvent('esx:showNotification', _source, _U('used_bandage')) end) RegisterServerEvent('esx_ambulancejob:firstSpawn') @@ -157,4 +176,4 @@ AddEventHandler('esx_ambulancejob:setDeathStatus', function(isDead) ['@identifier'] = GetPlayerIdentifiers(_source)[1], ['@isDead'] = isDead }) -end) \ No newline at end of file +end)