Skip to content

Commit

Permalink
convert: esx_basicneeds > bpt_basicneeds
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator authored Jun 10, 2024
1 parent 80a1fe5 commit a0cc7de
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions server-data/resources/[bpt_addons]/bpt_basicneeds/server/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
CreateThread(function()
for k, v in pairs(Config.Items) do
ESX.RegisterUsableItem(k, function(source)
local xPlayer = ESX.GetPlayerFromId(source)
if v.remove then
xPlayer.removeInventoryItem(k, 1)
end
if v.type == "food" then
TriggerClientEvent("bpt_status:add", source, "hunger", v.status)
TriggerClientEvent("bpt_basicneeds:onUse", source, v.type, v.prop, v.anim)
xPlayer.showNotification(TranslateCap("used_food", ESX.GetItemLabel(k)))
elseif v.type == "drink" then
TriggerClientEvent("bpt_status:add", source, "thirst", v.status)
TriggerClientEvent("bpt_basicneeds:onUse", source, v.type, v.prop, v.anim)
xPlayer.showNotification(TranslateCap("used_drink", ESX.GetItemLabel(k)))
else
print(string.format("^1[ERROR]^0 %s has no correct type defined.", k))
end
end)
end
end)

ESX.RegisterCommand("heal", "admin", function(xPlayer, args, showError)
args.playerId.triggerEvent("bpt_basicneeds:healPlayer")
args.playerId.showNotification(TranslateCap("got_healed"))
end, true, { help = "Heal a player, or yourself - restores thirst, hunger and health.", validate = true, arguments = {
{ name = "playerId", help = "the player id", type = "player" },
} })

AddEventHandler("txAdmin:events:healedPlayer", function(eventData)
if GetInvokingResource() ~= "monitor" or type(eventData) ~= "table" or type(eventData.id) ~= "number" then
return
end

TriggerClientEvent("bpt_basicneeds:healPlayer", eventData.id)
end)

0 comments on commit a0cc7de

Please sign in to comment.