Skip to content
This repository was archived by the owner on Aug 26, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@

[ Requirements ]

- ESX
- es_extended
- esx_menu_default
- pNotify

[ Video ]

- https://streamable.com/e7z1l
- <https://streamable.com/e7z1l>
15 changes: 14 additions & 1 deletion __resource.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'

description '99kr-shops'

client_scripts {
'@es_extended/locale.lua',
'locales/en.lua',
'locales/tr.lua',
'config.lua',
'client/main.lua',
'client/shop.lua',
}

server_scripts {
'@es_extended/locale.lua',
'locales/en.lua',
'locales/tr.lua',
'config.lua',
'server/main.lua',
}

shared_script 'config.lua'
dependencies {
'es_extended',
'esx_menu_default'
}
11 changes: 0 additions & 11 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,6 @@ Citizen.CreateThread(function()
end
end)

--[[ Function to trigger pNotify event for easier use :) ]]--
pNotify = function(message, messageType, messageTimeout)
TriggerEvent("pNotify:SendNotification", {
text = message,
type = messageType,
queue = "shopcl",
timeout = messageTimeout,
layout = "topRight"
})
end

Marker = function(pos)
DrawMarker(25, pos["x"], pos["y"], pos["z"] - 0.98, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75, 0.75, 0.75, 200, 200, 200, 60, false, false, 2, false, nil, nil, false)
DrawMarker(25, pos["x"], pos["y"], pos["z"] - 0.98, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.8, 0.8, 200, 200, 200, 60, false, false, 2, false, nil, nil, false)
Expand Down
44 changes: 22 additions & 22 deletions client/shop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Citizen.CreateThread(function()
local dist = GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()), blip["x"], blip["y"], blip["z"], true)
if dist <= 20.0 then
if dist >= 12.0 then
pNotify("You left the store, your basket is now empty!", "error", 2500)
ESX.ShowNotification(_U("99kr_shop_left_store"))
payAmount = 0
Basket = {}
end
Expand All @@ -53,7 +53,7 @@ OpenAction = function(action, shelf, text)
if payAmount > 0 and #Basket then
CashRegister(text)
else
pNotify("You don't have anything in your basket!", 'error', 1500)
ESX.ShowNotification(_U('99kr_shop_dont_have_anything'))
end
else
ShelfMenu(text, shelf)
Expand All @@ -63,14 +63,14 @@ end
--[[ Cash register menu ]]--
CashRegister = function(titel)
local elements = {
{label = '<span style="color:lightgreen; border-bottom: 1px solid lightgreen;">Confirm</span>', value = "yes"},
{label = 'Amount to pay: <span style="color:green">$' .. payAmount ..'</span>'},
{label = _U('99kr_shop_pay_with_confirm'), value = "yes"},
{label = _U('99kr_shop_label_amount_to_pay', payAmount)},
}

