Update server.lua

This commit is contained in:
MrNewb committed 2025-01-22 20:03:34 -05:00
1 parent 4b76a4095a
commit 6e84b3f9ca
1 file changed
+24 -29
+24 -29
View File
@@ -1,18 +1,19 @@
local NDCore = exports["ND_Core"]:GetCoreObject() --local NDCore = exports["ND_Core"]:GetCoreObject()
local NDCore = exports["ND_Core"]
Framework = {} 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 player = NDCore.getPlayer(src) local player = NDCore:getPlayer(src)
return player.id return player.id
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 player = NDCore.getPlayer(src) local player = NDCore:getPlayer(src)
return player.fullname return player.fullname
end end
@@ -53,7 +54,7 @@ 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 player = NDCore.getPlayer(src) local player = NDCore:getPlayer(src)
player.setMetadata(metadata, value) player.setMetadata(metadata, value)
return true return true
end end
@@ -61,7 +62,7 @@ end
-- Framework.GetMetadata(src, metadata) -- Framework.GetMetadata(src, metadata)
-- Gets the specified metadata key to the player's data. -- Gets the specified metadata key to the player's data.
Framework.GetPlayerMetadata = function(src, metadata) Framework.GetPlayerMetadata = function(src, metadata)
local player = NDCore.getPlayer(src) local player = NDCore:getPlayer(src)
local playerData = player.getMetadata(metadata) local playerData = player.getMetadata(metadata)
return playerData or false return playerData or false
end end
@@ -83,39 +84,33 @@ 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 player = NDCore.getPlayer(src) -- Im stuck
local oldHunger = player.getMetadata("hunger").status
local newHunger = (oldHunger or 0) + value
player.setMetadata('hunger', Math.Clamp(newHunger, 0, 100))
return newHunger
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 player = NDCore.getPlayer(src) -- Im stuck
local oldThirst = player.getMetadata("thirst").status
local newThirst = (oldThirst or 0) + value
player.setMetadata('thirst', Math.Clamp(newThirst, 0, 100))
return newThirst
end end
Framework.GetHunger = function(src) Framework.GetHunger = function(src)
local player = NDCore.getPlayer(src) local player = NDCore:getPlayer(src)
local hunger = player.getMetadata("hunger") local metaData = player.metadata
return hunger.status local hunger = metaData.status.hunger.status
return hunger
end end
Framework.GetThirst = function(src) Framework.GetThirst = function(src)
local player = NDCore.getPlayer(src) local player = NDCore:getPlayer(src)
local thirst = player.getMetadata("thirst") local metaData = player.metadata
return thirst.status local thirst = metaData.status.thirst.status
return 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 player = NDCore.getPlayer(src) local player = NDCore:getPlayer(src)
return player.phonenumber return player.phonenumber
end end
@@ -130,7 +125,7 @@ end
-- 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 playerList = {} local playerList = {}
local players = NDCore.getPlayers("job", job, false) local players = NDCore:getPlayers("job", job, false)
for playerSource, _ in pairs(players) do for playerSource, _ in pairs(players) do
table.insert(playerList, playerSource) table.insert(playerList, playerSource)
end end
@@ -140,7 +135,7 @@ 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 player = NDCore.getPlayer(src) local player = NDCore:getPlayer(src)
local jobName, jobInfo = player.getJob() local jobName, jobInfo = player.getJob()
return jobInfo.name, jobInfo.label, jobInfo.rankName, jobInfo.rank return jobInfo.name, jobInfo.label, jobInfo.rankName, jobInfo.rank
end end
@@ -148,7 +143,7 @@ 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 player = NDCore.getPlayer(src) local player = NDCore:getPlayer(src)
return player.setJob(name, grade) return player.setJob(name, grade)
end end
@@ -160,7 +155,7 @@ 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 player = NDCore.getPlayer(src) local player = NDCore:getPlayer(src)
if _type == 'money' then _type = 'cash' end if _type == 'money' then _type = 'cash' end
return player.addMoney(_type, amount, "") return player.addMoney(_type, amount, "")
end end
@@ -168,7 +163,7 @@ 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 player = NDCore.getPlayer(src) local player = NDCore:getPlayer(src)
if _type == 'money' then _type = 'cash' end if _type == 'money' then _type = 'cash' end
return player.deductMoney(_type, amount, "") return player.deductMoney(_type, amount, "")
end end
@@ -176,9 +171,9 @@ 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 player = NDCore.getPlayer(src) local player = NDCore:getPlayer(src)
if _type == 'money' then _type = 'cash' end if _type == 'money' then _type = 'cash' end
return player.getAccount(_type) return player.getData(_type)
end end
Framework.RegisterUsableItem = function(itemName, cb) Framework.RegisterUsableItem = function(itemName, cb)