Update server.lua
This commit is contained in:
1 parent
4b76a4095a
commit
6e84b3f9ca
1 file changed
+24
-29
@@ -1,18 +1,19 @@
|
||||
local NDCore = exports["ND_Core"]:GetCoreObject()
|
||||
--local NDCore = exports["ND_Core"]:GetCoreObject()
|
||||
local NDCore = exports["ND_Core"]
|
||||
|
||||
Framework = {}
|
||||
|
||||
-- Framework.GetPlayerIdentifier(src)
|
||||
-- Returns the citizen ID of the player.
|
||||
Framework.GetPlayerIdentifier = function(src)
|
||||
local player = NDCore.getPlayer(src)
|
||||
local player = NDCore:getPlayer(src)
|
||||
return player.id
|
||||
end
|
||||
|
||||
-- Framework.GetPlayerName(src)
|
||||
-- Returns the first and last name of the player.
|
||||
Framework.GetPlayerName = function(src)
|
||||
local player = NDCore.getPlayer(src)
|
||||
local player = NDCore:getPlayer(src)
|
||||
return player.fullname
|
||||
end
|
||||
|
||||
@@ -53,7 +54,7 @@ end
|
||||
-- Framework.SetMetadata(src, metadata, value)
|
||||
-- Adds the specified metadata key and number value to the player's data.
|
||||
Framework.SetPlayerMetadata = function(src, metadata, value)
|
||||
local player = NDCore.getPlayer(src)
|
||||
local player = NDCore:getPlayer(src)
|
||||
player.setMetadata(metadata, value)
|
||||
return true
|
||||
end
|
||||
@@ -61,7 +62,7 @@ end
|
||||
-- Framework.GetMetadata(src, metadata)
|
||||
-- Gets the specified metadata key to the player's data.
|
||||
Framework.GetPlayerMetadata = function(src, metadata)
|
||||
local player = NDCore.getPlayer(src)
|
||||
local player = NDCore:getPlayer(src)
|
||||
local playerData = player.getMetadata(metadata)
|
||||
return playerData or false
|
||||
end
|
||||
@@ -83,39 +84,33 @@ end
|
||||
-- Framework.AddHunger(src, value)
|
||||
-- Adds the specified value from the player's hunger level.
|
||||
Framework.AddHunger = function(src, value)
|
||||
local player = NDCore.getPlayer(src)
|
||||
local oldHunger = player.getMetadata("hunger").status
|
||||
local newHunger = (oldHunger or 0) + value
|
||||
player.setMetadata('hunger', Math.Clamp(newHunger, 0, 100))
|
||||
return newHunger
|
||||
-- Im stuck
|
||||
end
|
||||
|
||||
-- Framework.AddThirst(src, value)
|
||||
-- Adds the specified value from the player's thirst level.
|
||||
Framework.AddThirst = function(src, value)
|
||||
local player = NDCore.getPlayer(src)
|
||||
local oldThirst = player.getMetadata("thirst").status
|
||||
local newThirst = (oldThirst or 0) + value
|
||||
player.setMetadata('thirst', Math.Clamp(newThirst, 0, 100))
|
||||
return newThirst
|
||||
-- Im stuck
|
||||
end
|
||||
|
||||
Framework.GetHunger = function(src)
|
||||
local player = NDCore.getPlayer(src)
|
||||
local hunger = player.getMetadata("hunger")
|
||||
return hunger.status
|
||||
local player = NDCore:getPlayer(src)
|
||||
local metaData = player.metadata
|
||||
local hunger = metaData.status.hunger.status
|
||||
return hunger
|
||||
end
|
||||
|
||||
Framework.GetThirst = function(src)
|
||||
local player = NDCore.getPlayer(src)
|
||||
local thirst = player.getMetadata("thirst")
|
||||
return thirst.status
|
||||
local player = NDCore:getPlayer(src)
|
||||
local metaData = player.metadata
|
||||
local thirst = metaData.status.thirst.status
|
||||
return thirst
|
||||
end
|
||||
|
||||
-- Framework.GetPlayerPhone(src)
|
||||
-- Returns the phone number of the player.
|
||||
Framework.GetPlayerPhone = function(src)
|
||||
local player = NDCore.getPlayer(src)
|
||||
local player = NDCore:getPlayer(src)
|
||||
return player.phonenumber
|
||||
end
|
||||
|
||||
@@ -130,7 +125,7 @@ end
|
||||
-- returns a table of player sources that have the specified job name.
|
||||
Framework.GetPlayersByJob = function(job)
|
||||
local playerList = {}
|
||||
local players = NDCore.getPlayers("job", job, false)
|
||||
local players = NDCore:getPlayers("job", job, false)
|
||||
for playerSource, _ in pairs(players) do
|
||||
table.insert(playerList, playerSource)
|
||||
end
|
||||
@@ -140,7 +135,7 @@ end
|
||||
-- Framework.GetPlayerJob(src)
|
||||
-- Returns the job name, label, grade name, and grade level of the player.
|
||||
Framework.GetPlayerJob = function(src)
|
||||
local player = NDCore.getPlayer(src)
|
||||
local player = NDCore:getPlayer(src)
|
||||
local jobName, jobInfo = player.getJob()
|
||||
return jobInfo.name, jobInfo.label, jobInfo.rankName, jobInfo.rank
|
||||
end
|
||||
@@ -148,7 +143,7 @@ end
|
||||
-- Framework.SetPlayerJob(src, name, grade)
|
||||
-- Sets the player's job to the specified name and grade.
|
||||
Framework.SetPlayerJob = function(src, name, grade)
|
||||
local player = NDCore.getPlayer(src)
|
||||
local player = NDCore:getPlayer(src)
|
||||
return player.setJob(name, grade)
|
||||
end
|
||||
|
||||
@@ -160,7 +155,7 @@ end
|
||||
-- Framework.AddAccountBalance(src, _type, amount)
|
||||
-- Adds the specified amount to the player's account balance of the specified type.
|
||||
Framework.AddAccountBalance = function(src, _type, amount)
|
||||
local player = NDCore.getPlayer(src)
|
||||
local player = NDCore:getPlayer(src)
|
||||
if _type == 'money' then _type = 'cash' end
|
||||
return player.addMoney(_type, amount, "")
|
||||
end
|
||||
@@ -168,7 +163,7 @@ end
|
||||
-- Framework.RemoveAccountBalance(src, _type, amount)
|
||||
-- Removes the specified amount from the player's account balance of the specified type.
|
||||
Framework.RemoveAccountBalance = function(src, _type, amount)
|
||||
local player = NDCore.getPlayer(src)
|
||||
local player = NDCore:getPlayer(src)
|
||||
if _type == 'money' then _type = 'cash' end
|
||||
return player.deductMoney(_type, amount, "")
|
||||
end
|
||||
@@ -176,9 +171,9 @@ end
|
||||
-- Framework.GetAccountBalance(src, _type)
|
||||
-- Returns the player's account balance of the specified type.
|
||||
Framework.GetAccountBalance = function(src, _type)
|
||||
local player = NDCore.getPlayer(src)
|
||||
local player = NDCore:getPlayer(src)
|
||||
if _type == 'money' then _type = 'cash' end
|
||||
return player.getAccount(_type)
|
||||
return player.getData(_type)
|
||||
end
|
||||
|
||||
Framework.RegisterUsableItem = function(itemName, cb)
|
||||
|
||||
Reference in new issue
Block a user