Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MAV = MAV or {}
- Core = Core or nil
- -- Here you can modify all the functions that the HUD uses, in case you use a different ESX or QB or even another framework.
- MAV.Debug = function(...)
- if not Config.Debug then return end
- print(('^4[' .. GetCurrentResourceName() .. ']^7 # %s'):format(...))
- end
- if GetResourceState('es_extended') == 'started' then
- Core = exports['es_extended']:getSharedObject()
- MAV.Debug('framework - esx')
- end
- if GetResourceState('qb-core') == 'started' then
- Core = exports['qb-core']:GetCoreObject()
- MAV.Debug('framework - qbcore')
- end
- -- ? Events
- MAV.Events = MAV.Events or {}
- MAV.Events.OnPlayerLoaded = function ()
- local events = {
- ['qb'] = 'QBCore:Client:OnPlayerLoaded',
- ['esx'] = 'esx:playerLoaded'
- }
- return events[Config.Framework]
- end
- MAV.Events.OnPlayerUnload = function()
- local events = {
- ['qb'] = 'QBCore:Client:OnPlayerUnload',
- ['esx'] = 'esx:onPlayerLogout'
- }
- return events[Config.Framework]
- end
- MAV.Events.OnJobUpdate = function()
- local events = {
- ['qb'] = 'QBCore:Client:OnJobUpdate',
- ['esx'] = 'esx:setJob'
- }
- return events[Config.Framework]
- end
- MAV.Events.OnUpdateNeeds = function()
- local events = {
- ['qb'] = 'hud:client:UpdateNeeds',
- ['esx'] = 'esx_status:onTick'
- }
- return events[Config.Framework]
- end
- MAV.Events.OnMoneyChange = function()
- local events = {
- ['qb'] = 'hud:client:OnMoneyChange',
- ['esx'] = 'esx:setAccountMoney'
- }
- return events[Config.Framework]
- end
- -- ? Functions
- MAV.Functions = MAV.Functions or {}
- -- Get the notification
- -- @return void
- MAV.Functions.Notify = function(message, type)
- if Config.Framework == 'qb' then
- Core.Functions.Notify(message, type)
- end
- if Config.Framework == 'esx' then
- Core.ShowNotification(message, type, 3000)
- end
- end
- -- Get the current fuel of the vehicle
- -- @param vehicle
- -- @return number
- MAV.Functions.GetFuel = function(vehicle)
- if Config.Framework == 'qb' then
- return exports["bit-fuel"]:GetFuelLevel(vehicle)
- end
- if Config.Framework == 'esx' then
- local level = GetVehicleFuelLevel(vehicle)
- return Core.Math.Round(level, 1)
- end
- end
- -- Get the current job of the player
- -- @param job
- -- @return table
- MAV.Functions.GetJob = function(job)
- if Config.Framework == 'qb' then
- return {
- name = job.name,
- level = Config.Jobs[job.name][job.grade.level]
- }
- end
- if Config.Framework == 'esx' then
- return {
- name = job.name,
- level = job.grade_name
- }
- end
- end
- -- Get the current player data
- -- @return object
- MAV.Functions.GetPlayerData = function()
- if Config.Framework == 'qb' then
- return Core.Functions.GetPlayerData()
- end
- if Config.Framework == 'esx' then
- return Core.GetPlayerData()
- end
- end
- -- Get account money of the current player
- -- @return table
- MAV.Functions.GetAccount = function()
- if Config.Framework == 'qb' then
- local data = MAV.Functions.GetPlayerData()
- return {
- wallet = data.money['cash'],
- bank = data.money['bank']
- }
- end
- if Config.Framework == 'esx' then
- local data = MAV.Functions.GetPlayerData()
- return {
- wallet = data.accounts[2].money,
- bank = data.accounts[1].money
- }
- end
- end
- -- Check if the player is logged or not
- -- @return boolean
- MAV.Functions.PlayerIsLogged = function()
- if Config.Framework == 'qb' then return LocalPlayer.state.isLoggedIn end
- if Config.Framework == 'esx' then return Core.IsPlayerLoaded() end
- end
- -- Check if the weapon is whitelisted for the stress
- -- @return boolean
- MAV.Functions.IsWhitelistedWeaponStress = function(weapon)
- if weapon then
- for _, v in pairs(Config.WhitelistedWeaponStress) do
- if weapon == v then
- return true
- end
- end
- end
- return false
- end
- -- Get the effect interval
- -- @param level
- -- @return number
- MAV.Functions.GetEffectInterval = function(level)
- for _, v in pairs(Config.EffectInterval) do
- if level >= v.min and level <= v.max then
- return v.timeout
- end
- end
- return 60000
- end
- -- Get the blur intensity
- -- @param stress
- -- @return number
- MAV.Functions.GetBlurIntensity = function(stress)
- for _, v in pairs(Config.Intensity['BLUR']) do
- if stress >= v.min and stress <= v.max then
- return v.intensity
- end
- end
- return 1500
- end
- MAV.Functions.PlaySound = function(Data)
- if Data.Enabled then
- PlaySoundFrontend(-1, Data.AudioName, Data.AudioRef, true)
- end
- end
- if Config.Debug then
- for cb, _ in pairs(MAV.Functions) do
- MAV.Debug(('function - MAV.Functions.%s'):format(
- cb
- ))
- end
- for _, event in pairs(MAV.Events) do
- MAV.Debug(('event - %s'):format(
- event()
- ))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement