- remove locales module
This commit is contained in:
1 parent
d6cffd01bc
commit
07530a8662
25 files changed
+84
-724
No files matched your search
@@ -24,23 +24,23 @@ Shops.FinalizeCheckOut = function(shopName, item, itemLabel, price, amount)
|
||||
local generatedID = lib.string.random('Aa1A', 8) -- Generate a random ID if not provided
|
||||
local buildMenu = {
|
||||
{
|
||||
title = locale('Shops.PayByCash', tostring(mathStuff)),
|
||||
description = locale('Shops.AreYouSure', itemLabel),
|
||||
icon = locale('Shops.CashIcon'),
|
||||
title = lib.locale('Shops.PayByCash', tostring(mathStuff)),
|
||||
description = lib.locale('Shops.AreYouSure', itemLabel),
|
||||
icon = lib.locale('Shops.CashIcon'),
|
||||
onSelect = function(_, __, ___)
|
||||
TriggerServerEvent('community_bridge:Server:completeCheckout', shopName, item, amount, "money")
|
||||
end
|
||||
},
|
||||
{
|
||||
title = locale('Shops.PayByCard', tostring(mathStuff)),
|
||||
description = locale('Shops.AreYouSure', itemLabel),
|
||||
icon = locale('Shops.CardIcon'),
|
||||
title = lib.locale('Shops.PayByCard', tostring(mathStuff)),
|
||||
description = lib.locale('Shops.AreYouSure', itemLabel),
|
||||
icon = lib.locale('Shops.CardIcon'),
|
||||
onSelect = function(_, __, ___)
|
||||
TriggerServerEvent('community_bridge:Server:completeCheckout', shopName, item, amount, "bank")
|
||||
end
|
||||
}
|
||||
}
|
||||
Menu.Open({ id = generatedID, title = locale("Shops.Input"), options = buildMenu }, false)
|
||||
Menu.Open({ id = generatedID, title = lib.locale("Shops.Input"), options = buildMenu }, false)
|
||||
end
|
||||
|
||||
---This is an internal functions that is used to open the amount select menu. Please do not use this function directly.
|
||||
@@ -57,7 +57,7 @@ Shops.AmountSelect = function(shopName, item, itemLabel, price)
|
||||
table.insert(numberOptions, {label = tostring(i), value = i})
|
||||
end
|
||||
local _input = Input.Open(shopName, {
|
||||
{type = 'select', label = locale("Shops.PurchaseAmount"), options = numberOptions},
|
||||
{type = 'select', label = lib.locale("Shops.PurchaseAmount"), options = numberOptions},
|
||||
})
|
||||
|
||||
if _input and _input[1] then
|
||||
@@ -78,8 +78,8 @@ Shops.OpenShop = function(shopName, shopData)
|
||||
local getItemName = Inventory.GetItemInfo(v.name).label
|
||||
table.insert(buildMenu, {
|
||||
title = getItemName,
|
||||
description = locale('Shops.CurrencySymbol', tostring(v.price)),
|
||||
icon = locale('Shops.ShopIcon'),
|
||||
description = lib.locale('Shops.CurrencySymbol', tostring(v.price)),
|
||||
icon = lib.locale('Shops.ShopIcon'),
|
||||
onSelect = function(selected, secondary, args)
|
||||
Shops.AmountSelect(shopName, v.name, getItemName, v.price)
|
||||
end
|
||||
|
||||
@@ -3,9 +3,6 @@ Shops = Shops or {}
|
||||
|
||||
local registeredShops = {}
|
||||
|
||||
local Language = Language or Require("modules/locales/shared.lua")
|
||||
local locale = Language.Locale
|
||||
|
||||
---This can open a shop for the client
|
||||
---@param src number
|
||||
---@param shopName string
|
||||
@@ -51,23 +48,23 @@ Shops.CompleteCheckout = function(src, shopName, item, amount, account)
|
||||
end
|
||||
end
|
||||
if not itemData or not itemData.price then return print("community_bridge Player ID "..src.." attempted to purchase invalid item from shop: "..shopName) end
|
||||
if itemData.count and itemData.count <= 0 then return Notify.SendNotify(src, locale('Shops.NotEnoughStock'), "error", 5000) end
|
||||
if itemData.count and itemData.count <= 0 then return Notify.SendNotify(src, lib.locale('Shops.NotEnoughStock'), "error", 5000) end
|
||||
local totalCost = tonumber(itemData.price) * amount
|
||||
local balance = Framework.GetAccountBalance(src, account)
|
||||
if not balance then return end
|
||||
if balance <= 0 then return Notify.SendNotify(src, locale('Shops.NotEnoughMoney'), "error", 5000) end
|
||||
if balance < totalCost then return Notify.SendNotify(src, locale('Shops.NotEnoughMoney'), "error", 5000) end
|
||||
if balance <= 0 then return Notify.SendNotify(src, lib.locale('Shops.NotEnoughMoney'), "error", 5000) end
|
||||
if balance < totalCost then return Notify.SendNotify(src, lib.locale('Shops.NotEnoughMoney'), "error", 5000) end
|
||||
|
||||
if not Framework.RemoveAccountBalance(src, account, totalCost) then return end
|
||||
|
||||
local success = Inventory.AddItem(src, itemData.name, amount)
|
||||
if not success then
|
||||
Framework.AddAccountBalance(src, account, totalCost)
|
||||
return Notify.SendNotify(src, locale('Shops.PurchaseFailed'), "error", 5000)
|
||||
return Notify.SendNotify(src, lib.locale('Shops.PurchaseFailed'), "error", 5000)
|
||||
end
|
||||
|
||||
local itemLabel = Inventory.GetItemInfo(itemData.name).label or itemData.name
|
||||
Notify.SendNotify(src, locale('Shops.PurchasedItem', amount, itemLabel), "success", 5000)
|
||||
Notify.SendNotify(src, lib.locale('Shops.PurchasedItem', amount, itemLabel), "success", 5000)
|
||||
end
|
||||
|
||||
---This is an internal event to complete a checkout, complete with multiple validations. Please do not use this event directly.
|
||||
|
||||
Reference in new issue
Block a user