diff --git a/server-data/resources/[esx]/esx_menu_default/client/main.lua b/server-data/resources/[esx]/esx_menu_default/client/main.lua index 486729539..873b5a9e0 100644 --- a/server-data/resources/[esx]/esx_menu_default/client/main.lua +++ b/server-data/resources/[esx]/esx_menu_default/client/main.lua @@ -1,132 +1,132 @@ -local GUI, MenuType, OpenedMenus, CurrentNameSpace = {}, 'default', 0, nil +local GUI, MenuType, OpenedMenus, CurrentNameSpace = {}, "default", 0, nil GUI.Time = 0 local function openMenu(namespace, name, data) - CurrentNameSpace = namespace - OpenedMenus = OpenedMenus + 1 - SendNUIMessage({ - action = 'openMenu', - namespace = namespace, - name = name, - data = data - }) + CurrentNameSpace = namespace + OpenedMenus = OpenedMenus + 1 + SendNUIMessage({ + action = "openMenu", + namespace = namespace, + name = name, + data = data, + }) end local function closeMenu(namespace, name) - CurrentNameSpace = namespace - OpenedMenus = OpenedMenus - 1 - if OpenedMenus < 0 then - OpenedMenus = 0 - end - SendNUIMessage({ - action = 'closeMenu', - namespace = namespace, - name = name - }) + CurrentNameSpace = namespace + OpenedMenus = OpenedMenus - 1 + if OpenedMenus < 0 then + OpenedMenus = 0 + end + SendNUIMessage({ + action = "closeMenu", + namespace = namespace, + name = name, + }) end -AddEventHandler('onResourceStop', function(resource) - if GetCurrentResourceName() == resource and OpenedMenus > 0 then - ESX.UI.Menu.CloseAll() - elseif CurrentNameSpace ~= nil and CurrentNameSpace == resource and OpenedMenus > 0 then - ESX.UI.Menu.CloseAll() - end +AddEventHandler("onResourceStop", function(resource) + if GetCurrentResourceName() == resource and OpenedMenus > 0 then + ESX.UI.Menu.CloseAll() + elseif CurrentNameSpace ~= nil and CurrentNameSpace == resource and OpenedMenus > 0 then + ESX.UI.Menu.CloseAll() + end end) ESX.UI.Menu.RegisterType(MenuType, openMenu, closeMenu) -RegisterNUICallback('menu_submit', function(data, cb) - local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name) - if menu.submit ~= nil then - menu.submit(data, menu) - end - cb('OK') +RegisterNUICallback("menu_submit", function(data, cb) + local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name) + if menu.submit ~= nil then + menu.submit(data, menu) + end + cb("OK") end) -RegisterNUICallback('menu_cancel', function(data, cb) - local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name) +RegisterNUICallback("menu_cancel", function(data, cb) + local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name) - if menu.cancel ~= nil then - menu.cancel(data, menu) - end - cb('OK') + if menu.cancel ~= nil then + menu.cancel(data, menu) + end + cb("OK") end) -RegisterNUICallback('menu_change', function(data, cb) - local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name) +RegisterNUICallback("menu_change", function(data, cb) + local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name) - for i = 1, #data.elements, 1 do - menu.setElement(i, 'value', data.elements[i].value) + for i = 1, #data.elements, 1 do + menu.setElement(i, "value", data.elements[i].value) - if data.elements[i].selected then - menu.setElement(i, 'selected', true) - else - menu.setElement(i, 'selected', false) - end - end + if data.elements[i].selected then + menu.setElement(i, "selected", true) + else + menu.setElement(i, "selected", false) + end + end - if menu.change ~= nil then - menu.change(data, menu) - end - cb('OK') + if menu.change ~= nil then + menu.change(data, menu) + end + cb("OK") end) -ESX.RegisterInput('menu_default_enter', 'Submit menu item', 'keyboard', 'RETURN', function() - if OpenedMenus > 0 and (GetGameTimer() - GUI.Time) > 200 then - SendNUIMessage({ - action = 'controlPressed', - control = 'ENTER' - }) - GUI.Time = GetGameTimer() - end +ESX.RegisterInput("menu_default_enter", "Submit menu item", "keyboard", "RETURN", function() + if OpenedMenus > 0 and (GetGameTimer() - GUI.Time) > 200 then + SendNUIMessage({ + action = "controlPressed", + control = "ENTER", + }) + GUI.Time = GetGameTimer() + end end) -ESX.RegisterInput('menu_default_backspace', 'Close menu', 'keyboard', 'BACK', function() - if OpenedMenus > 0 then - SendNUIMessage({ - action = 'controlPressed', - control = 'BACKSPACE' - }) - GUI.Time = GetGameTimer() - end +ESX.RegisterInput("menu_default_backspace", "Close menu", "keyboard", "BACK", function() + if OpenedMenus > 0 then + SendNUIMessage({ + action = "controlPressed", + control = "BACKSPACE", + }) + GUI.Time = GetGameTimer() + end end) -ESX.RegisterInput('menu_default_top', 'Change menu focus to top item', 'keyboard', 'UP', function() - if OpenedMenus > 0 then - SendNUIMessage({ - action = 'controlPressed', - control = 'TOP' - }) - GUI.Time = GetGameTimer() - end +ESX.RegisterInput("menu_default_top", "Change menu focus to top item", "keyboard", "UP", function() + if OpenedMenus > 0 then + SendNUIMessage({ + action = "controlPressed", + control = "TOP", + }) + GUI.Time = GetGameTimer() + end end) -ESX.RegisterInput('menu_default_down', 'Change menu focus to down item', 'keyboard', 'DOWN', function() - if OpenedMenus > 0 then - SendNUIMessage({ - action = 'controlPressed', - control = 'DOWN' - }) - GUI.Time = GetGameTimer() - end +ESX.RegisterInput("menu_default_down", "Change menu focus to down item", "keyboard", "DOWN", function() + if OpenedMenus > 0 then + SendNUIMessage({ + action = "controlPressed", + control = "DOWN", + }) + GUI.Time = GetGameTimer() + end end) -ESX.RegisterInput('menu_default_left', 'Change menu slider to left', 'keyboard', 'LEFT', function() - if OpenedMenus > 0 then - SendNUIMessage({ - action = 'controlPressed', - control = 'LEFT' - }) - GUI.Time = GetGameTimer() - end +ESX.RegisterInput("menu_default_left", "Change menu slider to left", "keyboard", "LEFT", function() + if OpenedMenus > 0 then + SendNUIMessage({ + action = "controlPressed", + control = "LEFT", + }) + GUI.Time = GetGameTimer() + end end) -ESX.RegisterInput('menu_default_right', 'Change menu slider to right', 'keyboard', 'RIGHT', function() - if OpenedMenus > 0 then - SendNUIMessage({ - action = 'controlPressed', - control = 'RIGHT' - }) - GUI.Time = GetGameTimer() - end -end) \ No newline at end of file +ESX.RegisterInput("menu_default_right", "Change menu slider to right", "keyboard", "RIGHT", function() + if OpenedMenus > 0 then + SendNUIMessage({ + action = "controlPressed", + control = "RIGHT", + }) + GUI.Time = GetGameTimer() + end +end) diff --git a/server-data/resources/[esx]/esx_menu_default/fxmanifest.lua b/server-data/resources/[esx]/esx_menu_default/fxmanifest.lua index 4e4b6542e..9cea64063 100644 --- a/server-data/resources/[esx]/esx_menu_default/fxmanifest.lua +++ b/server-data/resources/[esx]/esx_menu_default/fxmanifest.lua @@ -1,15 +1,15 @@ -fx_version 'adamant' +fx_version("adamant") -game 'gta5' +game("gta5") -description 'Menu Default' -lua54 'yes' -version '1.0.0' +description("Menu Default") +lua54("yes") +version("1.0.0") -client_scripts {'@es_extended/imports.lua', 'client/main.lua'} +client_scripts({ "@es_extended/imports.lua", "client/main.lua" }) -ui_page {'html/ui.html'} +ui_page({ "html/ui.html" }) -files {'html/ui.html', 'html/css/app.css', 'html/js/mustache.min.js', 'html/js/app.js'} +files({ "html/ui.html", "html/css/app.css", "html/js/mustache.min.js", "html/js/app.js" }) -dependencies {'es_extended'} +dependencies({ "es_extended" }) diff --git a/server-data/resources/[esx]/esx_menu_default/html/js/app.js b/server-data/resources/[esx]/esx_menu_default/html/js/app.js index 9ee22bc7e..33c888bc0 100644 --- a/server-data/resources/[esx]/esx_menu_default/html/js/app.js +++ b/server-data/resources/[esx]/esx_menu_default/html/js/app.js @@ -18,143 +18,143 @@ ESX_MENU.pos = {}; ESX_MENU.open = function (namespace, name, data) { - if (typeof ESX_MENU.opened[namespace] === "undefined") { - ESX_MENU.opened[namespace] = {}; - } + if (typeof ESX_MENU.opened[namespace] === "undefined") { + ESX_MENU.opened[namespace] = {}; + } - if (typeof ESX_MENU.opened[namespace][name] != "undefined") { - ESX_MENU.close(namespace, name); - } + if (typeof ESX_MENU.opened[namespace][name] != "undefined") { + ESX_MENU.close(namespace, name); + } - if (typeof ESX_MENU.pos[namespace] === "undefined") { - ESX_MENU.pos[namespace] = {}; - } + if (typeof ESX_MENU.pos[namespace] === "undefined") { + ESX_MENU.pos[namespace] = {}; + } - for (let i = 0; i < data.elements.length; i++) { - if (typeof data.elements[i].type === "undefined") { - data.elements[i].type = "default"; - } + for (let i = 0; i < data.elements.length; i++) { + if (typeof data.elements[i].type === "undefined") { + data.elements[i].type = "default"; } + } - data._index = ESX_MENU.focus.length; - data._namespace = namespace; - data._name = name; + data._index = ESX_MENU.focus.length; + data._namespace = namespace; + data._name = name; - for (let i = 0; i < data.elements.length; i++) { - data.elements[i]._namespace = namespace; - data.elements[i]._name = name; - } + for (let i = 0; i < data.elements.length; i++) { + data.elements[i]._namespace = namespace; + data.elements[i]._name = name; + } - ESX_MENU.opened[namespace][name] = data; - ESX_MENU.pos[namespace][name] = 0; + ESX_MENU.opened[namespace][name] = data; + ESX_MENU.pos[namespace][name] = 0; - for (let i = 0; i < data.elements.length; i++) { - if (data.elements[i].selected) { - ESX_MENU.pos[namespace][name] = i; - } else { - data.elements[i].selected = false; - } + for (let i = 0; i < data.elements.length; i++) { + if (data.elements[i].selected) { + ESX_MENU.pos[namespace][name] = i; + } else { + data.elements[i].selected = false; } + } - ESX_MENU.focus.push({ - namespace: namespace, - name: name, - }); + ESX_MENU.focus.push({ + namespace: namespace, + name: name, + }); - ESX_MENU.render(); - $("#menu_" + namespace + "_" + name) - .find(".menu-item.selected")[0] - .scrollIntoView(); + ESX_MENU.render(); + $("#menu_" + namespace + "_" + name) + .find(".menu-item.selected")[0] + .scrollIntoView(); }; ESX_MENU.close = function (namespace, name) { delete ESX_MENU.opened[namespace][name]; - for (let i = 0; i < ESX_MENU.focus.length; i++) { - if (ESX_MENU.focus[i].namespace === namespace && ESX_MENU.focus[i].name === name) { - ESX_MENU.focus.splice(i, 1); - break; - } + for (let i = 0; i < ESX_MENU.focus.length; i++) { + if (ESX_MENU.focus[i].namespace === namespace && ESX_MENU.focus[i].name === name) { + ESX_MENU.focus.splice(i, 1); + break; } + } ESX_MENU.render(); }; ESX_MENU.render = function () { - let menuContainer = document.getElementById("menus"); - let focused = ESX_MENU.getFocused(); - menuContainer.innerHTML = ""; - $(menuContainer).hide(); + let menuContainer = document.getElementById("menus"); + let focused = ESX_MENU.getFocused(); + menuContainer.innerHTML = ""; + $(menuContainer).hide(); - for (let namespace in ESX_MENU.opened) { - for (let name in ESX_MENU.opened[namespace]) { - let menuData = ESX_MENU.opened[namespace][name]; - let view = JSON.parse(JSON.stringify(menuData)); + for (let namespace in ESX_MENU.opened) { + for (let name in ESX_MENU.opened[namespace]) { + let menuData = ESX_MENU.opened[namespace][name]; + let view = JSON.parse(JSON.stringify(menuData)); - for (let i = 0; i < menuData.elements.length; i++) { - let element = view.elements[i]; + for (let i = 0; i < menuData.elements.length; i++) { + let element = view.elements[i]; - switch (element.type) { - case "default": - break; - - case "slider": { - element.isSlider = true; - element.sliderLabel = typeof element.options === "undefined" ? element.value : element.options[element.value]; + switch (element.type) { + case "default": + break; - break; - } + case "slider": { + element.isSlider = true; + element.sliderLabel = typeof element.options === "undefined" ? element.value : element.options[element.value]; - default: - break; - } + break; + } - if (i === ESX_MENU.pos[namespace][name]) { - element.selected = true; - } - } + default: + break; + } - let menu = $(Mustache.render(MenuTpl, view))[0]; - $(menu).hide(); - menuContainer.appendChild(menu); + if (i === ESX_MENU.pos[namespace][name]) { + element.selected = true; } - } + } - if (typeof focused != "undefined") { - $("#menu_" + focused.namespace + "_" + focused.name).show(); + let menu = $(Mustache.render(MenuTpl, view))[0]; + $(menu).hide(); + menuContainer.appendChild(menu); } + } - $(menuContainer).show(); + if (typeof focused != "undefined") { + $("#menu_" + focused.namespace + "_" + focused.name).show(); + } + + $(menuContainer).show(); }; ESX_MENU.submit = function (namespace, name, data) { - $.post("http://" + ESX_MENU.ResourceName + "/menu_submit", - JSON.stringify({ - _namespace: namespace, - _name: name, - current: data, - elements: ESX_MENU.opened[namespace][name].elements, - }) - ); + $.post("http://" + ESX_MENU.ResourceName + "/menu_submit", + JSON.stringify({ + _namespace: namespace, + _name: name, + current: data, + elements: ESX_MENU.opened[namespace][name].elements, + }) + ); }; ESX_MENU.cancel = function (namespace, name) { - $.post("http://" + ESX_MENU.ResourceName + "/menu_cancel", - JSON.stringify({ - _namespace: namespace, - _name: name, - }) - ); + $.post("http://" + ESX_MENU.ResourceName + "/menu_cancel", + JSON.stringify({ + _namespace: namespace, + _name: name, + }) + ); }; ESX_MENU.change = function (namespace, name, data) { $.post("http://" + ESX_MENU.ResourceName + "/menu_change", - JSON.stringify({ - _namespace: namespace, - _name: name, - current: data, - elements: ESX_MENU.opened[namespace][name].elements, - })); + JSON.stringify({ + _namespace: namespace, + _name: name, + current: data, + elements: ESX_MENU.opened[namespace][name].elements, + })); }; ESX_MENU.getFocused = function () { @@ -162,196 +162,196 @@ }; window.onData = (data) => { - switch (data.action) { - case "openMenu": { - ESX_MENU.open(data.namespace, data.name, data.data); - break; - } - - case "closeMenu": { - ESX_MENU.close(data.namespace, data.name); - break; - } - - case "controlPressed": { - switch (data.control) { - case "ENTER": { - let focused = ESX_MENU.getFocused(); - - if (typeof focused != "undefined") { - let menu = ESX_MENU.opened[focused.namespace][focused.name]; - let pos = ESX_MENU.pos[focused.namespace][focused.name]; - let elem = menu.elements[pos]; - - if (menu.elements.length > 0) { - ESX_MENU.submit(focused.namespace, focused.name, elem); - } - } + switch (data.action) { + case "openMenu": { + ESX_MENU.open(data.namespace, data.name, data.data); + break; + } - break; - } + case "closeMenu": { + ESX_MENU.close(data.namespace, data.name); + break; + } - case "BACKSPACE": { - let focused = ESX_MENU.getFocused(); + case "controlPressed": { + switch (data.control) { + case "ENTER": { + let focused = ESX_MENU.getFocused(); - if (typeof focused != "undefined") { - ESX_MENU.cancel(focused.namespace, focused.name); - } + if (typeof focused != "undefined") { + let menu = ESX_MENU.opened[focused.namespace][focused.name]; + let pos = ESX_MENU.pos[focused.namespace][focused.name]; + let elem = menu.elements[pos]; - break; - } + if (menu.elements.length > 0) { + ESX_MENU.submit(focused.namespace, focused.name, elem); + } + } - case "TOP": { - let focused = ESX_MENU.getFocused(); + break; + } - if (typeof focused != "undefined") { - let menu = ESX_MENU.opened[focused.namespace][focused.name]; - let pos = ESX_MENU.pos[focused.namespace][focused.name]; + case "BACKSPACE": { + let focused = ESX_MENU.getFocused(); - if (pos > 0) { - ESX_MENU.pos[focused.namespace][focused.name]--; - } else { - ESX_MENU.pos[focused.namespace][focused.name] = menu.elements.length - 1; - } + if (typeof focused != "undefined") { + ESX_MENU.cancel(focused.namespace, focused.name); + } - let elem = menu.elements[ESX_MENU.pos[focused.namespace][focused.name]]; + break; + } - for (let i = 0; i < menu.elements.length; i++) { - if (i === ESX_MENU.pos[focused.namespace][focused.name]) { - menu.elements[i].selected = true; - } else { - menu.elements[i].selected = false; - } - } + case "TOP": { + let focused = ESX_MENU.getFocused(); - ESX_MENU.change(focused.namespace, focused.name, elem); - ESX_MENU.render(); + if (typeof focused != "undefined") { + let menu = ESX_MENU.opened[focused.namespace][focused.name]; + let pos = ESX_MENU.pos[focused.namespace][focused.name]; - $("#menu_" + focused.namespace + "_" + focused.name) - .find(".menu-item.selected")[0] - .scrollIntoView(); - } + if (pos > 0) { + ESX_MENU.pos[focused.namespace][focused.name]--; + } else { + ESX_MENU.pos[focused.namespace][focused.name] = menu.elements.length - 1; + } - break; - } + let elem = menu.elements[ESX_MENU.pos[focused.namespace][focused.name]]; - case "DOWN": { - let focused = ESX_MENU.getFocused(); + for (let i = 0; i < menu.elements.length; i++) { + if (i === ESX_MENU.pos[focused.namespace][focused.name]) { + menu.elements[i].selected = true; + } else { + menu.elements[i].selected = false; + } + } - if (typeof focused != "undefined") { - let menu = ESX_MENU.opened[focused.namespace][focused.name]; - let pos = ESX_MENU.pos[focused.namespace][focused.name]; - let length = menu.elements.length; + ESX_MENU.change(focused.namespace, focused.name, elem); + ESX_MENU.render(); - if (pos < length - 1) { - ESX_MENU.pos[focused.namespace][focused.name]++; - } else { - ESX_MENU.pos[focused.namespace][focused.name] = 0; - } + $("#menu_" + focused.namespace + "_" + focused.name) + .find(".menu-item.selected")[0] + .scrollIntoView(); + } - let elem = menu.elements[ESX_MENU.pos[focused.namespace][focused.name]]; + break; + } - for (let i = 0; i < menu.elements.length; i++) { - if (i === ESX_MENU.pos[focused.namespace][focused.name]) { - menu.elements[i].selected = true; - } else { - menu.elements[i].selected = false; - } - } + case "DOWN": { + let focused = ESX_MENU.getFocused(); - ESX_MENU.change(focused.namespace, focused.name, elem); - ESX_MENU.render(); + if (typeof focused != "undefined") { + let menu = ESX_MENU.opened[focused.namespace][focused.name]; + let pos = ESX_MENU.pos[focused.namespace][focused.name]; + let length = menu.elements.length; - $("#menu_" + focused.namespace + "_" + focused.name) - .find(".menu-item.selected")[0] - .scrollIntoView(); - } + if (pos < length - 1) { + ESX_MENU.pos[focused.namespace][focused.name]++; + } else { + ESX_MENU.pos[focused.namespace][focused.name] = 0; + } - break; - } + let elem = menu.elements[ESX_MENU.pos[focused.namespace][focused.name]]; - case "LEFT": { - let focused = ESX_MENU.getFocused(); + for (let i = 0; i < menu.elements.length; i++) { + if (i === ESX_MENU.pos[focused.namespace][focused.name]) { + menu.elements[i].selected = true; + } else { + menu.elements[i].selected = false; + } + } - if (typeof focused != "undefined") { - let menu = ESX_MENU.opened[focused.namespace][focused.name]; - let pos = ESX_MENU.pos[focused.namespace][focused.name]; - let elem = menu.elements[pos]; + ESX_MENU.change(focused.namespace, focused.name, elem); + ESX_MENU.render(); - switch (elem.type) { - case "default": - break; + $("#menu_" + focused.namespace + "_" + focused.name) + .find(".menu-item.selected")[0] + .scrollIntoView(); + } - case "slider": { - let min = typeof elem.min === "undefined" ? 0 : elem.min; + break; + } - if (elem.value > min) { - elem.value--; - ESX_MENU.change(focused.namespace, focused.name, elem); - } + case "LEFT": { + let focused = ESX_MENU.getFocused(); - ESX_MENU.render(); - break; - } + if (typeof focused != "undefined") { + let menu = ESX_MENU.opened[focused.namespace][focused.name]; + let pos = ESX_MENU.pos[focused.namespace][focused.name]; + let elem = menu.elements[pos]; - default: - break; - } + switch (elem.type) { + case "default": + break; - $("#menu_" + focused.namespace + "_" + focused.name) - .find(".menu-item.selected")[0] - .scrollIntoView(); - } + case "slider": { + let min = typeof elem.min === "undefined" ? 0 : elem.min; - break; + if (elem.value > min) { + elem.value--; + ESX_MENU.change(focused.namespace, focused.name, elem); } - case "RIGHT": { - let focused = ESX_MENU.getFocused(); + ESX_MENU.render(); + break; + } - if (typeof focused != "undefined") { - let menu = ESX_MENU.opened[focused.namespace][focused.name]; - let pos = ESX_MENU.pos[focused.namespace][focused.name]; - let elem = menu.elements[pos]; + default: + break; + } - switch (elem.type) { - case "default": - break; + $("#menu_" + focused.namespace + "_" + focused.name) + .find(".menu-item.selected")[0] + .scrollIntoView(); + } - case "slider": { - if (typeof elem.options != "undefined" && elem.value < elem.options.length - 1) { - elem.value++; - ESX_MENU.change(focused.namespace, focused.name, elem); - } + break; + } - if (typeof elem.max != "undefined" && elem.value < elem.max) { - elem.value++; - ESX_MENU.change(focused.namespace, focused.name, elem); - } + case "RIGHT": { + let focused = ESX_MENU.getFocused(); - ESX_MENU.render(); - break; - } + if (typeof focused != "undefined") { + let menu = ESX_MENU.opened[focused.namespace][focused.name]; + let pos = ESX_MENU.pos[focused.namespace][focused.name]; + let elem = menu.elements[pos]; - default: - break; - } + switch (elem.type) { + case "default": + break; - $("#menu_" + focused.namespace + "_" + focused.name) - .find(".menu-item.selected")[0] - .scrollIntoView(); - } + case "slider": { + if (typeof elem.options != "undefined" && elem.value < elem.options.length - 1) { + elem.value++; + ESX_MENU.change(focused.namespace, focused.name, elem); + } - break; + if (typeof elem.max != "undefined" && elem.value < elem.max) { + elem.value++; + ESX_MENU.change(focused.namespace, focused.name, elem); } - default: - break; + ESX_MENU.render(); + break; + } + + default: + break; } - break; + $("#menu_" + focused.namespace + "_" + focused.name) + .find(".menu-item.selected")[0] + .scrollIntoView(); + } + + break; } + + default: + break; + } + + break; } + } }; window.onload = function (e) { diff --git a/server-data/resources/[esx]/esx_menu_default/html/ui.html b/server-data/resources/[esx]/esx_menu_default/html/ui.html index e7660d818..0c8065a7d 100644 --- a/server-data/resources/[esx]/esx_menu_default/html/ui.html +++ b/server-data/resources/[esx]/esx_menu_default/html/ui.html @@ -1,16 +1,18 @@ - - - - - - - - + + + + + + + + + + + + + + - - - - \ No newline at end of file diff --git a/server-data/resources/[esx]/esx_multicharacter/client/main.lua b/server-data/resources/[esx]/esx_multicharacter/client/main.lua index 239e63812..0d655fa5d 100644 --- a/server-data/resources/[esx]/esx_multicharacter/client/main.lua +++ b/server-data/resources/[esx]/esx_multicharacter/client/main.lua @@ -11,7 +11,7 @@ if ESX.GetConfig().Multichar then if NetworkIsPlayerActive(PlayerId()) then exports.spawnmanager:setAutoSpawn(false) DoScreenFadeOut(0) - while GetResourceState('esx_context') ~= 'started' do + while GetResourceState("esx_context") ~= "started" do Wait(100) end TriggerEvent("esx_multicharacter:SetupCharacters") @@ -23,8 +23,8 @@ if ESX.GetConfig().Multichar then local canRelog, cam, spawned = true, nil, nil local Characters = {} - RegisterNetEvent('esx_multicharacter:SetupCharacters') - AddEventHandler('esx_multicharacter:SetupCharacters', function() + RegisterNetEvent("esx_multicharacter:SetupCharacters") + AddEventHandler("esx_multicharacter:SetupCharacters", function() ESX.PlayerLoaded = false ESX.PlayerData = {} spawned = false @@ -41,7 +41,7 @@ if ESX.GetConfig().Multichar then StartLoop() ShutdownLoadingScreen() ShutdownLoadingScreenNui() - TriggerEvent('esx:loadingScreenOff') + TriggerEvent("esx:loadingScreenOff") Wait(200) TriggerServerEvent("esx_multicharacter:SetupCharacters") end) @@ -65,7 +65,7 @@ if ESX.GetConfig().Multichar then HideHudComponentThisFrame(21) HideHudAndRadarThisFrame() Wait(0) - local vehicles = GetGamePool('CVehicle') + local vehicles = GetGamePool("CVehicle") for i = 1, #vehicles do SetEntityLocallyInvisible(vehicles[i]) end @@ -105,19 +105,25 @@ if ESX.GetConfig().Multichar then z = SpawnCoords.z, heading = SpawnCoords.w, model = Characters[index].model or mp_m_freemode_01, - skipFade = true + skipFade = true, }, function() canRelog = false if Characters[index] then local skin = Characters[index].skin or Config.Default if not Characters[index].model then - if Characters[index].sex == _U('female') then skin.sex = 1 else skin.sex = 0 end + if Characters[index].sex == _U("female") then + skin.sex = 1 + else + skin.sex = 0 + end end - TriggerEvent('skinchanger:loadSkin', skin) + TriggerEvent("skinchanger:loadSkin", skin) end DoScreenFadeIn(600) end) - repeat Wait(200) until not IsScreenFadedOut() + repeat + Wait(200) + until not IsScreenFadedOut() elseif Characters[index] and Characters[index].skin then if Characters[spawned] and Characters[spawned].model then RequestModel(Characters[index].model) @@ -128,7 +134,7 @@ if ESX.GetConfig().Multichar then SetPlayerModel(PlayerId(), Characters[index].model) SetModelAsNoLongerNeeded(Characters[index].model) end - TriggerEvent('skinchanger:loadSkin', Characters[index].skin) + TriggerEvent("skinchanger:loadSkin", Characters[index].skin) end spawned = index local playerPed = PlayerPedId() @@ -137,21 +143,38 @@ if ESX.GetConfig().Multichar then SetEntityAlpha(playerPed, 255) SendNUIMessage({ action = "openui", - character = Characters[spawned] + character = Characters[spawned], }) end function CharacterDeleteConfirmation(Characters, slots, SelectedCharacter, value) local elements = { - { title = _U('char_delete_confirmation'), icon = "fa-solid fa-users", description = _U('char_delete_confirmation_description'), unselectable = true }, - { title = _U('char_delete'), icon = "fa-solid fa-xmark", description = _U('char_delete_yes_description'), action = 'delete', value = value }, - { title = _U('return'), unselectable = false, icon = "fa-solid fa-arrow-left", description = _U('char_delete_no_description'), action = "return" } + { + title = _U("char_delete_confirmation"), + icon = "fa-solid fa-users", + description = _U("char_delete_confirmation_description"), + unselectable = true, + }, + { + title = _U("char_delete"), + icon = "fa-solid fa-xmark", + description = _U("char_delete_yes_description"), + action = "delete", + value = value, + }, + { + title = _U("return"), + unselectable = false, + icon = "fa-solid fa-arrow-left", + description = _U("char_delete_no_description"), + action = "return", + }, } ESX.OpenContext("left", elements, function(_, Action) if Action.action == "delete" then ESX.CloseContext() - TriggerServerEvent('esx_multicharacter:DeleteCharacter', Action.value) + TriggerServerEvent("esx_multicharacter:DeleteCharacter", Action.value) spawned = false elseif Action.action == "return" then CharacterOptions(Characters, slots, SelectedCharacter) @@ -160,21 +183,55 @@ if ESX.GetConfig().Multichar then end function CharacterOptions(Characters, slots, SelectedCharacter) - local elements = { { title = _U('character', Characters[SelectedCharacter.value].firstname .. " " .. Characters[SelectedCharacter.value].lastname), icon = "fa-regular fa-user", unselectable = true }, - { title = _U('return'), unselectable = false, icon = "fa-solid fa-arrow-left", description = _U('return_description'), action = "return" } } + local elements = { + { + title = _U( + "character", + Characters[SelectedCharacter.value].firstname .. " " .. Characters[SelectedCharacter.value].lastname + ), + icon = "fa-regular fa-user", + unselectable = true, + }, + { + title = _U("return"), + unselectable = false, + icon = "fa-solid fa-arrow-left", + description = _U("return_description"), + action = "return", + }, + } if not Characters[SelectedCharacter.value].disabled then - elements[3] = { title = _U('char_play'), description = _U('char_play_description'), icon = "fa-solid fa-play", action = 'play', value = SelectedCharacter.value } + elements[3] = { + title = _U("char_play"), + description = _U("char_play_description"), + icon = "fa-solid fa-play", + action = "play", + value = SelectedCharacter.value, + } else - elements[3] = { title = _U('char_disabled'), value = SelectedCharacter.value, icon = "fa-solid fa-xmark", description = _U('char_disabled_description'), } + elements[3] = { + title = _U("char_disabled"), + value = SelectedCharacter.value, + icon = "fa-solid fa-xmark", + description = _U("char_disabled_description"), + } + end + if Config.CanDelete then + elements[4] = { + title = _U("char_delete"), + icon = "fa-solid fa-xmark", + description = _U("char_delete_description"), + action = "delete", + value = SelectedCharacter.value, + } end - if Config.CanDelete then elements[4] = { title = _U('char_delete'), icon = "fa-solid fa-xmark", description = _U('char_delete_description'), action = 'delete', value = SelectedCharacter.value } end ESX.OpenContext("left", elements, function(_, Action) if Action.action == "play" then SendNUIMessage({ - action = "closeui" + action = "closeui", }) ESX.CloseContext() - TriggerServerEvent('esx_multicharacter:CharacterChosen', Action.value, false) + TriggerServerEvent("esx_multicharacter:CharacterChosen", Action.value, false) elseif Action.action == "delete" then CharacterDeleteConfirmation(Characters, slots, SelectedCharacter, Action.value) elseif Action.action == "return" then @@ -185,13 +242,28 @@ if ESX.GetConfig().Multichar then function SelectCharacterMenu(Characters, slots) local Character = next(Characters) - local elements = { { title = _U('select_char'), icon = "fa-solid fa-users", description = _U('select_char_description'), unselectable = true } } + local elements = { + { + title = _U("select_char"), + icon = "fa-solid fa-users", + description = _U("select_char_description"), + unselectable = true, + }, + } for k, v in pairs(Characters) do if not v.model and v.skin then - if v.skin.model then v.model = v.skin.model elseif v.skin.sex == 1 then v.model = mp_f_freemode_01 else v.model = mp_m_freemode_01 end + if v.skin.model then + v.model = v.skin.model + elseif v.skin.sex == 1 then + v.model = mp_f_freemode_01 + else + v.model = mp_m_freemode_01 + end end - if not spawned then SetupCharacter(Character) end - local label = v.firstname .. ' ' .. v.lastname + if not spawned then + SetupCharacter(Character) + end + local label = v.firstname .. " " .. v.lastname if Characters[k].disabled then elements[#elements + 1] = { title = label, icon = "fa-regular fa-user", value = v.id } else @@ -199,7 +271,8 @@ if ESX.GetConfig().Multichar then end end if #elements - 1 < slots then - elements[#elements + 1] = { title = _U('create_char'), icon = "fa-solid fa-plus", value = (#elements + 1), new = true } + elements[#elements + 1] = + { title = _U("create_char"), icon = "fa-solid fa-plus", value = (#elements + 1), new = true } end ESX.OpenContext("left", elements, function(_, SelectedCharacter) @@ -213,13 +286,13 @@ if ESX.GetConfig().Multichar then end end local slot = GetSlot() - TriggerServerEvent('esx_multicharacter:CharacterChosen', slot, true) - TriggerEvent('esx_identity:showRegisterIdentity') + TriggerServerEvent("esx_multicharacter:CharacterChosen", slot, true) + TriggerEvent("esx_identity:showRegisterIdentity") local playerPed = PlayerPedId() SetPedAoBlobRendering(playerPed, false) SetEntityAlpha(playerPed, 0) SendNUIMessage({ - action = "closeui" + action = "closeui", }) else CharacterOptions(Characters, slots, SelectedCharacter) @@ -231,8 +304,8 @@ if ESX.GetConfig().Multichar then end, nil, false) end - RegisterNetEvent('esx_multicharacter:SetupUI') - AddEventHandler('esx_multicharacter:SetupUI', function(data, slots) + RegisterNetEvent("esx_multicharacter:SetupUI") + AddEventHandler("esx_multicharacter:SetupUI", function(data, slots) DoScreenFadeOut(0) Characters = data slots = slots @@ -241,7 +314,7 @@ if ESX.GetConfig().Multichar then if not Character then SendNUIMessage({ - action = "closeui" + action = "closeui", }) exports.spawnmanager:spawnPlayer({ x = SpawnCoords.x, @@ -249,7 +322,7 @@ if ESX.GetConfig().Multichar then z = SpawnCoords.z, heading = SpawnCoords.w, model = mp_m_freemode_01, - skipFade = true + skipFade = true, }, function() canRelog = false DoScreenFadeIn(400) @@ -257,16 +330,16 @@ if ESX.GetConfig().Multichar then local playerPed = PlayerPedId() SetPedAoBlobRendering(playerPed, false) SetEntityAlpha(playerPed, 0) - TriggerServerEvent('esx_multicharacter:CharacterChosen', 1, true) - TriggerEvent('esx_identity:showRegisterIdentity') + TriggerServerEvent("esx_multicharacter:CharacterChosen", 1, true) + TriggerEvent("esx_identity:showRegisterIdentity") end) else SelectCharacterMenu(Characters, slots) end end) - RegisterNetEvent('esx:playerLoaded') - AddEventHandler('esx:playerLoaded', function(playerData, isNew, skin) + RegisterNetEvent("esx:playerLoaded") + AddEventHandler("esx:playerLoaded", function(playerData, isNew, skin) local spawn = playerData.coords or Config.Spawn if isNew or not skin or #skin == 1 then local finished = false @@ -280,20 +353,22 @@ if ESX.GetConfig().Multichar then end SetPlayerModel(PlayerId(), model) SetModelAsNoLongerNeeded(model) - TriggerEvent('skinchanger:loadSkin', skin, function() + TriggerEvent("skinchanger:loadSkin", skin, function() local playerPed = PlayerPedId() SetPedAoBlobRendering(playerPed, true) ResetEntityAlpha(playerPed) - TriggerEvent('esx_skin:openSaveableMenu', function() + TriggerEvent("esx_skin:openSaveableMenu", function() finished = true end, function() finished = true end) end) - repeat Wait(200) until finished + repeat + Wait(200) + until finished end - DoScreenFadeOut(750) + DoScreenFadeOut(750) Wait(750) SetCamActive(cam, false) @@ -303,38 +378,42 @@ if ESX.GetConfig().Multichar then FreezeEntityPosition(playerPed, true) SetEntityCoordsNoOffset(playerPed, spawn.x, spawn.y, spawn.z, false, false, false, true) SetEntityHeading(playerPed, spawn.heading) - if not isNew then TriggerEvent('skinchanger:loadSkin', skin or Characters[spawned].skin) end - Wait(500) + if not isNew then + TriggerEvent("skinchanger:loadSkin", skin or Characters[spawned].skin) + end + Wait(500) DoScreenFadeIn(750) Wait(750) - repeat Wait(200) until not IsScreenFadedOut() - TriggerServerEvent('esx:onPlayerSpawn') - TriggerEvent('esx:onPlayerSpawn') - TriggerEvent('playerSpawned') - TriggerEvent('esx:restoreLoadout') + repeat + Wait(200) + until not IsScreenFadedOut() + TriggerServerEvent("esx:onPlayerSpawn") + TriggerEvent("esx:onPlayerSpawn") + TriggerEvent("playerSpawned") + TriggerEvent("esx:restoreLoadout") Characters, hidePlayers = {}, false end) - RegisterNetEvent('esx:onPlayerLogout') - AddEventHandler('esx:onPlayerLogout', function() + RegisterNetEvent("esx:onPlayerLogout") + AddEventHandler("esx:onPlayerLogout", function() DoScreenFadeOut(500) Wait(1000) spawned = false TriggerEvent("esx_multicharacter:SetupCharacters") - TriggerEvent('esx_skin:resetFirstSpawn') + TriggerEvent("esx_skin:resetFirstSpawn") end) if Config.Relog then - RegisterCommand('relog', function() + RegisterCommand("relog", function() if canRelog then canRelog = false - TriggerServerEvent('esx_multicharacter:relog') + TriggerServerEvent("esx_multicharacter:relog") ESX.SetTimeout(10000, function() canRelog = true end) end end) end -end \ No newline at end of file +end diff --git a/server-data/resources/[esx]/esx_multicharacter/config.lua b/server-data/resources/[esx]/esx_multicharacter/config.lua index b60438446..f4002af82 100644 --- a/server-data/resources/[esx]/esx_multicharacter/config.lua +++ b/server-data/resources/[esx]/esx_multicharacter/config.lua @@ -1,5 +1,5 @@ Config = {} -Config.Locale = 'it' +Config.Locale = "it" -- Allows players to delete their characters Config.CanDelete = true @@ -11,7 +11,7 @@ if IsDuplicityVersion() then -------------------- -- Text to prepend to each character (char#:identifier) - keep it short - Config.Prefix = 'char' + Config.Prefix = "char" else -- Sets the location for the character selection scene -- To set the spawn location for new characters, modify the default value in the users SQL table @@ -122,7 +122,7 @@ else beard_1 = 11, beard_2 = 10, beard_3 = 0, - beard_4 = 0 + beard_4 = 0, }, ["f"] = { mom = 28, @@ -219,7 +219,7 @@ else beard_1 = 0, beard_2 = 0, beard_3 = 0, - beard_4 = 0 - } + beard_4 = 0, + }, } end diff --git a/server-data/resources/[esx]/esx_multicharacter/fxmanifest.lua b/server-data/resources/[esx]/esx_multicharacter/fxmanifest.lua index 99e4069c8..cec3f9920 100644 --- a/server-data/resources/[esx]/esx_multicharacter/fxmanifest.lua +++ b/server-data/resources/[esx]/esx_multicharacter/fxmanifest.lua @@ -1,19 +1,19 @@ -fx_version 'cerulean' +fx_version("cerulean") -game 'gta5' -author 'ESX-Framework - Linden - KASH' -description 'Official Multicharacter System For ESX Legacy' -version '1.0.0' -lua54 'yes' +game("gta5") +author("ESX-Framework - Linden - KASH") +description("Official Multicharacter System For ESX Legacy") +version("1.0.0") +lua54("yes") -dependencies { 'es_extended', 'esx_context', 'esx_identity', 'esx_skin' } +dependencies({ "es_extended", "esx_context", "esx_identity", "esx_skin" }) -shared_scripts { '@es_extended/imports.lua', '@es_extended/locale.lua', 'locales/*.lua', 'config.lua' } +shared_scripts({ "@es_extended/imports.lua", "@es_extended/locale.lua", "locales/*.lua", "config.lua" }) -server_scripts { '@oxmysql/lib/MySQL.lua', 'server/*.lua' } +server_scripts({ "@oxmysql/lib/MySQL.lua", "server/*.lua" }) -client_scripts { 'client/*.lua' } +client_scripts({ "client/*.lua" }) -ui_page { 'html/ui.html' } +ui_page({ "html/ui.html" }) -files { 'html/ui.html', 'html/css/main.css', 'html/js/app.js', 'html/locales/*.js' } +files({ "html/ui.html", "html/css/main.css", "html/js/app.js", "html/locales/*.js" }) diff --git a/server-data/resources/[esx]/esx_multicharacter/html/css/main.css b/server-data/resources/[esx]/esx_multicharacter/html/css/main.css index b6d866d54..9e652847e 100644 --- a/server-data/resources/[esx]/esx_multicharacter/html/css/main.css +++ b/server-data/resources/[esx]/esx_multicharacter/html/css/main.css @@ -1,5 +1,6 @@ @import url("https://fonts.googleapis.com/css2?family=Raleway:wght@300;600&display=swap"); @import url("https://fonts.googleapis.com/css2?family=Oswald&display=swap"); + * { margin: 0; padding: 0; @@ -73,4 +74,4 @@ h1 { padding-top: 1.3rem; display: block; font-weight: 0; -} +} \ No newline at end of file diff --git a/server-data/resources/[esx]/esx_multicharacter/html/js/app.js b/server-data/resources/[esx]/esx_multicharacter/html/js/app.js index 00cdb7f9c..0cbdb5c4a 100644 --- a/server-data/resources/[esx]/esx_multicharacter/html/js/app.js +++ b/server-data/resources/[esx]/esx_multicharacter/html/js/app.js @@ -13,34 +13,34 @@ var money = Intl.NumberFormat("en-US", { $("[data-charid=1]") .html( '

' + - `${translate.name} ` + - "

" + - data.firstname + - " " + - data.lastname + - '

' + - `${translate.job} ` + - "

" + - data.job + - " " + - data.job_grade + - '

' + - `${translate.money} ` + - "

" + - money.format(data.money) + - '

' + - `${translate.bank} ` + - "

" + - money.format(data.bank) + - '

' + - `${translate.dob} ` + - "

" + - data.dateofbirth + - '

' + - `${translate.gender} ` + - "

" + - data.sex + - "

" + `${translate.name} ` + + "" + + data.firstname + + " " + + data.lastname + + '

' + + `${translate.job} ` + + "

" + + data.job + + " " + + data.job_grade + + '

' + + `${translate.money} ` + + "

" + + money.format(data.money) + + '

' + + `${translate.bank} ` + + "

" + + money.format(data.bank) + + '

' + + `${translate.dob} ` + + "

" + + data.dateofbirth + + '

' + + `${translate.gender} ` + + "

" + + data.sex + + "

" ) .attr("data-ischar", "true"); }; diff --git a/server-data/resources/[esx]/esx_multicharacter/html/ui.html b/server-data/resources/[esx]/esx_multicharacter/html/ui.html index 77ee78f9b..40d1c1591 100644 --- a/server-data/resources/[esx]/esx_multicharacter/html/ui.html +++ b/server-data/resources/[esx]/esx_multicharacter/html/ui.html @@ -1,22 +1,26 @@ - - - - - - - - - -
-
Character Info
-
-

