esx_status
https://github.com/esx-framework/esx_status
ESX Status is a basic script that provides an easy way to add player status’s to your server. It is what allows esx_basicneeds
to handle the player’s hunger and thirst.
Configuration
Config.StatusMax
- type:
integer
- default:
1000000
- description: The maximum value a status can have.
- type:
Config.TickTime
- type:
integer
- default:
1000
- description: The time in milliseconds between each tick.
- type:
Config.UpdateInterval
- type:
integer
- default:
10000
- description: The time in milliseconds between each status save.
- type:
Config.Display
- type:
boolean
- default:
false
- description: Whether to display the status on the screen.
- type:
Usage
Client
registerStatus
Parameters:
name
(string): The name of the status.default
(number): The default value of the status.color
(table): The color of the status.r
(number): The red value of the color.g
(number): The green value of the color.b
(number): The blue value of the color.
visible
(boolean): (deprecated) Whether the status is visible on the screen.tickCallback
(function): A function that is called every status tick.
Example:
TriggerEvent("esx_status:registerStatus", 'hunger', 1000000, {r = 255, g = 255, b = 255}, function(status)
status.remove(1000)
end)
unregisterStatus
Parameters:
name
(string): The name of the status.
Example:
TriggerEvent("esx_status:unregisterStatus", 'hunger')
set
Sets the value of a status.
Parameters:
name
(string): The name of the status.val
(number): The value to set the status to.
Example:
TriggerEvent("esx_status:set", 'hunger', 1000000)
add
Adds a value to a status.
Parameters:
name
(string): The name of the status.val
(number): The value to add to the status.
Example:
TriggerEvent("esx_status:add", 'hunger', 1000)
remove
Removes a value from a status.
Parameters:
name
(string): The name of the status.val
(number): The value to remove from the status.
Example:
TriggerEvent("esx_status:remove", 'hunger', 1000)
getStatus
Gets the value of a status.
Parameters:
name
(string): The name of the status.callback
(function): A function that is called with the status value.
Example:
TriggerEvent("esx_status:getStatus", 'hunger', function(status)
print(status.val)
end)
getAllStatus
Gets the value of all statuses.
Parameters:
callback
(function): A function that is called with a table of all status values.
Example:
TriggerEvent("esx_status:getAllStatus", function(stats)
for i=1, #stats, 1 do
print(stats[i].name, stats[i].val)
end
end)
Server
getStatus
Gets the value of a status.
Parameters:
source
(number): The player’s server ID.name
(string): The name of the status.callback
(function): A function that is called with the status value.
Example:
TriggerEvent("esx_status:getStatus", source, 'hunger', function(status)
print(status.val)
end)
update
This is Triggered automatically, and should not be called manually.