Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions client/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,16 @@ WaitTimes = {
Speeding = 0,
}

function table_size(tbl)
local size = 0

for k, v in pairs(tbl) do
size = size + 1
end

return size
end

CreateThread(function()
while true do
if Config.Framework == "esx" then
PlayerData = Framework.GetPlayerData()
if table_size(PlayerData) > 0 then
if next(PlayerData) then
PlayerJob = PlayerData.job.name
end
else
PlayerData = Framework.Functions.GetPlayerData()
if table_size(PlayerData) > 0 then
if next(PlayerData) then
PlayerJob = PlayerData.job.name
end
end
Expand Down Expand Up @@ -83,9 +73,9 @@ CreateThread(function()
local gender

if Config.Framework == "esx" then
if PlayerData.sex == 1 then gender = "Female" else gender = "Male" end
gender = PlayerData.sex == 1 and "Female" or "Male"
else
if PlayerData.charinfo.gender == 1 then gender = "Female" else gender = "Male" end
gender = PlayerData.charinfo.gender == 1 and "Female" or "Male"
end

ShootingDispatch(location, coords, gender, weapon, vehicleName, vehicle, {"police"})
Expand Down Expand Up @@ -215,7 +205,7 @@ RegisterCommand('respondDispatch', function()
if latestDispatch then
SetWaypointOff()
SetNewWaypoint(latestDispatch.x, latestDispatch.y)
Config.Notification("Waypoint", "Waypoint Set.", "success", 5000)
Config.Notification(false, "Waypoint", "Waypoint Set.", "success", 5000)
latestDispatch = nil
end
end)
Expand Down
8 changes: 4 additions & 4 deletions client/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ function SendDispatch(title, code, blipSprite, jobs)
local gender

if Config.Framework == "esx" then
if PlayerData.sex == 1 then gender = "Female" else gender = "Male" end
gender = PlayerData.sex == 1 and "Female" or "Male"
else
if PlayerData.charinfo.gender == 1 then gender = "Female" else gender = "Male" end
gender = PlayerData.charinfo.gender == 1 and "Female" or "Male"
end

TriggerServerEvent("aty_dispatch:server:customDispatch", title, code, location, coords, gender, vehicleName, vehicle, weapon, blipSprite, jobs)
Expand All @@ -52,9 +52,9 @@ RegisterNetEvent("aty_dispatch:SendDispatch", function(title, code, blipSprite,
local gender

if Config.Framework == "esx" then
if PlayerData.sex == 1 then gender = "Female" else gender = "Male" end
gender = PlayerData.sex == 1 and "Female" or "Male"
else
if PlayerData.charinfo.gender == 1 then gender = "Female" else gender = "Male" end
gender = PlayerData.charinfo.gender == 1 and "Female" or "Male"
end

TriggerServerEvent("aty_dispatch:server:customDispatch", title, code, location, coords, gender, vehicleName, vehicle, weapon, blipSprite, jobs)
Expand Down
8 changes: 6 additions & 2 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ Config = {

BlipRemoveTime = 30, -- Seconds

Notification = function(title, message, type, length)
-- Your notification here
Notification = function(src, title, message, type, length)
if src then
-- Your Server Notification
else
-- Your Client Notification
end
end,

BlackListedWeapons = { -- Weapons that wont give andalert
Expand Down
87 changes: 38 additions & 49 deletions server/server.lua
Original file line number Diff line number Diff line change
@@ -1,94 +1,83 @@
Framework = Config.Framework == "esx" and exports['es_extended']:getSharedObject() or exports['qb-core']:GetCoreObject()

RegisterNetEvent("aty_dispatch:server:shootingDispatch", function(title, code, location, coords, gender, weapon, vehicleName, vehicle, jobs)
local players = GetPlayers()

for i, player in ipairs(players) do
local player = tonumber(player)
if Config.Framework == "qb" then
local xPlayer = Framework.Functions.GetPlayer(player)

if Config.Framework == "qb" then
local xPlayers = Framework.Functions.GetPlayers()
for i = 1, #xPlayers do
local src = xPlayers[i]
local xPlayer = Framework.Functions.GetPlayer(src)
if Config.UseGPS then
for _, job in pairs(jobs) do
local item = xPlayer.Functions.GetItemByName(Config.GPSItem) and xPlayer.Functions.GetItemByName(Config.GPSItem).amount or 0
if xPlayer.PlayerData.job.name == job and item > 0 then
TriggerClientEvent("aty_dispatch:client:shootingDispatch", player, title, code, location, coords, gender, weapon, vehicleName, vehicle)
TriggerClientEvent("aty_dispatch:client:shootingDispatch", src, title, code, location, coords, gender, weapon, vehicleName, vehicle)
elseif not item then
Config.Notification("GPS", "You don't have a gps on you.", "error", 5000)
Config.Notification(src, "GPS", "You don't have a gps on you.", "error", 5000)
end
end
else
for _, job in pairs(jobs) do
if xPlayer.PlayerData.job.name == job then
TriggerClientEvent("aty_dispatch:client:shootingDispatch", player, title, code, location, coords, gender, weapon, vehicleName, vehicle)
TriggerClientEvent("aty_dispatch:client:shootingDispatch", src, title, code, location, coords, gender, weapon, vehicleName, vehicle)
end
end
end
else
local xPlayer = Framework.GetPlayerFromId(player)

end
else
local xPlayers = Framework.GetExtendedPlayers('job', jobs)
for i = 1, #xPlayers do
local xPlayer = xPlayers[i]
if Config.UseGPS then
for _, job in pairs(jobs) do
local item = xPlayer.getInventoryItem(Config.GPSItem) and xPlayer.getInventoryItem(Config.GPSItem).count or 0
if xPlayer.job.name == job and item > 0 then
TriggerClientEvent("aty_dispatch:client:shootingDispatch", player, title, code, location, coords, gender, weapon, vehicleName, vehicle)
elseif not item then
Config.Notification("GPS", "You don't have a gps on you.", "error", 5000)
end
local item = xPlayer.getInventoryItem(Config.GPSItem) and xPlayer.getInventoryItem(Config.GPSItem).count or 0
if item > 0 then
TriggerClientEvent("aty_dispatch:client:shootingDispatch", xPlayer.source, title, code, location, coords, gender, weapon, vehicleName, vehicle)
elseif not item then
Config.Notification(xPlayer.source, "GPS", "You don't have a gps on you.", "error", 5000)
end
else
for _, job in pairs(jobs) do
if xPlayer.job.name == job then
TriggerClientEvent("aty_dispatch:client:shootingDispatch", player, title, code, location, coords, gender, weapon, vehicleName, vehicle)
end
end
TriggerClientEvent("aty_dispatch:client:shootingDispatch", xPlayer.source, title, code, location, coords, gender, weapon, vehicleName, vehicle)
end
end
end
end)

RegisterNetEvent("aty_dispatch:server:customDispatch", function(title, code, location, coords, gender, vehicleName, vehicle, weapon, blipSprite, jobs)
local players = GetPlayers()

for i, player in ipairs(players) do
local player = tonumber(player)
if Config.Framework == "qb" then
local xPlayer = Framework.Functions.GetPlayer(player)

if Config.Framework == "qb" then
local xPlayers = Framework.Functions.GetPlayers()
for i = 1, #xPlayers do
local src = xPlayers[i]
local xPlayer = Framework.Functions.GetPlayer(src)
if Config.UseGPS then
for _, job in pairs(jobs) do
local item = xPlayer.Functions.GetItemByName(Config.GPSItem) and xPlayer.Functions.GetItemByName(Config.GPSItem).amount or 0
if xPlayer.PlayerData.job.name == job and item > 0 then
TriggerClientEvent("aty_dispatch:client:customDispatch", player, title, code, location, coords, gender, vehicleName, vehicle, weapon, blipSprite)
TriggerClientEvent("aty_dispatch:client:customDispatch", src, title, code, location, coords, gender, vehicleName, vehicle, weapon, blipSprite)
elseif not item then
Config.Notification("GPS", "You don't have a gps on you.", "error", 5000)
Config.Notification(xPlayer.source, "GPS", "You don't have a gps on you.", "error", 5000)
end
end
else
for _, job in pairs(jobs) do
if xPlayer.PlayerData.job.name == job then
TriggerClientEvent("aty_dispatch:client:customDispatch", player, title, code, location, coords, gender, vehicleName, vehicle, weapon, blipSprite)
TriggerClientEvent("aty_dispatch:client:customDispatch", src, title, code, location, coords, gender, vehicleName, vehicle, weapon, blipSprite)
end
end
end
else
local xPlayer = Framework.GetPlayerFromId(player)

end
else
local xPlayers = Framework.GetExtendedPlayers('job', jobs)
for i = 1, #xPlayers do
local xPlayer = xPlayers[i]
if Config.UseGPS then
for _, job in pairs(jobs) do
local item = xPlayer.getInventoryItem(Config.GPSItem) and xPlayer.getInventoryItem(Config.GPSItem).count or 0
if xPlayer.job.name == job and item > 0 then
TriggerClientEvent("aty_dispatch:client:customDispatch", player, title, code, location, coords, gender, vehicleName, vehicle, weapon, blipSprite)
elseif not item then
Config.Notification("GPS", "You don't have a gps on you.", "error", 5000)
end
local item = xPlayer.getInventoryItem(Config.GPSItem) and xPlayer.getInventoryItem(Config.GPSItem).count or 0
if item > 0 then
TriggerClientEvent("aty_dispatch:client:customDispatch", xPlayer.source, title, code, location, coords, gender, vehicleName, vehicle, weapon, blipSprite)
elseif not item then
Config.Notification(xPlayer.source, "GPS", "You don't have a gps on you.", "error", 5000)
end
else
for _, job in pairs(jobs) do
if xPlayer.job.name == job then
TriggerClientEvent("aty_dispatch:client:customDispatch", player, title, code, location, coords, gender, vehicleName, vehicle, weapon, blipSprite)
end
end
TriggerClientEvent("aty_dispatch:client:customDispatch", xPlayer.source, title, code, location, coords, gender, vehicleName, vehicle, weapon, blipSprite)
end
end
end
Expand Down