-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
abe0cdd
commit 0146fa4
Showing
9 changed files
with
122 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,27 @@ | ||
# NPWD App for QB Services. Requires NPWD 1.5.0 or higher. | ||
<h1 align='center'>[NPWD] Services App</a></h1><p align='center'><b><a href='https://discord.gg/uy5N7jT5aJ'>Discord</a> - <a href='https://github.com/project-error'>Github</a> - <a href='https://projecterror.dev/docs/'>Documentation</a></b></h5> | ||
~ | ||
External NPWD app for Calling Services. | ||
|
||
### Make sure you have OxMyql | ||
Framework is automatically detected for ESX and QBCore | ||
|
||
![preview](https://user-images.githubusercontent.com/97451137/184982211-754f223f-8163-44ac-8b11-b7b07fece10c.png) | ||
|
||
## Requirements | ||
|
||
- NPWD (1.5.0 or higher) | ||
- oxmysql | ||
- ESX *or* QBcore | ||
|
||
## Install | ||
1. Download the `npwd_qb_services.zip` from releases. DO NOT CHANGE THE RESOURCE NAME. If you want to change it, you'll have to download the source code, alter `fetchNui.ts`, and build the project. | ||
1. Download the `npwd_services.zip` from releases. DO NOT CHANGE THE RESOURCE NAME. If you want to change it, you'll have to download the source code, alter `fetchNui.ts`, and build the project. | ||
2. Unzip and add the resource to your server resources folder | ||
3. Ensure `npwd_qb_services` BEFORE `npwd` | ||
4. Add app to NPWD config.json in the `apps` section `"apps": ["npwd_qb_services]` | ||
|
||
## Preview | ||
![7eb7fcc02058624e3cdfb2d2514d59ac](https://user-images.githubusercontent.com/97451137/184982211-754f223f-8163-44ac-8b11-b7b07fece10c.png) | ||
3. Ensure `npwd_services` BEFORE `npwd` | ||
4. Add app to NPWD config.json in the `apps` section `"apps": ["npwd_services]` | ||
|
||
#### PS: thanks chip cuz I stole half of it from esx app | ||
|
||
# Credits | ||
|
||
- chip (most of it from esx app) | ||
- Mycroft (Conveting to ESX) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,42 @@ | ||
RegisterNUICallback("npwd:qb-services:getPlayers", function(_, cb) | ||
TriggerServerEvent("npwd:qb-services:getPlayers") | ||
RegisterNetEvent("npwd:qb-services:sendPlayers", function(players) | ||
cb({ status = "ok", data = players }) | ||
local isESX = GetResourceState("es_extended") ~= "missing" | ||
local isQB = GetResourceState("qb-core") ~= "missing" | ||
local FrameworkObj = {} | ||
if isESX and isQB then | ||
print("[ERROR] You are using both ESX and QB-Core, please remove one of them.") | ||
elseif isESX then | ||
FrameworkObj = exports["es_extended"]:getSharedObject() | ||
elseif isQB then | ||
FrameworkObj = exports["qb-core"]:GetCoreObject() | ||
end | ||
|
||
if isESX then | ||
RegisterNUICallback("npwd:services:getPlayers", function(_, cb) | ||
FrameworkObj.TriggerServerCallback("npwd:services:getPlayers", function(PlayerList) | ||
cb({ status = "ok", data = PlayerList }) | ||
end) | ||
end) | ||
|
||
|
||
RegisterNUICallback("npwd:services:callPlayer", function(data, cb) | ||
-- print(data.job) job of player being called | ||
exports.npwd:startPhoneCall(tostring(data.number)) | ||
cb({}) | ||
end) | ||
end) | ||
end | ||
|
||
if isQB then | ||
RegisterNUICallback("npwd:services:getPlayers", function(_, cb) | ||
TriggerServerEvent("npwd:services:getPlayers") | ||
RegisterNetEvent("npwd:services:sendPlayers", function(players) | ||
cb({ status = "ok", data = players }) | ||
end) | ||
end) | ||
|
||
|
||
RegisterNUICallback("npwd:services:callPlayer", function(data, cb) | ||
-- print(data.job) job of player being called | ||
exports.npwd:startPhoneCall(tostring(data.number)) | ||
cb({}) | ||
end) | ||
end | ||
|
||
RegisterNUICallback("npwd:qb-services:callPlayer", function(data, cb) | ||
-- print(data.job) job of player being called | ||
exports.npwd:startPhoneCall(tostring(data.number)) | ||
cb({}) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,55 @@ | ||
local QBCore = exports['qb-core']:GetCoreObject() | ||
local isESX = GetResourceState("es_extended") ~= "missing" | ||
local isQB = GetResourceState("qb-core") ~= "missing" | ||
local FrameworkObj = {} | ||
if isESX and isQB then | ||
print("[ERROR] You are using both ESX and QB-Core, please remove one of them.") | ||
elseif isESX then | ||
FrameworkObj = exports["es_extended"]:getSharedObject() | ||
elseif isQB then | ||
FrameworkObj = exports["qb-core"]:GetCoreObject() | ||
end | ||
|
||
RegisterNetEvent("npwd:qb-services:getPlayers", function() | ||
local src = source | ||
local players = QBCore.Functions.GetQBPlayers() | ||
local playerList = {} | ||
if isESX then | ||
FrameworkObj.RegisterServerCallback('npwd:services:getPlayers', function(src, cb) | ||
local PlayerList = {} | ||
|
||
for jobIndex =1, #Config.Jobs do | ||
local PlayersWithJob = FrameworkObj.GetExtendedPlayers("job", Config.Jobs[jobIndex]) | ||
for playerIndex = 1, #PlayersWithJob do | ||
local xPlayer = PlayersWithJob[playerIndex] | ||
local PlayerData = exports.npwd:getPlayerData({source = src}) | ||
PlayerList[#PlayerList + 1] = { | ||
name = xPlayer.getName(), | ||
job = xPlayer.job.name, | ||
phoneNumber = PlayerData.phoneNumber, | ||
} | ||
end | ||
end | ||
cb(PlayerList) | ||
end) | ||
end | ||
|
||
if isQB then | ||
RegisterNetEvent("npwd:services:getPlayers", function() | ||
local src = source | ||
local players = FrameworkObj.Functions.GetQBPlayers() | ||
local playerList = {} | ||
|
||
for i = 1, #players do | ||
if not Config.ShowOffDuty and players[i].PlayerData.job.onduty then | ||
for _, job in pairs(Config.Jobs) do | ||
if job == players[i].PlayerData.job.name then | ||
table.insert(playerList, { | ||
name = players[i].PlayerData.charinfo.firstname .. " " .. players[i].PlayerData.charinfo.lastname, | ||
job = players[i].PlayerData.job.name, | ||
phoneNumber = players[i].PlayerData.charinfo.phone, | ||
}) | ||
|
||
for i = 1, #players do | ||
if not Config.ShowOffDuty and players[i].PlayerData.job.onduty then | ||
for _, job in pairs(Config.Jobs) do | ||
if job == players[i].PlayerData.job.name then | ||
table.insert(playerList, { | ||
name = players[i].PlayerData.charinfo.firstname .. " " .. players[i].PlayerData.charinfo.lastname, | ||
job = players[i].PlayerData.job.name, | ||
phoneNumber = players[i].PlayerData.charinfo.phone, | ||
}) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
TriggerClientEvent('npwd:qb-services:sendPlayers', src, playerList) | ||
end) | ||
|
||
|
||
|
||
TriggerClientEvent('npwd:services:sendPlayers', src, playerList) | ||
end) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters