Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(esx_shops): ✨ Add support for multiple paymenth methods, revert … #26

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

Arctos2win
Copy link
Contributor

…to esx_menu_default, migrate esx_shops to ESX Point system.

…to esx_menu_default, migrate esx_shops to ESX Point system.
@Kenshiin13 Kenshiin13 self-requested a review November 17, 2024 01:26
Copy link

@Kenshiin13 Kenshiin13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add type annotations, please.

client/main.lua Outdated
local function hasExitedMarker(zone)
currentAction = nil
ESX.CloseContext()
function createShopPoint(pos, zone, ShowMarker)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be consistent with variable naming. Why is ShowMarker capitalized?

client/main.lua Outdated
local hasAlreadyEnteredMarker, lastZone
local currentAction, currentActionMsg, currentActionData = nil, nil, {}

local currentZone, TextUI, inMenu

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be consistent with variable naming. Why is TextUI capitalized?

client/main.lua Outdated
value = 1,
type = "slider",
min = 1,
max = 10

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a good idea to add min and max as optionals to the config.

@@ -1,53 +1,52 @@
function GetItemFromShop(itemName, zone)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should explicitly return false when item is not found.


return true,item.price, item.label
function PlayerPosCheck(playerCoords, zone)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should explicitly return false if pos check fails

config.lua Outdated
Config.Locale = GetConvar('esx:locale', 'en')

Config.Zones = {
-- Accounts that can be used for paymenth
Config.PaymenthAccounts = {"money", "bank"}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix typo "Paymenth"

end
end

local missingMoney = price - xPlayer.getMoney()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be hardcoded. Get one of the configured accounts with the highest amount in it

return print(('[^3WARNING^7] Player ^5%s^7 attempted to exploit the shop!'):format(source))
end

if amount < 0 or not PlayerPosCheck(xPlayer.getCoords(true), zone) then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be amount <= 0

if account.money >= price then
xPlayer.removeAccountMoney(account.name, price, ("%s %s"):format(name, TranslateCap('purchase')))
xPlayer.addInventoryItem(name, amount)
return xPlayer.showNotification(TranslateCap('bought', amount, name, ESX.Math.GroupDigits(price)))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Display item label to the user, not item name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Pending
Development

Successfully merging this pull request may close these issues.

2 participants