diff --git a/server-data/resources/[bpt_addons]/bpt_addonaccount/fxmanifest.lua b/server-data/resources/[bpt_addons]/bpt_addonaccount/fxmanifest.lua index 5a7c19517..ea4ca5027 100644 --- a/server-data/resources/[bpt_addons]/bpt_addonaccount/fxmanifest.lua +++ b/server-data/resources/[bpt_addons]/bpt_addonaccount/fxmanifest.lua @@ -1,21 +1,21 @@ -fx_version 'adamant' -game 'gta5' +fx_version("adamant") +game("gta5") -author 'bitpredator' -description 'Allows resources to store account data, such as society funds' -lua54 'yes' -version '1.0.1' +author("bitpredator") +description("Allows resources to store account data, such as society funds") +lua54("yes") +version("1.0.1") -server_scripts { - '@es_extended/imports.lua', - '@oxmysql/lib/MySQL.lua', - 'server/classes/addonaccount.lua', - 'server/main.lua' -} +server_scripts({ + "@es_extended/imports.lua", + "@oxmysql/lib/MySQL.lua", + "server/classes/addonaccount.lua", + "server/main.lua", +}) -server_exports { - 'GetSharedAccount', - 'AddSharedAccount' -} +server_exports({ + "GetSharedAccount", + "AddSharedAccount", +}) -dependency 'es_extended' +dependency("es_extended") diff --git a/server-data/resources/[bpt_addons]/bpt_addonaccount/server/classes/addonaccount.lua b/server-data/resources/[bpt_addons]/bpt_addonaccount/server/classes/addonaccount.lua index d71d71b61..2af5eea1c 100644 --- a/server-data/resources/[bpt_addons]/bpt_addonaccount/server/classes/addonaccount.lua +++ b/server-data/resources/[bpt_addons]/bpt_addonaccount/server/classes/addonaccount.lua @@ -1,36 +1,35 @@ function CreateAddonAccount(name, owner, money) local self = {} - self.name = name + self.name = name self.owner = owner self.money = money function self.addMoney(m) self.money = self.money + m self.save() - TriggerEvent('bpt_addonaccount:addMoney', self.name, m) + TriggerEvent("bpt_addonaccount:addMoney", self.name, m) end function self.removeMoney(m) self.money = self.money - m self.save() - TriggerEvent('bpt_addonaccount:removeMoney', self.name, m) + TriggerEvent("bpt_addonaccount:removeMoney", self.name, m) end function self.setMoney(m) self.money = m self.save() - TriggerEvent('bpt_addonaccount:setMoney', self.name, m) + TriggerEvent("bpt_addonaccount:setMoney", self.name, m) end function self.save() if self.owner == nil then - MySQL.update('UPDATE addon_account_data SET money = ? WHERE account_name = ?', { self.money, self.name }) + MySQL.update("UPDATE addon_account_data SET money = ? WHERE account_name = ?", { self.money, self.name }) else - MySQL.update('UPDATE addon_account_data SET money = ? WHERE account_name = ? AND owner = ?', - { self.money, self.name, self.owner }) + MySQL.update("UPDATE addon_account_data SET money = ? WHERE account_name = ? AND owner = ?", { self.money, self.name, self.owner }) end - TriggerClientEvent('bpt_addonaccount:setMoney', -1, self.name, self.money) + TriggerClientEvent("bpt_addonaccount:setMoney", -1, self.name, self.money) end return self diff --git a/server-data/resources/[bpt_addons]/bpt_addoninventory/fxmanifest.lua b/server-data/resources/[bpt_addons]/bpt_addoninventory/fxmanifest.lua index 105e4b672..70efb6864 100644 --- a/server-data/resources/[bpt_addons]/bpt_addoninventory/fxmanifest.lua +++ b/server-data/resources/[bpt_addons]/bpt_addoninventory/fxmanifest.lua @@ -1,22 +1,22 @@ -fx_version 'adamant' +fx_version("adamant") -game 'gta5' +game("gta5") -description 'Adds a way for resources to store items for players' -lua54 'yes' +description("Adds a way for resources to store items for players") +lua54("yes") -version '1.0.1' +version("1.0.1") -server_scripts { - '@es_extended/imports.lua', - '@oxmysql/lib/MySQL.lua', - 'server/classes/addoninventory.lua', - 'server/main.lua' -} +server_scripts({ + "@es_extended/imports.lua", + "@oxmysql/lib/MySQL.lua", + "server/classes/addoninventory.lua", + "server/main.lua", +}) -server_exports { - 'GetSharedInventory', - 'AddSharedInventory' -} +server_exports({ + "GetSharedInventory", + "AddSharedInventory", +}) -dependency 'es_extended' +dependency("es_extended") diff --git a/server-data/resources/[bpt_addons]/bpt_addoninventory/server/classes/addoninventory.lua b/server-data/resources/[bpt_addons]/bpt_addoninventory/server/classes/addoninventory.lua index 09fb2ebe8..dd4e79a04 100644 --- a/server-data/resources/[bpt_addons]/bpt_addoninventory/server/classes/addoninventory.lua +++ b/server-data/resources/[bpt_addons]/bpt_addoninventory/server/classes/addoninventory.lua @@ -1,7 +1,7 @@ local self, name, owner, items = {}, {}, {}, {} -self.name = name -self.owner = owner -self.items = items +self.name = name +self.owner = owner +self.items = items function CreateAddonInventory() function self.addItem(name, count) @@ -35,30 +35,26 @@ function CreateAddonInventory() end item = { - name = name, + name = name, count = 0, - label = Items[name] + label = Items[name], } table.insert(self.items, item) if self.owner == nil then - MySQL.update( - 'INSERT INTO addon_inventory_items (inventory_name, name, count) VALUES (@inventory_name, @item_name, @count)', - { - ['@inventory_name'] = self.name, - ['@item_name'] = name, - ['@count'] = 0 - }) + MySQL.update("INSERT INTO addon_inventory_items (inventory_name, name, count) VALUES (@inventory_name, @item_name, @count)", { + ["@inventory_name"] = self.name, + ["@item_name"] = name, + ["@count"] = 0, + }) else - MySQL.update( - 'INSERT INTO addon_inventory_items (inventory_name, name, count, owner) VALUES (@inventory_name, @item_name, @count, @owner)', - { - ['@inventory_name'] = self.name, - ['@item_name'] = name, - ['@count'] = 0, - ['@owner'] = self.owner - }) + MySQL.update("INSERT INTO addon_inventory_items (inventory_name, name, count, owner) VALUES (@inventory_name, @item_name, @count, @owner)", { + ["@inventory_name"] = self.name, + ["@item_name"] = name, + ["@count"] = 0, + ["@owner"] = self.owner, + }) end return item @@ -66,22 +62,18 @@ function CreateAddonInventory() function self.saveItem(name, count) if self.owner == nil then - MySQL.update( - 'UPDATE addon_inventory_items SET count = @count WHERE inventory_name = @inventory_name AND name = @item_name', - { - ['@inventory_name'] = self.name, - ['@item_name'] = name, - ['@count'] = count - }) + MySQL.update("UPDATE addon_inventory_items SET count = @count WHERE inventory_name = @inventory_name AND name = @item_name", { + ["@inventory_name"] = self.name, + ["@item_name"] = name, + ["@count"] = count, + }) else - MySQL.update( - 'UPDATE addon_inventory_items SET count = @count WHERE inventory_name = @inventory_name AND name = @item_name AND owner = @owner', - { - ['@inventory_name'] = self.name, - ['@item_name'] = name, - ['@count'] = count, - ['@owner'] = self.owner - }) + MySQL.update("UPDATE addon_inventory_items SET count = @count WHERE inventory_name = @inventory_name AND name = @item_name AND owner = @owner", { + ["@inventory_name"] = self.name, + ["@item_name"] = name, + ["@count"] = count, + ["@owner"] = self.owner, + }) end end diff --git a/server-data/resources/[bpt_addons]/bpt_allowlist/config.lua b/server-data/resources/[bpt_addons]/bpt_allowlist/config.lua index c21cc1d9e..05590f5cc 100644 --- a/server-data/resources/[bpt_addons]/bpt_allowlist/config.lua +++ b/server-data/resources/[bpt_addons]/bpt_allowlist/config.lua @@ -1,4 +1,4 @@ Config = {} -Config.Locale = GetConvar('esx:locale', 'en') +Config.Locale = GetConvar("esx:locale", "en") Config.MinPlayer = 10 --Set how many players need to be connect before whitelist start, 0-32 diff --git a/server-data/resources/[bpt_addons]/bpt_allowlist/fxmanifest.lua b/server-data/resources/[bpt_addons]/bpt_allowlist/fxmanifest.lua index 1497a39d6..6793c7eac 100644 --- a/server-data/resources/[bpt_addons]/bpt_allowlist/fxmanifest.lua +++ b/server-data/resources/[bpt_addons]/bpt_allowlist/fxmanifest.lua @@ -1,19 +1,19 @@ -fx_version 'adamant' +fx_version("adamant") -game 'gta5' +game("gta5") -author 'bitpredator' -description 'Allowlist system that allows you to only allow specific people to access your server' +author("bitpredator") +description("Allowlist system that allows you to only allow specific people to access your server") -version '1.0.1' +version("1.0.1") -lua54 'yes' -server_only 'yes' +lua54("yes") +server_only("yes") -server_scripts { - '@es_extended/imports.lua', - '@es_extended/locale.lua', - 'config.lua', - 'locales/*.lua', - 'server/main.lua' -} +server_scripts({ + "@es_extended/imports.lua", + "@es_extended/locale.lua", + "config.lua", + "locales/*.lua", + "server/main.lua", +}) diff --git a/server-data/resources/[bpt_addons]/bpt_allowlist/locales/en.lua b/server-data/resources/[bpt_addons]/bpt_allowlist/locales/en.lua index 656f19341..196773392 100644 --- a/server-data/resources/[bpt_addons]/bpt_allowlist/locales/en.lua +++ b/server-data/resources/[bpt_addons]/bpt_allowlist/locales/en.lua @@ -1,14 +1,14 @@ -Locales['en'] = { - ['allowlist_check'] = 'Checking if you are Allowlisted.', - ['not_allowlisted'] = 'You Must be Allowlisted to join this server!', - ['allowlist_empty'] = 'There Are no allowlists saved for this server.', - ['license_missing'] = 'Error: Your Identifier is missing!', - ['help_allowlist_add'] = 'add someone to the allowlist', - ['help_allowlist_load'] = 'reload the allowlist', - ['help_allowlist_remove'] = 'remove someone from the allowlist', - ['error'] = 'There Was An Error, Please Contact the server owner!', - ['already_allowlisted'] = 'The player is already allowlisted on this server!', - ['license'] = 'license', - ['help_license'] = 'the player license', - ['identifier_not_allowlisted'] = 'Identifier is not Allowlisted on this server!', +Locales["en"] = { + ["allowlist_check"] = "Checking if you are Allowlisted.", + ["not_allowlisted"] = "You Must be Allowlisted to join this server!", + ["allowlist_empty"] = "There Are no allowlists saved for this server.", + ["license_missing"] = "Error: Your Identifier is missing!", + ["help_allowlist_add"] = "add someone to the allowlist", + ["help_allowlist_load"] = "reload the allowlist", + ["help_allowlist_remove"] = "remove someone from the allowlist", + ["error"] = "There Was An Error, Please Contact the server owner!", + ["already_allowlisted"] = "The player is already allowlisted on this server!", + ["license"] = "license", + ["help_license"] = "the player license", + ["identifier_not_allowlisted"] = "Identifier is not Allowlisted on this server!", } diff --git a/server-data/resources/[bpt_addons]/bpt_allowlist/locales/it.lua b/server-data/resources/[bpt_addons]/bpt_allowlist/locales/it.lua index a03995c33..84a37bd09 100644 --- a/server-data/resources/[bpt_addons]/bpt_allowlist/locales/it.lua +++ b/server-data/resources/[bpt_addons]/bpt_allowlist/locales/it.lua @@ -1,14 +1,14 @@ -Locales['it'] = { - ['allowlist_check'] = 'verifica Allowlist.', - ['not_allowlisted'] = 'devi essere nella Allowlist per unirti a questo server!', - ['allowlist_empty'] = 'non ci sono allowlist salvate per questo server.', - ['license_missing'] = 'Errore: il tuo identificatore è mancante!', - ['help_allowlist_add'] = 'aggiungi qualcuno alla allowlist', - ['help_allowlist_load'] = 'ricarica la allowlist', - ['help_allowlist_remove'] = 'rimuovi un utente dalla allowlist', - ['error'] = 'É stato riscontrato un errore, contatta il proprietario del server!', - ['already_allowlisted'] = 'Il giocatore è già allowlistato nel server', - ['license'] = 'licenza', - ['help_license'] = 'la licenza del giocatore', - ['identifier_not_allowlisted'] = 'L\' identificativo non è allowlistato nel server', +Locales["it"] = { + ["allowlist_check"] = "verifica Allowlist.", + ["not_allowlisted"] = "devi essere nella Allowlist per unirti a questo server!", + ["allowlist_empty"] = "non ci sono allowlist salvate per questo server.", + ["license_missing"] = "Errore: il tuo identificatore è mancante!", + ["help_allowlist_add"] = "aggiungi qualcuno alla allowlist", + ["help_allowlist_load"] = "ricarica la allowlist", + ["help_allowlist_remove"] = "rimuovi un utente dalla allowlist", + ["error"] = "É stato riscontrato un errore, contatta il proprietario del server!", + ["already_allowlisted"] = "Il giocatore è già allowlistato nel server", + ["license"] = "licenza", + ["help_license"] = "la licenza del giocatore", + ["identifier_not_allowlisted"] = "L' identificativo non è allowlistato nel server", } diff --git a/server-data/resources/[bpt_addons]/bpt_allowlist/server/main.lua b/server-data/resources/[bpt_addons]/bpt_allowlist/server/main.lua index 780aa4aca..adf1ec427 100644 --- a/server-data/resources/[bpt_addons]/bpt_allowlist/server/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_allowlist/server/main.lua @@ -3,7 +3,7 @@ local allowList = {} local function loadAllowList() allowList = {} - local list = LoadResourceFile(GetCurrentResourceName(), 'players.json') + local list = LoadResourceFile(GetCurrentResourceName(), "players.json") if list then allowList = json.decode(list) end @@ -11,15 +11,17 @@ end CreateThread(loadAllowList) -AddEventHandler('playerConnecting', function(name, setCallback, deferrals) +AddEventHandler("playerConnecting", function(name, setCallback, deferrals) local players = GetPlayers() - if #players < Config.MinPlayer then return end + if #players < Config.MinPlayer then + return + end deferrals.defer() - local playerId, kickReason = source, TranslateCap('error') + local playerId, kickReason = source, TranslateCap("error") - deferrals.update(TranslateCap('allowlist_check')) + deferrals.update(TranslateCap("allowlist_check")) --Not for nothing was this 100 but even this is not the best solution. Wait(100) @@ -27,57 +29,71 @@ AddEventHandler('playerConnecting', function(name, setCallback, deferrals) local identifier = ESX.GetIdentifier(playerId) if ESX.Table.SizeOf(allowList) == 0 then - kickReason = "[BPT] " .. TranslateCap('allowlist_empty') + kickReason = "[BPT] " .. TranslateCap("allowlist_empty") elseif not identifier then - kickReason = "[BPT] " .. TranslateCap('license_missing') + kickReason = "[BPT] " .. TranslateCap("license_missing") elseif not allowList[identifier] then - kickReason = "[BPT] " .. TranslateCap('not_allowlist') + kickReason = "[BPT] " .. TranslateCap("not_allowlist") end - if kickReason then return deferrals.done(kickReason) end + if kickReason then + return deferrals.done(kickReason) + end deferrals.done() end) -ESX.RegisterCommand('alrefresh', 'admin', function(xPlayer, args) +ESX.RegisterCommand("alrefresh", "admin", function(xPlayer, args) loadAllowList() - print('[^2INFO^7] Allowlist ^5Refreshed^7!') -end, true, { help = TranslateCap('help_allowlist_load') }) - -ESX.RegisterCommand('aladd', 'admin', function(xPlayer, args, showError) - local playerLicense = args.license:lower() - - if allowList[playerLicense] then - showError('The player is already allowlisted on this server!') - else - allowList[playerLicense] = true - SaveResourceFile(GetCurrentResourceName(), 'players.json', json.encode(allowList)) - loadAllowList() - return - end -end, true, { - help = TranslateCap('help_allowlist_add'), - validate = true, - arguments = { - { name = TranslateCap('license'), help = TranslateCap('help_license'), type = 'string' } + print("[^2INFO^7] Allowlist ^5Refreshed^7!") +end, true, { help = TranslateCap("help_allowlist_load") }) + +ESX.RegisterCommand( + "aladd", + "admin", + function(xPlayer, args, showError) + local playerLicense = args.license:lower() + + if allowList[playerLicense] then + showError("The player is already allowlisted on this server!") + else + allowList[playerLicense] = true + SaveResourceFile(GetCurrentResourceName(), "players.json", json.encode(allowList)) + loadAllowList() + return + end + end, + true, + { + help = TranslateCap("help_allowlist_add"), + validate = true, + arguments = { + { name = TranslateCap("license"), help = TranslateCap("help_license"), type = "string" }, + }, } -}) - -ESX.RegisterCommand('alremove', 'admin', function(xPlayer, args, showError) - local playerLicense = args.license:lower() - - if allowList[playerLicense] then - allowList[playerLicense] = nil - SaveResourceFile(GetCurrentResourceName(), 'players.json', json.encode(allowList)) - loadAllowList() - else - showError(TranslateCap('identifier_not_allowlisted')) - return - end -end, true, { - help = TranslateCap('help_allowlist_remove'), - validate = true, - arguments = { - { name = TranslateCap('license'), help = TranslateCap('help_license'), type = 'string' } +) + +ESX.RegisterCommand( + "alremove", + "admin", + function(xPlayer, args, showError) + local playerLicense = args.license:lower() + + if allowList[playerLicense] then + allowList[playerLicense] = nil + SaveResourceFile(GetCurrentResourceName(), "players.json", json.encode(allowList)) + loadAllowList() + else + showError(TranslateCap("identifier_not_allowlisted")) + return + end + end, + true, + { + help = TranslateCap("help_allowlist_remove"), + validate = true, + arguments = { + { name = TranslateCap("license"), help = TranslateCap("help_license"), type = "string" }, + }, } -}) +) diff --git a/server-data/resources/[bpt_addons]/bpt_ambulancejob/client/main.lua b/server-data/resources/[bpt_addons]/bpt_ambulancejob/client/main.lua index 187857dee..23a52f45b 100644 --- a/server-data/resources/[bpt_addons]/bpt_ambulancejob/client/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_ambulancejob/client/main.lua @@ -3,397 +3,381 @@ local firstSpawn, PlayerLoaded = true, false isDead, isSearched, medic = false, false, 0 AddEventHandler("onClientMapStart", function() - exports.spawnmanager:spawnPlayer() - Wait(5000) - exports.spawnmanager:setAutoSpawn(false) + exports.spawnmanager:spawnPlayer() + Wait(5000) + exports.spawnmanager:setAutoSpawn(false) end) CreateThread(function() - ESX = exports["es_extended"]:getSharedObject() - while ESX.GetPlayerData().job == nil do - Wait(100) - end - PlayerLoaded = true - ESX.PlayerData = ESX.GetPlayerData() + ESX = exports["es_extended"]:getSharedObject() + while ESX.GetPlayerData().job == nil do + Wait(100) + end + PlayerLoaded = true + ESX.PlayerData = ESX.GetPlayerData() end) RegisterNetEvent("esx:playerLoaded") AddEventHandler("esx:playerLoaded", function(xPlayer) - ESX.PlayerData = xPlayer - PlayerLoaded = true + ESX.PlayerData = xPlayer + PlayerLoaded = true end) RegisterNetEvent("esx:setJob") AddEventHandler("esx:setJob", function(job) - ESX.PlayerData.job = job + ESX.PlayerData.job = job end) AddEventHandler("esx:onPlayerSpawn", function() - isDead = false - - if firstSpawn then - firstSpawn = false - - if Config.AntiCombatLog then - while not PlayerLoaded do - Wait(5000) - end - - ESX.TriggerServerCallback("bpt_ambulancejob:getDeathStatus", function(shouldDie) - if shouldDie then - Wait(10000) - SetEntityHealth(PlayerPedId(), 0) - end - end) - end - end + isDead = false + + if firstSpawn then + firstSpawn = false + + if Config.AntiCombatLog then + while not PlayerLoaded do + Wait(5000) + end + + ESX.TriggerServerCallback("bpt_ambulancejob:getDeathStatus", function(shouldDie) + if shouldDie then + Wait(10000) + SetEntityHealth(PlayerPedId(), 0) + end + end) + end + end end) -- Create blips CreateThread(function() - for _, v in pairs(Config.Hospitals) do - local blip = AddBlipForCoord(v.Blip.coords) - - SetBlipSprite(blip, v.Blip.sprite) - SetBlipScale(blip, v.Blip.scale) - SetBlipColour(blip, v.Blip.color) - SetBlipAsShortRange(blip, true) - - BeginTextCommandSetBlipName("STRING") - AddTextComponentSubstringPlayerName(TranslateCap("blip_hospital")) - EndTextCommandSetBlipName(blip) - end + for _, v in pairs(Config.Hospitals) do + local blip = AddBlipForCoord(v.Blip.coords) + + SetBlipSprite(blip, v.Blip.sprite) + SetBlipScale(blip, v.Blip.scale) + SetBlipColour(blip, v.Blip.color) + SetBlipAsShortRange(blip, true) + + BeginTextCommandSetBlipName("STRING") + AddTextComponentSubstringPlayerName(TranslateCap("blip_hospital")) + EndTextCommandSetBlipName(blip) + end end) -- Disable most inputs when dead CreateThread(function() - while true do - Wait(0) - - if isDead then - DisableAllControlActions(0) - EnableControlAction(0, 47, true) - EnableControlAction(0, 245, true) - EnableControlAction(0, 38, true) - else - Wait(500) - end - end + while true do + Wait(0) + + if isDead then + DisableAllControlActions(0) + EnableControlAction(0, 47, true) + EnableControlAction(0, 245, true) + EnableControlAction(0, 38, true) + else + Wait(500) + end + end end) CreateThread(function() - while true do - Wait(0) - if isDead and isSearched then - local playerPed = PlayerPedId() - local ped = GetPlayerPed(GetPlayerFromServerId(medic)) - isSearched = false - - AttachEntityToEntity( - playerPed, - ped, - 11816, - 0.54, - 0.54, - 0.0, - 0.0, - 0.0, - 0.0, - false, - false, - false, - false, - 2, - true - ) - Wait(1000) - DetachEntity(playerPed, true, false) - ClearPedTasksImmediately(playerPed) - end - end + while true do + Wait(0) + if isDead and isSearched then + local playerPed = PlayerPedId() + local ped = GetPlayerPed(GetPlayerFromServerId(medic)) + isSearched = false + + AttachEntityToEntity(playerPed, ped, 11816, 0.54, 0.54, 0.0, 0.0, 0.0, 0.0, false, false, false, false, 2, true) + Wait(1000) + DetachEntity(playerPed, true, false) + ClearPedTasksImmediately(playerPed) + end + end end) RegisterNetEvent("bpt_ambulancejob:clsearch") AddEventHandler("bpt_ambulancejob:clsearch", function(medicId) - local playerPed = PlayerPedId() - - if isDead then - local coords = GetEntityCoords(playerPed) - local playersInArea = ESX.Game.GetPlayersInArea(coords, 50.0) - - for i = 1, #playersInArea, 1 do - local player = playersInArea[i] - if player == GetPlayerFromServerId(medicId) then - medic = tonumber(medicId) - isSearched = true - break - end - end - end + local playerPed = PlayerPedId() + + if isDead then + local coords = GetEntityCoords(playerPed) + local playersInArea = ESX.Game.GetPlayersInArea(coords, 50.0) + + for i = 1, #playersInArea, 1 do + local player = playersInArea[i] + if player == GetPlayerFromServerId(medicId) then + medic = tonumber(medicId) + isSearched = true + break + end + end + end end) function OnPlayerDeath() - isDead = true - ESX.CloseContext() - TriggerServerEvent("bpt_ambulancejob:setDeathStatus", true) + isDead = true + ESX.CloseContext() + TriggerServerEvent("bpt_ambulancejob:setDeathStatus", true) - StartDeathTimer() - StartDistressSignal() + StartDeathTimer() + StartDistressSignal() - StartScreenEffect("DeathFailOut", 0, false) + StartScreenEffect("DeathFailOut", 0, false) end RegisterNetEvent("bpt_ambulancejob:useItem") AddEventHandler("bpt_ambulancejob:useItem", function(itemName) - ESX.CloseContext() - - if itemName == "medikit" then - local lib, anim = "anim@heists@narcotics@funding@gang_idle", "gang_chatting_idle01" -- TODO better animations - local playerPed = PlayerPedId() - - ESX.Streaming.RequestAnimDict(lib, function() - TaskPlayAnim(playerPed, lib, anim, 8.0, -8.0, -1, 0, 0, false, false, false) - - Wait(500) - while IsEntityPlayingAnim(playerPed, lib, anim, 3) do - Wait(0) - DisableAllControlActions(0) - end - - TriggerEvent("bpt_ambulancejob:heal", "big", true) - ESX.ShowNotification(TranslateCap("used_medikit")) - end) - elseif itemName == "bandage" then - local lib, anim = "anim@heists@narcotics@funding@gang_idle", "gang_chatting_idle01" -- TODO better animations - local playerPed = PlayerPedId() - - ESX.Streaming.RequestAnimDict(lib, function() - TaskPlayAnim(playerPed, lib, anim, 8.0, -8.0, -1, 0, 0, false, false, false) - - Wait(500) - while IsEntityPlayingAnim(playerPed, lib, anim, 3) do - Wait(0) - DisableAllControlActions(0) - end - - TriggerEvent("bpt_ambulancejob:heal", "small", true) - ESX.ShowNotification(TranslateCap("used_bandage")) - end) - end + ESX.CloseContext() + + if itemName == "medikit" then + local lib, anim = "anim@heists@narcotics@funding@gang_idle", "gang_chatting_idle01" -- TODO better animations + local playerPed = PlayerPedId() + + ESX.Streaming.RequestAnimDict(lib, function() + TaskPlayAnim(playerPed, lib, anim, 8.0, -8.0, -1, 0, 0, false, false, false) + + Wait(500) + while IsEntityPlayingAnim(playerPed, lib, anim, 3) do + Wait(0) + DisableAllControlActions(0) + end + + TriggerEvent("bpt_ambulancejob:heal", "big", true) + ESX.ShowNotification(TranslateCap("used_medikit")) + end) + elseif itemName == "bandage" then + local lib, anim = "anim@heists@narcotics@funding@gang_idle", "gang_chatting_idle01" -- TODO better animations + local playerPed = PlayerPedId() + + ESX.Streaming.RequestAnimDict(lib, function() + TaskPlayAnim(playerPed, lib, anim, 8.0, -8.0, -1, 0, 0, false, false, false) + + Wait(500) + while IsEntityPlayingAnim(playerPed, lib, anim, 3) do + Wait(0) + DisableAllControlActions(0) + end + + TriggerEvent("bpt_ambulancejob:heal", "small", true) + ESX.ShowNotification(TranslateCap("used_bandage")) + end) + end end) function StartDistressSignal() - CreateThread(function() - local timer = Config.BleedoutTimer - - while timer > 0 and isDead do - Wait(0) - timer = timer - 30 - - SetTextFont(4) - SetTextScale(0.45, 0.45) - SetTextColour(185, 185, 185, 255) - SetTextDropshadow(0, 0, 0, 0, 255) - SetTextDropShadow() - SetTextOutline() - BeginTextCommandDisplayText("STRING") - AddTextComponentSubstringPlayerName(TranslateCap("distress_send")) - EndTextCommandDisplayText(0.175, 0.805) - - if IsControlJustReleased(0, 47) then - SendDistressSignal() - break - end - end - end) + CreateThread(function() + local timer = Config.BleedoutTimer + + while timer > 0 and isDead do + Wait(0) + timer = timer - 30 + + SetTextFont(4) + SetTextScale(0.45, 0.45) + SetTextColour(185, 185, 185, 255) + SetTextDropshadow(0, 0, 0, 0, 255) + SetTextDropShadow() + SetTextOutline() + BeginTextCommandDisplayText("STRING") + AddTextComponentSubstringPlayerName(TranslateCap("distress_send")) + EndTextCommandDisplayText(0.175, 0.805) + + if IsControlJustReleased(0, 47) then + SendDistressSignal() + break + end + end + end) end function SendDistressSignal() - local playerPed = PlayerPedId() - local _ = GetEntityCoords(playerPed) + local playerPed = PlayerPedId() + local _ = GetEntityCoords(playerPed) - ESX.ShowNotification(TranslateCap("distress_sent")) - TriggerServerEvent("bpt_ambulancejob:onPlayerDistress") + ESX.ShowNotification(TranslateCap("distress_sent")) + TriggerServerEvent("bpt_ambulancejob:onPlayerDistress") end function DrawGenericTextThisFrame() - SetTextFont(4) - SetTextScale(0.0, 0.5) - SetTextColour(255, 255, 255, 255) - SetTextDropshadow(0, 0, 0, 0, 255) - SetTextDropShadow() - SetTextOutline() - SetTextCentre(true) + SetTextFont(4) + SetTextScale(0.0, 0.5) + SetTextColour(255, 255, 255, 255) + SetTextDropshadow(0, 0, 0, 0, 255) + SetTextDropShadow() + SetTextOutline() + SetTextCentre(true) end function secondsToClock(seconds) - local _ = tonumber(seconds) + local _ = tonumber(seconds) - if seconds <= 0 then - return 0, 0 - else - local hours = string.format("%02.f", math.floor(seconds / 3600)) - local mins = string.format("%02.f", math.floor(seconds / 60 - (hours * 60))) - local secs = string.format("%02.f", math.floor(seconds - hours * 3600 - mins * 60)) + if seconds <= 0 then + return 0, 0 + else + local hours = string.format("%02.f", math.floor(seconds / 3600)) + local mins = string.format("%02.f", math.floor(seconds / 60 - (hours * 60))) + local secs = string.format("%02.f", math.floor(seconds - hours * 3600 - mins * 60)) - return mins, secs - end + return mins, secs + end end function StartDeathTimer() - local canPayFine = false - - if Config.EarlyRespawnFine then - ESX.TriggerServerCallback("bpt_ambulancejob:checkBalance", function(canPay) - canPayFine = canPay - end) - end - - local earlySpawnTimer = ESX.Math.Round(Config.EarlyRespawnTimer / 1000) - local bleedoutTimer = ESX.Math.Round(Config.BleedoutTimer / 1000) - - CreateThread(function() - -- early respawn timer - while earlySpawnTimer > 0 and isDead do - Wait(1000) - - if earlySpawnTimer > 0 then - earlySpawnTimer = earlySpawnTimer - 1 - end - end - - -- bleedout timer - while bleedoutTimer > 0 and isDead do - Wait(1000) - - if bleedoutTimer > 0 then - bleedoutTimer = bleedoutTimer - 1 - end - end - end) - - CreateThread(function() - local text, timeHeld - - -- early respawn timer - while earlySpawnTimer > 0 and isDead do - Wait(0) - text = TranslateCap("respawn_available_in", secondsToClock(earlySpawnTimer)) - - DrawGenericTextThisFrame() - - SetTextEntry("STRING") - AddTextComponentString(text) - DrawText(0.5, 0.8) - end - - -- bleedout timer - while bleedoutTimer > 0 and isDead do - Wait(0) - text = TranslateCap("respawn_bleedout_in", secondsToClock(bleedoutTimer)) - - if not Config.EarlyRespawnFine then - text = text .. TranslateCap("respawn_bleedout_prompt") - - if IsControlPressed(0, 38) and timeHeld > 60 then - RemoveItemsAfterRPDeath() - break - end - elseif Config.EarlyRespawnFine and canPayFine then - text = text .. TranslateCap("respawn_bleedout_fine", ESX.Math.GroupDigits(Config.EarlyRespawnFineAmount)) - - if IsControlPressed(0, 38) and timeHeld > 60 then - TriggerServerEvent("bpt_ambulancejob:payFine") - RemoveItemsAfterRPDeath() - break - end - end - - if IsControlPressed(0, 38) then - timeHeld = timeHeld + 1 - else - timeHeld = 0 - end - - DrawGenericTextThisFrame() - - SetTextEntry("STRING") - AddTextComponentString(text) - DrawText(0.5, 0.8) - end - - if bleedoutTimer < 1 and isDead then - RemoveItemsAfterRPDeath() - end - end) + local canPayFine = false + + if Config.EarlyRespawnFine then + ESX.TriggerServerCallback("bpt_ambulancejob:checkBalance", function(canPay) + canPayFine = canPay + end) + end + + local earlySpawnTimer = ESX.Math.Round(Config.EarlyRespawnTimer / 1000) + local bleedoutTimer = ESX.Math.Round(Config.BleedoutTimer / 1000) + + CreateThread(function() + -- early respawn timer + while earlySpawnTimer > 0 and isDead do + Wait(1000) + + if earlySpawnTimer > 0 then + earlySpawnTimer = earlySpawnTimer - 1 + end + end + + -- bleedout timer + while bleedoutTimer > 0 and isDead do + Wait(1000) + + if bleedoutTimer > 0 then + bleedoutTimer = bleedoutTimer - 1 + end + end + end) + + CreateThread(function() + local text, timeHeld + + -- early respawn timer + while earlySpawnTimer > 0 and isDead do + Wait(0) + text = TranslateCap("respawn_available_in", secondsToClock(earlySpawnTimer)) + + DrawGenericTextThisFrame() + + SetTextEntry("STRING") + AddTextComponentString(text) + DrawText(0.5, 0.8) + end + + -- bleedout timer + while bleedoutTimer > 0 and isDead do + Wait(0) + text = TranslateCap("respawn_bleedout_in", secondsToClock(bleedoutTimer)) + + if not Config.EarlyRespawnFine then + text = text .. TranslateCap("respawn_bleedout_prompt") + + if IsControlPressed(0, 38) and timeHeld > 60 then + RemoveItemsAfterRPDeath() + break + end + elseif Config.EarlyRespawnFine and canPayFine then + text = text .. TranslateCap("respawn_bleedout_fine", ESX.Math.GroupDigits(Config.EarlyRespawnFineAmount)) + + if IsControlPressed(0, 38) and timeHeld > 60 then + TriggerServerEvent("bpt_ambulancejob:payFine") + RemoveItemsAfterRPDeath() + break + end + end + + if IsControlPressed(0, 38) then + timeHeld = timeHeld + 1 + else + timeHeld = 0 + end + + DrawGenericTextThisFrame() + + SetTextEntry("STRING") + AddTextComponentString(text) + DrawText(0.5, 0.8) + end + + if bleedoutTimer < 1 and isDead then + RemoveItemsAfterRPDeath() + end + end) end function RemoveItemsAfterRPDeath() - TriggerServerEvent("bpt_ambulancejob:setDeathStatus", false) + TriggerServerEvent("bpt_ambulancejob:setDeathStatus", false) - CreateThread(function() - DoScreenFadeOut(800) + CreateThread(function() + DoScreenFadeOut(800) - while not IsScreenFadedOut() do - Wait(10) - end + while not IsScreenFadedOut() do + Wait(10) + end - ESX.TriggerServerCallback("bpt_ambulancejob:removeItemsAfterRPDeath", function() - local formattedCoords = { - x = Config.RespawnPoint.coords.x, - y = Config.RespawnPoint.coords.y, - z = Config.RespawnPoint.coords.z, - } + ESX.TriggerServerCallback("bpt_ambulancejob:removeItemsAfterRPDeath", function() + local formattedCoords = { + x = Config.RespawnPoint.coords.x, + y = Config.RespawnPoint.coords.y, + z = Config.RespawnPoint.coords.z, + } - ESX.SetPlayerData("loadout", {}) - RespawnPed(PlayerPedId(), formattedCoords, Config.RespawnPoint.heading) + ESX.SetPlayerData("loadout", {}) + RespawnPed(PlayerPedId(), formattedCoords, Config.RespawnPoint.heading) - StopScreenEffect("DeathFailOut") - DoScreenFadeIn(800) - end) - end) + StopScreenEffect("DeathFailOut") + DoScreenFadeIn(800) + end) + end) end function RespawnPed(ped, coords, heading) - SetEntityCoordsNoOffset(ped, coords.x, coords.y, coords.z, false, false, false, true) - NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, heading, true, false) - SetPlayerInvincible(ped, false) - ClearPedBloodDamage(ped) - - TriggerServerEvent("esx:onPlayerSpawn") - TriggerEvent("esx:onPlayerSpawn") - TriggerEvent("playerSpawned") -- compatibility with old scripts, will be removed soon + SetEntityCoordsNoOffset(ped, coords.x, coords.y, coords.z, false, false, false, true) + NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, heading, true, false) + SetPlayerInvincible(ped, false) + ClearPedBloodDamage(ped) + + TriggerServerEvent("esx:onPlayerSpawn") + TriggerEvent("esx:onPlayerSpawn") + TriggerEvent("playerSpawned") -- compatibility with old scripts, will be removed soon end AddEventHandler("esx:onPlayerDeath", function() - OnPlayerDeath() + OnPlayerDeath() end) RegisterNetEvent("bpt_ambulancejob:revive") AddEventHandler("bpt_ambulancejob:revive", function() - local playerPed = PlayerPedId() - local coords = GetEntityCoords(playerPed) - TriggerServerEvent("bpt_ambulancejob:setDeathStatus", false) + local playerPed = PlayerPedId() + local coords = GetEntityCoords(playerPed) + TriggerServerEvent("bpt_ambulancejob:setDeathStatus", false) - DoScreenFadeOut(800) + DoScreenFadeOut(800) - while not IsScreenFadedOut() do - Wait(50) - end + while not IsScreenFadedOut() do + Wait(50) + end - local formattedCoords = { - x = ESX.Math.Round(coords.x, 1), - y = ESX.Math.Round(coords.y, 1), - z = ESX.Math.Round(coords.z, 1), - } + local formattedCoords = { + x = ESX.Math.Round(coords.x, 1), + y = ESX.Math.Round(coords.y, 1), + z = ESX.Math.Round(coords.z, 1), + } - RespawnPed(playerPed, formattedCoords, 0.0) + RespawnPed(playerPed, formattedCoords, 0.0) - StopScreenEffect("DeathFailOut") - DoScreenFadeIn(800) + StopScreenEffect("DeathFailOut") + DoScreenFadeIn(800) end) -- Load unloaded IPLs if Config.LoadIpl then - RequestIpl("Coroner_Int_on") -- Morgue + RequestIpl("Coroner_Int_on") -- Morgue end diff --git a/server-data/resources/[bpt_addons]/bpt_ambulancejob/client/vehicle.lua b/server-data/resources/[bpt_addons]/bpt_ambulancejob/client/vehicle.lua index 10ab8dcb1..77c081023 100644 --- a/server-data/resources/[bpt_addons]/bpt_ambulancejob/client/vehicle.lua +++ b/server-data/resources/[bpt_addons]/bpt_ambulancejob/client/vehicle.lua @@ -1,316 +1,297 @@ local spawnedVehicles = {} function OpenVehicleSpawnerMenu(type, hospital, part, partNum) - local playerCoords = GetEntityCoords(PlayerPedId()) - local elements = { - { unselectable = true, icon = "fas fa-car", title = TranslateCap("garage_title") }, - { icon = "fas fa-car", title = TranslateCap("garage_storeditem"), action = "garage" }, - { icon = "fas fa-car", title = TranslateCap("garage_storeitem"), action = "store_garage" }, - { icon = "fas fa-car", title = TranslateCap("garage_buyitem"), action = "buy_vehicle" }, - } - ESX.OpenContext("right", elements, function(_, element) - if element.action == "buy_vehicle" then - local shopElements = {} - local authorizedVehicles = Config.AuthorizedVehicles[type][ESX.PlayerData.job.grade_name] - local shopCoords = Config.Hospitals[hospital][part][partNum].InsideShop - - if #authorizedVehicles > 0 then - for _, vehicle in ipairs(authorizedVehicles) do - if IsModelInCdimage(vehicle.model) then - local vehicleLabel = GetLabelText(GetDisplayNameFromVehicleModel(vehicle.model)) - - shopElements[#shopElements + 1] = { - icon = "fas fa-car", - title = ('%s - %s'):format( - vehicleLabel, - TranslateCap("shop_item", ESX.Math.GroupDigits(vehicle.price)) - ), - name = vehicleLabel, - model = vehicle.model, - price = vehicle.price, - props = vehicle.props, - type = type, - } - end - end - - if #shopElements > 0 then - OpenShopMenu(shopElements, playerCoords, shopCoords) - else - ESX.ShowNotification(TranslateCap("garage_notauthorized")) - end - else - ESX.ShowNotification(TranslateCap("garage_notauthorized")) - end - elseif element.action == "garage" then - local garage = { - { unselectable = true, icon = "fas fa-car", title = "Garage" }, - } - - ESX.TriggerServerCallback("esx_vehicleshop:retrieveJobVehicles", function(jobVehicles) - if #jobVehicles > 0 then - local allVehicleProps = {} - - for _, v in ipairs(jobVehicles) do - local props = json.decode(v.vehicle) - - if IsModelInCdimage(props.model) then - local vehicleName = GetLabelText(GetDisplayNameFromVehicleModel(props.model)) - local label = ('%s - %s: '):format( - vehicleName, - props.plate - ) - - if v.stored then - label = label .. - ('%s'):format(TranslateCap("garage_stored")) - else - label = label - .. ('%s'):format(TranslateCap("garage_notstored")) - end - - garage[#garage + 1] = { - icon = "fas fa-car", - title = label, - stored = v.stored, - model = props.model, - plate = props.plate, - } - - allVehicleProps[props.plate] = props - end - end - - if #garage > 0 then - ESX.OpenContext("right", garage, function(_, elementG) - if elementG.stored == 1 then - local foundSpawn, spawnPoint = GetAvailableVehicleSpawnPoint(hospital, part, partNum) - - if foundSpawn then - ESX.CloseContext() - - ESX.Game.SpawnVehicle( - elementG.model, - spawnPoint.coords, - spawnPoint.heading, - function(vehicle) - local vehicleProps = allVehicleProps[elementG.plate] - ESX.Game.SetVehicleProperties(vehicle, vehicleProps) - TriggerServerEvent( - "esx_vehicleshop:setJobVehicleState", - elementG.plate, - false - ) - ESX.ShowNotification(TranslateCap("garage_released")) - end - ) - end - else - ESX.ShowNotification(TranslateCap("garage_notavailable")) - end - end) - else - ESX.ShowNotification(TranslateCap("garage_empty")) - end - else - ESX.ShowNotification(TranslateCap("garage_empty")) - end - end, type) - elseif element.action == "store_garage" then - StoreNearbyVehicle(playerCoords) - end - end) + local playerCoords = GetEntityCoords(PlayerPedId()) + local elements = { + { unselectable = true, icon = "fas fa-car", title = TranslateCap("garage_title") }, + { icon = "fas fa-car", title = TranslateCap("garage_storeditem"), action = "garage" }, + { icon = "fas fa-car", title = TranslateCap("garage_storeitem"), action = "store_garage" }, + { icon = "fas fa-car", title = TranslateCap("garage_buyitem"), action = "buy_vehicle" }, + } + ESX.OpenContext("right", elements, function(_, element) + if element.action == "buy_vehicle" then + local shopElements = {} + local authorizedVehicles = Config.AuthorizedVehicles[type][ESX.PlayerData.job.grade_name] + local shopCoords = Config.Hospitals[hospital][part][partNum].InsideShop + + if #authorizedVehicles > 0 then + for _, vehicle in ipairs(authorizedVehicles) do + if IsModelInCdimage(vehicle.model) then + local vehicleLabel = GetLabelText(GetDisplayNameFromVehicleModel(vehicle.model)) + + shopElements[#shopElements + 1] = { + icon = "fas fa-car", + title = ('%s - %s'):format(vehicleLabel, TranslateCap("shop_item", ESX.Math.GroupDigits(vehicle.price))), + name = vehicleLabel, + model = vehicle.model, + price = vehicle.price, + props = vehicle.props, + type = type, + } + end + end + + if #shopElements > 0 then + OpenShopMenu(shopElements, playerCoords, shopCoords) + else + ESX.ShowNotification(TranslateCap("garage_notauthorized")) + end + else + ESX.ShowNotification(TranslateCap("garage_notauthorized")) + end + elseif element.action == "garage" then + local garage = { + { unselectable = true, icon = "fas fa-car", title = "Garage" }, + } + + ESX.TriggerServerCallback("esx_vehicleshop:retrieveJobVehicles", function(jobVehicles) + if #jobVehicles > 0 then + local allVehicleProps = {} + + for _, v in ipairs(jobVehicles) do + local props = json.decode(v.vehicle) + + if IsModelInCdimage(props.model) then + local vehicleName = GetLabelText(GetDisplayNameFromVehicleModel(props.model)) + local label = ('%s - %s: '):format(vehicleName, props.plate) + + if v.stored then + label = label .. ('%s'):format(TranslateCap("garage_stored")) + else + label = label .. ('%s'):format(TranslateCap("garage_notstored")) + end + + garage[#garage + 1] = { + icon = "fas fa-car", + title = label, + stored = v.stored, + model = props.model, + plate = props.plate, + } + + allVehicleProps[props.plate] = props + end + end + + if #garage > 0 then + ESX.OpenContext("right", garage, function(_, elementG) + if elementG.stored == 1 then + local foundSpawn, spawnPoint = GetAvailableVehicleSpawnPoint(hospital, part, partNum) + + if foundSpawn then + ESX.CloseContext() + + ESX.Game.SpawnVehicle(elementG.model, spawnPoint.coords, spawnPoint.heading, function(vehicle) + local vehicleProps = allVehicleProps[elementG.plate] + ESX.Game.SetVehicleProperties(vehicle, vehicleProps) + TriggerServerEvent("esx_vehicleshop:setJobVehicleState", elementG.plate, false) + ESX.ShowNotification(TranslateCap("garage_released")) + end) + end + else + ESX.ShowNotification(TranslateCap("garage_notavailable")) + end + end) + else + ESX.ShowNotification(TranslateCap("garage_empty")) + end + else + ESX.ShowNotification(TranslateCap("garage_empty")) + end + end, type) + elseif element.action == "store_garage" then + StoreNearbyVehicle(playerCoords) + end + end) end function StoreNearbyVehicle(playerCoords) - local vehicles, vehiclePlates = ESX.Game.GetVehiclesInArea(playerCoords, 30.0), {} - - if #vehicles > 0 then - for _, v in ipairs(vehicles) do - -- Make sure the vehicle we're saving is empty, or else it wont be deleted - if GetVehicleNumberOfPassengers(v) == 0 and IsVehicleSeatFree(v, -1) then - table.insert(vehiclePlates, { - vehicle = v, - plate = ESX.Math.Trim(GetVehicleNumberPlateText(v)), - }) - end - end - else - ESX.ShowNotification(TranslateCap("garage_store_nearby")) - return - end - - ESX.TriggerServerCallback("bpt_ambulancejob:storeNearbyVehicle", function(storeSuccess, foundNum) - if storeSuccess then - local vehicleId = vehiclePlates[foundNum] - local attempts = 0 - ESX.Game.DeleteVehicle(vehicleId.vehicle) - local isBusy = true - local drawLoadingText = {} - - CreateThread(function() - while isBusy do - Wait(0) - drawLoadingText(TranslateCap("garage_storing"), 255, 255, 255, 255) - end - end) - - -- Workaround for vehicle not deleting when other players are near it. - while DoesEntityExist(vehicleId.vehicle) do - Wait(500) - attempts = attempts + 1 - - -- Give up - if attempts > 30 then - break - end - - vehicles = ESX.Game.GetVehiclesInArea(playerCoords, 30.0) - if #vehicles > 0 then - for _, v in ipairs(vehicles) do - if ESX.Math.Trim(GetVehicleNumberPlateText(v)) == vehicleId.plate then - ESX.Game.DeleteVehicle(v) - break - end - end - end - end - - isBusy = false - ESX.ShowNotification(TranslateCap("garage_has_stored")) - else - ESX.ShowNotification(TranslateCap("garage_has_notstored")) - end - end, vehiclePlates) + local vehicles, vehiclePlates = ESX.Game.GetVehiclesInArea(playerCoords, 30.0), {} + + if #vehicles > 0 then + for _, v in ipairs(vehicles) do + -- Make sure the vehicle we're saving is empty, or else it wont be deleted + if GetVehicleNumberOfPassengers(v) == 0 and IsVehicleSeatFree(v, -1) then + table.insert(vehiclePlates, { + vehicle = v, + plate = ESX.Math.Trim(GetVehicleNumberPlateText(v)), + }) + end + end + else + ESX.ShowNotification(TranslateCap("garage_store_nearby")) + return + end + + ESX.TriggerServerCallback("bpt_ambulancejob:storeNearbyVehicle", function(storeSuccess, foundNum) + if storeSuccess then + local vehicleId = vehiclePlates[foundNum] + local attempts = 0 + ESX.Game.DeleteVehicle(vehicleId.vehicle) + local isBusy = true + local drawLoadingText = {} + + CreateThread(function() + while isBusy do + Wait(0) + drawLoadingText(TranslateCap("garage_storing"), 255, 255, 255, 255) + end + end) + + -- Workaround for vehicle not deleting when other players are near it. + while DoesEntityExist(vehicleId.vehicle) do + Wait(500) + attempts = attempts + 1 + + -- Give up + if attempts > 30 then + break + end + + vehicles = ESX.Game.GetVehiclesInArea(playerCoords, 30.0) + if #vehicles > 0 then + for _, v in ipairs(vehicles) do + if ESX.Math.Trim(GetVehicleNumberPlateText(v)) == vehicleId.plate then + ESX.Game.DeleteVehicle(v) + break + end + end + end + end + + isBusy = false + ESX.ShowNotification(TranslateCap("garage_has_stored")) + else + ESX.ShowNotification(TranslateCap("garage_has_notstored")) + end + end, vehiclePlates) end function GetAvailableVehicleSpawnPoint(hospital, part, partNum) - local spawnPoints = Config.Hospitals[hospital][part][partNum].SpawnPoints - local found, foundSpawnPoint = false, nil - - for i = 1, #spawnPoints, 1 do - if ESX.Game.IsSpawnPointClear(spawnPoints[i].coords, spawnPoints[i].radius) then - found, foundSpawnPoint = true, spawnPoints[i] - break - end - end - - if found then - return true, foundSpawnPoint - else - ESX.ShowNotification(TranslateCap("garage_blocked")) - return false - end + local spawnPoints = Config.Hospitals[hospital][part][partNum].SpawnPoints + local found, foundSpawnPoint = false, nil + + for i = 1, #spawnPoints, 1 do + if ESX.Game.IsSpawnPointClear(spawnPoints[i].coords, spawnPoints[i].radius) then + found, foundSpawnPoint = true, spawnPoints[i] + break + end + end + + if found then + return true, foundSpawnPoint + else + ESX.ShowNotification(TranslateCap("garage_blocked")) + return false + end end function OpenShopMenu(elements, restoreCoords, shopCoords) - local playerPed = PlayerPedId() - isInShopMenu = true - ESX.OpenContext("right", elements, function(_, element) - local elements2 = { - { unselectable = true, icon = "fas fa-car", title = element.title }, - { icon = "fas fa-eye", title = "View", value = "view" }, - } - - ESX.OpenContext("right", elements2, function(_, element2) - if element2.value == "view" then - DeleteSpawnedVehicles() - WaitForVehicleToLoad(element.model) - - ESX.Game.SpawnLocalVehicle(element.model, shopCoords, 0.0, function(vehicle) - table.insert(spawnedVehicles, vehicle) - TaskWarpPedIntoVehicle(playerPed, vehicle, -1) - FreezeEntityPosition(vehicle, true) - SetModelAsNoLongerNeeded(element.model) - - if element.props then - ESX.Game.SetVehicleProperties(vehicle, element.props) - end - end) - - local elements3 = { - { unselectable = true, icon = "fas fa-car", title = element.title }, - { icon = "fas fa-check-double", title = "Buy", value = "buy" }, - { icon = "fas fa-eye", title = "Stop Viewing", value = "stop" }, - } - - ESX.OpenContext("right", elements3, function(_, element3) - if element3.value == "stop" then - isInShopMenu = false - ESX.CloseContext() - - DeleteSpawnedVehicles() - FreezeEntityPosition(playerPed, false) - SetEntityVisible(playerPed, true) - - ESX.Game.Teleport(playerPed, restoreCoords) - elseif element3.value == "buy" then - local newPlate = exports["esx_vehicleshop"]:GeneratePlate() - local vehicle = GetVehiclePedIsIn(playerPed, false) - local props = ESX.Game.GetVehicleProperties(vehicle) - props.plate = newPlate - - ESX.TriggerServerCallback("bpt_ambulancejob:buyJobVehicle", function(bought) - if bought then - ESX.ShowNotification( - TranslateCap("vehicleshop_bought", element.name, ESX.Math.GroupDigits(element.price)) - ) - - isInShopMenu = false - ESX.CloseContext() - DeleteSpawnedVehicles() - FreezeEntityPosition(playerPed, false) - SetEntityVisible(playerPed, true) - - ESX.Game.Teleport(playerPed, restoreCoords) - else - ESX.ShowNotification(TranslateCap("vehicleshop_money")) - ESX.CloseContext() - end - end, props, element.type) - end - end) - end - end) - end) + local playerPed = PlayerPedId() + isInShopMenu = true + ESX.OpenContext("right", elements, function(_, element) + local elements2 = { + { unselectable = true, icon = "fas fa-car", title = element.title }, + { icon = "fas fa-eye", title = "View", value = "view" }, + } + + ESX.OpenContext("right", elements2, function(_, element2) + if element2.value == "view" then + DeleteSpawnedVehicles() + WaitForVehicleToLoad(element.model) + + ESX.Game.SpawnLocalVehicle(element.model, shopCoords, 0.0, function(vehicle) + table.insert(spawnedVehicles, vehicle) + TaskWarpPedIntoVehicle(playerPed, vehicle, -1) + FreezeEntityPosition(vehicle, true) + SetModelAsNoLongerNeeded(element.model) + + if element.props then + ESX.Game.SetVehicleProperties(vehicle, element.props) + end + end) + + local elements3 = { + { unselectable = true, icon = "fas fa-car", title = element.title }, + { icon = "fas fa-check-double", title = "Buy", value = "buy" }, + { icon = "fas fa-eye", title = "Stop Viewing", value = "stop" }, + } + + ESX.OpenContext("right", elements3, function(_, element3) + if element3.value == "stop" then + isInShopMenu = false + ESX.CloseContext() + + DeleteSpawnedVehicles() + FreezeEntityPosition(playerPed, false) + SetEntityVisible(playerPed, true) + + ESX.Game.Teleport(playerPed, restoreCoords) + elseif element3.value == "buy" then + local newPlate = exports["esx_vehicleshop"]:GeneratePlate() + local vehicle = GetVehiclePedIsIn(playerPed, false) + local props = ESX.Game.GetVehicleProperties(vehicle) + props.plate = newPlate + + ESX.TriggerServerCallback("bpt_ambulancejob:buyJobVehicle", function(bought) + if bought then + ESX.ShowNotification(TranslateCap("vehicleshop_bought", element.name, ESX.Math.GroupDigits(element.price))) + + isInShopMenu = false + ESX.CloseContext() + DeleteSpawnedVehicles() + FreezeEntityPosition(playerPed, false) + SetEntityVisible(playerPed, true) + + ESX.Game.Teleport(playerPed, restoreCoords) + else + ESX.ShowNotification(TranslateCap("vehicleshop_money")) + ESX.CloseContext() + end + end, props, element.type) + end + end) + end + end) + end) end CreateThread(function() - while true do - Wait(0) - - if isInShopMenu then - DisableControlAction(0, 75, true) -- Disable exit vehicle - DisableControlAction(27, 75, true) -- Disable exit vehicle - else - Wait(500) - end - end + while true do + Wait(0) + + if isInShopMenu then + DisableControlAction(0, 75, true) -- Disable exit vehicle + DisableControlAction(27, 75, true) -- Disable exit vehicle + else + Wait(500) + end + end end) function DeleteSpawnedVehicles() - while #spawnedVehicles > 0 do - local vehicle = spawnedVehicles[1] - ESX.Game.DeleteVehicle(vehicle) - table.remove(spawnedVehicles, 1) - end + while #spawnedVehicles > 0 do + local vehicle = spawnedVehicles[1] + ESX.Game.DeleteVehicle(vehicle) + table.remove(spawnedVehicles, 1) + end end function WaitForVehicleToLoad(modelHash) - modelHash = (type(modelHash) == "number" and modelHash or GetHashKey(modelHash)) + modelHash = (type(modelHash) == "number" and modelHash or GetHashKey(modelHash)) - if not HasModelLoaded(modelHash) then - RequestModel(modelHash) + if not HasModelLoaded(modelHash) then + RequestModel(modelHash) - BeginTextCommandBusyspinnerOn("STRING") - AddTextComponentSubstringPlayerName(TranslateCap("vehicleshop_awaiting_model")) - EndTextCommandBusyspinnerOn(4) + BeginTextCommandBusyspinnerOn("STRING") + AddTextComponentSubstringPlayerName(TranslateCap("vehicleshop_awaiting_model")) + EndTextCommandBusyspinnerOn(4) - while not HasModelLoaded(modelHash) do - Wait(0) - DisableAllControlActions(0) - end + while not HasModelLoaded(modelHash) do + Wait(0) + DisableAllControlActions(0) + end - BusyspinnerOff() - end + BusyspinnerOff() + end end diff --git a/server-data/resources/[bpt_addons]/bpt_ambulancejob/config.lua b/server-data/resources/[bpt_addons]/bpt_ambulancejob/config.lua index c19f9f30d..74667b6f5 100644 --- a/server-data/resources/[bpt_addons]/bpt_ambulancejob/config.lua +++ b/server-data/resources/[bpt_addons]/bpt_ambulancejob/config.lua @@ -27,107 +27,107 @@ Config.RespawnPoint = { coords = vector3(341.0, -1397.3, 32.5), heading = 48.5 } Config.Hospitals = { - CentralLosSantos = { - - Blip = { - coords = vector3(292.05, -582.39, 43.18), - sprite = 61, - scale = 1.2, - color = 2, - }, - - AmbulanceActions = { - vector3(301.925293, -598.549438, 42.282104), - }, - - Vehicles = { - { - Spawner = vector3(338.123077, -575.947266, 28.791260), - InsideShop = vector3(320.756042, -548.004395, 28.740601), - Marker = { type = 36, x = 1.0, y = 1.0, z = 1.0, r = 100, g = 50, b = 200, a = 100, rotate = true }, - SpawnPoints = { - { coords = vector3(328.021973, -576.553833, 28.791260), heading = 227.6, radius = 4.0 }, - }, - }, - }, - - Helicopters = { - { - Spawner = vector3(352.04, -588.39, 74.16), - InsideShop = vector3(352.04, -588.39, 74.16), - Marker = { type = 34, x = 1.5, y = 1.5, z = 1.5, r = 100, g = 150, b = 150, a = 100, rotate = true }, - SpawnPoints = { - { coords = vector3(352.04, -588.39, 74.16), heading = 142.7, radius = 10.0 }, - }, - }, - }, - - FastTravels = { - -- roof access (ok) - { - From = vector3(329.393402, -601.081299, 42.282104), - To = { coords = vector3(341.076935, -581.604370, 74.150879), heading = 0.0 }, - Marker = { type = 1, x = 1.5, y = 1.5, z = 0.5, r = 102, g = 0, b = 102, a = 100, rotate = false }, - }, - - -- DW main - { - From = vector3(339.454956, -584.175842, 73.150879), - To = { coords = vector3(331.371429, -595.424194, 43.282104), heading = 0.0 }, - Marker = { type = 1, x = 2.0, y = 2.0, z = 0.5, r = 102, g = 0, b = 102, a = 100, rotate = false }, - }, - - -- Garage dw - { - From = vector3(327.217590, -603.560425, 42.282104), - To = { coords = vector3(339.283508, -584.479126, 28.791260), heading = 0.0 }, - Marker = { type = 1, x = 2.0, y = 2.0, z = 0.5, r = 102, g = 0, b = 102, a = 100, rotate = false }, - }, - - -- Garage up - { - From = vector3(340.892303, -580.378052, 27.791260), - To = { coords = vector3(332.175812, -595.569214, 43.282104), heading = 0.0 }, - Marker = { type = 1, x = 2.0, y = 2.0, z = 0.5, r = 102, g = 0, b = 102, a = 100, rotate = false }, - }, - - -- Roof access end - }, - }, + CentralLosSantos = { + + Blip = { + coords = vector3(292.05, -582.39, 43.18), + sprite = 61, + scale = 1.2, + color = 2, + }, + + AmbulanceActions = { + vector3(301.925293, -598.549438, 42.282104), + }, + + Vehicles = { + { + Spawner = vector3(338.123077, -575.947266, 28.791260), + InsideShop = vector3(320.756042, -548.004395, 28.740601), + Marker = { type = 36, x = 1.0, y = 1.0, z = 1.0, r = 100, g = 50, b = 200, a = 100, rotate = true }, + SpawnPoints = { + { coords = vector3(328.021973, -576.553833, 28.791260), heading = 227.6, radius = 4.0 }, + }, + }, + }, + + Helicopters = { + { + Spawner = vector3(352.04, -588.39, 74.16), + InsideShop = vector3(352.04, -588.39, 74.16), + Marker = { type = 34, x = 1.5, y = 1.5, z = 1.5, r = 100, g = 150, b = 150, a = 100, rotate = true }, + SpawnPoints = { + { coords = vector3(352.04, -588.39, 74.16), heading = 142.7, radius = 10.0 }, + }, + }, + }, + + FastTravels = { + -- roof access (ok) + { + From = vector3(329.393402, -601.081299, 42.282104), + To = { coords = vector3(341.076935, -581.604370, 74.150879), heading = 0.0 }, + Marker = { type = 1, x = 1.5, y = 1.5, z = 0.5, r = 102, g = 0, b = 102, a = 100, rotate = false }, + }, + + -- DW main + { + From = vector3(339.454956, -584.175842, 73.150879), + To = { coords = vector3(331.371429, -595.424194, 43.282104), heading = 0.0 }, + Marker = { type = 1, x = 2.0, y = 2.0, z = 0.5, r = 102, g = 0, b = 102, a = 100, rotate = false }, + }, + + -- Garage dw + { + From = vector3(327.217590, -603.560425, 42.282104), + To = { coords = vector3(339.283508, -584.479126, 28.791260), heading = 0.0 }, + Marker = { type = 1, x = 2.0, y = 2.0, z = 0.5, r = 102, g = 0, b = 102, a = 100, rotate = false }, + }, + + -- Garage up + { + From = vector3(340.892303, -580.378052, 27.791260), + To = { coords = vector3(332.175812, -595.569214, 43.282104), heading = 0.0 }, + Marker = { type = 1, x = 2.0, y = 2.0, z = 0.5, r = 102, g = 0, b = 102, a = 100, rotate = false }, + }, + + -- Roof access end + }, + }, } Config.AuthorizedVehicles = { - car = { - ambulance = { - { model = "ambulance", price = 5000 }, - }, - - doctor = { - { model = "ambulance", price = 4500 }, - }, - - chief_doctor = { - { model = "ambulance", price = 3000 }, - }, - - boss = { - { model = "ambulance", price = 2000 }, - }, - }, - - helicopter = { - ambulance = {}, - - doctor = { - { model = "frogger2", price = 150000 }, - }, - - chief_doctor = { - { model = "frogger2", price = 150000 }, - }, - - boss = { - { model = "frogger2", price = 10000 }, - }, - }, + car = { + ambulance = { + { model = "ambulance", price = 5000 }, + }, + + doctor = { + { model = "ambulance", price = 4500 }, + }, + + chief_doctor = { + { model = "ambulance", price = 3000 }, + }, + + boss = { + { model = "ambulance", price = 2000 }, + }, + }, + + helicopter = { + ambulance = {}, + + doctor = { + { model = "frogger2", price = 150000 }, + }, + + chief_doctor = { + { model = "frogger2", price = 150000 }, + }, + + boss = { + { model = "frogger2", price = 10000 }, + }, + }, } diff --git a/server-data/resources/[bpt_addons]/bpt_ambulancejob/fxmanifest.lua b/server-data/resources/[bpt_addons]/bpt_ambulancejob/fxmanifest.lua index 5770f7709..966f53b59 100644 --- a/server-data/resources/[bpt_addons]/bpt_ambulancejob/fxmanifest.lua +++ b/server-data/resources/[bpt_addons]/bpt_ambulancejob/fxmanifest.lua @@ -9,20 +9,20 @@ version("1.0.1") shared_script("@es_extended/imports.lua") server_scripts({ - "@oxmysql/lib/MySQL.lua", - "@es_extended/locale.lua", - "locales/*.lua", - "config.lua", - "server/*.lua", + "@oxmysql/lib/MySQL.lua", + "@es_extended/locale.lua", + "locales/*.lua", + "config.lua", + "server/*.lua", }) client_scripts({ - "@es_extended/locale.lua", - "locales/*.lua", - "config.lua", - "client/*.lua", + "@es_extended/locale.lua", + "locales/*.lua", + "config.lua", + "client/*.lua", }) dependencies({ - "es_extended", + "es_extended", }) diff --git a/server-data/resources/[bpt_addons]/bpt_ambulancejob/locales/en.lua b/server-data/resources/[bpt_addons]/bpt_ambulancejob/locales/en.lua index fe3cc9da0..e8fb85411 100644 --- a/server-data/resources/[bpt_addons]/bpt_ambulancejob/locales/en.lua +++ b/server-data/resources/[bpt_addons]/bpt_ambulancejob/locales/en.lua @@ -1,85 +1,85 @@ Locales["en"] = { - -- Cloakroom - ["cloakroom"] = "locker Room", - ["ems_clothes_civil"] = "civilian Clothes", - ["ems_clothes_ems"] = "EMS Clothes", - -- Vehicles - ["ambulance"] = "ambulance", - ["helicopter_prompt"] = "press ~INPUT_CONTEXT~ to access the ~y~Helicopter Actions~s~.", - ["garage_prompt"] = "press ~INPUT_CONTEXT~ to access the ~y~Vehicle Actions~s~.", - ["garage_title"] = "vehicle Actions", - ["garage_stored"] = "stored", - ["garage_notstored"] = "not in garage", - ["garage_storing"] = "we're attempting to remove the vehicle, make sure no players are around it.", - ["garage_has_stored"] = "the vehicle has been stored in your garage", - ["garage_has_notstored"] = "no nearby owned vehicles were found", - ["garage_notavailable"] = "your vehicle is not stored in the garage.", - ["garage_blocked"] = "there's no available spawn points!", - ["garage_empty"] = "you dont have any vehicles in your garage.", - ["garage_released"] = "your vehicle has been released from the garage.", - ["garage_store_nearby"] = "there is no nearby vehicles.", - ["garage_storeditem"] = "open garage", - ["garage_storeitem"] = "store vehicle in garage", - ["garage_buyitem"] = "vehicle shop", - ["shop_item"] = "$%s", - ["vehicleshop_title"] = "vehicle Shop", - ["vehicleshop_confirm"] = "do you want to buy this vehicle?", - ["vehicleshop_bought"] = "you have bought ~y~%s~s~ for ~g~$%s~s~", - ["vehicleshop_money"] = "you cannot afford that vehicle", - ["vehicleshop_awaiting_model"] = "the vehicle is currently ~g~DOWNLOADING & LOADING~s~ please wait", - ["confirm_no"] = "no", - ["confirm_yes"] = "yes", - -- Action Menu - ["revive_inprogress"] = "a revive is in progress!", - ["revive_complete"] = "you have revived ~y~%s~s~", - ["revive_complete_award"] = "you have revived ~y~%s~s~ and earned ~g~$%s~s~!", - ["revive_fail_offline"] = "that player is no longer online", - ["heal_inprogress"] = "you are healing!", - ["heal_complete"] = "you have healed ~y~%s~s~", - ["no_players"] = "no players nearby", - ["player_not_unconscious"] = "that player is not unconscious!", - ["player_not_conscious"] = "that player is not conscious!", - -- Boss Menu - ["boss_actions"] = "boss Actions", - -- Misc - ["invalid_amount"] = "~r~Invalid amount", - ["actions_prompt"] = "press ~INPUT_CONTEXT~ access the ~y~Ambulance Actions~s~.", - ["deposit_amount"] = "deposit Amount", - ["money_withdraw"] = "amount withdrawn", - ["fast_travel"] = "press ~INPUT_CONTEXT~ to fast travel.", - ["medikit"] = "medikit", - ["bandage"] = "bandage", - ["max_item"] = "You are already carrying enough.", - -- F6 Menu - ["ems_menu"] = "EMS Menu", - ["ems_menu_title"] = "ambulance - EMS Menu", - ["ems_menu_revive"] = "revive Player", - ["ems_menu_putincar"] = "put in Vehicle", - ["ems_menu_small"] = "heal small wounds", - ["ems_menu_big"] = "treat serious injuries", - ["ems_menu_search"] = "patient not found", - -- billing - ["billing"] = "billing", - ["invoice_amount"] = "invoice amount", - ["no_players_near"] = "no players nearby", - -- Death - ["respawn_available_in"] = "respawn available in ~b~%s minutes %s seconds~s~", - ["respawn_bleedout_in"] = "you will bleed out in ~b~%s minutes %s seconds~s~\n", - ["respawn_bleedout_prompt"] = "hold [~b~E~s~] to respawn", - ["respawn_bleedout_fine"] = "hold [~b~E~s~] to respawn for ~g~$%s~s~", - ["respawn_bleedout_fine_msg"] = "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!", - ["combatlog_message"] = "you have been force-respawned because you've previously left the server when dead.", - -- Revive - ["revive_help"] = "revive a player", - -- Item - ["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~s~.", - ["not_enough_bandage"] = "You do not have ~b~bandage~s~.", - ["healed"] = "you have been treated.", - -- Blips - ["blip_hospital"] = "hospital", - ["blip_dead"] = "unconscious player", + -- Cloakroom + ["cloakroom"] = "locker Room", + ["ems_clothes_civil"] = "civilian Clothes", + ["ems_clothes_ems"] = "EMS Clothes", + -- Vehicles + ["ambulance"] = "ambulance", + ["helicopter_prompt"] = "press ~INPUT_CONTEXT~ to access the ~y~Helicopter Actions~s~.", + ["garage_prompt"] = "press ~INPUT_CONTEXT~ to access the ~y~Vehicle Actions~s~.", + ["garage_title"] = "vehicle Actions", + ["garage_stored"] = "stored", + ["garage_notstored"] = "not in garage", + ["garage_storing"] = "we're attempting to remove the vehicle, make sure no players are around it.", + ["garage_has_stored"] = "the vehicle has been stored in your garage", + ["garage_has_notstored"] = "no nearby owned vehicles were found", + ["garage_notavailable"] = "your vehicle is not stored in the garage.", + ["garage_blocked"] = "there's no available spawn points!", + ["garage_empty"] = "you dont have any vehicles in your garage.", + ["garage_released"] = "your vehicle has been released from the garage.", + ["garage_store_nearby"] = "there is no nearby vehicles.", + ["garage_storeditem"] = "open garage", + ["garage_storeitem"] = "store vehicle in garage", + ["garage_buyitem"] = "vehicle shop", + ["shop_item"] = "$%s", + ["vehicleshop_title"] = "vehicle Shop", + ["vehicleshop_confirm"] = "do you want to buy this vehicle?", + ["vehicleshop_bought"] = "you have bought ~y~%s~s~ for ~g~$%s~s~", + ["vehicleshop_money"] = "you cannot afford that vehicle", + ["vehicleshop_awaiting_model"] = "the vehicle is currently ~g~DOWNLOADING & LOADING~s~ please wait", + ["confirm_no"] = "no", + ["confirm_yes"] = "yes", + -- Action Menu + ["revive_inprogress"] = "a revive is in progress!", + ["revive_complete"] = "you have revived ~y~%s~s~", + ["revive_complete_award"] = "you have revived ~y~%s~s~ and earned ~g~$%s~s~!", + ["revive_fail_offline"] = "that player is no longer online", + ["heal_inprogress"] = "you are healing!", + ["heal_complete"] = "you have healed ~y~%s~s~", + ["no_players"] = "no players nearby", + ["player_not_unconscious"] = "that player is not unconscious!", + ["player_not_conscious"] = "that player is not conscious!", + -- Boss Menu + ["boss_actions"] = "boss Actions", + -- Misc + ["invalid_amount"] = "~r~Invalid amount", + ["actions_prompt"] = "press ~INPUT_CONTEXT~ access the ~y~Ambulance Actions~s~.", + ["deposit_amount"] = "deposit Amount", + ["money_withdraw"] = "amount withdrawn", + ["fast_travel"] = "press ~INPUT_CONTEXT~ to fast travel.", + ["medikit"] = "medikit", + ["bandage"] = "bandage", + ["max_item"] = "You are already carrying enough.", + -- F6 Menu + ["ems_menu"] = "EMS Menu", + ["ems_menu_title"] = "ambulance - EMS Menu", + ["ems_menu_revive"] = "revive Player", + ["ems_menu_putincar"] = "put in Vehicle", + ["ems_menu_small"] = "heal small wounds", + ["ems_menu_big"] = "treat serious injuries", + ["ems_menu_search"] = "patient not found", + -- billing + ["billing"] = "billing", + ["invoice_amount"] = "invoice amount", + ["no_players_near"] = "no players nearby", + -- Death + ["respawn_available_in"] = "respawn available in ~b~%s minutes %s seconds~s~", + ["respawn_bleedout_in"] = "you will bleed out in ~b~%s minutes %s seconds~s~\n", + ["respawn_bleedout_prompt"] = "hold [~b~E~s~] to respawn", + ["respawn_bleedout_fine"] = "hold [~b~E~s~] to respawn for ~g~$%s~s~", + ["respawn_bleedout_fine_msg"] = "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!", + ["combatlog_message"] = "you have been force-respawned because you've previously left the server when dead.", + -- Revive + ["revive_help"] = "revive a player", + -- Item + ["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~s~.", + ["not_enough_bandage"] = "You do not have ~b~bandage~s~.", + ["healed"] = "you have been treated.", + -- Blips + ["blip_hospital"] = "hospital", + ["blip_dead"] = "unconscious player", } diff --git a/server-data/resources/[bpt_addons]/bpt_ambulancejob/server/main.lua b/server-data/resources/[bpt_addons]/bpt_ambulancejob/server/main.lua index 8e37584f2..c81afae84 100644 --- a/server-data/resources/[bpt_addons]/bpt_ambulancejob/server/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_ambulancejob/server/main.lua @@ -2,338 +2,326 @@ local playersHealing, deadPlayers = {}, {} ESX = exports["es_extended"]:getSharedObject() -TriggerEvent("esx_society:registerSociety", "ambulance", "Ambulance", "society_ambulance", "society_ambulance", - "society_ambulance", - { - type = "public" - } -) +TriggerEvent("esx_society:registerSociety", "ambulance", "Ambulance", "society_ambulance", "society_ambulance", "society_ambulance", { + type = "public", +}) RegisterNetEvent("bpt_ambulancejob:revive") AddEventHandler("bpt_ambulancejob:revive", function(playerId) - local xPlayer = ESX.GetPlayerFromId(source) - - if xPlayer and xPlayer.job.name == "ambulance" then - local xTarget = ESX.GetPlayerFromId(playerId) - - if xTarget then - if deadPlayers[playerId] then - if Config.ReviveReward > 0 then - xPlayer.showNotification(TranslateCap("revive_complete_award", xTarget.name, Config.ReviveReward)) - xPlayer.addMoney(Config.ReviveReward, "Revive Reward") - xTarget.triggerEvent("bpt_ambulancejob:revive") - else - xPlayer.showNotification(TranslateCap("revive_complete", xTarget.name)) - xTarget.triggerEvent("bpt_ambulancejob:revive") - end - else - xPlayer.showNotification(TranslateCap("player_notTranslateCapnconscious")) - end - else - xPlayer.showNotification(TranslateCap("revive_fail_offline")) - end - end + local xPlayer = ESX.GetPlayerFromId(source) + + if xPlayer and xPlayer.job.name == "ambulance" then + local xTarget = ESX.GetPlayerFromId(playerId) + + if xTarget then + if deadPlayers[playerId] then + if Config.ReviveReward > 0 then + xPlayer.showNotification(TranslateCap("revive_complete_award", xTarget.name, Config.ReviveReward)) + xPlayer.addMoney(Config.ReviveReward, "Revive Reward") + xTarget.triggerEvent("bpt_ambulancejob:revive") + else + xPlayer.showNotification(TranslateCap("revive_complete", xTarget.name)) + xTarget.triggerEvent("bpt_ambulancejob:revive") + end + else + xPlayer.showNotification(TranslateCap("player_notTranslateCapnconscious")) + end + else + xPlayer.showNotification(TranslateCap("revive_fail_offline")) + end + end end) RegisterNetEvent("esx:onPlayerDeath") AddEventHandler("esx:onPlayerDeath", function() - deadPlayers[source] = "dead" - TriggerClientEvent("bpt_ambulancejob:setDeadPlayers", -1, deadPlayers) + deadPlayers[source] = "dead" + TriggerClientEvent("bpt_ambulancejob:setDeadPlayers", -1, deadPlayers) end) RegisterServerEvent("bpt_ambulancejob:svsearch") AddEventHandler("bpt_ambulancejob:svsearch", function() - TriggerClientEvent("bpt_ambulancejob:clsearch", -1, source) + TriggerClientEvent("bpt_ambulancejob:clsearch", -1, source) end) RegisterNetEvent("bpt_ambulancejob:onPlayerDistress") AddEventHandler("bpt_ambulancejob:onPlayerDistress", function() - if deadPlayers[source] then - deadPlayers[source] = "distress" - TriggerClientEvent("bpt_ambulancejob:setDeadPlayers", -1, deadPlayers) - end + if deadPlayers[source] then + deadPlayers[source] = "distress" + TriggerClientEvent("bpt_ambulancejob:setDeadPlayers", -1, deadPlayers) + end end) RegisterNetEvent("esx:onPlayerSpawn") AddEventHandler("esx:onPlayerSpawn", function() - if deadPlayers[source] then - deadPlayers[source] = nil - TriggerClientEvent("bpt_ambulancejob:setDeadPlayers", -1, deadPlayers) - end + if deadPlayers[source] then + deadPlayers[source] = nil + TriggerClientEvent("bpt_ambulancejob:setDeadPlayers", -1, deadPlayers) + end end) AddEventHandler("esx:playerDropped", function(playerId) - if deadPlayers[playerId] then - deadPlayers[playerId] = nil - TriggerClientEvent("bpt_ambulancejob:setDeadPlayers", -1, deadPlayers) - end + if deadPlayers[playerId] then + deadPlayers[playerId] = nil + TriggerClientEvent("bpt_ambulancejob:setDeadPlayers", -1, deadPlayers) + end end) RegisterNetEvent("bpt_ambulancejob:heal") AddEventHandler("bpt_ambulancejob:heal", function(target, type) - local xPlayer = ESX.GetPlayerFromId(source) + local xPlayer = ESX.GetPlayerFromId(source) - if xPlayer.job.name == "ambulance" then - TriggerClientEvent("bpt_ambulancejob:heal", target, type) - end + if xPlayer.job.name == "ambulance" then + TriggerClientEvent("bpt_ambulancejob:heal", target, type) + end end) RegisterNetEvent("bpt_ambulancejob:putInVehicle") AddEventHandler("bpt_ambulancejob:putInVehicle", function(target) - local xPlayer = ESX.GetPlayerFromId(source) + local xPlayer = ESX.GetPlayerFromId(source) - if xPlayer.job.name == "ambulance" then - TriggerClientEvent("bpt_ambulancejob:putInVehicle", target) - end + if xPlayer.job.name == "ambulance" then + TriggerClientEvent("bpt_ambulancejob:putInVehicle", target) + end end) ESX.RegisterServerCallback("bpt_ambulancejob:removeItemsAfterRPDeath", function(source, cb) - local xPlayer = ESX.GetPlayerFromId(source) - - if Config.RemoveCashAfterRPDeath then - if xPlayer.getMoney() > 0 then - xPlayer.removeMoney(xPlayer.getMoney(), "Death") - end - - if xPlayer.getAccount("black_money").money > 0 then - xPlayer.setAccountMoney("black_money", 0, "Death") - end - end - - if Config.RemoveItemsAfterRPDeath then - for i = 1, #xPlayer.inventory, 1 do - if xPlayer.inventory[i].count > 0 then - xPlayer.setInventoryItem(xPlayer.inventory[i].name, 0) - end - end - end - - local playerLoadout = {} - if Config.RemoveWeaponsAfterRPDeath then - for i = 1, #xPlayer.loadout, 1 do - xPlayer.removeWeapon(xPlayer.loadout[i].name) - end - else -- save weapons & restore em' since spawnmanager removes them - for i = 1, #xPlayer.loadout, 1 do - table.insert(playerLoadout, xPlayer.loadout[i]) - end - - -- give back wepaons after a couple of seconds - CreateThread(function() - Wait(5000) - for i = 1, #playerLoadout, 1 do - if playerLoadout[i].label ~= nil then - xPlayer.addWeapon(playerLoadout[i].name, playerLoadout[i].ammo) - end - end - end) - end - - cb() + local xPlayer = ESX.GetPlayerFromId(source) + + if Config.RemoveCashAfterRPDeath then + if xPlayer.getMoney() > 0 then + xPlayer.removeMoney(xPlayer.getMoney(), "Death") + end + + if xPlayer.getAccount("black_money").money > 0 then + xPlayer.setAccountMoney("black_money", 0, "Death") + end + end + + if Config.RemoveItemsAfterRPDeath then + for i = 1, #xPlayer.inventory, 1 do + if xPlayer.inventory[i].count > 0 then + xPlayer.setInventoryItem(xPlayer.inventory[i].name, 0) + end + end + end + + local playerLoadout = {} + if Config.RemoveWeaponsAfterRPDeath then + for i = 1, #xPlayer.loadout, 1 do + xPlayer.removeWeapon(xPlayer.loadout[i].name) + end + else -- save weapons & restore em' since spawnmanager removes them + for i = 1, #xPlayer.loadout, 1 do + table.insert(playerLoadout, xPlayer.loadout[i]) + end + + -- give back wepaons after a couple of seconds + CreateThread(function() + Wait(5000) + for i = 1, #playerLoadout, 1 do + if playerLoadout[i].label ~= nil then + xPlayer.addWeapon(playerLoadout[i].name, playerLoadout[i].ammo) + end + end + end) + end + + cb() end) if Config.EarlyRespawnFine then - ESX.RegisterServerCallback("bpt_ambulancejob:checkBalance", function(source, cb) - local xPlayer = ESX.GetPlayerFromId(source) - local bankBalance = xPlayer.getAccount("bank").money + ESX.RegisterServerCallback("bpt_ambulancejob:checkBalance", function(source, cb) + local xPlayer = ESX.GetPlayerFromId(source) + local bankBalance = xPlayer.getAccount("bank").money - cb(bankBalance >= Config.EarlyRespawnFineAmount) - end) + cb(bankBalance >= Config.EarlyRespawnFineAmount) + end) - RegisterNetEvent("bpt_ambulancejob:payFine") - AddEventHandler("bpt_ambulancejob:payFine", function() - local xPlayer = ESX.GetPlayerFromId(source) - local fineAmount = Config.EarlyRespawnFineAmount + RegisterNetEvent("bpt_ambulancejob:payFine") + AddEventHandler("bpt_ambulancejob:payFine", function() + local xPlayer = ESX.GetPlayerFromId(source) + local fineAmount = Config.EarlyRespawnFineAmount - xPlayer.showNotification(TranslateCap("respawn_bleedout_fine_msg", ESX.Math.GroupDigits(fineAmount))) - xPlayer.removeAccountMoney("bank", fineAmount, "Respawn Fine") - end) + xPlayer.showNotification(TranslateCap("respawn_bleedout_fine_msg", ESX.Math.GroupDigits(fineAmount))) + xPlayer.removeAccountMoney("bank", fineAmount, "Respawn Fine") + end) end ESX.RegisterServerCallback("bpt_ambulancejob:getItemAmount", function(source, cb, item) - local xPlayer = ESX.GetPlayerFromId(source) - local quantity = xPlayer.getInventoryItem(item).count + local xPlayer = ESX.GetPlayerFromId(source) + local quantity = xPlayer.getInventoryItem(item).count - cb(quantity) + cb(quantity) end) ESX.RegisterServerCallback("bpt_ambulancejob:buyJobVehicle", function(source, cb, vehicleProps, type) - local xPlayer = ESX.GetPlayerFromId(source) - local price = getPriceFromHash(vehicleProps.model, xPlayer.job.grade_name, type) - - -- vehicle model not found - if price == 0 then - cb(false) - else - if xPlayer.getMoney() >= price then - xPlayer.removeMoney(price, "Job Vehicle Purchase") - - MySQL.Async.execute( - "INSERT INTO owned_vehicles (owner, vehicle, plate, type, job, `stored`) VALUES (@owner, @vehicle, @plate, @type, @job, @stored)", - { - ["@owner"] = xPlayer.identifier, - ["@vehicle"] = json.encode(vehicleProps), - ["@plate"] = vehicleProps.plate, - ["@type"] = type, - ["@job"] = xPlayer.job.name, - ["@stored"] = true, - }, - function() - cb(true) - end - ) - else - cb(false) - end - end + local xPlayer = ESX.GetPlayerFromId(source) + local price = getPriceFromHash(vehicleProps.model, xPlayer.job.grade_name, type) + + -- vehicle model not found + if price == 0 then + cb(false) + else + if xPlayer.getMoney() >= price then + xPlayer.removeMoney(price, "Job Vehicle Purchase") + + MySQL.Async.execute("INSERT INTO owned_vehicles (owner, vehicle, plate, type, job, `stored`) VALUES (@owner, @vehicle, @plate, @type, @job, @stored)", { + ["@owner"] = xPlayer.identifier, + ["@vehicle"] = json.encode(vehicleProps), + ["@plate"] = vehicleProps.plate, + ["@type"] = type, + ["@job"] = xPlayer.job.name, + ["@stored"] = true, + }, function() + cb(true) + end) + else + cb(false) + end + end end) ESX.RegisterServerCallback("bpt_ambulancejob:storeNearbyVehicle", function(source, cb, nearbyVehicles) - local xPlayer = ESX.GetPlayerFromId(source) - local foundPlate, foundNum - - for k, v in ipairs(nearbyVehicles) do - local result = MySQL.Sync.fetchAll( - "SELECT plate FROM owned_vehicles WHERE owner = @owner AND plate = @plate AND job = @job", - { - ["@owner"] = xPlayer.identifier, - ["@plate"] = v.plate, - ["@job"] = xPlayer.job.name, - } - ) - - if result[1] then - foundPlate, foundNum = result[1].plate, k - break - end - end - - if not foundPlate then - cb(false) - else - MySQL.Async.execute( - "UPDATE owned_vehicles SET `stored` = true WHERE owner = @owner AND plate = @plate AND job = @job", - { - ["@owner"] = xPlayer.identifier, - ["@plate"] = foundPlate, - ["@job"] = xPlayer.job.name, - }, - function(rowsChanged) - if rowsChanged == 0 then - cb(false) - else - cb(true, foundNum) - end - end - ) - end + local xPlayer = ESX.GetPlayerFromId(source) + local foundPlate, foundNum + + for k, v in ipairs(nearbyVehicles) do + local result = MySQL.Sync.fetchAll("SELECT plate FROM owned_vehicles WHERE owner = @owner AND plate = @plate AND job = @job", { + ["@owner"] = xPlayer.identifier, + ["@plate"] = v.plate, + ["@job"] = xPlayer.job.name, + }) + + if result[1] then + foundPlate, foundNum = result[1].plate, k + break + end + end + + if not foundPlate then + cb(false) + else + MySQL.Async.execute("UPDATE owned_vehicles SET `stored` = true WHERE owner = @owner AND plate = @plate AND job = @job", { + ["@owner"] = xPlayer.identifier, + ["@plate"] = foundPlate, + ["@job"] = xPlayer.job.name, + }, function(rowsChanged) + if rowsChanged == 0 then + cb(false) + else + cb(true, foundNum) + end + end) + end end) function getPriceFromHash(vehicleHash, jobGrade, type) - local vehicles = Config.AuthorizedVehicles[type][jobGrade] + local vehicles = Config.AuthorizedVehicles[type][jobGrade] - for _, v in ipairs(vehicles) do - if GetHashKey(v.model) == vehicleHash then - return v.price - end - end + for _, v in ipairs(vehicles) do + if GetHashKey(v.model) == vehicleHash then + return v.price + end + end - return 0 + return 0 end RegisterNetEvent("bpt_ambulancejob:removeItem") AddEventHandler("bpt_ambulancejob:removeItem", function(item) - local xPlayer = ESX.GetPlayerFromId(source) - xPlayer.removeInventoryItem(item, 1) - - if item == "bandage" then - xPlayer.showNotification(TranslateCap("used_bandage")) - elseif item == "medikit" then - xPlayer.showNotification(TranslateCap("used_medikit")) - end + local xPlayer = ESX.GetPlayerFromId(source) + xPlayer.removeInventoryItem(item, 1) + + if item == "bandage" then + xPlayer.showNotification(TranslateCap("used_bandage")) + elseif item == "medikit" then + xPlayer.showNotification(TranslateCap("used_medikit")) + end end) RegisterNetEvent("bpt_ambulancejob:giveItem") AddEventHandler("bpt_ambulancejob:giveItem", function(itemName, amount) - local xPlayer = ESX.GetPlayerFromId(source) - - if xPlayer.job.name ~= "ambulance" then - print(('[bpt_ambulancejob] [^2INFO^7] "%s" attempted to spawn in an item!'):format(xPlayer.identifier)) - return - elseif itemName ~= "medikit" and itemName ~= "bandage" then - print(('[bpt_ambulancejob] [^2INFO^7] "%s" attempted to spawn in an item!'):format(xPlayer.identifier)) - return - end - - if xPlayer.canCarryItem(itemName, amount) then - xPlayer.addInventoryItem(itemName, amount) - else - xPlayer.showNotification(TranslateCap("max_item")) - end + local xPlayer = ESX.GetPlayerFromId(source) + + if xPlayer.job.name ~= "ambulance" then + print(('[bpt_ambulancejob] [^2INFO^7] "%s" attempted to spawn in an item!'):format(xPlayer.identifier)) + return + elseif itemName ~= "medikit" and itemName ~= "bandage" then + print(('[bpt_ambulancejob] [^2INFO^7] "%s" attempted to spawn in an item!'):format(xPlayer.identifier)) + return + end + + if xPlayer.canCarryItem(itemName, amount) then + xPlayer.addInventoryItem(itemName, amount) + else + xPlayer.showNotification(TranslateCap("max_item")) + end end) -ESX.RegisterCommand("revive", "admin", - function(_, args) - args.playerId.triggerEvent("bpt_ambulancejob:revive") - end, - true, - { - help = TranslateCap("revive_help"), - validate = true, - arguments = { - { name = "playerId", help = "The player id", type = "player" }, - }, - } +ESX.RegisterCommand( + "revive", + "admin", + function(_, args) + args.playerId.triggerEvent("bpt_ambulancejob:revive") + end, + true, + { + help = TranslateCap("revive_help"), + validate = true, + arguments = { + { name = "playerId", help = "The player id", type = "player" }, + }, + } ) ESX.RegisterUsableItem("medikit", function(source) - if not playersHealing[source] then - local xPlayer = ESX.GetPlayerFromId(source) - xPlayer.removeInventoryItem("medikit", 1) + if not playersHealing[source] then + local xPlayer = ESX.GetPlayerFromId(source) + xPlayer.removeInventoryItem("medikit", 1) - playersHealing[source] = true - TriggerClientEvent("bpt_ambulancejob:useItem", source, "medikit") + playersHealing[source] = true + TriggerClientEvent("bpt_ambulancejob:useItem", source, "medikit") - Wait(10000) - playersHealing[source] = nil - end + Wait(10000) + playersHealing[source] = nil + end end) ESX.RegisterUsableItem("bandage", function(source) - if not playersHealing[source] then - local xPlayer = ESX.GetPlayerFromId(source) - xPlayer.removeInventoryItem("bandage", 1) + if not playersHealing[source] then + local xPlayer = ESX.GetPlayerFromId(source) + xPlayer.removeInventoryItem("bandage", 1) - playersHealing[source] = true - TriggerClientEvent("bpt_ambulancejob:useItem", source, "bandage") + playersHealing[source] = true + TriggerClientEvent("bpt_ambulancejob:useItem", source, "bandage") - Wait(10000) - playersHealing[source] = nil - end + Wait(10000) + playersHealing[source] = nil + end end) ESX.RegisterServerCallback("bpt_ambulancejob:getDeathStatus", function(source, cb) - local xPlayer = ESX.GetPlayerFromId(source) + local xPlayer = ESX.GetPlayerFromId(source) - MySQL.Async.fetchScalar("SELECT is_dead FROM users WHERE identifier = @identifier", { - ["@identifier"] = xPlayer.identifier, - }, function(isDead) - if isDead then - print(('[bpt_ambulancejob] [^2INFO^7] "%s" attempted combat logging'):format(xPlayer.identifier)) - end + MySQL.Async.fetchScalar("SELECT is_dead FROM users WHERE identifier = @identifier", { + ["@identifier"] = xPlayer.identifier, + }, function(isDead) + if isDead then + print(('[bpt_ambulancejob] [^2INFO^7] "%s" attempted combat logging'):format(xPlayer.identifier)) + end - cb(isDead) - end) + cb(isDead) + end) end) RegisterNetEvent("bpt_ambulancejob:setDeathStatus") AddEventHandler("bpt_ambulancejob:setDeathStatus", function(isDead) - local xPlayer = ESX.GetPlayerFromId(source) - - if type(isDead) == "boolean" then - MySQL.Sync.execute("UPDATE users SET is_dead = @isDead WHERE identifier = @identifier", { - ["@identifier"] = xPlayer.identifier, - ["@isDead"] = isDead, - }) - end + local xPlayer = ESX.GetPlayerFromId(source) + + if type(isDead) == "boolean" then + MySQL.Sync.execute("UPDATE users SET is_dead = @isDead WHERE identifier = @identifier", { + ["@identifier"] = xPlayer.identifier, + ["@isDead"] = isDead, + }) + end end) diff --git a/server-data/resources/[bpt_addons]/bpt_ammujob/config.lua b/server-data/resources/[bpt_addons]/bpt_ammujob/config.lua index 8bf936d28..cfdae28b8 100644 --- a/server-data/resources/[bpt_addons]/bpt_ammujob/config.lua +++ b/server-data/resources/[bpt_addons]/bpt_ammujob/config.lua @@ -7,48 +7,48 @@ Config.Locale = "en" Config.OxInventory = ESX.GetConfig().OxInventory Config.AuthorizedVehicles = { - { model = "rumpo", label = "Rumpo" }, + { model = "rumpo", label = "Rumpo" }, } Config.Zones = { - VehicleSpawner = { - Pos = { x = 821.340637, y = -2146.417480, z = 28.706909 }, - Size = { x = 1.0, y = 1.0, z = 1.0 }, - Color = { r = 145, g = 30, b = 30 }, - Type = 36, - Rotate = true, - }, + VehicleSpawner = { + Pos = { x = 821.340637, y = -2146.417480, z = 28.706909 }, + Size = { x = 1.0, y = 1.0, z = 1.0 }, + Color = { r = 145, g = 30, b = 30 }, + Type = 36, + Rotate = true, + }, - VehicleSpawnPoint = { - Pos = { x = 822.540649, y = -2134.575928, z = 29.279907 }, - Size = { x = 1.5, y = 1.5, z = 1.0 }, - Type = -1, - Rotate = false, - Heading = 225.0, - }, + VehicleSpawnPoint = { + Pos = { x = 822.540649, y = -2134.575928, z = 29.279907 }, + Size = { x = 1.5, y = 1.5, z = 1.0 }, + Type = -1, + Rotate = false, + Heading = 225.0, + }, - VehicleDeleter = { - Pos = { x = 822.540649, y = -2134.575928, z = 28.279907 }, - Size = { x = 3.0, y = 3.0, z = 0.25 }, - Color = { r = 255, g = 0, b = 0 }, - Type = 1, - Rotate = false, - }, + VehicleDeleter = { + Pos = { x = 822.540649, y = -2134.575928, z = 28.279907 }, + Size = { x = 3.0, y = 3.0, z = 0.25 }, + Color = { r = 255, g = 0, b = 0 }, + Type = 1, + Rotate = false, + }, - AmmuActions = { - Pos = { x = 812.479126, y = -2159.182373, z = 29.616821 }, - Size = { x = 0.5, y = 0.5, z = 0.5 }, - Color = { r = 204, g = 204, b = 0 }, - Type = 20, - Rotate = true, - }, + AmmuActions = { + Pos = { x = 812.479126, y = -2159.182373, z = 29.616821 }, + Size = { x = 0.5, y = 0.5, z = 0.5 }, + Color = { r = 204, g = 204, b = 0 }, + Type = 20, + Rotate = true, + }, - Cloakroom = { - Pos = { x = 810.065918, y = -2162.439453, z = 29.616821 }, - Size = { x = 0.5, y = 0.5, z = 0.5 }, - Color = { r = 204, g = 204, b = 0 }, - Type = 21, - Rotate = true, - }, + Cloakroom = { + Pos = { x = 810.065918, y = -2162.439453, z = 29.616821 }, + Size = { x = 0.5, y = 0.5, z = 0.5 }, + Color = { r = 204, g = 204, b = 0 }, + Type = 21, + Rotate = true, + }, } diff --git a/server-data/resources/[bpt_addons]/bpt_ammujob/fxmanifest.lua b/server-data/resources/[bpt_addons]/bpt_ammujob/fxmanifest.lua index 31e4575a6..2150dda58 100644 --- a/server-data/resources/[bpt_addons]/bpt_ammujob/fxmanifest.lua +++ b/server-data/resources/[bpt_addons]/bpt_ammujob/fxmanifest.lua @@ -9,17 +9,17 @@ version("1.0.1") shared_script("@es_extended/imports.lua") client_scripts({ - "@es_extended/locale.lua", - "locales/*.lua", - "config.lua", - "client/*.lua", + "@es_extended/locale.lua", + "locales/*.lua", + "config.lua", + "client/*.lua", }) server_scripts({ - "@es_extended/locale.lua", - "locales/*.lua", - "config.lua", - "server/*.lua", + "@es_extended/locale.lua", + "locales/*.lua", + "config.lua", + "server/*.lua", }) dependency("es_extended") diff --git a/server-data/resources/[bpt_addons]/bpt_ammujob/locales/en.lua b/server-data/resources/[bpt_addons]/bpt_ammujob/locales/en.lua index 42eb21460..748409dcf 100644 --- a/server-data/resources/[bpt_addons]/bpt_ammujob/locales/en.lua +++ b/server-data/resources/[bpt_addons]/bpt_ammujob/locales/en.lua @@ -1,34 +1,34 @@ Locales["en"] = { - -- cloakroom - ["cloakroom_menu"] = "cloakroom", - ["cloakroom_prompt"] = "press [E] to access the cloakroom.", - ["wear_citizen"] = "civilian clothing", - ["wear_work"] = "work clothes", - -- Inventory - ["deposit_stock"] = "Deposit stock", - ["take_stock"] = "Take stock", - ["have_deposited"] = "Have deposited", - ["quantity_invalid"] = "Quantity invelid", - -- garage - ["spawner_prompt"] = "press [E] to access the garage.", - ["vehicle_spawned"] = "vehicle spawned successfully!", - ["store_veh"] = "press [E] to deposit the vehicle", - ["spawn_veh"] = "spawn vehicle", - ["spawnpoint_blocked"] = "vehicle blocks the spawnpoint!", - ["only_ammu"] = "you can only deposit company vehicles.", - ["empty_garage"] = "no vehicles in the garage!", - ["taking_service"] = "Take service: Gunsmith", - ["full_service"] = "complete service: ", - ["amount_invalid"] = "invalid amount", - ["press_to_open"] = "press [E] to access the menu", - ["billing"] = "billing", - ["billing_sent"] = "the invoice has been posted!", - ["invoice_amount"] = "invoice amount", - ["no_players_near"] = "no players nearby", - ["boss_actions"] = "Boss actions", - ["blip_ammu"] = "Armory.", - ["ammu"] = "ammu", - -- billing - ["bill_amount"] = "Amount to bill..", - ["confirm"] = "Confirm", + -- cloakroom + ["cloakroom_menu"] = "cloakroom", + ["cloakroom_prompt"] = "press [E] to access the cloakroom.", + ["wear_citizen"] = "civilian clothing", + ["wear_work"] = "work clothes", + -- Inventory + ["deposit_stock"] = "Deposit stock", + ["take_stock"] = "Take stock", + ["have_deposited"] = "Have deposited", + ["quantity_invalid"] = "Quantity invelid", + -- garage + ["spawner_prompt"] = "press [E] to access the garage.", + ["vehicle_spawned"] = "vehicle spawned successfully!", + ["store_veh"] = "press [E] to deposit the vehicle", + ["spawn_veh"] = "spawn vehicle", + ["spawnpoint_blocked"] = "vehicle blocks the spawnpoint!", + ["only_ammu"] = "you can only deposit company vehicles.", + ["empty_garage"] = "no vehicles in the garage!", + ["taking_service"] = "Take service: Gunsmith", + ["full_service"] = "complete service: ", + ["amount_invalid"] = "invalid amount", + ["press_to_open"] = "press [E] to access the menu", + ["billing"] = "billing", + ["billing_sent"] = "the invoice has been posted!", + ["invoice_amount"] = "invoice amount", + ["no_players_near"] = "no players nearby", + ["boss_actions"] = "Boss actions", + ["blip_ammu"] = "Armory.", + ["ammu"] = "ammu", + -- billing + ["bill_amount"] = "Amount to bill..", + ["confirm"] = "Confirm", } diff --git a/server-data/resources/[bpt_addons]/bpt_ammujob/locales/it.lua b/server-data/resources/[bpt_addons]/bpt_ammujob/locales/it.lua index 99dacc9b2..685ec0731 100644 --- a/server-data/resources/[bpt_addons]/bpt_ammujob/locales/it.lua +++ b/server-data/resources/[bpt_addons]/bpt_ammujob/locales/it.lua @@ -1,34 +1,34 @@ Locales["it"] = { - -- cloakroom - ["cloakroom_menu"] = "guardaroba", - ["cloakroom_prompt"] = "premi [E] per accedere al guardaroba.", - ["wear_citizen"] = "abbigliamento civile", - ["wear_work"] = "abiti da lavoro", - -- Inventory - ["deposit_stock"] = "Depositare", - ["take_stock"] = "Prendi", - ["have_deposited"] = "Hai depositato", - ["quantity_invalid"] = "Qunatità non valida", - -- garage - ["spawner_prompt"] = "premi [E] per accedere al garage.", - ["vehicle_spawned"] = "veicolo generato con successo!", - ["store_veh"] = "premi [E] per depositare il veicolo", - ["spawn_veh"] = "genera veicolo", - ["spawnpoint_blocked"] = "un veicolo blocca lo spawnpoint!", - ["only_ammu"] = "puoi depositare solo veicoli aziendali.", - ["empty_garage"] = "nessun veicolo nel garage!", - ["taking_service"] = "prendi servizio: Armaiolo", - ["full_service"] = "servizio completo: ", - ["amount_invalid"] = "importo non valido", - ["press_to_open"] = "premi [E] per accedere al menu", - ["billing"] = "fattura", - ["billing_sent"] = "la fattura è stata registrata!", - ["invoice_amount"] = "importo fattura", - ["no_players_near"] = "nessun giocatore nelle vicinanze", - ["boss_actions"] = "Azioni del capo", - ["blip_ammu"] = "Armeria.", - ["ammu"] = "ammu", - -- billing - ["bill_amount"] = "importo della fattura", - ["confirm"] = "Conferma", + -- cloakroom + ["cloakroom_menu"] = "guardaroba", + ["cloakroom_prompt"] = "premi [E] per accedere al guardaroba.", + ["wear_citizen"] = "abbigliamento civile", + ["wear_work"] = "abiti da lavoro", + -- Inventory + ["deposit_stock"] = "Depositare", + ["take_stock"] = "Prendi", + ["have_deposited"] = "Hai depositato", + ["quantity_invalid"] = "Qunatità non valida", + -- garage + ["spawner_prompt"] = "premi [E] per accedere al garage.", + ["vehicle_spawned"] = "veicolo generato con successo!", + ["store_veh"] = "premi [E] per depositare il veicolo", + ["spawn_veh"] = "genera veicolo", + ["spawnpoint_blocked"] = "un veicolo blocca lo spawnpoint!", + ["only_ammu"] = "puoi depositare solo veicoli aziendali.", + ["empty_garage"] = "nessun veicolo nel garage!", + ["taking_service"] = "prendi servizio: Armaiolo", + ["full_service"] = "servizio completo: ", + ["amount_invalid"] = "importo non valido", + ["press_to_open"] = "premi [E] per accedere al menu", + ["billing"] = "fattura", + ["billing_sent"] = "la fattura è stata registrata!", + ["invoice_amount"] = "importo fattura", + ["no_players_near"] = "nessun giocatore nelle vicinanze", + ["boss_actions"] = "Azioni del capo", + ["blip_ammu"] = "Armeria.", + ["ammu"] = "ammu", + -- billing + ["bill_amount"] = "importo della fattura", + ["confirm"] = "Conferma", } diff --git a/server-data/resources/[bpt_addons]/bpt_ammujob/server/main.lua b/server-data/resources/[bpt_addons]/bpt_ammujob/server/main.lua index 2eb3d0ae8..11ae39975 100644 --- a/server-data/resources/[bpt_addons]/bpt_ammujob/server/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_ammujob/server/main.lua @@ -1,84 +1,80 @@ TriggerEvent("esx_society:registerSociety", "ammu", "Ammu", "society_ammu", "society_ammu", "society_ammu", { - type = "public", + type = "public", }) if Config.MaxInService ~= -1 then - TriggerEvent("esx_service:activateService", "ammu", Config.MaxInService) + TriggerEvent("esx_service:activateService", "ammu", Config.MaxInService) end ESX.RegisterServerCallback("bpt_ammujob:SpawnVehicle", function(source, cb, model, props) - local xPlayer = ESX.GetPlayerFromId(source) + local xPlayer = ESX.GetPlayerFromId(source) - if xPlayer.job.name ~= "ammu" then - print(("[^3WARNING^7] Player ^5%s^7 attempted to Exploit Vehicle Spawing!!"):format(source)) - return - end - local SpawnPoint = vector3( - Config.Zones.VehicleSpawnPoint.Pos.x, - Config.Zones.VehicleSpawnPoint.Pos.y, - Config.Zones.VehicleSpawnPoint.Pos.z - ) - ESX.OneSync.SpawnVehicle(joaat(model), SpawnPoint, Config.Zones.VehicleSpawnPoint.Heading, props, function() - local vehicle = NetworkGetEntityFromNetworkId() - while GetVehicleNumberPlateText(vehicle) ~= props.plate do - Wait(0) - end - TaskWarpPedIntoVehicle(GetPlayerPed(source), vehicle, -1) - end) - cb() + if xPlayer.job.name ~= "ammu" then + print(("[^3WARNING^7] Player ^5%s^7 attempted to Exploit Vehicle Spawing!!"):format(source)) + return + end + local SpawnPoint = vector3(Config.Zones.VehicleSpawnPoint.Pos.x, Config.Zones.VehicleSpawnPoint.Pos.y, Config.Zones.VehicleSpawnPoint.Pos.z) + ESX.OneSync.SpawnVehicle(joaat(model), SpawnPoint, Config.Zones.VehicleSpawnPoint.Heading, props, function() + local vehicle = NetworkGetEntityFromNetworkId() + while GetVehicleNumberPlateText(vehicle) ~= props.plate do + Wait(0) + end + TaskWarpPedIntoVehicle(GetPlayerPed(source), vehicle, -1) + end) + cb() end) RegisterNetEvent("bpt_ammujob:getStockItem") AddEventHandler("bpt_ammujob:getStockItem", function(itemName, count) - local xPlayer = ESX.GetPlayerFromId(source) + local xPlayer = ESX.GetPlayerFromId(source) - if xPlayer.job.name == "ammu" then - TriggerEvent("bpt_addoninventory:getSharedInventory", "society_ammu", function(inventory) - local item = inventory.getItem(itemName) + if xPlayer.job.name == "ammu" then + TriggerEvent("bpt_addoninventory:getSharedInventory", "society_ammu", function(inventory) + local item = inventory.getItem(itemName) - -- is there enough in the society? - if count > 0 and item.count >= count then - -- can the player carry the said amount of x item? - if xPlayer.canCarryItem(itemName, count) then - inventory.removeItem(itemName, count) - xPlayer.addInventoryItem(itemName, count) - xPlayer.showNotification(TranslateCap("have_withdrawn", count, item.label)) - else - xPlayer.showNotification(TranslateCap("player_cannot_hold")) - end - else - xPlayer.showNotification(TranslateCap("quantity_invalid")) - end - end) - else - print(("[^3WARNING^7] Player ^5%s^7 attempted ^5bpt_ammujob:getStockItem^7 (cheating)"):format(source)) - end + -- is there enough in the society? + if count > 0 and item.count >= count then + -- can the player carry the said amount of x item? + if xPlayer.canCarryItem(itemName, count) then + inventory.removeItem(itemName, count) + xPlayer.addInventoryItem(itemName, count) + xPlayer.showNotification(TranslateCap("have_withdrawn", count, item.label)) + else + xPlayer.showNotification(TranslateCap("player_cannot_hold")) + end + else + xPlayer.showNotification(TranslateCap("quantity_invalid")) + end + end) + else + print(("[^3WARNING^7] Player ^5%s^7 attempted ^5bpt_ammujob:getStockItem^7 (cheating)"):format(source)) + end end) ESX.RegisterServerCallback("bpt_ammujob:getStockItems", function(_, cb) - TriggerEvent("bpt_addoninventory:getSharedInventory", "society_ammu", function(inventory) - cb(inventory.items) - end) + TriggerEvent("bpt_addoninventory:getSharedInventory", "society_ammu", function(inventory) + cb(inventory.items) + end) end) RegisterNetEvent("bpt_ammujob:putStockItems") AddEventHandler("bpt_ammujob:putStockItems", function(itemName, count) - local xPlayer = ESX.GetPlayerFromId(source) - local sourceItem = xPlayer.getInventoryItem(itemName) + local xPlayer = ESX.GetPlayerFromId(source) + local sourceItem = xPlayer.getInventoryItem(itemName) - if xPlayer.job.name == "ammu" then - TriggerEvent("bpt_addoninventory:getSharedInventory", "society_ammu", function(inventory) - local item = inventory.getItem(itemName) + if xPlayer.job.name == "ammu" then + TriggerEvent("bpt_addoninventory:getSharedInventory", "society_ammu", function(inventory) + local item = inventory.getItem(itemName) - if sourceItem.count >= count and count > 0 then - xPlayer.removeInventoryItem(itemName, count) - inventory.addItem(itemName, count) - xPlayer.showNotification(TranslateCap("have_deposited", count, item.label)) - else - xPlayer.showNotification(TranslateCap("quantity_invalid")) - end - end) - else - print(("[^3WARNING^7] Player ^5%s^7 attempted ^5bpt_ammujob:putStockItems^7 (cheating)"):format(source)) - end + if sourceItem.count >= count and count > 0 then + xPlayer.removeInventoryItem(itemName, count) + inventory.addItem(itemName, count) + xPlayer.showNotification(TranslateCap("have_deposited", count, item.label)) + else + xPlayer.showNotification(TranslateCap("quantity_invalid")) + end + end) + else + print(("[^3WARNING^7] Player ^5%s^7 attempted ^5bpt_ammujob:putStockItems^7 (cheating)"):format(source)) + end end)