1
0
Fork 0
forked from Simnation/Main
Main/resources/[inventory]/mr-consumables/open/server/sv_functions.lua
2025-06-07 08:51:21 +02:00

42 lines
1.7 KiB
Lua

function Notify(src, text, type) -- You Can Put Your Own Notification System Here
TriggerClientEvent("QBCore:Notify", src, text, type)
end
function OnMetadataSet(src, ItemName, Metadata, NewValue) -- You Can Use This Function To Trigger Anything You Want When An Item Has Been Used Like Buffs
if Metadata == "hunger" or Metadata == "thirst" then -- Make Sure This Function Stays Here If You Want Your HUD to Update Once It Changed
local Player = Core.Functions.GetPlayer(src)
if Player then
TriggerClientEvent("hud:client:UpdateNeeds", src, Player.PlayerData.metadata['hunger'],
Player.PlayerData.metadata['thirst'])
end
end
end
function BanCheater(src) -- Add Ban If You Want, The Function This Triggered By Will Get Returned Anyway If This Function Will Trigger
print("BAN CHEATER")
end
local PlayerSounds = {} -- DON'T REMOVE THIS IF YOU ARE USING SOUNDS
function PlaySound(src, sound)
if not Config.Sounds.Enabled then return end
if GetResourceState(Config.Sounds.Resource) ~= "started" then
DebugPrint("ERROR", "The Sound Resource Does Not Exists Therefore Sounds Are Not Enabled")
return
end
if PlayerSounds[src] then
exports.xsound:Destroy(src, PlayerSounds[src])
end
PlayerSounds[src] = string.format("consumables_%s", src)
exports.xsound:PlayUrlPos(src, PlayerSounds[src], sound, Config.Sounds.Volume, GetEntityCoords(GetPlayerPed(src)))
Wait(100)
exports.xsound:Distance(PlayerSounds[src], Config.Sounds.Distance)
end
function StopSound(src)
if not Config.Sounds.Enabled then return end
if PlayerSounds[src] then
exports.xsound:Destroy(src, PlayerSounds[src])
PlayerSounds[src] = nil
end
end