-
-
Notifications
You must be signed in to change notification settings - Fork 754
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(es_extended/server/modules/commands.lua): Add Validation Number #1617
Open
YOMAN1792
wants to merge
12
commits into
esx-framework:dev
Choose a base branch
from
YOMAN1792:dev
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3dae29d
Fix ox crash
YOMAN1792 d9fe2d8
Fix oc crash and the impossibility to give anymore money
YOMAN1792 5e91bad
feat(commands): add maximum amount validation for giveitem, giveweapo…
YOMAN1792 221e23b
feat(commands): prevent Ox from breaking due to money overflow
YOMAN1792 91e783c
feat(commands): prevent money overflow from blocking further transact…
YOMAN1792 a0389d7
feat(commands): add max amount validation for giveitem, giveweapon, a…
YOMAN1792 b4dbb5e
Merge branch 'dev' of https://github.com/YOMAN1792/esx_core into dev
YOMAN1792 b60eb3b
feat(commands): rename amount to count for giveitem and update ammo v…
YOMAN1792 f2cde31
feat(commands): remove maximum amount validation for account money an…
YOMAN1792 7877d9e
feat(inventory): implement maximum amount cap for account money trans…
YOMAN1792 90ba450
feat(player): enforce maximum amount limit for account money transact…
YOMAN1792 6693a7f
feat(player): update inventory item addition to enforce maximum count…
YOMAN1792 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory, weight, job, loadout, name, coords, metadata) | ||
---@class xPlayer | ||
local self = {} | ||
local MAX_AMOUNT = 1.79769e+308 | ||
|
||
self.accounts = accounts | ||
self.coords = coords | ||
|
@@ -313,6 +314,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory, | |
error(("Tried To Set Account ^5%s^1 For Player ^5%s^1 To An Invalid Number -> ^5%s^1"):format(accountName, self.playerId, money)) | ||
return | ||
end | ||
money = money <= MAX_AMOUNT and money or MAX_AMOUNT | ||
if money >= 0 then | ||
local account = self.getAccount(accountName) | ||
|
||
|
@@ -340,6 +342,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory, | |
error(("Tried To Set Account ^5%s^1 For Player ^5%s^1 To An Invalid Number -> ^5%s^1"):format(accountName, self.playerId, money)) | ||
return | ||
end | ||
money = money <= MAX_AMOUNT and money or MAX_AMOUNT | ||
if money > 0 then | ||
local account = self.getAccount(accountName) | ||
if account then | ||
|
@@ -366,6 +369,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory, | |
error(("Tried To Set Account ^5%s^1 For Player ^5%s^1 To An Invalid Number -> ^5%s^1"):format(accountName, self.playerId, money)) | ||
return | ||
end | ||
money = money <= MAX_AMOUNT and money or MAX_AMOUNT | ||
if money > 0 then | ||
local account = self.getAccount(accountName) | ||
|
||
|
@@ -403,15 +407,14 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory, | |
---@return nil | ||
function self.addInventoryItem(itemName, count) | ||
local item = self.getInventoryItem(itemName) | ||
if not item then return end | ||
|
||
if item then | ||
count = ESX.Math.Round(count) | ||
item.count = item.count + count | ||
self.weight = self.weight + (item.weight * count) | ||
count += item.count | ||
item.count = (count <= MAX_AMOUNT and count) or MAX_AMOUNT | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use ESX.Math.Round here |
||
self.weight += (item.weight * count) | ||
|
||
TriggerEvent("esx:onAddInventoryItem", self.source, item.name, item.count) | ||
self.triggerEvent("esx:addInventoryItem", item.name, item.count) | ||
end | ||
TriggerEvent("esx:onAddInventoryItem", self.source, item.name, item.count) | ||
self.triggerEvent("esx:addInventoryItem", item.name, item.count) | ||
end | ||
|
||
---@param itemName string | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably best if we dont return