Skip to content

Commit

Permalink
Update v1.7.1
Browse files Browse the repository at this point in the history
* Fixed some Errors with ESX
  • Loading branch information
Musiker15 committed Sep 4, 2023
1 parent 856c4d7 commit 6511ab0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 32 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7
1.7.1
17 changes: 3 additions & 14 deletions client.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
if Config.Framework:match('ESX') then -- ESX Framework
ESX = exports["es_extended"]:getSharedObject()

RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer, isNew, skin)
ESX.PlayerData = xPlayer
end)

RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
ESX.PlayerData.job = job
end)
elseif Config.Framework:match('QBCore') then -- QBCore Framework
if Config.Framework:match('QBCore') then -- QBCore Framework
QBCore = exports['qb-core']:GetCoreObject()
end

Expand Down Expand Up @@ -42,10 +30,11 @@ CreateThread(function()
local sleep = 500
local playerPed = PlayerPedId()
local dist = #(GetEntityCoords(playerPed) - Config.startPoint.coords)
local playerJob
local playerJob = nil

if Config.blacklistedJobs.enable then
if Config.Framework:match('ESX') then -- ESX Framework
while not ESX.PlayerData.job do Wait(0) end
playerJob = ESX.PlayerData.job.name
elseif Config.Framework:match('QBCore') then -- QBCore Framework
playerJob = QBCore.Functions.GetPlayerData().job.name
Expand Down
2 changes: 1 addition & 1 deletion config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Config.Notification = function(source, message)
end
end
----------------------------------------------------------------
Config.Framework = 'ESX' -- 'ESX' or 'QBCore'
Config.Framework = 'ESX' -- 'ESX' or 'QBCore' // Remove es_extended from fxmanifest.lua if you are using QBCore
Config.Hotkey = 38 -- deafult: 38 = E

Config.Timeout = 10 -- in minutes // Timeout before the next blackout can be started
Expand Down
6 changes: 5 additions & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ games { 'gta5' }
author 'Musiker15 - MSK Scripts'
name 'msk_blackout'
description 'Weather Blackout Miniheist'
version '1.7'
version '1.7.1'

lua54 'yes'

shared_scripts {
'@es_extended/imports.lua', -- Remove if you are using QBCore !!!
'@msk_core/import.lua',
'@ox_lib/init.lua',
'config.lua',
Expand All @@ -25,6 +26,9 @@ server_scripts {
}

dependencies {
'es_extended', -- Remove if you are using QBCore !!!
-- 'qb-core', -- Remove if you are using ESX !!!

'msk_core', -- https://github.com/MSK-Scripts/msk_core
'oxmysql',
'ox_lib', -- https://github.com/overextended/ox_lib
Expand Down
24 changes: 9 additions & 15 deletions server.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
if Config.Framework:match('ESX') then -- ESX Framework
ESX = exports["es_extended"]:getSharedObject()
elseif Config.Framework:match('QBCore') then -- QBCore Framework
if Config.Framework:match('QBCore') then -- QBCore Framework
QBCore = exports['qb-core']:GetCoreObject()
end

Expand All @@ -11,11 +9,9 @@ AddEventHandler('msk_blackout:notifyJobs', function()
if not Config.notifyJobs.enable then return end

if Config.Framework:match('ESX') then
local xPlayers = ESX.GetPlayers()

for i = 1, #xPlayers do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
local xPlayers = ESX.GetExtendedPlayers()

for k, xPlayer in pairs(xPlayers) do
if MSK.Table_Contains(Config.notifyJobs.jobs, xPlayer.job.name) then
Config.Notification(xPlayer.source, Translation[Config.Locale]['job_notify_blackout_started'])
TriggerClientEvent('msk_blackout:sendJobBlipNotify', xPlayer.source)
Expand All @@ -24,8 +20,8 @@ AddEventHandler('msk_blackout:notifyJobs', function()
elseif Config.Framework:match('QBCore') then
local Players = QBCore.Functions.GetQBPlayers()

for i = 1, #Players do
local Player = QBCore.Functions.GetPlayer(Players[i])
for k, v in pairs(Players) do
local Player = QBCore.Functions.GetPlayer(v)

if MSK.Table_Contains(Config.notifyJobs.jobs, Player.PlayerData.job.name) then
Config.Notification(Player.PlayerData.source, Translation[Config.Locale]['job_notify_blackout_started'])
Expand Down Expand Up @@ -117,20 +113,18 @@ MSK.RegisterCallback('msk_blackout:getCops', function(source, cb)
local OnlineCops = 0

if Config.Framework:match('ESX') then
local xPlayers = ESX.GetPlayers()

for i = 1, #xPlayers do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
local xPlayers = ESX.GetExtendedPlayers()

for k, xPlayer in pairs(xPlayers) do
if MSK.Table_Contains(Config.Cops.jobs, xPlayer.job.name) then
OnlineCops = OnlineCops + 1
end
end
elseif Config.Framework:match('QBCore') then
local Players = QBCore.Functions.GetQBPlayers()

for i = 1, #Players do
local Player = QBCore.Functions.GetPlayer(Players[i])
for k, v in pairs(Players) do
local Player = QBCore.Functions.GetPlayer(v)

if MSK.Table_Contains(Config.Cops.jobs, Player.PlayerData.job.name) then
OnlineCops = OnlineCops + 1
Expand Down

0 comments on commit 6511ab0

Please sign in to comment.