This commit is contained in:
MrNewb committed 2025-02-05 20:01:58 -05:00
1 parent 2094afa293
commit 35237ff0a0
1 file changed
+22 -93
+22 -93
View File
@@ -7,75 +7,45 @@ Framework = {}
-- Framework.GetPlayerIdentifier(src) -- Framework.GetPlayerIdentifier(src)
-- Returns the citizen ID of the player. -- Returns the citizen ID of the player.
Framework.GetPlayerIdentifier = function(src) Framework.GetPlayerIdentifier = function(src)
local xPlayer = ESX.GetPlayerFromId(src) -- wip
return xPlayer.getIdentifier()
end end
-- Framework.GetPlayerName(src) -- Framework.GetPlayerName(src)
-- Returns the first and last name of the player. -- Returns the first and last name of the player.
Framework.GetPlayerName = function(src) Framework.GetPlayerName = function(src)
local xPlayer = ESX.GetPlayerFromId(src) -- wip
return xPlayer.variables.firstName, xPlayer.variables.lastName
end end
-- Framework.GetItem(src, item, metadata) -- Framework.GetItem(src, item, metadata)
-- Returns a table of items matching the specified name and if passed metadata from the player's inventory. -- Returns a table of items matching the specified name and if passed metadata from the player's inventory.
-- returns {name = v.name, count = v.amount, metadata = v.info, slot = v.slot} -- returns {name = v.name, count = v.amount, metadata = v.info, slot = v.slot}
Framework.GetItem = function(src, item, _) Framework.GetItem = function(src, item, _)
local playerItems = ESX.GetPlayerFromId(src).getInventory() -- wip
local repackedTable = {}
for _, v in pairs(playerItems) do
if v.name == item then
table.insert(repackedTable, {
name = v.name,
count = v.count,
--metadata = v.metadata,
--slot = v.slot,
})
end
end
return repackedTable
end end
-- Framework.GetItemCount(src, item, _) -- Framework.GetItemCount(src, item, _)
-- Returns the count of items matching the specified name and if passed metadata from the player's inventory. -- Returns the count of items matching the specified name and if passed metadata from the player's inventory.
Framework.GetItemCount = function(src, item, _) Framework.GetItemCount = function(src, item, _)
local xPlayer = ESX.GetPlayerFromId(src) -- wip
return xPlayer.getInventoryItem(item).count
end end
-- Framework.GetPlayerInventory(src) -- Framework.GetPlayerInventory(src)
-- Returns the entire inventory of the player as a table. -- Returns the entire inventory of the player as a table.
-- returns {name = v.name, count = v.amount, _, _} -- returns {name = v.name, count = v.amount, _, _}
Framework.GetPlayerInventory = function(src) Framework.GetPlayerInventory = function(src)
local playerItems = ESX.GetPlayerFromId(src).getInventory() -- wip
local repackedTable = {}
for _, v in pairs(playerItems) do
if v.count > 0 then
table.insert(repackedTable, {
name = v.name,
count = v.count,
--metadata = v.metadata,
--slot = v.slot,
})
end
end
return repackedTable
end end
-- Framework.SetMetadata(src, metadata, value) -- Framework.SetMetadata(src, metadata, value)
-- Adds the specified metadata key and number value to the player's data. -- Adds the specified metadata key and number value to the player's data.
Framework.SetPlayerMetadata = function(src, metadata, value) Framework.SetPlayerMetadata = function(src, metadata, value)
local xPlayer = ESX.GetPlayerFromId(src) -- wip
xPlayer.setMeta(metadata, value, nil)
return true
end end
-- Framework.GetMetadata(src, metadata) -- Framework.GetMetadata(src, metadata)
-- Gets the specified metadata key and value to the player's data. -- Gets the specified metadata key and value to the player's data.
Framework.GetPlayerMetadata = function(src, metadata) Framework.GetPlayerMetadata = function(src, metadata)
local xPlayer = ESX.GetPlayerFromId(src) -- wip
return xPlayer.getMeta(metadata) or false
end end
-- defualt esx Available tables are -- defualt esx Available tables are
@@ -84,116 +54,85 @@ end
-- skin, status, is_dead, id, disabled, last_property, created_at, last_seen, -- skin, status, is_dead, id, disabled, last_property, created_at, last_seen,
-- phone_number, pincode -- phone_number, pincode
Framework.GetStatus = function(src, column) Framework.GetStatus = function(src, column)
local xPlayer = ESX.GetPlayerFromId(src) -- wip
return xPlayer.get(column) or nil
end end
-- Framework.AddThirst(src, value) -- Framework.AddThirst(src, value)
-- Adds the specified value from the player's thirst level. -- Adds the specified value from the player's thirst level.
Framework.AddThirst = function(src, value) Framework.AddThirst = function(src, value)
local clampIT = Math.Clamp(value, 0, 200000) -- wip
local levelForEsx = clampIT * 2000
TriggerClientEvent('esx_status:add', src, 'thirst', levelForEsx)
return levelForEsx
end end
-- Framework.AddHunger(src, value) -- Framework.AddHunger(src, value)
-- Adds the specified value from the player's hunger level. -- Adds the specified value from the player's hunger level.
Framework.AddHunger = function(src, value) Framework.AddHunger = function(src, value)
local clampIT = Math.Clamp(value, 0, 200000) -- wip
local levelForEsx = clampIT * 2000
TriggerClientEvent('esx_status:add', src, 'hunger', levelForEsx)
return levelForEsx
end end
Framework.GetHunger = function(src) Framework.GetHunger = function(src)
local status = Framework.GetStatus(src, "status") -- wip
if not status then return 0 end
return status.hunger
end end
Framework.GetThirst = function(src) Framework.GetThirst = function(src)
local status = Framework.GetStatus(src, "status") -- wip
if not status then return 0 end
return status.thirst
end end
-- Framework.GetPlayerPhone(src) -- Framework.GetPlayerPhone(src)
-- Returns the phone number of the player. -- Returns the phone number of the player.
Framework.GetPlayerPhone = function(src) Framework.GetPlayerPhone = function(src)
local xPlayer = ESX.GetPlayerFromId(src) -- wip
return xPlayer.get("phone_number")
end end
-- Framework.GetPlayerJob(src) -- Framework.GetPlayerJob(src)
-- Returns the job name, label, grade name, and grade level of the player. -- Returns the job name, label, grade name, and grade level of the player.
Framework.GetPlayerJob = function(src) Framework.GetPlayerJob = function(src)
local xPlayer = ESX.GetPlayerFromId(src) -- wip
return xPlayer.getJob().name, xPlayer.getJob().label, xPlayer.getJob().grade_label, xPlayer.getJob().grade
end end
-- Framework.GetPlayersByJob(jobname) -- Framework.GetPlayersByJob(jobname)
-- returns a table of player sources that have the specified job name. -- returns a table of player sources that have the specified job name.
Framework.GetPlayersByJob = function(job) Framework.GetPlayersByJob = function(job)
local players = GetPlayers() -- wip
local playerList = {}
for _, src in pairs(players) do
local xPlayer = ESX.GetPlayerFromId(src)
if xPlayer.getJob().name == job then
table.insert(playerList, src)
end
end
return playerList
end end
-- Framework.SetPlayerJob(src, name, grade) -- Framework.SetPlayerJob(src, name, grade)
-- Sets the player's job to the specified name and grade. -- Sets the player's job to the specified name and grade.
Framework.SetPlayerJob = function(src, name, grade) Framework.SetPlayerJob = function(src, name, grade)
local xPlayer = ESX.GetPlayerFromId(src) -- wip
if not ESX.DoesJobExist(name, grade) then lib.print.error("Job Does Not Exsist In Framework :NAME "..name.." Grade:"..grade) return end
return xPlayer.setJob(name, grade, true)
end end
Framework.ToggleDuty = function(src, status) Framework.ToggleDuty = function(src, status)
local xPlayer = ESX.GetPlayerFromId(src) -- wip
local name = xPlayer.getJob().name
local grade = xPlayer.getJob().grade
xPlayer.setJob(name, grade, status)
end end
-- Framework.AddAccountBalance(src, _type, amount) -- Framework.AddAccountBalance(src, _type, amount)
-- Adds the specified amount to the player's account balance of the specified type. -- Adds the specified amount to the player's account balance of the specified type.
Framework.AddAccountBalance = function(src, _type, amount) Framework.AddAccountBalance = function(src, _type, amount)
local xPlayer = ESX.GetPlayerFromId(src) -- wip
return xPlayer.addAccountMoney(_type, amount)
end end
-- Framework.RemoveAccountBalance(src, _type, amount) -- Framework.RemoveAccountBalance(src, _type, amount)
-- Removes the specified amount from the player's account balance of the specified type. -- Removes the specified amount from the player's account balance of the specified type.
Framework.RemoveAccountBalance = function(src, _type, amount) Framework.RemoveAccountBalance = function(src, _type, amount)
local xPlayer = ESX.GetPlayerFromId(src) -- wip
return xPlayer.removeAccountMoney(_type, amount)
end end
-- Framework.GetAccountBalance(src, _type) -- Framework.GetAccountBalance(src, _type)
-- Returns the player's account balance of the specified type. -- Returns the player's account balance of the specified type.
Framework.GetAccountBalance = function(src, _type) Framework.GetAccountBalance = function(src, _type)
local xPlayer = ESX.GetPlayerFromId(src) -- wip
return xPlayer.getAccount(_type).money
end end
-- Framework.AddItem(src, item, amount, _, _) -- Framework.AddItem(src, item, amount, _, _)
-- Adds the specified item to the player's inventory. -- Adds the specified item to the player's inventory.
Framework.AddItem = function(src, item, amount, slot, metadata) Framework.AddItem = function(src, item, amount, slot, metadata)
local xPlayer = ESX.GetPlayerFromId(src) -- wip
return xPlayer.addInventoryItem(item, amount)
end end
-- Framework.RemoveItem(src, item, amount, _, _) -- Framework.RemoveItem(src, item, amount, _, _)
-- Removes the specified item from the player's inventory. -- Removes the specified item from the player's inventory.
Framework.RemoveItem = function(src, item, amount, slot, metadata) Framework.RemoveItem = function(src, item, amount, slot, metadata)
local xPlayer = ESX.GetPlayerFromId(src) -- wip
return xPlayer.removeInventoryItem(item, amount)
end end
-- Framework.RegisterUsableItem(item, cb) -- Framework.RegisterUsableItem(item, cb)
@@ -206,13 +145,3 @@ Framework.RegisterUsableItem = function(itemName, cb)
end end
end) end)
end end
Framework.Commands = {}
Framework.Commands.Add = function(name, help, arguments, argsrequired, callback, permission, ...)
ESX.RegisterCommand(name, permission, function(xPlayer, args, showError)
callback(xPlayer, args)
end, false, {
help = help,
arguments = arguments
})
end