From 5173547b242546f357f56c05e1637ea80266b2ec Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Nov 2023 17:52:35 -0800 Subject: [PATCH] init commit --- client/main.lua | 144 ++++++++++++++++++++++++++++++++++++++++++++++++ config.lua | 2 + fxmanifest.lua | 24 ++++++++ locales/ar.lua | 27 +++++++++ locales/da.lua | 40 ++++++++++++++ locales/en.lua | 25 +++++++++ locales/es.lua | 40 ++++++++++++++ locales/et.lua | 40 ++++++++++++++ locales/fr.lua | 40 ++++++++++++++ locales/is.lua | 40 ++++++++++++++ locales/it.lua | 40 ++++++++++++++ locales/nl.lua | 40 ++++++++++++++ locales/tr.lua | 40 ++++++++++++++ server/main.lua | 11 ++++ 14 files changed, 553 insertions(+) create mode 100644 client/main.lua create mode 100644 config.lua create mode 100644 fxmanifest.lua create mode 100644 locales/ar.lua create mode 100644 locales/da.lua create mode 100644 locales/en.lua create mode 100644 locales/es.lua create mode 100644 locales/et.lua create mode 100644 locales/fr.lua create mode 100644 locales/is.lua create mode 100644 locales/it.lua create mode 100644 locales/nl.lua create mode 100644 locales/tr.lua create mode 100644 server/main.lua diff --git a/client/main.lua b/client/main.lua new file mode 100644 index 0000000..d1eab3d --- /dev/null +++ b/client/main.lua @@ -0,0 +1,144 @@ +local currentGear = { + mask = 0, + tank = 0, + oxygen = 0, + enabled = false +} + +local isWearingSuit = false +local oxygenLevel = 0 + +RegisterNetEvent("qb-diving:client:setoxygenlevel", function() + if oxygenLevel == 0 then + oxygenLevel = Config.OxygenLevel + exports.qbx_core:Notify(Lang:t("success.tube_filled"), 'success') + TriggerServerEvent('qb-diving:server:removeItemAfterFill') + return + end + + exports.qbx_core:Notify(Lang:t("error.oxygenlevel", {oxygenlevel = oxygenLevel}), 'error') +end) + +local function deleteGear() + if currentGear.mask ~= 0 then + DetachEntity(currentGear.mask, false, true) + DeleteEntity(currentGear.mask) + currentGear.mask = 0 + end + + if currentGear.tank ~= 0 then + DetachEntity(currentGear.tank, false, true) + DeleteEntity(currentGear.tank) + currentGear.tank = 0 + end +end + +RegisterNetEvent('qb-diving:client:UseGear', function() + if isWearingSuit then + if lib.progressBar({ + duration = 5000, + label = Lang:t("info.pullout_suit"), + useWhileDead = false, + canCancel = true, + anim = { + dict = "clothingshirt", + clip = "try_shirt_positive_d", + blendIn = 8.0 + } + }) then + SetEnableScuba(cache.ped, false) + SetPedMaxTimeUnderwater(cache.ped, 50.00) + currentGear.enabled = false + deleteGear() + exports.qbx_core:Notify(Lang:t("success.took_out")) + TriggerServerEvent("InteractSound_SV:PlayOnSource", nil, 0.25) + isWearingSuit = false + oxygenLevel = oxygenLevel + end + + ClearPedTasks(cache.ped) + else + if oxygenLevel <= 0 then + exports.qbx_core:Notify(Lang:t("error.need_otube"), 'error') + return + end + + isWearingSuit = true + + if IsPedSwimming(cache.ped) or cache.vehicle then + exports.qbx_core:Notify(Lang:t("error.not_standing_up"), 'error') + return + end + + if lib.progressBar({ + duration = 5000, + label = Lang:t("info.put_suit"), + useWhileDead = false, + canCancel = true, + anim = { + dict = "clothingshirt", + clip = "try_shirt_positive_d", + blendIn = 8.0 + } + }) then + deleteGear() + local maskModel = `p_d_scuba_mask_s` + local tankModel = `p_s_scuba_tank_s` + lib.requestModel(maskModel) + lib.requestModel(tankModel) + currentGear.tank = CreateObject(tankModel, 1.0, 1.0, 1.0, true, true, false) + local bone1 = GetPedBoneIndex(cache.ped, 24818) + AttachEntityToEntity(currentGear.tank, cache.ped, bone1, -0.25, -0.25, 0.0, 180.0, 90.0, 0.0, true, true, false, false, 2, true) + currentGear.mask = CreateObject(maskModel, 1.0, 1.0, 1.0, true, true, false) + local bone2 = GetPedBoneIndex(cache.ped, 12844) + AttachEntityToEntity(currentGear.mask, cache.ped, bone2, 0.0, 0.0, 0.0, 180.0, 90.0, 0.0, true, true, false, false, 2, true) + SetEnableScuba(cache.ped, true) + SetPedMaxTimeUnderwater(cache.ped, 2000.00) + currentGear.enabled = true + TriggerServerEvent("InteractSound_SV:PlayOnSource", "breathdivingsuit", 0.25) + CreateThread(function() + while currentGear.enabled do + if IsPedSwimmingUnderWater(cache.ped) and oxygenLevel > 0 then + oxygenLevel -= 1 + if oxygenLevel % 10 == 0 and oxygenLevel ~= Config.OxygenLevel then + TriggerServerEvent("InteractSound_SV:PlayOnSource", "breathdivingsuit", 0.25) + elseif oxygenLevel == 0 then + SetEnableScuba(cache.ped, false) + SetPedMaxTimeUnderwater(cache.ped, 1.00) + currentGear.enabled = false + isWearingSuit = false + TriggerServerEvent("InteractSound_SV:PlayOnSource", nil, 0.25) + end + end + Wait(1000) + end + end) + end + + ClearPedTasks(cache.ped) + end +end) + +local function DrawText(text) + SetTextFont(4) + SetTextProportional(true) + SetTextScale(0.0, 0.45) + SetTextDropshadow(1, 0, 0, 0, 255) + SetTextEdge(1, 0, 0, 0, 255) + SetTextDropShadow() + SetTextOutline() + BeginTextCommandDisplayText("STRING") + AddTextComponentSubstringPlayerName(text) + EndTextCommandDisplayText(0.45, 0.90) +end + +CreateThread(function() + while true do + if currentGear.enabled and isWearingSuit then + if IsPedSwimmingUnderWater(cache.ped) then + DrawText(oxygenLevel..'⏱') + end + end + Wait(0) + end +end) diff --git a/config.lua b/config.lua new file mode 100644 index 0000000..635379f --- /dev/null +++ b/config.lua @@ -0,0 +1,2 @@ +Config = {} +Config.OxygenLevel = 100 -- in seconds \ No newline at end of file diff --git a/fxmanifest.lua b/fxmanifest.lua new file mode 100644 index 0000000..51742a7 --- /dev/null +++ b/fxmanifest.lua @@ -0,0 +1,24 @@ +fx_version 'cerulean' +game 'gta5' + +description 'items to help players breathe and move underwater' +version '0.0.0' + +shared_script { + '@ox_lib/init.lua', + '@qb-core/shared/locale.lua', + 'locales/en.lua', + 'locales/*.lua', + 'config.lua', +} + +server_scripts { + 'server/*', +} + +client_scripts { + 'client/*' +} + +lua54 'yes' +use_experimental_fxv2_oal 'yes' diff --git a/locales/ar.lua b/locales/ar.lua new file mode 100644 index 0000000..289afd7 --- /dev/null +++ b/locales/ar.lua @@ -0,0 +1,27 @@ +local Translations = { + error = { + ["canceled"] = "تم الالغاء", + ["take_off"] = "/divingsuit لنزع بدلة الغوص الخاصة بك", + ["not_wearing"] = "أنت لا ترتدي معدات الغوص", + ["not_standing_up"] = "الوقوف لاستخدام خزان الأكسجين", + }, + success = { + ["took_out"] = "جاري اخد لباس الغوض", + }, + info = { + ["put_suit"] = "وضعت بدلة الغوص", + ["pullout_suit"] = "ترك بدلة الغوص", + }, + warning = { + ["oxygen_one_minute"] = "لديك أقل من ستين ثانية متبقية", + ["oxygen_running_out"] = "الأكسجين ينفد منك", + }, +} + +if GetConvar('qb_locale', 'en') == 'ar' then + Lang = Locale:new({ + phrases = Translations, + warnOnMissing = true, + fallbackLang = Lang, + }) +end diff --git a/locales/da.lua b/locales/da.lua new file mode 100644 index 0000000..d5e7404 --- /dev/null +++ b/locales/da.lua @@ -0,0 +1,40 @@ +local Translations = { + error = { + ["canceled"] = "annulleret", + ["911_chatmessage"] = "Alarmcentral", + ["take_off"] = "/divingsuit for at tage din dykkerdragt af", + ["not_wearing"] = "Du har ikke dykkerudstyr på ..", + ["no_coral"] = "Du har ingen koraller du kan sælge..", + ["not_standing_up"] = "Du skal stå op for at tage dykkerudstyret på", + }, + success = { + ["took_out"] = "Du tog din våddragt af", + }, + info = { + ["collecting_coral"] = "Samler koraller", + ["diving_area"] = "Dykker område", + ["collect_coral"] = "Saml koraller", + ["collect_coral_dt"] = "[E] - aml koraller", + ["checking_pockets"] = "Du tjkker dine lommer for koraller du kan sælge", + ["sell_coral"] = "Sælg koraller", + ["sell_coral_dt"] = "[E] - Sælg koraller", + ["blip_text"] = "112 - En person samler koraller ulovligt", + ["put_suit"] = "Tag en dykkerdragt på", + ["pullout_suit"] = "Træk en dykker dragt ud ..", + ["cop_msg"] = "Disse koraller er muligvis stjålet", + ["cop_title"] = "Ulovlig dykning", + ["command_diving"] = "Tag din dykkerdragt af", + }, + warning = { + ["oxygen_one_minute"] = "Du har mindre end 1 minuts luft tilbage", + ["oxygen_running_out"] = " Du er ved at løbe tør for luft", + }, +} + +if GetConvar('qb_locale', 'en') == 'da' then + Lang = Locale:new({ + phrases = Translations, + warnOnMissing = true, + fallbackLang = Lang, + }) +end diff --git a/locales/en.lua b/locales/en.lua new file mode 100644 index 0000000..82dab04 --- /dev/null +++ b/locales/en.lua @@ -0,0 +1,25 @@ +local Translations = { + error = { + canceled = "Canceled", + not_standing_up = "You need to be on solid ground to put this on...", + need_otube = "you need to refill your oxygen! Get a replacement air supply!", + oxygenlevel = "Your air level is %{oxygenlevel}, it must be at 0 to refill!", + }, + success = { + took_out = "You took your diving gear off.", + tube_filled = "You've successfully refilled your air tank!" + }, + info = { + put_suit = "Putting on your diving suit...", + pullout_suit = "Taking off your diving suit...", + }, + warning = { + oxygen_one_minute = "You have less than one minute of air remaining!", + oxygen_running_out = "Your air tank is running out of air!", + }, +} + +Lang = Lang or Locale:new({ + phrases = Translations, + warnOnMissing = true +}) diff --git a/locales/es.lua b/locales/es.lua new file mode 100644 index 0000000..9d132c7 --- /dev/null +++ b/locales/es.lua @@ -0,0 +1,40 @@ +local Translations = { + error = { + ["canceled"] = "Cancelado", + ["911_chatmessage"] = "MENSAJE 911", + ["take_off"] = "/divingsuit para quitarte tu traje de buceo", + ["not_wearing"] = "No estás usando equipo de buceo..", + ["no_coral"] = "No tienes ningún coral para vender..", + ["not_standing_up"] = "Tienes que estar de pie para ponerte el equipo de buceo", + }, + success = { + ["took_out"] = "Te quitaste tu traje de neopreno", + }, + info = { + ["collecting_coral"] = "Recolectando coral", + ["diving_area"] = "Area de buceo", + ["collect_coral"] = "Recolectar coral", + ["collect_coral_dt"] = "[E] - Recolectar coral", + ["checking_pockets"] = "Revisando bolsillos para vender coral", + ["sell_coral"] = "Vender coral", + ["sell_coral_dt"] = "[E] - Vender coral", + ["blip_text"] = "Sitio de buceo - 911", + ["put_suit"] = "Ponerse equipo de buceo", + ["pullout_suit"] = "Saca un equipo de buceo..", + ["cop_msg"] = "Este coral puede ser robado", + ["cop_title"] = "Buceo ilegal", + ["command_diving"] = "Quitarse equipo de buceo", + }, + warning = { + ["oxygen_one_minute"] = "Le queda menos de 1 minuto de aire", + ["oxygen_running_out"] = "Su equipo de buceo se está quedando sin aire", + }, +} + +if GetConvar('qb_locale', 'en') == 'es' then + Lang = Locale:new({ + phrases = Translations, + warnOnMissing = true, + fallbackLang = Lang, + }) +end diff --git a/locales/et.lua b/locales/et.lua new file mode 100644 index 0000000..747bcb2 --- /dev/null +++ b/locales/et.lua @@ -0,0 +1,40 @@ +local Translations = { + error = { + ["canceled"] = "Tühistatud", + ["911_chatmessage"] = "911 KIRI", + ["take_off"] = "/divingsuit kui soovid võtta seljast sukeldumisvarustust", + ["not_wearing"] = "Te ei kanna sukeldumisvarustust ..", + ["no_coral"] = "Teil pole koralle, mida müüa..", + ["not_standing_up"] = "Sukeldumisvarustuse selga panemiseks peate püsti seisma", + }, + success = { + ["took_out"] = "Sa võtsid sukeldumisülikonna seljast", + }, + info = { + ["collecting_coral"] = "Korallide kogumine", + ["diving_area"] = "Sukeldumiskoht", + ["collect_coral"] = "Koguge koralle", + ["collect_coral_dt"] = "[E] - Koguge koralle", + ["checking_pockets"] = "Taskute kontrollimine koralli müümiseks", + ["sell_coral"] = "Müü koralle", + ["sell_coral_dt"] = "[E] - Müü koralle", + ["blip_text"] = "911 - Sukeldumiskoht", + ["put_suit"] = "Pane selga sukeldumisvarustust", + ["pullout_suit"] = "Võta välja sukeldumisvarustus ..", + ["cop_msg"] = "Se korall võib olla varastatud", + ["cop_title"] = "Ebaseaduslik sukeldumine", + ["command_diving"] = "Võta seljast Sukeldumisvarustuse", + }, + warning = { + ["oxygen_one_minute"] = "Teil on järelejäänud vähem kui 1 minut õhku", + ["oxygen_running_out"] = "Õhk hakkab otsa saama", + }, +} + +if GetConvar('qb_locale', 'en') == 'et' then + Lang = Locale:new({ + phrases = Translations, + warnOnMissing = true, + fallbackLang = Lang, + }) +end diff --git a/locales/fr.lua b/locales/fr.lua new file mode 100644 index 0000000..d4fbd53 --- /dev/null +++ b/locales/fr.lua @@ -0,0 +1,40 @@ +local Translations = { + error = { + canceled = "Annulé", + ["911_chatmessage"] = "MESSAGE 911", + no_coral = "Vous n'avez pas de corail à vendre", + not_standing_up = "Vous devez être debout pour vous equiper", + need_otube = "Vous avez besoin d'une bouteille d'oxygène", + oxygenlevel = "Le niveau d'oxygène est %{oxygenlevel}, Il doit être à 0%" + }, + success = { + took_out = "Vous avez enlevé votre kit de plongée", + tube_filled = "La Bouteille à été rempli" + }, + info = { + collecting_coral = "Vous récupérez des coraux", + diving_area = "Zone de plongée", + collect_coral = "Récupérer des coraux", + collect_coral_dt = "[E] - Récupérer des coraux", + checking_pockets = "Vend des coraux...", + sell_coral = "Vendre des coraux", + sell_coral_dt = "[E] - Vendre des coraux", + blip_text = "911 - Site de plongée", + put_suit = "Mettre votre kit de plongée", + pullout_suit = "Enlever votre kit de plongée", + cop_msg = "Ce corail peut être volé", + cop_title = "Plongée illégale" + }, + warning = { + oxygen_one_minute = "Il vous reste une minute d'oxygène", + oxygen_running_out = "Vous n'avez plus d'oxygène", + }, +} + +if GetConvar('qb_locale', 'en') == 'fr' then + Lang = Locale:new({ + phrases = Translations, + warnOnMissing = true, + fallbackLang = Lang, + }) +end diff --git a/locales/is.lua b/locales/is.lua new file mode 100644 index 0000000..5ee7192 --- /dev/null +++ b/locales/is.lua @@ -0,0 +1,40 @@ +local Translations = { + error = { + ["canceled"] = "Hætt", + ["911_chatmessage"] = "911 SKILABOÐ", + ["take_off"] = "/divingsuit til að fara úr köfunarbúningnum", + ["not_wearing"] = "Þú ert ekki í köfunarbúnaði ..", + ["no_coral"] = "Þú hefur engan kóral til að selja..", + ["not_standing_up"] = "Þú þarft að standa upp til að setja á þig köfunarbúnaðinn", + }, + success = { + ["took_out"] = "Þú tókst blautbúninginn þinn af þér", + }, + info = { + ["collecting_coral"] = "Söfnun kórals", + ["diving_area"] = "Köfunarsvæði", + ["collect_coral"] = "Safna kóral", + ["collect_coral_dt"] = "[E] - Safna kóral", + ["checking_pockets"] = "Athuga vasa til að selja kóral", + ["sell_coral"] = "Selja Kóral", + ["sell_coral_dt"] = "[E] - Selja Kóral", + ["blip_text"] = "911 - Köfunarsíða", + ["put_suit"] = "Farðu í köfunargalla", + ["pullout_suit"] = "Dragðu fram köfunargalla ..", + ["cop_msg"] = "Þessum kóral gæti verið stolið", + ["cop_title"] = "Ólögleg köfun", + ["command_diving"] = "Farðu úr köfunarbúningnum", + }, + warning = { + ["oxygen_one_minute"] = "Þú átt innan við 1 mínútu af lofti eftir", + ["oxygen_running_out"] = "Köfunarbúnaðurinn þinn er að verða uppiskroppa með loftið", + }, +} + +if GetConvar('qb_locale', 'en') == 'is' then + Lang = Locale:new({ + phrases = Translations, + warnOnMissing = true, + fallbackLang = Lang, + }) +end diff --git a/locales/it.lua b/locales/it.lua new file mode 100644 index 0000000..dbbde94 --- /dev/null +++ b/locales/it.lua @@ -0,0 +1,40 @@ +local Translations = { + error = { + ["canceled"] = "Annullato", + ["911_chatmessage"] = "911", + ["take_off"] = "/divingsuit per togliersi la muta da sub", + ["not_wearing"] = "Non indossi un'attrezzatura da sub..", + ["no_coral"] = "Non hai coralli da vendere..", + ["not_standing_up"] = "Devi essere in piedi per indossare l'attrezzatura subacquea", + }, + success = { + ["took_out"] = "Ti sei tolto la muta da sub", + }, + info = { + ["collecting_coral"] = "Raccogliendo coralli..", + ["diving_area"] = "Area di immersione", + ["collect_coral"] = "Raccogli coralli", + ["collect_coral_dt"] = "[E] - Raccogli coralli", + ["checking_pockets"] = "Controllando i coralli..", + ["sell_coral"] = "Vendi coralli", + ["sell_coral_dt"] = "[E] - Vendi coralli", + ["blip_text"] = "911 - Area di immersione", + ["put_suit"] = "Indossando muta da sub..", + ["pullout_suit"] = "Rimuovendo muta da sub..", + ["cop_msg"] = "Dei coralli potrebbero essere stati rubati", + ["cop_title"] = "Pesca illegale", + ["command_diving"] = "Togliti la muta da sub", + }, + warning = { + ["oxygen_one_minute"] = "Hai meno di 1 minuto di aria rimanente", + ["oxygen_running_out"] = "La tua attrezzatura da sub sta finendo l'aria", + }, +} + +if GetConvar('qb_locale', 'en') == 'it' then + Lang = Locale:new({ + phrases = Translations, + warnOnMissing = true, + fallbackLang = Lang, + }) +end diff --git a/locales/nl.lua b/locales/nl.lua new file mode 100644 index 0000000..fb365ad --- /dev/null +++ b/locales/nl.lua @@ -0,0 +1,40 @@ +local Translations = { + error = { + ["canceled"] = "Geannuleerd", + ["911_chatmessage"] = "911 BERICHT", + ["take_off"] = "/divingsuit om je duikpak uit te doen", + ["not_wearing"] = "Je hebt geen duikuitrusting aan..", + ["no_coral"] = "Je hebt geen koraal om te verkopen..", + ["not_standing_up"] = "Je moet rechtop staan ​​om de duikuitrusting aan te trekken", + }, + success = { + ["took_out"] = "Je hebt je wetsuit uitgedaan", + }, + info = { + ["collecting_coral"] = "Koraal verzamelen", + ["diving_area"] = "Duikgebied", + ["collect_coral"] = "Verzamel koraal", + ["collect_coral_dt"] = "[E] - Verzamel Koraal", + ["checking_pockets"] = "Zakken controleren om koraal te verkopen", + ["sell_coral"] = "Verkoop Koraal", + ["sell_coral_dt"] = "[E] - Verkoop Koraal", + ["blip_text"] = "911 - Duiklocatie", + ["put_suit"] = "Doe een duikpak aan", + ["pullout_suit"] = "Trek een duikpak uit ..", + ["cop_msg"] = "Dit koraal is mogelijk gestolen", + ["cop_title"] = "Illegaal duiken", + ["command_diving"] = "Doe je duikpak uit", + }, + warning = { + ["oxygen_one_minute"] = "Je hebt minder dan 1 minuut lucht over", + ["oxygen_running_out"] = "Je duikuitrusting heeft bijna geen lucht meer", + }, +} + +if GetConvar('qb_locale', 'en') == 'nl' then + Lang = Locale:new({ + phrases = Translations, + warnOnMissing = true, + fallbackLang = Lang, + }) +end diff --git a/locales/tr.lua b/locales/tr.lua new file mode 100644 index 0000000..75e791b --- /dev/null +++ b/locales/tr.lua @@ -0,0 +1,40 @@ +local Translations = { + error = { + ["canceled"] = "İptal edildi", + ["911_chatmessage"] = "911 MESAJI", + ["take_off"] = "dalış kıyafetini çıkarmak için /divingsuit yaz", + ["not_wearing"] = "Dalış teçhizatı takmıyorsun..", + ["no_coral"] = "Satacak mercanınız yok..", + ["not_standing_up"] = "Dalış teçhizatını takmak için ayağa kalkman gerekiyor", + }, + success = { + ["took_out"] = "Dalgıç giysini çıkardın", + }, + info = { + ["collecting_coral"] = "Mercan toplanıyor", + ["diving_area"] = "Dalış Alanı", + ["collect_coral"] = "Mercan topla", + ["collect_coral_dt"] = "[E] - Mercan Topla", + ["checking_pockets"] = "Mercan Satmak İçin Ceplerin Kontrol Ediliyor", + ["sell_coral"] = "Mercan Sat", + ["sell_coral_dt"] = "[E] - Mercan Sat", + ["blip_text"] = "911 - Dalış Alanı", + ["put_suit"] = "Dalış kıyafeti giy", + ["pullout_suit"] = "Dalgıç kıyafeti çıkarılıyor..", + ["cop_msg"] = "Çalıntı mercan olabilir", + ["cop_title"] = "Yasadışı dalış", + ["command_diving"] = "Dalış elbiseni çıkar", + }, + warning = { + ["oxygen_one_minute"] = "1 dakikadan az havanız kaldı", + ["oxygen_running_out"] = "Dalış teçhizatınızın havası bitiyor", + }, +} + +if GetConvar('qb_locale', 'en') == 'tr' then + Lang = Locale:new({ + phrases = Translations, + warnOnMissing = true, + fallbackLang = Lang, + }) +end diff --git a/server/main.lua b/server/main.lua new file mode 100644 index 0000000..524db63 --- /dev/null +++ b/server/main.lua @@ -0,0 +1,11 @@ +exports.qbx_core:CreateUseableItem("diving_gear", function(source) + TriggerClientEvent("qb-diving:client:UseGear", source) +end) + +exports.qbx_core:CreateUseableItem("diving_fill", function(source) + TriggerClientEvent("qb-diving:client:setoxygenlevel", source) +end) + +RegisterNetEvent('qb-diving:server:removeItemAfterFill', function() + exports.ox_inventory:RemoveItem(source, 'diving_fill', 1) +end) \ No newline at end of file