shops FIN
This commit is contained in:
1 parent
e54213398e
commit
3de3bf2883
3 files changed
+30
-37
No files matched your search
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
"place_object_scroll_down": "[SCROLL DOWN] Turn left",
|
"place_object_scroll_down": "[SCROLL DOWN] Turn left",
|
||||||
"enter_text": "Enter Text",
|
"enter_text": "Enter Text",
|
||||||
"no_prop_defined": "You didnt define any object to place",
|
"no_prop_defined": "You didnt define any object to place",
|
||||||
"Shops": {"NotEnoughMoney": "You dont have enough money to buy this item", "PurchasedItem": "You Have Purchased ", "CurrencySymbol": "$", "Confirm":"Confirm Purchase","AreYouSure":"Are you sure you want to purchase a ", "PayByCash": "Pay by cash", "PayByCard": "Pay by card" },
|
"Shops": {"NotEnoughMoney": "You dont have enough money to buy this item", "Input":"Amount Input", "PurchaseAmount":"Purchase Quanity","PurchasedItem": "You Have Purchased ", "CurrencySymbol": "$", "Confirm":"Confirm Purchase","AreYouSure":"Are you sure you want to purchase a ", "PayByCash": "Pay by cash", "PayByCard": "Pay by card" },
|
||||||
"UNITTEST": {
|
"UNITTEST": {
|
||||||
"UNITTESTA": "Im a %s %s",
|
"UNITTESTA": "Im a %s %s",
|
||||||
"UNITTEST": {
|
"UNITTEST": {
|
||||||
|
|||||||
@@ -31,55 +31,45 @@ Shops.FinalizeCheckOut = function(shopName, item, itemLabel, price)
|
|||||||
Bridge.Menu.Open({ id = generatedID, title = locale("Shops.Confirm"), options = buildMenu }, false)
|
Bridge.Menu.Open({ id = generatedID, title = locale("Shops.Confirm"), options = buildMenu }, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
Shops.FinalizeCheckOut = function(shopName, item, itemLabel, price)
|
Shops.FinalizeCheckOut = function(shopName, item, itemLabel, price, amount)
|
||||||
if not shopName and not item and not itemLabel and not price then return end
|
if not shopName and not item and not itemLabel and not price then return end
|
||||||
|
local mathStuff = tonumber(price) * tonumber(amount)
|
||||||
local generatedID = Ids.CreateUniqueId()
|
local generatedID = Ids.CreateUniqueId()
|
||||||
local buildMenu = {
|
local buildMenu = {
|
||||||
{
|
{
|
||||||
title = locale('Shops.PayByCash')..tostring(price),
|
title = locale('Shops.PayByCash').." "..tostring(mathStuff),
|
||||||
description = locale('Shops.AreYouSure') .. itemLabel,
|
description = locale('Shops.AreYouSure') .. itemLabel,
|
||||||
icon = "fa-solid fa-money-bill-wave",
|
icon = "fa-solid fa-money-bill-wave",
|
||||||
onSelect = function(_, __, ___)
|
onSelect = function(_, __, ___)
|
||||||
TriggerServerEvent('community_bridge:completeCheckout', shopName, item, "cash")
|
TriggerServerEvent('community_bridge:completeCheckout', shopName, item, amount, "money")
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title = locale('Shops.PayByCard')..tostring(price),
|
title = locale('Shops.PayByCard').." "..tostring(mathStuff),
|
||||||
description = locale('Shops.AreYouSure') .. itemLabel,
|
description = locale('Shops.AreYouSure') .. itemLabel,
|
||||||
icon = "fa-solid fa-building-column",
|
icon = "fa-solid fa-building-column",
|
||||||
onSelect = function(_, __, ___)
|
onSelect = function(_, __, ___)
|
||||||
TriggerServerEvent('community_bridge:completeCheckout', shopName, item, "bank")
|
TriggerServerEvent('community_bridge:completeCheckout', shopName, item, amount, "bank")
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Menu.Open({ id = generatedID, title = locale("Shops.Input"), options = buildMenu }, false)
|
Menu.Open({ id = generatedID, title = locale("Shops.Input"), options = buildMenu }, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
|
||||||
Shops.AmountSelect = function(shopName, item, itemLabel, price)
|
Shops.AmountSelect = function(shopName, item, itemLabel, price)
|
||||||
if not shopName and not item and not itemLabel and not price then return end
|
if not shopName and not item and not itemLabel and not price then return end
|
||||||
local generatedID = Ids.CreateUniqueId()
|
local numberOptions = {}
|
||||||
local buildMenu = {
|
for i = 1, 100 do
|
||||||
{
|
table.insert(numberOptions, {label = tostring(i), value = i})
|
||||||
title = locale('Shops.PayByCash')..tostring(price),
|
end
|
||||||
description = locale('Shops.AreYouSure') .. itemLabel,
|
local _input = Input.Open(shopName, {
|
||||||
icon = "fa-solid fa-money-bill-wave",
|
{type = 'select', label = locale("Shops.PurchaseAmount"), options = numberOptions},
|
||||||
onSelect = function(_, __, ___)
|
})
|
||||||
TriggerServerEvent('community_bridge:completeCheckout', shopName, item, "cash")
|
|
||||||
end
|
if _input and _input[1] then
|
||||||
},
|
Shops.FinalizeCheckOut(shopName, item, itemLabel, price, tostring(_input[1]))
|
||||||
{
|
end
|
||||||
title = locale('Shops.PayByCard')..tostring(price),
|
|
||||||
description = locale('Shops.AreYouSure') .. itemLabel,
|
|
||||||
icon = "fa-solid fa-building-column",
|
|
||||||
onSelect = function(_, __, ___)
|
|
||||||
TriggerServerEvent('community_bridge:completeCheckout', shopName, item, "bank")
|
|
||||||
end
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Menu.Open({ id = generatedID, title = locale("Shops.Input"), options = buildMenu }, false)
|
|
||||||
end
|
end
|
||||||
--]]
|
|
||||||
|
|
||||||
Shops.OpenShop = function(title, shopData)
|
Shops.OpenShop = function(title, shopData)
|
||||||
if not title and not shopData and not title then return print("No Title Passed") end
|
if not title and not shopData and not title then return print("No Title Passed") end
|
||||||
@@ -92,7 +82,8 @@ Shops.OpenShop = function(title, shopData)
|
|||||||
description = locale('Shops.CurrencySymbol')..tostring(v.price),
|
description = locale('Shops.CurrencySymbol')..tostring(v.price),
|
||||||
icon = "fa-solid fa-basket-shopping",
|
icon = "fa-solid fa-basket-shopping",
|
||||||
onSelect = function(selected, secondary, args)
|
onSelect = function(selected, secondary, args)
|
||||||
Shops.FinalizeCheckOut(title, v.name, getItemName, v.price)
|
Shops.AmountSelect(title, v.name, getItemName, v.price)
|
||||||
|
--Shops.FinalizeCheckOut(title, v.name, getItemName, v.price)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ Shops.CreateShop = function(shopTitle, shopInventory, shopCoords, shopGroups)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
Shops.CompleteCheckout = function(src, shopName, item, paymentType)
|
Shops.CompleteCheckout = function(src, shopName, item, amount, paymentType)
|
||||||
if not src and not shopName and not item and not paymentType then return end
|
|
||||||
|
if not src and not shopName and not item and not amount and not paymentType then return end
|
||||||
local ilocale = Language.Locale
|
local ilocale = Language.Locale
|
||||||
local shopData = registeredShops[shopName]
|
local shopData = registeredShops[shopName]
|
||||||
if not shopData then return end
|
if not shopData then return end
|
||||||
@@ -29,16 +30,17 @@ Shops.CompleteCheckout = function(src, shopName, item, paymentType)
|
|||||||
if not itemData then return print("Player ID "..src.." Is Possibly A Cheater And Has Attempted To Purchase A "..item) end
|
if not itemData then return print("Player ID "..src.." Is Possibly A Cheater And Has Attempted To Purchase A "..item) end
|
||||||
if not itemData.price then return end
|
if not itemData.price then return end
|
||||||
local balance = Framework.GetAccountBalance(src, paymentType)
|
local balance = Framework.GetAccountBalance(src, paymentType)
|
||||||
if balance < itemData.price then return Notify.SendNotify(src, ilocale('Shops.NotEnoughMoney'), "error", 5000) end
|
local mathStuff = tonumber(itemData.price) * tonumber(amount)
|
||||||
if not Framework.RemoveAccountBalance(src, paymentType, itemData.price) then return end
|
if balance < mathStuff then return Notify.SendNotify(src, ilocale('Shops.NotEnoughMoney'), "error", 5000) end
|
||||||
Inventory.AddItem(src, itemData.name, 1)
|
if not Framework.RemoveAccountBalance(src, paymentType, mathStuff) then return end
|
||||||
|
Inventory.AddItem(src, itemData.name, amount)
|
||||||
local itemLabel = Inventory.GetItemInfo(itemData.name).label
|
local itemLabel = Inventory.GetItemInfo(itemData.name).label
|
||||||
Notify.SendNotify(src, ilocale('Shops.PurchasedItem')..itemLabel, "success", 5000)
|
Notify.SendNotify(src, ilocale('Shops.PurchasedItem')..itemLabel, "success", 5000)
|
||||||
end
|
end
|
||||||
|
|
||||||
RegisterNetEvent("community_bridge:completeCheckout", function(shopName, item, paymentType)
|
RegisterNetEvent("community_bridge:completeCheckout", function(shopName, item, amount, paymentType)
|
||||||
local src = source
|
local src = source
|
||||||
if not shopName and not item and not paymentType then return end
|
if not shopName and not item and not paymentType then return end
|
||||||
if not paymentType == "cash" or not paymentType == "bank" then return end
|
if not paymentType == "money" or not paymentType == "bank" then return end
|
||||||
Shops.CompleteCheckout(src, shopName, item, paymentType)
|
Shops.CompleteCheckout(src, shopName, item, amount, paymentType)
|
||||||
end)
|
end)
|
||||||
Reference in new issue
Block a user