diff --git a/__resource.lua b/__resource.lua index fb66dda0..8014bec8 100644 --- a/__resource.lua +++ b/__resource.lua @@ -33,4 +33,4 @@ client_scripts { 'client/main.lua' } -dependency 'es_extended' \ No newline at end of file +dependency 'es_extended' diff --git a/client/main.lua b/client/main.lua index 08291653..b8f3b0cb 100644 --- a/client/main.lua +++ b/client/main.lua @@ -10,21 +10,22 @@ local Keys = { ["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 HasAlreadyEnteredMarker = false -local LastZone = nil -local CurrentAction = nil -local CurrentActionMsg = '' -local CurrentActionData = {} -local IsBusy = false -ESX = nil +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 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) @@ -46,60 +47,61 @@ 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 StartRespawnTimer() Citizen.SetTimeout(Config.RespawnDelayAfterRPDeath, function() - if IsDead then - RemoveItemsAfterRPDeath() - end + if IsDead then + RemoveItemsAfterRPDeath() + end end) end function StartDistressSignal() Citizen.CreateThread(function() - local respawnTimer = Config.RespawnDelayAfterRPDeath + local timer = Config.RespawnDelayAfterRPDeath - while respawnTimer > 0 and IsDead do - Citizen.Wait(2) - respawnTimer = respawnTimer - 30 + while timer > 0 and IsDead do + Citizen.Wait(2) + timer = timer - 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 + if IsControlPressed(0, Keys['G']) then + SendDistressSignal() + break + end 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 @@ -110,67 +112,67 @@ function ShowDeathTimer() local payFine = false if Config.EarlyRespawn and Config.EarlyRespawnFine then - ESX.TriggerServerCallback('esx_ambulancejob:checkBalance', function(finePayable) - if finePayable then - payFine = true - else - payFine = false - end - end) + 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) + 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] + 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() + 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) + local text = _U('please_wait', minutes, seconds) - if Config.EarlyRespawn then - 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 - - SetTextCentre(true) - SetTextEntry("STRING") - AddTextComponentString(text) - DrawText(0.5, 0.8) - - 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 + if Config.EarlyRespawn then + 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 + + SetTextCentre(true) + SetTextEntry("STRING") + AddTextComponentString(text) + DrawText(0.5, 0.8) + + 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 - respawnTimer = respawnTimer - 15 - end end) end @@ -178,21 +180,21 @@ 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 @@ -206,8 +208,8 @@ function OnPlayerDeath() IsDead = true TriggerServerEvent('esx_ambulancejob:setDeathStatus', 1) - if Config.ShowDeathTimer then - ShowDeathTimer() + if Config.ShowDeathTimer == true then + ShowDeathTimer() end StartRespawnTimer() @@ -221,15 +223,15 @@ function TeleportFadeEffect(entity, coords) 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) @@ -240,29 +242,29 @@ function WarpPedInClosestVehicle(ped) local coords = GetEntityCoords(ped) local vehicle, distance = ESX.Game.GetClosestVehicle({ - x = coords.x, - y = coords.y, - z = coords.z + x = coords.x, + y = coords.y, + z = coords.z }) 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 + for i=maxSeats - 1, 0, -1 do + if IsVehicleSeatFree(vehicle, i) then + freeSeat = i + break + end 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')) + ESX.ShowNotification(_U('no_vehicles')) end end @@ -270,44 +272,44 @@ end function OpenAmbulanceActionsMenu() local elements = { - {label = _U('cloakroom'), value = 'cloakroom'} + {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'}) + table.insert(elements, {label = _U('boss_actions'), value = 'boss_actions'}) end ESX.UI.Menu.CloseAll() ESX.UI.Menu.Open( - 'default', GetCurrentResourceName(), 'ambulance_actions', - { - title = _U('ambulance'), - align = 'top-left', - elements = elements - }, - function(data, menu) + '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 + + end, + function(data, menu) - if data.current.value == 'boss_actions' then - TriggerEvent('esx_society:openBossMenu', 'ambulance', function(data, menu) menu.close() - end, {wash = false}) + + CurrentAction = 'ambulance_actions_menu' + CurrentActionMsg = _U('open_menu') + CurrentActionData = {} + end - - end, - function(data, menu) - - menu.close() - - CurrentAction = 'ambulance_actions_menu' - CurrentActionMsg = _U('open_menu') - CurrentActionData = {} - - end ) end @@ -319,195 +321,195 @@ 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'}, - } - }, 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'}, + title = _U('ambulance'), + align = 'top-left', + elements = { + {label = _U('ems_menu'), value = 'citizen_interaction'}, } - }, function(data, menu) - if IsBusy then return end - if data.current.value == 'revive' then -- revive + }, 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() + 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('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)) + if closestPlayer == -1 or closestDistance > 3.0 then + ESX.ShowNotification(_U('no_players')) else - ESX.ShowNotification(_U('revive_complete', GetPlayerName(closestPlayer))) + 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('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 + 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) + + 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 - 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) - - 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, function(data, menu) + menu.close() + 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'}, + '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) + 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 - - if data.current.value == 'ambulance_wear' then - - 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 - end) + if data.current.value == 'ambulance_wear' then + 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 + + end) + + end + + CurrentAction = 'ambulance_actions_menu' + CurrentActionMsg = _U('open_menu') + CurrentActionData = {} + + end, + function(data, menu) + menu.close() end - - CurrentAction = 'ambulance_actions_menu' - CurrentActionMsg = _U('open_menu') - CurrentActionData = {} - - end, - function(data, menu) - menu.close() - end ) end @@ -518,61 +520,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 + 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 ESX.UI.Menu.Open( 'default', GetCurrentResourceName(), 'vehicle_spawner', { - title = _U('veh_menu'), - align = 'top-left', - elements = elements, + title = _U('veh_menu'), + align = 'top-left', + elements = Config.AuthorizedVehicles }, 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) - + 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 = {} + 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 @@ -582,20 +584,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 @@ -604,9 +606,9 @@ 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) @@ -624,9 +626,9 @@ RegisterNetEvent('esx_phone:loaded') AddEventHandler('esx_phone:loaded', function(phoneNumber, contacts) local specialContact = { - name = 'Ambulance', - number = 'ambulance', - base64Icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEwAACxMBAJqcGAAABp5JREFUWIW1l21sFNcVhp/58npn195de23Ha4Mh2EASSvk0CPVHmmCEI0RCTQMBKVVooxYoalBVCVokICWFVFVEFeKoUdNECkZQIlAoFGMhIkrBQGxHwhAcChjbeLcsYHvNfsx+zNz+MBDWNrYhzSvdP+e+c973XM2cc0dihFi9Yo6vSzN/63dqcwPZcnEwS9PDmYoE4IxZIj+ciBb2m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Hn1CloXm9aLBEIEDl/IS2W6rg+qIFEYR7+OJTesqJqYa95/VKBNOHLjDBZ8sDS2998a0Bs/F//gvu5Z9NivadOc/U3676pEsizBIN1jCYlhClL+ELJDrkobNUBfBZqQfMN305HAgnIeYi4OnYMh7q/AsAXSdXK+eH41sykxd+TV/AsXvR/MeARAttD9pSqF9nDNfSEoDQsb5O31zQFprcaV244JPY7bqG6Xd9K3C3ALgbfk3NzqNE6CdplZrVFL27eWR+UASb6479ULfhD5AzOlSuGFTE6OohebElbcb8fhxA4xEPUgdTK19hiNKCZgknB+Ep44E44d82cxqPPOKctCGXzTmsBXbV1j1S5XQhyHq6NvnABPylu46A7QmVLpP7w9pNz4IEb0YyOrnmjb8bjB129fDBRkDVj2ojFbYBnCHHb7HL+OC7KQXeEsmAiNrnTqLy3d3+s/bvlVmxpgffM1fyM5cfsPZLuK+YHnvHELl8eUlwV4BXim0r6QV+4gD9Nlnjbfg1vJGktbI5UbN/TcGmAAYDG84Gry/MLLl/zKouO2Xukq/YkCyuWYV5owTIGjhVFCPL6J7kLOTcH89ereF1r4qOsm3gjSevl85El1Z98cfhB3qBN9+dLp1fUTco+0OrVMnNjFuv0chYbBYT2HcBoa+8TALyWQOt/ImPHoFS9SI3WyRajgdt2mbJgIlbREplfveuLf/XXemjXX7v46ZxzPlfd8YlZ01My5MUEVdIY5rueYopw4fQHkbv7/rZkTw6JwjyalBCHur9iD9cI2mU0UzD3P9H6yZ1G5dt7Gwe96w07dl5fXj7vYqH2XsNovdTI6KMrlsAXhRyz7/C7FBO/DubdVq4nBLPaohcnBeMr3/2k4fhQ+Uc8995YPq2wMzNjww2X+vwNt1p00ynrd2yKDJAVN628sBX1hZIdxXdStU9G5W2bd9YHR5L3f/CNmJeY9G8WAAAAAElFTkSuQmCC' + name = 'Ambulance', + number = 'ambulance', + base64Icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAAlwSFl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nBeMr3/2k4fhQ+Uc8995YPq2wMzNjww2X+vwNt1p00ynrd2yKDJAVN628sBX1hZIdxXdStU9G5W2bd9YHR5L3f/CNmJeY9G8WAAAAAElFTkSuQmCC' } TriggerEvent('esx_phone:addSpecialContact', specialContact.name, specialContact.number, specialContact.base64Icon) @@ -641,7 +643,7 @@ RegisterNetEvent('esx_ambulancejob:revive') AddEventHandler('esx_ambulancejob:revive', function() local playerPed = GetPlayerPed(-1) - local coords = GetEntityCoords(playerPed) + local coords = GetEntityCoords(playerPed) TriggerServerEvent('esx_ambulancejob:setDeathStatus', 0) Citizen.CreateThread(function() @@ -681,18 +683,17 @@ end) AddEventHandler('esx_ambulancejob:hasEnteredMarker', function(zone) if zone == 'HospitalInteriorEntering1' then - TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.HospitalInteriorInside1.Pos) + TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.HospitalInteriorInside1.Pos) end if zone == 'HospitalInteriorExit1' then - TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.HospitalInteriorOutside1.Pos) + TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.HospitalInteriorOutside1.Pos) end 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 + 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, @@ -703,80 +704,80 @@ AddEventHandler('esx_ambulancejob:hasEnteredMarker', function(zone) end) end - TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.HospitalInteriorInside2.Pos) + TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.HospitalInteriorInside2.Pos) end if zone == 'HospitalInteriorExit2' then - TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.HospitalInteriorOutside2.Pos) + TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.HospitalInteriorOutside2.Pos) end if zone == 'ParkingDoorGoOutInside' then - TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.ParkingDoorGoOutOutside.Pos) + TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.ParkingDoorGoOutOutside.Pos) end if zone == 'ParkingDoorGoInOutside' then - TeleportFadeEffect(GetPlayerPed(-1), Config.Zones.ParkingDoorGoInInside.Pos) + 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} + 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} + 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 = {} + CurrentAction = 'ambulance_actions_menu' + CurrentActionMsg = _U('open_menu') + CurrentActionData = {} end if zone == 'VehicleSpawner' then - CurrentAction = 'vehicle_spawner_menu' - CurrentActionMsg = _U('veh_spawn') - CurrentActionData = {} + CurrentAction = 'vehicle_spawner_menu' + CurrentActionMsg = _U('veh_spawn') + CurrentActionData = {} end if zone == 'Pharmacy' then - CurrentAction = 'pharmacy' - CurrentActionMsg = _U('open_pharmacy') - CurrentActionData = {} + CurrentAction = 'pharmacy' + CurrentActionMsg = _U('open_pharmacy') + CurrentActionData = {} end 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) function FastTravel(pos) - TeleportFadeEffect(GetPlayerPed(-1), pos) + TeleportFadeEffect(GetPlayerPed(-1), pos) end AddEventHandler('esx_ambulancejob:hasExitedMarker', function(zone) @@ -789,10 +790,10 @@ Citizen.CreateThread(function() local blip = AddBlipForCoord(Config.Blip.Pos.x, Config.Blip.Pos.y, Config.Blip.Pos.z) - SetBlipSprite (blip, Config.Blip.Sprite) + SetBlipSprite(blip, Config.Blip.Sprite) SetBlipDisplay(blip, Config.Blip.Display) - SetBlipScale (blip, Config.Blip.Scale) - SetBlipColour (blip, Config.Blip.Colour) + SetBlipScale(blip, Config.Blip.Scale) + SetBlipColour(blip, Config.Blip.Colour) SetBlipAsShortRange(blip, true) BeginTextCommandSetBlipName("STRING") @@ -804,53 +805,52 @@ end) -- Display markers Citizen.CreateThread(function() while true do - Citizen.Wait(0) + 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 + 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 + 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 end) -- Activate menu when player is inside marker Citizen.CreateThread(function() while true do - Citizen.Wait(10) + 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 + 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 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 + if isInMarker and not hasAlreadyEnteredMarker then + hasAlreadyEnteredMarker = true + lastZone = currentZone + TriggerEvent('esx_ambulancejob:hasEnteredMarker', currentZone) end - 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 + if not isInMarker and hasAlreadyEnteredMarker then + hasAlreadyEnteredMarker = false + TriggerEvent('esx_ambulancejob:hasExitedMarker', lastZone) + end end end) @@ -858,49 +858,49 @@ end) Citizen.CreateThread(function() 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 + + CurrentAction = nil - 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 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) @@ -919,7 +919,7 @@ if Config.LoadIpl then LoadMpDlcMaps() EnableMpDlcMaps(true) RequestIpl('Coroner_Int_on') -- Morgue - end) + end) end -- String string