-
-
- + + + + + + + + + + + +
+
Character Info
+
+

+
- - - - + +
+ + + + + \ No newline at end of file diff --git a/server-data/resources/[esx]/esx_multicharacter/locales/es.lua b/server-data/resources/[esx]/esx_multicharacter/locales/es.lua index 0f3cc6bf8..5c1f6b624 100644 --- a/server-data/resources/[esx]/esx_multicharacter/locales/es.lua +++ b/server-data/resources/[esx]/esx_multicharacter/locales/es.lua @@ -1,28 +1,28 @@ Locales["es"] = { - ["male"] = "Masculino", - ["female"] = "Femenino", - ["select_char"] = "Seleccionar personaje", - ["select_char_description"] = "Selecciona un personaje para jugar.", - ["create_char"] = "Crear nuevo personaje", - ["char_play"] = "Seleccionar personaje", - ["char_play_description"] = "Ingresar a la ciudad.", - ["char_disabled"] = "Este personaje está deshabilitado", - ["char_disabled_description"] = "Este personaje no se encuentra disponible.", - ["char_delete"] = "Borrar el personaje seleccionado", - ["char_delete_description"] = "Eliminar este personaje.", - ["character"] = "Personaje: %s", - ["return"] = "Volver", - ["return_description"] = "Volver a la selección de personajes.", - ["command_setslots"] = "Establecer el numero de slots de un jugador", - ["command_remslots"] = "Elimina slots de un jugador.", - ["command_enablechar"] = "Activar el personaje de un jugador", - ["command_disablechar"] = "Deshabilitar personaje al jugador.", - ["command_charslot"] = "Número de slot del personaje", - ["command_identifier"] = "Identificador del jugador", - ["command_slots"] = "Nº de slots", - ["slotsadd"] = "Has establecido los slots de %s a %s", - ["slotsrem"] = "Has eliminado un slot a %s", - ["charenabled"] = "Has habilitado el personaje Nº%s de %s", - ["chardisabled"] = "Has deshabilitado el personaje Nº%s de %s", - ["charnotfound"] = "Personaje Nº%s de %s no existe", + ["male"] = "Masculino", + ["female"] = "Femenino", + ["select_char"] = "Seleccionar personaje", + ["select_char_description"] = "Selecciona un personaje para jugar.", + ["create_char"] = "Crear nuevo personaje", + ["char_play"] = "Seleccionar personaje", + ["char_play_description"] = "Ingresar a la ciudad.", + ["char_disabled"] = "Este personaje está deshabilitado", + ["char_disabled_description"] = "Este personaje no se encuentra disponible.", + ["char_delete"] = "Borrar el personaje seleccionado", + ["char_delete_description"] = "Eliminar este personaje.", + ["character"] = "Personaje: %s", + ["return"] = "Volver", + ["return_description"] = "Volver a la selección de personajes.", + ["command_setslots"] = "Establecer el numero de slots de un jugador", + ["command_remslots"] = "Elimina slots de un jugador.", + ["command_enablechar"] = "Activar el personaje de un jugador", + ["command_disablechar"] = "Deshabilitar personaje al jugador.", + ["command_charslot"] = "Número de slot del personaje", + ["command_identifier"] = "Identificador del jugador", + ["command_slots"] = "Nº de slots", + ["slotsadd"] = "Has establecido los slots de %s a %s", + ["slotsrem"] = "Has eliminado un slot a %s", + ["charenabled"] = "Has habilitado el personaje Nº%s de %s", + ["chardisabled"] = "Has deshabilitado el personaje Nº%s de %s", + ["charnotfound"] = "Personaje Nº%s de %s no existe", } diff --git a/server-data/resources/[esx]/esx_multicharacter/locales/fr.lua b/server-data/resources/[esx]/esx_multicharacter/locales/fr.lua index bd1193b9b..0eba5276b 100644 --- a/server-data/resources/[esx]/esx_multicharacter/locales/fr.lua +++ b/server-data/resources/[esx]/esx_multicharacter/locales/fr.lua @@ -5,11 +5,11 @@ Locales["fr"] = { ["select_char_description"] = "Sélectionnez un personnage avec lequel jouer.", ["create_char"] = "Créer un nouveau personnage", ["char_play"] = "Jouer ce personnage", - ["char_play_description"] = "Continuez dans la ville.", + ["char_play_description"] = "Continuez dans la ville.", ["char_disabled"] = "Ce personnage est désactivé", - ["char_disabled_description"] = "Ce personnage est inutilisable.", + ["char_disabled_description"] = "Ce personnage est inutilisable.", ["char_delete"] = "Supprimer ce personnage", - ["char_delete_description"] = "Supprimer définitivement ce personnage.", + ["char_delete_description"] = "Supprimer définitivement ce personnage.", ["char_delete_confirmation"] = "Confirmation de suppression", ["char_delete_confirmation_description"] = "Êtes-vous sûr de vouloir supprimer ce personnage?", ["char_delete_yes_description"] = "Oui, je suis sur de vouloir supprimer ce personnage", diff --git a/server-data/resources/[esx]/esx_multicharacter/locales/sl.lua b/server-data/resources/[esx]/esx_multicharacter/locales/sl.lua index 799a1563d..3ebdcb667 100644 --- a/server-data/resources/[esx]/esx_multicharacter/locales/sl.lua +++ b/server-data/resources/[esx]/esx_multicharacter/locales/sl.lua @@ -1,33 +1,33 @@ Locales["sl"] = { - ["male"] = "Moški", - ["female"] = "Ženska", - ["select_char"] = "Izberi znak", - ["select_char_description"] = "Izberite lik za igranje.", - ["create_char"] = "Nov lik", - ["char_play"] = "Predvajaj", - ["char_play_description"] = "Nadaljujte v mesto.", - ["char_disabled"] = "Onemogočeno", - ["char_disabled_description"] = "Ta znak je neuporaben.", - ["char_delete"] = "Izbriši", - ["char_delete_description"] = "Trajno odstrani ta znak.", - ["char_delete_confirmation"] = "Potrditev brisanja", - ["char_delete_confirmation_description"] = "Ali ste prepicani da hocete zbrisati svoj karakter*", - ["char_delete_yes_description"] = "Da", - ["char_delete_no_description"] = "Ne", - ["character"] = "Znak: %s", - ["return"] = "Vrni se", - ["return_description"] = "Nazaj na izbiro znakov.", - ["command_setslots"] = "Nastavi število večznakovnih mest za igralca", - ["command_remslots"] = "Odstrani večznakovno število rež igralca", - ["command_enablechar"] = "Omogoči določen lik igralca", - ["command_disablechar"] = "Onemogoči določen lik igralca", - ["command_charslot"] = "Številka reže znaka", - ["command_identifier"] = "Identifikator igralca", - ["command_slots"] = "Št. rež", - ["slotsadd"] = "Dodali ste %s rež v %s", - ["slotsedit"] = "%s rež ste nastavili na %s", - ["slotsrem"] = "Odstranili ste reže za %s", - ["charenabled"] = "Omogočili ste znak #%s od %s", - ["chardisabled"] = "Onemogočili ste znak #%s od %s", - ["charnotfound"] = "Znak #%s od %s ne obstaja", + ["male"] = "Moški", + ["female"] = "Ženska", + ["select_char"] = "Izberi znak", + ["select_char_description"] = "Izberite lik za igranje.", + ["create_char"] = "Nov lik", + ["char_play"] = "Predvajaj", + ["char_play_description"] = "Nadaljujte v mesto.", + ["char_disabled"] = "Onemogočeno", + ["char_disabled_description"] = "Ta znak je neuporaben.", + ["char_delete"] = "Izbriši", + ["char_delete_description"] = "Trajno odstrani ta znak.", + ["char_delete_confirmation"] = "Potrditev brisanja", + ["char_delete_confirmation_description"] = "Ali ste prepicani da hocete zbrisati svoj karakter*", + ["char_delete_yes_description"] = "Da", + ["char_delete_no_description"] = "Ne", + ["character"] = "Znak: %s", + ["return"] = "Vrni se", + ["return_description"] = "Nazaj na izbiro znakov.", + ["command_setslots"] = "Nastavi število večznakovnih mest za igralca", + ["command_remslots"] = "Odstrani večznakovno število rež igralca", + ["command_enablechar"] = "Omogoči določen lik igralca", + ["command_disablechar"] = "Onemogoči določen lik igralca", + ["command_charslot"] = "Številka reže znaka", + ["command_identifier"] = "Identifikator igralca", + ["command_slots"] = "Št. rež", + ["slotsadd"] = "Dodali ste %s rež v %s", + ["slotsedit"] = "%s rež ste nastavili na %s", + ["slotsrem"] = "Odstranili ste reže za %s", + ["charenabled"] = "Omogočili ste znak #%s od %s", + ["chardisabled"] = "Onemogočili ste znak #%s od %s", + ["charnotfound"] = "Znak #%s od %s ne obstaja", } diff --git a/server-data/resources/[esx]/esx_multicharacter/server/commands.lua b/server-data/resources/[esx]/esx_multicharacter/server/commands.lua index 85b46b35f..e5b66d297 100644 --- a/server-data/resources/[esx]/esx_multicharacter/server/commands.lua +++ b/server-data/resources/[esx]/esx_multicharacter/server/commands.lua @@ -1,79 +1,106 @@ -ESX.RegisterCommand('setslots', 'admin', function(xPlayer, args) - MySQL.insert('INSERT INTO `multicharacter_slots` (`identifier`, `slots`) VALUES (?, ?) ON DUPLICATE KEY UPDATE `slots` = VALUES(`slots`)', { - args.identifier, - args.slots, - }) - xPlayer.triggerEvent('esx:showNotification', _U('slotsadd', args.slots, args.identifier)) -end, true, { - help = _U('command_setslots'), - validate = true, - arguments = { - { name = 'identifier', help = _U('command_identifier'), type = 'string' }, - { name = 'slots', help = _U('command_slots'), type = 'number' } +ESX.RegisterCommand( + "setslots", + "admin", + function(xPlayer, args) + MySQL.insert( + "INSERT INTO `multicharacter_slots` (`identifier`, `slots`) VALUES (?, ?) ON DUPLICATE KEY UPDATE `slots` = VALUES(`slots`)", + { + args.identifier, + args.slots, + } + ) + xPlayer.triggerEvent("esx:showNotification", _U("slotsadd", args.slots, args.identifier)) + end, + true, + { + help = _U("command_setslots"), + validate = true, + arguments = { + { name = "identifier", help = _U("command_identifier"), type = "string" }, + { name = "slots", help = _U("command_slots"), type = "number" }, + }, } -}) +) -ESX.RegisterCommand('remslots', 'admin', function(xPlayer, args) - local slots = MySQL.scalar.await('SELECT `slots` FROM `multicharacter_slots` WHERE identifier = ?', { - args.identifier - }) - - if slots then - MySQL.update('DELETE FROM `multicharacter_slots` WHERE `identifier` = ?', { - args.identifier +ESX.RegisterCommand( + "remslots", + "admin", + function(xPlayer, args) + local slots = MySQL.scalar.await("SELECT `slots` FROM `multicharacter_slots` WHERE identifier = ?", { + args.identifier, }) - xPlayer.triggerEvent('esx:showNotification', _U('slotsrem', args.identifier)) - end -end, true, { - help = _U('command_remslots'), - validate = true, - arguments = { - { name = 'identifier', help = _U('command_identifier'), type = 'string' } + + if slots then + MySQL.update("DELETE FROM `multicharacter_slots` WHERE `identifier` = ?", { + args.identifier, + }) + xPlayer.triggerEvent("esx:showNotification", _U("slotsrem", args.identifier)) + end + end, + true, + { + help = _U("command_remslots"), + validate = true, + arguments = { + { name = "identifier", help = _U("command_identifier"), type = "string" }, + }, } -}) +) -ESX.RegisterCommand('enablechar', 'admin', function(xPlayer, args) - local selectedCharacter = 'char' .. args.charslot .. ':' .. args.identifier; +ESX.RegisterCommand( + "enablechar", + "admin", + function(xPlayer, args) + local selectedCharacter = "char" .. args.charslot .. ":" .. args.identifier - MySQL.update('UPDATE `users` SET `disabled` = 0 WHERE identifier = ?', { - selectedCharacter - }, function(result) - if result > 0 then - xPlayer.triggerEvent('esx:showNotification', _U('charenabled', args.charslot, args.identifier)) - else - xPlayer.triggerEvent('esx:showNotification', _U('charnotfound', args.charslot, args.identifier)) - end - end) -end, true, { - help = _U('command_enablechar'), - validate = true, - arguments = { - { name = 'identifier', help = _U('command_identifier'), type = 'string' }, - { name = 'charslot', help = _U('command_charslot'), type = 'number' } + MySQL.update("UPDATE `users` SET `disabled` = 0 WHERE identifier = ?", { + selectedCharacter, + }, function(result) + if result > 0 then + xPlayer.triggerEvent("esx:showNotification", _U("charenabled", args.charslot, args.identifier)) + else + xPlayer.triggerEvent("esx:showNotification", _U("charnotfound", args.charslot, args.identifier)) + end + end) + end, + true, + { + help = _U("command_enablechar"), + validate = true, + arguments = { + { name = "identifier", help = _U("command_identifier"), type = "string" }, + { name = "charslot", help = _U("command_charslot"), type = "number" }, + }, } -}) +) -ESX.RegisterCommand('disablechar', 'admin', function(xPlayer, args) - local selectedCharacter = 'char' .. args.charslot .. ':' .. args.identifier; +ESX.RegisterCommand( + "disablechar", + "admin", + function(xPlayer, args) + local selectedCharacter = "char" .. args.charslot .. ":" .. args.identifier - MySQL.update('UPDATE `users` SET `disabled` = 1 WHERE identifier = ?', { - selectedCharacter - }, function(result) - if result > 0 then - xPlayer.triggerEvent('esx:showNotification', _U('chardisabled', args.charslot, args.identifier)) - else - xPlayer.triggerEvent('esx:showNotification', _U('charnotfound', args.charslot, args.identifier)) - end - end) -end, true, { - help = _U('command_disablechar'), - validate = true, - arguments = { - { name = 'identifier', help = _U('command_identifier'), type = 'string' }, - { name = 'charslot', help = _U('command_charslot'), type = 'number' } + MySQL.update("UPDATE `users` SET `disabled` = 1 WHERE identifier = ?", { + selectedCharacter, + }, function(result) + if result > 0 then + xPlayer.triggerEvent("esx:showNotification", _U("chardisabled", args.charslot, args.identifier)) + else + xPlayer.triggerEvent("esx:showNotification", _U("charnotfound", args.charslot, args.identifier)) + end + end) + end, + true, + { + help = _U("command_disablechar"), + validate = true, + arguments = { + { name = "identifier", help = _U("command_identifier"), type = "string" }, + { name = "charslot", help = _U("command_charslot"), type = "number" }, + }, } -}) +) -RegisterCommand('forcelog', function(source) - TriggerEvent('esx:playerLogout', source) +RegisterCommand("forcelog", function(source) + TriggerEvent("esx:playerLogout", source) end, true) diff --git a/server-data/resources/[esx]/esx_progressbar/Progress.lua b/server-data/resources/[esx]/esx_progressbar/Progress.lua index 6b6a6abef..6e4c47602 100644 --- a/server-data/resources/[esx]/esx_progressbar/Progress.lua +++ b/server-data/resources/[esx]/esx_progressbar/Progress.lua @@ -1,54 +1,78 @@ local CurrentProgress = nil local function Progressbar(message, length, Options) - if CurrentProgress then - return false - end - CurrentProgress = Options or {} - if CurrentProgress.animation then - if CurrentProgress.animation.type == "anim" then - ESX.Streaming.RequestAnimDict(CurrentProgress.animation.dict, function() - TaskPlayAnim(ESX.PlayerData.ped, CurrentProgress.animation.dict, CurrentProgress.animation.lib, 1.0, 1.0, length, 1, 1.0, false, false, false) - RemoveAnimDict(CurrentProgress.animation.dict) - end) - elseif CurrentProgress.animation.type == "Scenario" then - TaskStartScenarioInPlace(ESX.PlayerData.ped, CurrentProgress.animation.Scenario, 0, true) - end - end - if CurrentProgress.FreezePlayer then FreezeEntityPosition(PlayerPedId(), CurrentProgress.FreezePlayer) end - SendNUIMessage({ - type = "Progressbar", - length = length or 3000, - message = message or "ESX-Framework" - }) - CurrentProgress.length = length or 3000 - while CurrentProgress ~= nil do - if CurrentProgress.length > 0 then - CurrentProgress.length = CurrentProgress.length - 1000 - else - ClearPedTasks(ESX.PlayerData.ped) - if CurrentProgress.FreezePlayer then FreezeEntityPosition(PlayerPedId(), false) end - if CurrentProgress.onFinish then CurrentProgress.onFinish() end - CurrentProgress = nil - end - Wait(1000) - end + if CurrentProgress then + return false + end + CurrentProgress = Options or {} + if CurrentProgress.animation then + if CurrentProgress.animation.type == "anim" then + ESX.Streaming.RequestAnimDict(CurrentProgress.animation.dict, function() + TaskPlayAnim( + ESX.PlayerData.ped, + CurrentProgress.animation.dict, + CurrentProgress.animation.lib, + 1.0, + 1.0, + length, + 1, + 1.0, + false, + false, + false + ) + RemoveAnimDict(CurrentProgress.animation.dict) + end) + elseif CurrentProgress.animation.type == "Scenario" then + TaskStartScenarioInPlace(ESX.PlayerData.ped, CurrentProgress.animation.Scenario, 0, true) + end + end + if CurrentProgress.FreezePlayer then + FreezeEntityPosition(PlayerPedId(), CurrentProgress.FreezePlayer) + end + SendNUIMessage({ + type = "Progressbar", + length = length or 3000, + message = message or "ESX-Framework", + }) + CurrentProgress.length = length or 3000 + while CurrentProgress ~= nil do + if CurrentProgress.length > 0 then + CurrentProgress.length = CurrentProgress.length - 1000 + else + ClearPedTasks(ESX.PlayerData.ped) + if CurrentProgress.FreezePlayer then + FreezeEntityPosition(PlayerPedId(), false) + end + if CurrentProgress.onFinish then + CurrentProgress.onFinish() + end + CurrentProgress = nil + end + Wait(1000) + end end local function CancelProgressbar() - if not CurrentProgress then return end - SendNUIMessage({ - type = "Close" - }) - ClearPedTasks(ESX.PlayerData.ped) - if CurrentProgress.FreezePlayer then FreezeEntityPosition(PlayerPedId(), false) end - if CurrentProgress.onCancel then CurrentProgress.onCancel() end - CurrentProgress.canceled = true - CurrentProgress.length = 0 - CurrentProgress = nil + if not CurrentProgress then + return + end + SendNUIMessage({ + type = "Close", + }) + ClearPedTasks(ESX.PlayerData.ped) + if CurrentProgress.FreezePlayer then + FreezeEntityPosition(PlayerPedId(), false) + end + if CurrentProgress.onCancel then + CurrentProgress.onCancel() + end + CurrentProgress.canceled = true + CurrentProgress.length = 0 + CurrentProgress = nil end ESX.RegisterInput("cancelprog", "[ProgressBar] Cancel Progressbar", "keyboard", "BACK", CancelProgressbar) -exports('Progressbar', Progressbar) -exports('CancelProgressbar', CancelProgressbar) \ No newline at end of file +exports("Progressbar", Progressbar) +exports("CancelProgressbar", CancelProgressbar) diff --git a/server-data/resources/[esx]/esx_progressbar/fxmanifest.lua b/server-data/resources/[esx]/esx_progressbar/fxmanifest.lua index 864583f4b..8308489ba 100644 --- a/server-data/resources/[esx]/esx_progressbar/fxmanifest.lua +++ b/server-data/resources/[esx]/esx_progressbar/fxmanifest.lua @@ -1,16 +1,16 @@ -fx_version 'adamant' -game 'gta5' -author 'BPT-Framework' -lua54 'yes' -description 'BPT Progressbar' -version '1.0.0' +fx_version("adamant") +game("gta5") +author("BPT-Framework") +lua54("yes") +description("BPT Progressbar") +version("1.0.0") -client_scripts { 'Progress.lua' } -shared_script '@es_extended/imports.lua' -ui_page 'nui/index.html' +client_scripts({ "Progress.lua" }) +shared_script("@es_extended/imports.lua") +ui_page("nui/index.html") -files { - 'nui/index.html', - 'nui/js/*.js', - 'nui/css/*.css', -} \ No newline at end of file +files({ + "nui/index.html", + "nui/js/*.js", + "nui/css/*.css", +}) diff --git a/server-data/resources/[esx]/esx_progressbar/nui/index.html b/server-data/resources/[esx]/esx_progressbar/nui/index.html index 9c1d4bc8b..db896788a 100644 --- a/server-data/resources/[esx]/esx_progressbar/nui/index.html +++ b/server-data/resources/[esx]/esx_progressbar/nui/index.html @@ -1,19 +1,22 @@ - - - - - -
-
- -

-
-
+ + + + + + + +
+
+ +

- - +
+
+ + +