mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 04:01:22 +00:00
Merge pull request #1617 from YOMAN1792/dev
feat(es_extended/server/modules/commands.lua): Add Validation Number
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
local Inventory
|
||||
local MAX_AMOUNT = 1.79769e+308
|
||||
|
||||
if Config.CustomInventory ~= "ox" then return end
|
||||
|
||||
@@ -45,6 +46,7 @@ Core.PlayerFunctionOverrides.OxInventory = {
|
||||
setAccountMoney = function(self)
|
||||
return function(accountName, money, reason)
|
||||
reason = reason or "unknown"
|
||||
money = money <= MAX_AMOUNT and money or MAX_AMOUNT
|
||||
if money < 0 then return end
|
||||
local account = self.getAccount(accountName)
|
||||
|
||||
@@ -64,6 +66,7 @@ Core.PlayerFunctionOverrides.OxInventory = {
|
||||
addAccountMoney = function(self)
|
||||
return function(accountName, money, reason)
|
||||
reason = reason or "unknown"
|
||||
money = money <= MAX_AMOUNT and money or MAX_AMOUNT
|
||||
if money < 1 then return end
|
||||
|
||||
local account = self.getAccount(accountName)
|
||||
@@ -82,6 +85,7 @@ Core.PlayerFunctionOverrides.OxInventory = {
|
||||
removeAccountMoney = function(self)
|
||||
return function(accountName, money, reason)
|
||||
reason = reason or "unknown"
|
||||
money = money <= MAX_AMOUNT and money or MAX_AMOUNT
|
||||
if money < 1 then return end
|
||||
|
||||
local account = self.getAccount(accountName)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -404,14 +408,12 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
function self.addInventoryItem(itemName, count)
|
||||
local item = self.getInventoryItem(itemName)
|
||||
|
||||
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 = ESX.Math.Round(count) <= MAX_AMOUNT and ESX.Math.Round(count) or MAX_AMOUNT
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user