for i=1, #Basket do
local item = Basket[i]
table.insert(elements, {
label = '<span style="color:red">*</span> ' .. item["label"] .. ': ' .. item["amount"] .. ' pcs',
label = _U('99kr_shop_item_x', item["label"], item["amount"]),
value = item["value"],
})
end
Expand All @@ -79,7 +79,7 @@ CashRegister = function(titel)
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'penis',
{
title = "Shop - " .. titel,
title = _U('99kr_shop_titel', titel),
align = 'center',
elements = elements
},
Expand All @@ -90,11 +90,11 @@ CashRegister = function(titel)
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'penis2',
{
title = "Shop - Payment",
title = _U('99kr_shop_payment'),
align = 'center',
elements = {
{label = "Pay with Cash", value = "cash"},
{label = "Pay with Credit Card", value = "bank"},
{label = _U('99kr_shop_pay_with_cash'), value = "cash"},
{label = _U('99kr_shop_pay_with_card'), value = "bank"},
},
},
function(data2, menu2)
Expand All @@ -105,7 +105,7 @@ CashRegister = function(titel)
Basket = {}
menu2.close()
else
pNotify("You don't have enough money!", 'error', 1500)
ESX.ShowNotification(_U('99kr_shop_dont_have_money'))
end
end, payAmount, data2.current["value"])
end,
Expand All @@ -127,7 +127,7 @@ ShelfMenu = function(titel, shelf)
local shelf = shelf[i]
table.insert(elements, {
realLabel = shelf["label"],
label = shelf["label"] .. ' (<span style="color:green">$' .. shelf["price"] .. '</span>)',
label = _U('99kr_shop_price', shelf["label"], shelf["price"]),
item = shelf["item"],
price = shelf["price"],
value = 1, type = 'slider', min = 1, max = 100,
Expand All @@ -137,7 +137,7 @@ ShelfMenu = function(titel, shelf)
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'penis',
{
title = "Shop - " .. titel,
title = _U('99kr_shop_titel', titel),
align = 'center',
elements = elements
},
Expand All @@ -155,7 +155,7 @@ ShelfMenu = function(titel, shelf)
})
end
payAmount = payAmount + data.current["price"] * data.current.value
pNotify("Put " .. data.current.value .. " pieces of " .. data.current["realLabel"] .. " in the basket", 'alert', 1500)
ESX.ShowNotification(_U('99kr_shop_put_in_basket', data.current.value, data.current["realLabel"]))
end,
function(data, menu)
menu.close()
Expand Down Expand Up @@ -186,23 +186,23 @@ end)
OpenBasket = function()
if payAmount > 0 and #Basket then
local elements = {
{label = 'Amount to pay: <span style="color:green">$' .. payAmount},
{label = _U('99kr_shop_label_amount_to_pay', payAmount)},
}
for i=1, #Basket do
local item = Basket[i]
table.insert(elements, {
label = '<span style="color:red">*</span> ' .. item["label"] .. ': ' .. item["amount"] .. ' pcs (<span style="color:green">$' .. item["price"] * item["amount"] .. '</span>)',
label = _U('99kr_shop_label_amount_x', item["label"], item["amount"], item["price"] * item["amount"]),
value = "item_menu",
index = i
})
end
table.insert(elements, {label = '<span style="color:red">Empty Cart', value = "empty"})
table.insert(elements, {label = _U('99kr_shop_empty_cart'), value = "empty"})

ESX.UI.Menu.CloseAll()
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'basket',
{
title = "Shopping Cart",
title = _U('99kr_shop_shopping_cart'),
align = 'center',
elements = elements
},
Expand All @@ -211,7 +211,7 @@ OpenBasket = function()
Basket = {}
payAmount = 0
menu.close()
pNotify("Removed everything from your basket.", "error", 2500)
ESX.ShowNotification(_U('99kr_shop_removed_everything'))
end
if data.current.value == "item_menu" then
menu.close()
Expand All @@ -222,16 +222,16 @@ OpenBasket = function()
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'basket_detailedmenu',
{
title = "Shopping Cart - " .. shopItem["label"] .. " - " .. shopItem["amount"] .. "pcs",
title = _U('99kr_shop_shopping_cart_x', shopItem["label"], shopItem["amount"]),
align = 'center',
elements = {
{label = shopItem["label"] .. " - $" .. shopItem["price"] * shopItem["amount"]},
{label = '<span style="color:red">Delete Item</span>', value = "deleteItem"},
{label = _U('99kr_shop_label_price', shopItem["label"], shopItem["price"] * shopItem["amount"])},
{label = _U('99kr_shop_delete_item'), value = "deleteItem"},
},
},
function(data2, menu2)
if data2.current["value"] == "deleteItem" then
pNotify("Removed " .. Basket[index]["amount"] .." ".. Basket[index]["label"] .. " from basket.", "alert", 2500)
ESX.ShowNotification(_U('99kr_shop_removed_x', Basket[index]["amount"], Basket[index]["label"]))
payAmount = payAmount - (Basket[index]["amount"] * Basket[index]["price"])
table.remove(Basket, index)
OpenBasket()
Expand Down
Loading