mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-18 14:26:03 +01:00
Updated 2.1.0
Updated everything to new format, N1K0 is about to work on some more stuff.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
author "Andyyy#7666"
|
author "Andyyy#7666"
|
||||||
description "ND Framework ATMs"
|
description "ND Framework ATMs"
|
||||||
version "2.0.0"
|
version "2.1.0"
|
||||||
|
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
game "gta5"
|
game "gta5"
|
||||||
@@ -18,3 +18,5 @@ files {
|
|||||||
|
|
||||||
server_script "source/server.lua"
|
server_script "source/server.lua"
|
||||||
client_script "source/client.lua"
|
client_script "source/client.lua"
|
||||||
|
|
||||||
|
dependency "ND_Core"
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||||
|
|
||||||
|
NDCore = exports["ND_Core"]:GetCoreObject()
|
||||||
local display = false
|
local display = false
|
||||||
local nearModel = false
|
local nearModel = false
|
||||||
|
|
||||||
@@ -35,13 +36,13 @@ end
|
|||||||
|
|
||||||
-- Hide/Show ui
|
-- Hide/Show ui
|
||||||
function SetDisplay(bool)
|
function SetDisplay(bool)
|
||||||
local playerInfo = exports["ND_Core"]:getCharacterInfo()
|
local selectedCharacter = NDCore.functions:getSelectedCharacter()
|
||||||
display = bool
|
display = bool
|
||||||
SetNuiFocus(bool, bool)
|
SetNuiFocus(bool, bool)
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
status = bool,
|
status = bool,
|
||||||
playerName = playerInfo.firstName .. " " .. playerInfo.lastName,
|
playerName = selectedCharacter.firstName .. " " .. selectedCharacter.lastName,
|
||||||
balance = "Account Balance: $" .. playerInfo.bank .. ".00",
|
balance = "Account Balance: $" .. selectedCharacter.bank .. ".00",
|
||||||
date = days[GetClockDayOfWeek() + 1],
|
date = days[GetClockDayOfWeek() + 1],
|
||||||
time = getTime()
|
time = getTime()
|
||||||
})
|
})
|
||||||
@@ -116,7 +117,7 @@ RegisterNUICallback("useATM", function(data)
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
TriggerServerEvent("ND_ATM:withdraw", data.amount)
|
TriggerServerEvent("ND_ATMs:withdraw", data.amount)
|
||||||
elseif action == "DEPOSIT" then
|
elseif action == "DEPOSIT" then
|
||||||
if data.amount == "" then
|
if data.amount == "" then
|
||||||
Citizen.Wait(1000)
|
Citizen.Wait(1000)
|
||||||
@@ -125,17 +126,17 @@ RegisterNUICallback("useATM", function(data)
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
TriggerServerEvent("ND_ATM:deposit", data.amount)
|
TriggerServerEvent("ND_ATMs:deposit", data.amount)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- update the balance on the ui and confirm if the deposit/withdraw was successful.
|
-- update the balance on the ui and confirm if the deposit/withdraw was successful.
|
||||||
RegisterNetEvent("ND_ATM:update")
|
RegisterNetEvent("ND_ATMs:update")
|
||||||
AddEventHandler("ND_ATM:update", function(status)
|
AddEventHandler("ND_ATMs:update", function(status)
|
||||||
Citizen.Wait(1000)
|
Citizen.Wait(1000)
|
||||||
local playerInfo = exports["ND_Core"]:getCharacterInfo()
|
local selectedCharacter = NDCore.functions:getSelectedCharacter()
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
balance = "Account Balance: $" .. playerInfo.bank .. ".00",
|
balance = "Account Balance: $" .. selectedCharacter.bank .. ".00",
|
||||||
success = status
|
success = status
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
@@ -1,13 +1,16 @@
|
|||||||
RegisterNetEvent("ND_ATM:withdraw")
|
NDCore = exports["ND_Core"]:GetCoreObject()
|
||||||
AddEventHandler("ND_ATM:withdraw", function(amount)
|
NDCore.functions:versionChecker("ND_ATMs", GetCurrentResourceName(), "https://github.com/Andyyy7666/ND_Framework", "https://raw.githubusercontent.com/Andyyy7666/ND_Framework/main/ND_ATMs/fxmanifest.lua")
|
||||||
|
|
||||||
|
RegisterNetEvent("ND_ATMs:withdraw")
|
||||||
|
AddEventHandler("ND_ATMs:withdraw", function(amount)
|
||||||
local player = source
|
local player = source
|
||||||
local update = exports["ND_Core"]:withdrawMoney(amount, player)
|
local update = NDCore.functions:withdrawMoney(amount, player)
|
||||||
TriggerClientEvent("ND_ATM:update", player, update)
|
TriggerClientEvent("ND_ATMs:update", player, update)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent("ND_ATM:deposit")
|
RegisterNetEvent("ND_ATMs:deposit")
|
||||||
AddEventHandler("ND_ATM:deposit", function(amount)
|
AddEventHandler("ND_ATMs:deposit", function(amount)
|
||||||
local player = source
|
local player = source
|
||||||
local update = exports["ND_Core"]:depositMoney(amount, player)
|
local update = NDCore.functions:depositMoney(amount, player)
|
||||||
TriggerClientEvent("ND_ATM:update", player, update)
|
TriggerClientEvent("ND_ATMs:update", player, update)
|
||||||
end)
|
end)
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
author "Andyyy#7666"
|
author "Andyyy#7666"
|
||||||
description "ND Framework Banks"
|
description "ND Framework Banks"
|
||||||
version "2.0.0"
|
version "2.1.0"
|
||||||
|
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
game "gta5"
|
game "gta5"
|
||||||
@@ -18,3 +18,5 @@ files {
|
|||||||
|
|
||||||
server_script "source/server.lua"
|
server_script "source/server.lua"
|
||||||
client_script "source/client.lua"
|
client_script "source/client.lua"
|
||||||
|
|
||||||
|
dependency "ND_Core"
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||||
|
|
||||||
|
NDCore = exports["ND_Core"]:GetCoreObject()
|
||||||
local display = false
|
local display = false
|
||||||
local nearModel = false
|
local nearModel = false
|
||||||
|
|
||||||
@@ -38,13 +39,13 @@ end
|
|||||||
|
|
||||||
-- Hide/Show ui
|
-- Hide/Show ui
|
||||||
function SetDisplay(bool)
|
function SetDisplay(bool)
|
||||||
local playerInfo = exports["ND_Core"]:getCharacterInfo()
|
local selectedCharacter = NDCore.functions:getSelectedCharacter()
|
||||||
display = bool
|
display = bool
|
||||||
SetNuiFocus(bool, bool)
|
SetNuiFocus(bool, bool)
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
status = bool,
|
status = bool,
|
||||||
playerName = playerInfo.firstName .. " " .. playerInfo.lastName,
|
playerName = selectedCharacter.firstName .. " " .. selectedCharacter.lastName,
|
||||||
balance = "Account Balance: $" .. playerInfo.bank .. ".00",
|
balance = "Account Balance: $" .. selectedCharacter.bank .. ".00",
|
||||||
date = days[GetClockDayOfWeek() + 1],
|
date = days[GetClockDayOfWeek() + 1],
|
||||||
time = getTime()
|
time = getTime()
|
||||||
})
|
})
|
||||||
@@ -145,9 +146,9 @@ end)
|
|||||||
RegisterNetEvent("ND_Banks:update")
|
RegisterNetEvent("ND_Banks:update")
|
||||||
AddEventHandler("ND_Banks:update", function(status)
|
AddEventHandler("ND_Banks:update", function(status)
|
||||||
Citizen.Wait(1000)
|
Citizen.Wait(1000)
|
||||||
local playerInfo = exports["ND_Core"]:getCharacterInfo()
|
local selectedCharacter = NDCore.functions:getSelectedCharacter()
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
balance = "Account Balance: $" .. playerInfo.bank .. ".00",
|
balance = "Account Balance: $" .. selectedCharacter.bank .. ".00",
|
||||||
success = status
|
success = status
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
@@ -1,20 +1,23 @@
|
|||||||
|
NDCore = exports["ND_Core"]:GetCoreObject()
|
||||||
|
NDCore.functions:versionChecker("ND_Banks", GetCurrentResourceName(), "https://github.com/Andyyy7666/ND_Framework", "https://raw.githubusercontent.com/Andyyy7666/ND_Framework/main/ND_Banks/fxmanifest.lua")
|
||||||
|
|
||||||
RegisterNetEvent("ND_Banks:withdraw")
|
RegisterNetEvent("ND_Banks:withdraw")
|
||||||
AddEventHandler("ND_Banks:withdraw", function(amount)
|
AddEventHandler("ND_Banks:withdraw", function(amount)
|
||||||
local player = source
|
local player = source
|
||||||
local update = exports["ND_Core"]:withdrawMoney(amount, player)
|
local update = NDCore.functions:withdrawMoney(amount, player)
|
||||||
TriggerClientEvent("ND_Banks:update", player, update)
|
TriggerClientEvent("ND_Banks:update", player, update)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent("ND_Banks:deposit")
|
RegisterNetEvent("ND_Banks:deposit")
|
||||||
AddEventHandler("ND_Banks:deposit", function(amount)
|
AddEventHandler("ND_Banks:deposit", function(amount)
|
||||||
local player = source
|
local player = source
|
||||||
local update = exports["ND_Core"]:depositMoney(amount, player)
|
local update = NDCore.functions:depositMoney(amount, player)
|
||||||
TriggerClientEvent("ND_Banks:update", player, update)
|
TriggerClientEvent("ND_Banks:update", player, update)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent("ND_Banks:transfer")
|
RegisterNetEvent("ND_Banks:transfer")
|
||||||
AddEventHandler("ND_Banks:transfer", function(amount, target)
|
AddEventHandler("ND_Banks:transfer", function(amount, target)
|
||||||
local player = source
|
local player = source
|
||||||
local update = exports["ND_Core"]:transferBank(amount, player, target)
|
local update = NDCore.functions:transferBank(amount, player, target)
|
||||||
TriggerClientEvent("ND_Banks:update", player, update)
|
TriggerClientEvent("ND_Banks:update", player, update)
|
||||||
end)
|
end)
|
||||||
56
ND_CharacterSelection/config.lua
Normal file
56
ND_CharacterSelection/config.lua
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||||
|
|
||||||
|
config = {
|
||||||
|
changeCharacterCommand = "changecharacter", -- this is the command to open the ui again and change your character.
|
||||||
|
|
||||||
|
characterSelectionAopDisplay = false,
|
||||||
|
aop = function ()
|
||||||
|
return "AOP: " .. exports["SimpleHUD"]:getAOP() -- exports["ModernHUD"]:getAOP()
|
||||||
|
end,
|
||||||
|
|
||||||
|
-- set your backgrounds, if you have more than 1 then it will randomly change everytime you open the ui.
|
||||||
|
backgrounds = {
|
||||||
|
"https://i.imgur.com/E51ckFx.png", -- Credits: Fuzzman270#0270
|
||||||
|
"https://i.imgur.com/SeZD7TP.png", -- Credits: Fuzzman270#0270
|
||||||
|
"https://i.imgur.com/ZWKfYD9.png" -- Credits: 2XRondo#6374
|
||||||
|
},
|
||||||
|
|
||||||
|
departments = {
|
||||||
|
["CIV"] = {"0"},
|
||||||
|
["SAHP"] = {"0"},
|
||||||
|
["LSPD"] = {"0"},
|
||||||
|
["BCSO"] = {"872921520719142932"},
|
||||||
|
["LSFD"] = {"872921520719142932"}
|
||||||
|
},
|
||||||
|
|
||||||
|
-- set up the spawn buttons for each department.
|
||||||
|
spawns = {
|
||||||
|
["CIV"] = {
|
||||||
|
{x = -102.78, y = 6336.28, z = 31.49, name = "Dream View Motel (Paleto Bay)"},
|
||||||
|
{x = 343.53, y = 2636.94, z = 43.94, name = "Eastern Motel (Sandy Shores)"},
|
||||||
|
{x = 196.96, y = -934.54, z = 29.69, name = "Legion Square"},
|
||||||
|
{x = -1616.69, y = -1073.81, z = 12.15, name = "Del Perro Pier"},
|
||||||
|
{x = -1039.65, y = -2741.02, z = 12.89, name = "LSIA"}
|
||||||
|
},
|
||||||
|
["SAHP"] = {
|
||||||
|
{x = -447.2, y = 6009.4, z = 30.72, name = "Paleto Bay Sheriff"},
|
||||||
|
{x = 1849.4, y = 3688.6, z = 33.27, name = "Sandy Shores Sheriff"},
|
||||||
|
{x = 437.6, y = -986.6, z = 29.69, name = "Mission Row PD"}
|
||||||
|
},
|
||||||
|
["LSPD"] = {
|
||||||
|
{x = -447.2, y = 6009.4, z = 30.72, name = "Paleto Bay Sheriff"},
|
||||||
|
{x = 1849.4, y = 3688.6, z = 33.27, name = "Sandy Shores Sheriff"},
|
||||||
|
{x = 437.6, y = -986.6, z = 29.69, name = "Mission Row PD"}
|
||||||
|
},
|
||||||
|
["BCSO"] = {
|
||||||
|
{x = -447.2, y = 6009.4, z = 30.72, name = "Paleto Bay Sheriff"},
|
||||||
|
{x = 1849.4, y = 3688.6, z = 33.27, name = "Sandy Shores Sheriff"},
|
||||||
|
{x = 437.6, y = -986.6, z = 29.69, name = "Mission Row Police "}
|
||||||
|
},
|
||||||
|
["LSFD"] = {
|
||||||
|
{x = -384.07, y = 6117.9, z = 30.48, name = "Fire Station No1 (Paleto Bay)"},
|
||||||
|
{x = 1691.5, y = 3597.95, z = 34.56, name = "Fire Station No2 (Sandy Shores)"},
|
||||||
|
{x = 1194.71, y = -1474.14, z = 33.86, name = "Fire Station No7 (Los Santos)"}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
22
ND_CharacterSelection/fxmanifest.lua
Normal file
22
ND_CharacterSelection/fxmanifest.lua
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||||
|
|
||||||
|
author "Andyyy#7666"
|
||||||
|
description "ND Character Selection (DOJ Based)"
|
||||||
|
version "2.1.0"
|
||||||
|
|
||||||
|
fx_version "cerulean"
|
||||||
|
game "gta5"
|
||||||
|
lua54 "yes"
|
||||||
|
|
||||||
|
files {
|
||||||
|
"source/ui/index.html",
|
||||||
|
"source/ui/script.js",
|
||||||
|
"source/ui/style.css"
|
||||||
|
}
|
||||||
|
ui_page "source/ui/index.html"
|
||||||
|
|
||||||
|
shared_script "config.lua"
|
||||||
|
server_script "source/server.lua"
|
||||||
|
client_script "source/client.lua"
|
||||||
|
|
||||||
|
dependency "ND_Core"
|
||||||
192
ND_CharacterSelection/source/client.lua
Normal file
192
ND_CharacterSelection/source/client.lua
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||||
|
|
||||||
|
NDCore = exports["ND_Core"]:GetCoreObject()
|
||||||
|
|
||||||
|
function tablelength(table)
|
||||||
|
local count = 0
|
||||||
|
for _ in pairs(table) do
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
return count
|
||||||
|
end
|
||||||
|
|
||||||
|
function SetDisplay(bool, typeName, bg)
|
||||||
|
if not bg then
|
||||||
|
background = config.backgrounds[math.random(1, #config.backgrounds)]
|
||||||
|
end
|
||||||
|
SetNuiFocus(bool, bool)
|
||||||
|
SendNUIMessage({
|
||||||
|
type = typeName,
|
||||||
|
background = background,
|
||||||
|
status = bool,
|
||||||
|
serverName = NDCore.config.serverName,
|
||||||
|
characterAmount = tablelength(NDCore.characters) .. "/" .. NDCore.config.characterLimit
|
||||||
|
})
|
||||||
|
if config.characterSelectionAopDisplay then
|
||||||
|
SendNUIMessage({
|
||||||
|
type = "aop",
|
||||||
|
aop = config.aop()
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function start(switch)
|
||||||
|
TriggerServerEvent("ND_CharacterSelection:checkPerms")
|
||||||
|
TriggerServerEvent("ND:getCharacters")
|
||||||
|
if switch then
|
||||||
|
local ped = PlayerPedId()
|
||||||
|
SwitchOutPlayer(ped, 0, 1)
|
||||||
|
FreezeEntityPosition(ped, true)
|
||||||
|
SetEntityVisible(ped, false, 0)
|
||||||
|
end
|
||||||
|
SendNUIMessage({
|
||||||
|
type = "onStart",
|
||||||
|
maxStartingBank = NDCore.config.startingBank,
|
||||||
|
maxStartingCash = NDCore.config.startingCash
|
||||||
|
})
|
||||||
|
if config.characterSelectionAopDisplay then
|
||||||
|
SendNUIMessage({
|
||||||
|
type = "aop",
|
||||||
|
aop = config.aop()
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
AddEventHandler("onResourceStart", function(resourceName)
|
||||||
|
if (GetCurrentResourceName() ~= resourceName) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
Citizen.Wait(2000)
|
||||||
|
start(false)
|
||||||
|
end)
|
||||||
|
|
||||||
|
AddEventHandler("playerSpawned", function()
|
||||||
|
start(true)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- This is used to add department drop down on the ui.
|
||||||
|
RegisterNetEvent("ND_CharacterSelection:permsChecked")
|
||||||
|
AddEventHandler("ND_CharacterSelection:permsChecked", function(allowedRoles)
|
||||||
|
for _, dept in pairs(allowedRoles) do
|
||||||
|
SendNUIMessage({
|
||||||
|
type = "givePerms",
|
||||||
|
deptRole = dept
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Gets all the characters and displays them on the ui.
|
||||||
|
RegisterNetEvent("ND:returnCharacters")
|
||||||
|
AddEventHandler("ND:returnCharacters", function(characters)
|
||||||
|
SendNUIMessage({
|
||||||
|
type = "refresh"
|
||||||
|
})
|
||||||
|
for _, character in pairs(characters) do
|
||||||
|
SendNUIMessage({
|
||||||
|
type = "character",
|
||||||
|
id = character.id,
|
||||||
|
firstName = character.firstName,
|
||||||
|
lastName = character.lastName,
|
||||||
|
dateOfBirth = character.dob,
|
||||||
|
gender = character.gender,
|
||||||
|
twtName = character.twt,
|
||||||
|
department = character.job,
|
||||||
|
startingCash = character.cash,
|
||||||
|
startingBank = character.bank
|
||||||
|
})
|
||||||
|
end
|
||||||
|
SetDisplay(true, "ui", background)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Selecting a player from the iu.
|
||||||
|
RegisterNUICallback("setMainCharacter", function(data)
|
||||||
|
NDCore.functions:getCharacters(function(characters)
|
||||||
|
NDCore.selectedCharacter = characters[data.id]
|
||||||
|
end)
|
||||||
|
for _, spawn in pairs(config.spawns[NDCore.selectedCharacter.job]) do
|
||||||
|
SendNUIMessage({
|
||||||
|
type = "setSpawns",
|
||||||
|
x = spawn.x,
|
||||||
|
y = spawn.y,
|
||||||
|
z = spawn.z,
|
||||||
|
name = spawn.name
|
||||||
|
})
|
||||||
|
end
|
||||||
|
TriggerServerEvent("ND:setCharacterOnline", NDCore.selectedCharacter.id)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Creating a character from the ui.
|
||||||
|
RegisterNUICallback("newCharacter", function(data)
|
||||||
|
if tablelength(NDCore.characters) < NDCore.config.characterLimit then
|
||||||
|
TriggerServerEvent("ND_CharacterSelection:newCharacter", {
|
||||||
|
firstName = data.firstName,
|
||||||
|
lastName = data.lastName,
|
||||||
|
dob = data.dateOfBirth,
|
||||||
|
gender = data.gender,
|
||||||
|
twt = data.twtName,
|
||||||
|
job = data.department,
|
||||||
|
cash = data.startingCash,
|
||||||
|
bank = data.startingBank
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- editing a character from the ui.
|
||||||
|
RegisterNUICallback("editCharacter", function(data)
|
||||||
|
TriggerServerEvent("ND_CharacterSelection:editCharacter", {
|
||||||
|
id = data.id,
|
||||||
|
firstName = data.firstName,
|
||||||
|
lastName = data.lastName,
|
||||||
|
dob = data.dateOfBirth,
|
||||||
|
gender = data.gender,
|
||||||
|
twt = data.twtName,
|
||||||
|
job = data.department
|
||||||
|
})
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- deleting a character from the ui.
|
||||||
|
RegisterNUICallback("delCharacter", function(data)
|
||||||
|
TriggerServerEvent("ND:deleteCharacter", data.character)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Quit button from ui.
|
||||||
|
RegisterNUICallback("exitGame", function()
|
||||||
|
TriggerServerEvent("ND:exitGame")
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Teleporting using ui.
|
||||||
|
RegisterNUICallback("tpToLocation", function(data)
|
||||||
|
local ped = PlayerPedId()
|
||||||
|
FreezeEntityPosition(ped, false)
|
||||||
|
SetEntityCoords(ped, tonumber(data.x), tonumber(data.y), tonumber(data.z), false, false, false, false)
|
||||||
|
FreezeEntityPosition(ped, true)
|
||||||
|
SwitchInPlayer(ped)
|
||||||
|
Citizen.Wait(500)
|
||||||
|
SetDisplay(false, "ui")
|
||||||
|
Citizen.Wait(500)
|
||||||
|
FreezeEntityPosition(ped, false)
|
||||||
|
SetEntityVisible(ped, true, 0)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Choosing the do not tp button.
|
||||||
|
RegisterNUICallback("tpDoNot", function()
|
||||||
|
local ped = PlayerPedId()
|
||||||
|
SwitchInPlayer(ped)
|
||||||
|
Citizen.Wait(500)
|
||||||
|
SetDisplay(false, "ui")
|
||||||
|
Citizen.Wait(500)
|
||||||
|
SetEntityVisible(ped, true, 0)
|
||||||
|
FreezeEntityPosition(ped, false)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Change character command
|
||||||
|
RegisterCommand(config.changeCharacterCommand, function()
|
||||||
|
SwitchOutPlayer(PlayerPedId(), 0, 1)
|
||||||
|
Citizen.Wait(2000)
|
||||||
|
FreezeEntityPosition(ped, true)
|
||||||
|
SetEntityVisible(ped, false, 0)
|
||||||
|
SetDisplay(true, "ui")
|
||||||
|
end, false)
|
||||||
|
|
||||||
|
-- chat suggestions
|
||||||
|
TriggerEvent("chat:addSuggestion", "/" .. config.changeCharacterCommand, "Switch your framework character.")
|
||||||
67
ND_CharacterSelection/source/server.lua
Normal file
67
ND_CharacterSelection/source/server.lua
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||||
|
|
||||||
|
NDCore = exports["ND_Core"]:GetCoreObject()
|
||||||
|
|
||||||
|
function validateDepartment(player, department)
|
||||||
|
local departmentExists = config.departments[department]
|
||||||
|
if departmentExists then
|
||||||
|
local discordUserId = string.gsub(NDCore.functions:GetPlayerIdentifierFromType("discord", player), "discord:", "")
|
||||||
|
local roles = NDCore.functions:getUserDiscordInfo(discordUserId).roles
|
||||||
|
|
||||||
|
-- validate that the player actually has the role that they selected on the client.
|
||||||
|
for _, roleId in pairs(departmentExists) do
|
||||||
|
if roles[roleId] or roleId == 0 or roleId == "0" then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Creating a new character.
|
||||||
|
RegisterNetEvent("ND_CharacterSelection:newCharacter")
|
||||||
|
AddEventHandler("ND_CharacterSelection:newCharacter", function(newCharacter)
|
||||||
|
local player = source
|
||||||
|
|
||||||
|
-- validate that the person has permission to use the department.
|
||||||
|
local departmentCheck = validateDepartment(player, newCharacter.job)
|
||||||
|
if not departmentCheck then return end
|
||||||
|
|
||||||
|
-- Create the character if the player has permission to the department.
|
||||||
|
NDCore.functions:createCharacter(player, newCharacter.firstName, newCharacter.lastName, newCharacter.dob, newCharacter.gender, newCharacter.twt, newCharacter.job, newCharacter.cash, newCharacter.bank)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Update the character info when edited.
|
||||||
|
RegisterNetEvent("ND_CharacterSelection:editCharacter")
|
||||||
|
AddEventHandler("ND_CharacterSelection:editCharacter", function(newCharacter)
|
||||||
|
local player = source
|
||||||
|
|
||||||
|
-- validate that the person has permission to use the department.
|
||||||
|
local departmentCheck = validateDepartment(player, newCharacter.job)
|
||||||
|
if not departmentCheck then return end
|
||||||
|
|
||||||
|
-- Updating the character information in the database.
|
||||||
|
NDCore.functions:updateCharacterData(newCharacter.id, newCharacter.firstName, newCharacter.lastName, newCharacter.dob, newCharacter.gender, newCharacter.twt, newCharacter.job)
|
||||||
|
|
||||||
|
-- Updating characters on the client.
|
||||||
|
TriggerClientEvent("ND:returnCharacters", player, NDCore.functions:getPlayerCharacters(player))
|
||||||
|
end)
|
||||||
|
|
||||||
|
RegisterNetEvent("ND_CharacterSelection:checkPerms")
|
||||||
|
AddEventHandler("ND_CharacterSelection:checkPerms", function()
|
||||||
|
local player = source
|
||||||
|
local discordUserId = string.gsub(NDCore.functions:GetPlayerIdentifierFromType("discord", player), "discord:", "")
|
||||||
|
local allowedRoles = {}
|
||||||
|
local roles = NDCore.functions:getUserDiscordInfo(discordUserId).roles
|
||||||
|
|
||||||
|
-- Check if the players discord roles will grant them permission to the department.
|
||||||
|
for dept, roleTable in pairs(config.departments) do
|
||||||
|
for _, roleId in pairs(roleTable) do
|
||||||
|
if roles[roleId] or roleId == 0 or roleId == "0" then
|
||||||
|
table.insert(allowedRoles, dept)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
TriggerClientEvent("ND_CharacterSelection:permsChecked", player, allowedRoles)
|
||||||
|
end)
|
||||||
@@ -148,15 +148,7 @@ $(function() {
|
|||||||
$(`#characterButton${id}`).click(function() {
|
$(`#characterButton${id}`).click(function() {
|
||||||
spawnMenu(true)
|
spawnMenu(true)
|
||||||
$.post(`https://${GetParentResourceName()}/setMainCharacter`, JSON.stringify({
|
$.post(`https://${GetParentResourceName()}/setMainCharacter`, JSON.stringify({
|
||||||
firstName: firstName,
|
id: id
|
||||||
lastName: lastName,
|
|
||||||
dateOfBirth: dateOfBirth,
|
|
||||||
gender: gender,
|
|
||||||
twtName: twtName,
|
|
||||||
department: department,
|
|
||||||
startingCash: startingCash,
|
|
||||||
startingBank: startingBank,
|
|
||||||
character: id
|
|
||||||
}));
|
}));
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
85
ND_Core/client/main.lua
Normal file
85
ND_Core/client/main.lua
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||||
|
|
||||||
|
NDCore = {}
|
||||||
|
NDCore.selectedCharacter = nil
|
||||||
|
NDCore.characters = {}
|
||||||
|
NDCore.functions = {}
|
||||||
|
NDCore.config = config
|
||||||
|
|
||||||
|
function GetCoreObject()
|
||||||
|
return NDCore
|
||||||
|
end
|
||||||
|
|
||||||
|
function NDCore.functions:getSelectedCharacter(cb)
|
||||||
|
if not cb then return NDCore.selectedCharacter end
|
||||||
|
cb(NDCore.selectedCharacter)
|
||||||
|
end
|
||||||
|
|
||||||
|
function NDCore.functions:getCharacters(cb)
|
||||||
|
if not cb then return NDCore.selectedCharacter end
|
||||||
|
cb(NDCore.characters)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- discord rich precense will show on a users profile.
|
||||||
|
if config.enableRichPrecence then
|
||||||
|
Citizen.CreateThread(function()
|
||||||
|
SetDiscordAppId(config.appId)
|
||||||
|
while true do
|
||||||
|
if NDCore.selectedCharacter then
|
||||||
|
SetRichPresence(" Playing : " .. config.serverName .. " as " .. NDCore.selectedCharacter.firstName .. " " .. NDCore.selectedCharacter.lastName)
|
||||||
|
SetDiscordRichPresenceAsset(config.largeLogo)
|
||||||
|
SetDiscordRichPresenceAssetText("Playing: " .. config.serverName)
|
||||||
|
SetDiscordRichPresenceAssetSmall(config.smallLogo)
|
||||||
|
SetDiscordRichPresenceAssetSmallText("Playing as: " .. NDCore.selectedCharacter.firstName .. " " .. NDCore.selectedCharacter.lastName)
|
||||||
|
SetDiscordRichPresenceAction(0, config.firstButtonName, config.firstButtonLink)
|
||||||
|
SetDiscordRichPresenceAction(1, config.secondButtonName, config.secondButtonLink)
|
||||||
|
end
|
||||||
|
Citizen.Wait(config.updateIntervall * 1000)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- show server name, first name, last name, and the amount of money the character has in the pause menu.
|
||||||
|
if config.customPauseMenu then
|
||||||
|
Citizen.CreateThread(function()
|
||||||
|
while true do
|
||||||
|
Citizen.Wait(0)
|
||||||
|
if NDCore.selectedCharacter then
|
||||||
|
if IsPauseMenuActive() then
|
||||||
|
BeginScaleformMovieMethodOnFrontendHeader("SET_HEADING_DETAILS")
|
||||||
|
AddTextEntry("FE_THDR_GTAO", config.serverName)
|
||||||
|
ScaleformMovieMethodAddParamPlayerNameString(NDCore.selectedCharacter.firstName .. " " .. NDCore.selectedCharacter.lastName)
|
||||||
|
PushScaleformMovieFunctionParameterString("Cash: $" .. tostring(NDCore.selectedCharacter.cash))
|
||||||
|
PushScaleformMovieFunctionParameterString("Bank: $" .. tostring(NDCore.selectedCharacter.bank))
|
||||||
|
EndScaleformMovieMethod()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
RegisterNetEvent("ND:returnCharacters")
|
||||||
|
AddEventHandler("ND:returnCharacters", function(characters)
|
||||||
|
NDCore.characters = characters
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- updates the money on the client.
|
||||||
|
RegisterNetEvent("ND:updateMoney")
|
||||||
|
AddEventHandler("ND:updateMoney", function(cash, bank)
|
||||||
|
NDCore.selectedCharacter.cash = cash
|
||||||
|
NDCore.selectedCharacter.bank = bank
|
||||||
|
end)
|
||||||
|
|
||||||
|
RegisterNetEvent("ND:setCharacter")
|
||||||
|
AddEventHandler("ND:setCharacter", function(character)
|
||||||
|
NDCore.selectedCharacter = character
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Enables pvp if it's selected in the config.
|
||||||
|
AddEventHandler("playerSpawned", function()
|
||||||
|
if config.enablePVP then
|
||||||
|
SetCanAttackFriendly(PlayerPedId(), true, false)
|
||||||
|
NetworkSetFriendlyFireOption(true)
|
||||||
|
end
|
||||||
|
print("^0This framework is created by ^5Andyyy#7666 ^0for support you can join the ^5discord: ^0https://discord.gg/Z9Mxu72zZ6")
|
||||||
|
end)
|
||||||
@@ -2,62 +2,19 @@
|
|||||||
|
|
||||||
config = {
|
config = {
|
||||||
serverName = "Andy's Development",
|
serverName = "Andy's Development",
|
||||||
characterLimit = 15,
|
characterLimit = 15, -- How many characters can a player create.
|
||||||
changeCharacterCommand = "changecharacter", -- this is the command to open the ui again and change your character.
|
customPauseMenu = true, -- A custom pause menu will display your money, characters name and the server name in the pause menu.
|
||||||
customPauseMenu = true, -- this will create a custom pause menu. It will display your money, characters name and the server name in the pause menu.
|
enablePVP = true, -- pvp allows doing damage to other players.
|
||||||
|
|
||||||
-- set your backgrounds, if you have more than 1 then it will randomly change everytime you open the ui.
|
|
||||||
backgrounds = {
|
|
||||||
"https://i.imgur.com/E51ckFx.png", -- Credits: Fuzzman270#0270
|
|
||||||
"https://i.imgur.com/SeZD7TP.png", -- Credits: Fuzzman270#0270
|
|
||||||
"https://i.imgur.com/ZWKfYD9.png" -- Credits: 2XRondo#6374
|
|
||||||
},
|
|
||||||
|
|
||||||
departments = {
|
|
||||||
["CIV"] = {"872921520719142932"},
|
|
||||||
["SAHP"] = {"872921520719142932"},
|
|
||||||
["LSPD"] = {"872921520719142932"},
|
|
||||||
["BCSO"] = {"872921520719142932"},
|
|
||||||
["LSFD"] = {"872921520719142932"}
|
|
||||||
},
|
|
||||||
|
|
||||||
-- set up the spawn buttons for each department.
|
|
||||||
spawns = {
|
|
||||||
["CIV"] = {
|
|
||||||
{x = -102.78, y = 6336.28, z = 31.49, name = "Dream View Motel (Paleto Bay)"},
|
|
||||||
{x = 343.53, y = 2636.94, z = 43.94, name = "Eastern Motel (Sandy Shores)"},
|
|
||||||
{x = 196.96, y = -934.54, z = 29.69, name = "Legion Square"},
|
|
||||||
{x = -1616.69, y = -1073.81, z = 12.15, name = "Del Perro Pier"},
|
|
||||||
{x = -1039.65, y = -2741.02, z = 12.89, name = "LSIA"}
|
|
||||||
},
|
|
||||||
["SAHP"] = {
|
|
||||||
{x = -447.2, y = 6009.4, z = 30.72, name = "Paleto Bay Sheriff"},
|
|
||||||
{x = 1849.4, y = 3688.6, z = 33.27, name = "Sandy Shores Sheriff"},
|
|
||||||
{x = 437.6, y = -986.6, z = 29.69, name = "Mission Row PD"}
|
|
||||||
},
|
|
||||||
["LSPD"] = {
|
|
||||||
{x = -447.2, y = 6009.4, z = 30.72, name = "Paleto Bay Sheriff"},
|
|
||||||
{x = 1849.4, y = 3688.6, z = 33.27, name = "Sandy Shores Sheriff"},
|
|
||||||
{x = 437.6, y = -986.6, z = 29.69, name = "Mission Row PD"}
|
|
||||||
},
|
|
||||||
["BCSO"] = {
|
|
||||||
{x = -447.2, y = 6009.4, z = 30.72, name = "Paleto Bay Sheriff"},
|
|
||||||
{x = 1849.4, y = 3688.6, z = 33.27, name = "Sandy Shores Sheriff"},
|
|
||||||
{x = 437.6, y = -986.6, z = 29.69, name = "Mission Row Police "}
|
|
||||||
},
|
|
||||||
["LSFD"] = {
|
|
||||||
{x = -384.07, y = 6117.9, z = 30.48, name = "Fire Station No1 (Paleto Bay)"},
|
|
||||||
{x = 1691.5, y = 3597.95, z = 34.56, name = "Fire Station No2 (Sandy Shores)"},
|
|
||||||
{x = 1194.71, y = -1474.14, z = 33.86, name = "Fire Station No7 (Los Santos)"}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
-- Money related
|
-- Money related
|
||||||
enableMoneySystem = true,
|
startingCash = 2500, -- default cash the character will start with if the character creator doesn't specify it.
|
||||||
maxStartingCash = 2500,
|
startingBank = 8000,-- default money in the bank account the character will start with if the character creator doesn't specify it.
|
||||||
maxStartingBank = 8000,
|
|
||||||
payCommand = "pay", -- Command to transfer money from your bank to another persons.
|
-- If you'd like to whitelist certain roles on discord then set this to true and add role ids.
|
||||||
giveCommand = "give", -- Command to give someone near you cash.
|
enableDiscordWhitelist = false,
|
||||||
|
whitelistRoles = {
|
||||||
|
"0"
|
||||||
|
},
|
||||||
|
|
||||||
-- Discord Rich presence
|
-- Discord Rich presence
|
||||||
enableRichPresence = true,
|
enableRichPresence = true,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||||
|
|
||||||
server_config = {
|
server_config = {
|
||||||
discordServerToken = "", -- discord bot token for permissions
|
discordServerToken = "OTAwODg1MDMxMDQ2Nzc0ODQ1.GU1TSC.Ed8D2_wcU-UQ1vZhe1khahgV8J3hLahOp4N1D8", -- discord bot token for permissions
|
||||||
guildId = "", -- discord guild id
|
guildId = "872496972454592523", -- discord guild id
|
||||||
}
|
}
|
||||||
@@ -1,57 +1,29 @@
|
|||||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||||
|
|
||||||
author "Andyyy#7666"
|
author "Andyyy#7666"
|
||||||
description "ND-Core"
|
description "ND Framework Core"
|
||||||
version "2.0.0"
|
version "3.0.0"
|
||||||
|
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
game "gta5"
|
game "gta5"
|
||||||
lua54 "yes"
|
lua54 "yes"
|
||||||
|
|
||||||
files {
|
|
||||||
"source/ui/index.html",
|
|
||||||
"source/ui/script.js",
|
|
||||||
"source/ui/style.css"
|
|
||||||
}
|
|
||||||
ui_page "source/ui/index.html"
|
|
||||||
|
|
||||||
shared_script "config_client.lua"
|
shared_script "config_client.lua"
|
||||||
client_script "source/client.lua"
|
client_script "client/main.lua"
|
||||||
server_scripts {
|
server_scripts {
|
||||||
|
"@oxmysql/lib/MySQL.lua",
|
||||||
"config_server.lua",
|
"config_server.lua",
|
||||||
"source/server.lua"
|
"server/main.lua",
|
||||||
|
"server/functions.lua",
|
||||||
|
"server/events.lua"
|
||||||
}
|
}
|
||||||
|
|
||||||
exports {
|
exports {
|
||||||
"getCharacterInfo",
|
"GetCoreObject"
|
||||||
}
|
}
|
||||||
|
|
||||||
server_exports {
|
server_exports {
|
||||||
"transferBank", -- exports["ND_Core"]:transferBank(amount, player, target)
|
"GetCoreObject"
|
||||||
"giveCashToClosestTarget", -- exports["ND_Core"]:giveCashToClosestTarget(amount, player)
|
|
||||||
"withdrawMoney", -- exports["ND_Core"]:withdrawMoney(amount, player)
|
|
||||||
"depositMoney", -- exports["ND_Core"]:depositMoney(amount, player)
|
|
||||||
"deductMoney", -- exports["ND_Core"]:deductMoney(amount, player, from)
|
|
||||||
"addMoney", -- exports["ND_Core"]:addMoney(amount, player, to)
|
|
||||||
"getCharacterTable" -- exports["ND_Core"]:getCharacterTable() this will return a table with all the online players and their info. View below on how to use this.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependency "oxmysql"
|
dependency "oxmysql"
|
||||||
|
|
||||||
--[[
|
|
||||||
Keys in the getCharacterTable:
|
|
||||||
|
|
||||||
characterId
|
|
||||||
firstName
|
|
||||||
lastName
|
|
||||||
dob
|
|
||||||
gender
|
|
||||||
twt
|
|
||||||
dept
|
|
||||||
cash
|
|
||||||
bank
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
players = exports["ND_Core"]:getCharacterTable()
|
|
||||||
print(players[3].bank) this will print the bank account of the player with id 3.
|
|
||||||
]]
|
|
||||||
@@ -6,7 +6,7 @@ CREATE TABLE `characters` (
|
|||||||
`dob` VARCHAR(50) NULL DEFAULT NULL,
|
`dob` VARCHAR(50) NULL DEFAULT NULL,
|
||||||
`gender` VARCHAR(50) NULL DEFAULT NULL,
|
`gender` VARCHAR(50) NULL DEFAULT NULL,
|
||||||
`twt` VARCHAR(50) NULL DEFAULT NULL,
|
`twt` VARCHAR(50) NULL DEFAULT NULL,
|
||||||
`department` VARCHAR(50) NULL DEFAULT NULL,
|
`job` VARCHAR(50) NULL DEFAULT NULL,
|
||||||
`cash` INT(10) NULL DEFAULT '0',
|
`cash` INT(10) NULL DEFAULT '0',
|
||||||
`bank` INT(10) NULL DEFAULT '0',
|
`bank` INT(10) NULL DEFAULT '0',
|
||||||
PRIMARY KEY (`character_id`) USING BTREE
|
PRIMARY KEY (`character_id`) USING BTREE
|
||||||
|
|||||||
49
ND_Core/server/events.lua
Normal file
49
ND_Core/server/events.lua
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||||
|
|
||||||
|
-- Getting all the characters the player has and returning them to the client.
|
||||||
|
RegisterNetEvent("ND:getCharacters")
|
||||||
|
AddEventHandler("ND:getCharacters", function()
|
||||||
|
local player = source
|
||||||
|
TriggerClientEvent("ND:returnCharacters", player, NDCore.functions:getPlayerCharacters(player))
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Creating a new character.
|
||||||
|
RegisterNetEvent("ND:newCharacter")
|
||||||
|
AddEventHandler("ND:newCharacter", function(newCharacter)
|
||||||
|
local player = source
|
||||||
|
NDCore.functions:createCharacter(player, newCharacter.firstName, newCharacter.lastName, newCharacter.dob, newCharacter.gender, newCharacter.twt, newCharacter.job, newCharacter.cash, newCharacter.bank)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Update the character info when edited.
|
||||||
|
RegisterNetEvent("ND:editCharacter")
|
||||||
|
AddEventHandler("ND:editCharacter", function(newCharacter)
|
||||||
|
local player = source
|
||||||
|
NDCore.functions:updateCharacterData(newCharacter.id, newCharacter.firstName, newCharacter.lastName, newCharacter.dob, newCharacter.gender, newCharacter.twt, newCharacter.job)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Delete character from database.
|
||||||
|
RegisterNetEvent("ND:deleteCharacter")
|
||||||
|
AddEventHandler("ND:deleteCharacter", function(characterId)
|
||||||
|
local player = source
|
||||||
|
NDCore.functions:deleteCharacter(characterId)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- add a player to the table.
|
||||||
|
RegisterNetEvent("ND:setCharacterOnline")
|
||||||
|
AddEventHandler("ND:setCharacterOnline", function(id)
|
||||||
|
local player = source
|
||||||
|
NDCore.functions:setActiveCharacter(player, id)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Disconnecting a player
|
||||||
|
RegisterNetEvent("ND:exitGame")
|
||||||
|
AddEventHandler("ND:exitGame", function()
|
||||||
|
local player = source
|
||||||
|
DropPlayer(player, "Disconnected.")
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Remove player from NDCore.players table when they leave.
|
||||||
|
AddEventHandler("playerDropped", function()
|
||||||
|
local player = source
|
||||||
|
NDCore.players[player] = nil
|
||||||
|
end)
|
||||||
309
ND_Core/server/functions.lua
Normal file
309
ND_Core/server/functions.lua
Normal file
@@ -0,0 +1,309 @@
|
|||||||
|
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||||
|
|
||||||
|
-- Callback to update each selected character on the server.
|
||||||
|
function NDCore.functions:getPlayers(players)
|
||||||
|
if not cb then return NDCore.players end
|
||||||
|
cb(NDCore.players)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Used to retrive the players discord server nickname, discord name and tag, and the roles.
|
||||||
|
function NDCore.functions:getUserDiscordInfo(discordUserId)
|
||||||
|
local data
|
||||||
|
PerformHttpRequest("https://discordapp.com/api/guilds/" .. server_config.guildId .. "/members/" .. discordUserId, function(errorCode, resultData, resultHeaders)
|
||||||
|
if errorCode ~= 200 then
|
||||||
|
print("Error: " .. errorCode .. ", discord token might be missing.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local result = json.decode(resultData)
|
||||||
|
local roles = {}
|
||||||
|
for _, roleId in pairs(result.roles) do
|
||||||
|
roles[roleId] = roleId
|
||||||
|
end
|
||||||
|
data = {
|
||||||
|
nickname = result.nick,
|
||||||
|
discordTag = tostring(result.user.username) .. "#" .. tostring(result.user.discriminator),
|
||||||
|
roles = roles
|
||||||
|
}
|
||||||
|
end, "GET", "", {["Content-Type"] = "application/json", ["Authorization"] = "Bot " .. server_config.discordServerToken})
|
||||||
|
while not data do
|
||||||
|
Citizen.Wait(0)
|
||||||
|
end
|
||||||
|
return data
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get player any identifier, available types: steam, license, xbl, ip, discord, live.
|
||||||
|
function NDCore.functions:GetPlayerIdentifierFromType(type, player)
|
||||||
|
local identifierCount = GetNumPlayerIdentifiers(player)
|
||||||
|
for count = 0, identifierCount do
|
||||||
|
local identifier = GetPlayerIdentifier(player, count)
|
||||||
|
if identifier and string.find(identifier, type) then
|
||||||
|
return identifier
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- This will return the server id and ND player data of a nearby player.
|
||||||
|
function NDCore.functions:getNearbyPedToPlayer(player)
|
||||||
|
local pedCoords = GetEntityCoords(GetPlayerPed(player))
|
||||||
|
for targetId, targetInfo in pairs(NDCore.players) do
|
||||||
|
local targetCoords = GetEntityCoords(GetPlayerPed(targetId))
|
||||||
|
if #(pedCoords - targetCoords) < 2.0 and targetId ~= player then
|
||||||
|
return targetId, targetInfo
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- update the players money on the client kinda like a refresh.
|
||||||
|
function NDCore.functions:updateMoney(player)
|
||||||
|
local player = tonumber(player)
|
||||||
|
MySQL.query("SELECT cash, bank FROM characters WHERE character_id = ?", {NDCore.players[player].id}, function(result)
|
||||||
|
if result then
|
||||||
|
local cash = result[1].cash
|
||||||
|
local bank = result[1].bank
|
||||||
|
NDCore.players[player].cash = cash
|
||||||
|
NDCore.players[player].bank = bank
|
||||||
|
TriggerClientEvent("ND:updateMoney", player, cash, bank)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Transfer money from one players bank account to another.
|
||||||
|
function NDCore.functions:transferBank(amount, player, target)
|
||||||
|
local amount = tonumber(amount)
|
||||||
|
local player = tonumber(player)
|
||||||
|
local target = tonumber(target)
|
||||||
|
if player == target then
|
||||||
|
TriggerClientEvent("chat:addMessage", player, {
|
||||||
|
color = {255, 0, 0},
|
||||||
|
args = {"Error", "You can't send money to yourself."}
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
elseif GetPlayerPing(target) == 0 then
|
||||||
|
TriggerClientEvent("chat:addMessage", player, {
|
||||||
|
color = {255, 0, 0},
|
||||||
|
args = {"Error", "That player does not exist."}
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
elseif amount <= 0 then
|
||||||
|
TriggerClientEvent("chat:addMessage", player, {
|
||||||
|
color = {255, 0, 0},
|
||||||
|
args = {"Error", "You can't send that amount."}
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
elseif NDCore.players[player].bank < amount then
|
||||||
|
TriggerClientEvent("chat:addMessage", player, {
|
||||||
|
color = {255, 0, 0},
|
||||||
|
args = {"Error", "You don't have enough money."}
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
MySQL.query.await("UPDATE characters SET bank = bank - ? WHERE character_id = ?", {amount, NDCore.players[player].id})
|
||||||
|
NDCore.functions:updateMoney(player)
|
||||||
|
MySQL.query.await("UPDATE characters SET bank = bank + ? WHERE character_id = ?", {amount, NDCore.players[target].id})
|
||||||
|
NDCore.functions:updateMoney(target)
|
||||||
|
TriggerClientEvent("chat:addMessage", player, {
|
||||||
|
color = {0, 255, 0},
|
||||||
|
args = {"Success", "You paid " .. NDCore.players[target].firstName .. " " .. NDCore.players[target].lastName .. " $" .. amount .. "."}
|
||||||
|
})
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Give cash from one players wallet to another.
|
||||||
|
function NDCore.functions:giveCash(amount, player, target)
|
||||||
|
local amount = tonumber(amount)
|
||||||
|
local player = tonumber(player)
|
||||||
|
local target = tonumber(target)
|
||||||
|
if player == target then
|
||||||
|
TriggerClientEvent("chat:addMessage", player, {
|
||||||
|
color = {255, 0, 0},
|
||||||
|
args = {"Error", "You can't give money to yourself."}
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
elseif GetPlayerPing(target) == 0 then
|
||||||
|
TriggerClientEvent("chat:addMessage", player, {
|
||||||
|
color = {255, 0, 0},
|
||||||
|
args = {"Error", "That player does not exist."}
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
elseif amount <= 0 then
|
||||||
|
TriggerClientEvent("chat:addMessage", player, {
|
||||||
|
color = {255, 0, 0},
|
||||||
|
args = {"Error", "You can't give that amount."}
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
elseif NDCore.players[player].cash < amount then
|
||||||
|
TriggerClientEvent("chat:addMessage", player, {
|
||||||
|
color = {255, 0, 0},
|
||||||
|
args = {"Error", "You don't have enough money."}
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
MySQL.query.await("UPDATE characters SET cash = cash - ? WHERE character_id = ?", {amount, NDCore.players[player].id})
|
||||||
|
NDCore.functions:updateMoney(player)
|
||||||
|
MySQL.query.await("UPDATE characters SET cash = cash + ? WHERE character_id = ?", {amount, NDCore.players[target].id})
|
||||||
|
NDCore.functions:updateMoney(target)
|
||||||
|
TriggerClientEvent("chat:addMessage", player, {
|
||||||
|
color = {0, 255, 0},
|
||||||
|
args = {"Success", "You gave " .. NDCore.players[target].firstName .. " " .. NDCore.players[target].lastName .. " $" .. amount .. "."}
|
||||||
|
})
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Give money from a players wallet to a nearby player.
|
||||||
|
function NDCore.functions:giveCashToNearbyPlayer(player, amount)
|
||||||
|
local targetId = NDCore.functions:getNearbyPedToPlayer(player)
|
||||||
|
if targetId then
|
||||||
|
NDCore.functions:giveCash(amount, player, targetId)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
TriggerClientEvent("chat:addMessage", player, {
|
||||||
|
color = {255, 0, 0},
|
||||||
|
args = {"Error", "No players nearby."}
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- withdraws money from a players bank account to their wallet/cash.
|
||||||
|
function NDCore.functions:withdrawMoney(amount, player)
|
||||||
|
local amount = tonumber(amount)
|
||||||
|
local player = tonumber(player)
|
||||||
|
if amount <= 0 then return false end
|
||||||
|
if NDCore.players[player].bank < amount then return false end
|
||||||
|
MySQL.query.await("UPDATE characters SET bank = bank - ? WHERE character_id = ?", {amount, NDCore.players[player].id})
|
||||||
|
MySQL.query.await("UPDATE characters SET cash = cash + ? WHERE character_id = ?", {amount, NDCore.players[player].id})
|
||||||
|
NDCore.functions:updateMoney(player)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- deposits money from a players wallet/cash to their bank account.
|
||||||
|
function NDCore.functions:depositMoney(amount, player)
|
||||||
|
local amount = tonumber(amount)
|
||||||
|
local player = tonumber(player)
|
||||||
|
if amount <= 0 then return false end
|
||||||
|
if NDCore.players[player].cash < amount then return false end
|
||||||
|
MySQL.query.await("UPDATE characters SET cash = cash - ? WHERE character_id = ?", {amount, NDCore.players[player].id})
|
||||||
|
MySQL.query.await("UPDATE characters SET bank = bank + ? WHERE character_id = ?", {amount, NDCore.players[player].id})
|
||||||
|
NDCore.functions:updateMoney(player)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Deducts money from the player, "bank" or "cash" needs to be specified.
|
||||||
|
function NDCore.functions:deductMoney(amount, player, from)
|
||||||
|
local amount = tonumber(amount)
|
||||||
|
local player = tonumber(player)
|
||||||
|
if from == "bank" then
|
||||||
|
MySQL.query.await("UPDATE characters SET bank = bank - ? WHERE character_id = ?", {amount, NDCore.players[player].id})
|
||||||
|
elseif from == "cash" then
|
||||||
|
MySQL.query.await("UPDATE characters SET cash = cash - ? WHERE character_id = ?", {amount, NDCore.players[player].id})
|
||||||
|
end
|
||||||
|
NDCore.functions:updateMoney(player)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Adds money from the player, "bank" or "cash" needs to be specified.
|
||||||
|
function NDCore.functions:addMoney(amount, player, to)
|
||||||
|
local amount = tonumber(amount)
|
||||||
|
local player = tonumber(player)
|
||||||
|
if to == "bank" then
|
||||||
|
MySQL.query.await("UPDATE characters SET bank = bank + ? WHERE character_id = ?", {amount, NDCore.players[player].id})
|
||||||
|
elseif to == "cash" then
|
||||||
|
MySQL.query.await("UPDATE characters SET cash = cash + ? WHERE character_id = ?", {amount, NDCore.players[player].id})
|
||||||
|
end
|
||||||
|
NDCore.functions:updateMoney(player)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Adds the players character to the NDCore.players table, this table consists of every players selected character.
|
||||||
|
function NDCore.functions:setActiveCharacter(player, characterId)
|
||||||
|
local result = MySQL.query.await("SELECT * FROM characters WHERE character_id = ?", {characterId})
|
||||||
|
if result then
|
||||||
|
local i = result[1]
|
||||||
|
NDCore.players[player] = {
|
||||||
|
id = characterId,
|
||||||
|
firstName = i.first_name,
|
||||||
|
lastName = i.last_name,
|
||||||
|
dob = i.dob,
|
||||||
|
gender = i.gender,
|
||||||
|
twt = i.twt,
|
||||||
|
job = i.job,
|
||||||
|
cash = i.cash,
|
||||||
|
bank = i.bank
|
||||||
|
}
|
||||||
|
end
|
||||||
|
TriggerClientEvent("ND:setCharacter", player, NDCore.players[player])
|
||||||
|
end
|
||||||
|
|
||||||
|
-- This returns all the characters the player has.
|
||||||
|
function NDCore.functions:getPlayerCharacters(player)
|
||||||
|
local characters = {}
|
||||||
|
local result = MySQL.query.await("SELECT * FROM characters WHERE license = ?", {NDCore.functions:GetPlayerIdentifierFromType("license", player)})
|
||||||
|
for i = 1, #result do
|
||||||
|
local temp = result[i]
|
||||||
|
characters[temp.character_id] = {id = temp.character_id, firstName = temp.first_name, lastName = temp.last_name, dob = temp.dob, gender = temp.gender, twt = temp.twt, job = temp.job, cash = temp.cash, bank = temp.bank}
|
||||||
|
end
|
||||||
|
return characters
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Creates a new character for the player and returns all their characters to the client.
|
||||||
|
function NDCore.functions:createCharacter(player, firstName, lastName, dob, gender, twt, job, cash, bank)
|
||||||
|
local license = NDCore.functions:GetPlayerIdentifierFromType("license", player)
|
||||||
|
if not cash or not bank or tonumber(cash) > config.startingCash or tonumber(bank) > config.startingBank then
|
||||||
|
cash = config.startingCash
|
||||||
|
bank = config.startingBank
|
||||||
|
end
|
||||||
|
local result = MySQL.query.await("SELECT character_id FROM characters WHERE license = ?", {license})
|
||||||
|
if result and config.characterLimit > #result then
|
||||||
|
MySQL.query.await("INSERT INTO characters (license, first_name, last_name, dob, gender, twt, job, cash, bank) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", {license, firstName, lastName, dob, gender, twt, job, cash, bank})
|
||||||
|
TriggerClientEvent("ND:returnCharacters", player, NDCore.functions:getPlayerCharacters(player))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Update/edit a character by character id.
|
||||||
|
function NDCore.functions:updateCharacterData(characterId, firstName, lastName, dob, gender, twt, job)
|
||||||
|
MySQL.query("UPDATE characters SET first_name = ?, last_name = ?, dob = ?, gender = ?, twt = ?, job = ? WHERE character_id = ?", {firstName, lastName, dob, gender, twt, job, characterId})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Delete a character by character id.
|
||||||
|
function NDCore.functions:deleteCharacter(characterId)
|
||||||
|
MySQL.query("DELETE FROM characters WHERE character_id = ?", {characterId})
|
||||||
|
end
|
||||||
|
|
||||||
|
function NDCore.functions:versionChecker(expectedResourceName, resourceName, downloadLink, rawGithubLink)
|
||||||
|
if expectedResourceName ~= resourceName then
|
||||||
|
print("^1[^4" .. expectedResourceName .. "^1] WARNING^0")
|
||||||
|
print("Change the resource name to ^4" .. expectedResourceName .. " ^0or else it won't work properly!")
|
||||||
|
StopResource(resourceName)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
PerformHttpRequest(rawGithubLink, function(errorCode, resultData, resultHeaders)
|
||||||
|
local i, j = string.find(tostring(resultData), "version")
|
||||||
|
local resultData = string.sub(tostring(resultData), i, j + 12)
|
||||||
|
local resultData = string.gsub(resultData, "version \"", "")
|
||||||
|
local i, j = string.find(resultData, "\"")
|
||||||
|
local resultData = string.sub(resultData, 1, i - 1)
|
||||||
|
local githubVersion = string.gsub(resultData, "%.", "")
|
||||||
|
local fileVersion = string.gsub(GetResourceMetadata(expectedResourceName, "version", 0), "%.", "")
|
||||||
|
local githubVersion = tonumber(githubVersion)
|
||||||
|
local fileVersion = tonumber(fileVersion)
|
||||||
|
|
||||||
|
if not githubVersion and not fileVersion then
|
||||||
|
print("^1[^4" .. expectedResourceName .. "^1] WARNING^0")
|
||||||
|
print("You may not have the latest version of ^4" .. expectedResourceName .. "^0. A newer, improved version may be present at ^5" .. downloadLink .. "^0")
|
||||||
|
elseif githubVersion > fileVersion then
|
||||||
|
local oldVersion = string.sub(fileVersion, 1, 1) .. "." .. string.sub(fileVersion, 2, 2) .. "." .. string.sub(fileVersion, 3, 3)
|
||||||
|
local newVersion = string.sub(githubVersion, 1, 1) .. "." .. string.sub(githubVersion, 2, 2) .. "." .. string.sub(githubVersion, 3, 3)
|
||||||
|
print("^1[^4" .. expectedResourceName .. "^1] WARNING^0")
|
||||||
|
print("^4" .. expectedResourceName .. " ^0is outdated. Please update it from ^5" .. downloadLink .. " ^0| Current Version: ^1" .. oldVersion .. " ^0| New Version: ^2" .. newVersion .. " ^0|")
|
||||||
|
elseif githubVersion < fileVersion then
|
||||||
|
local oldVersion = string.sub(fileVersion, 1, 1) .. "." .. string.sub(fileVersion, 2, 2) .. "." .. string.sub(fileVersion, 3, 3)
|
||||||
|
local newVersion = string.sub(githubVersion, 1, 1) .. "." .. string.sub(githubVersion, 2, 2) .. "." .. string.sub(githubVersion, 3, 3)
|
||||||
|
print("^1[^4" .. expectedResourceName .. "^1] WARNING^0")
|
||||||
|
print("^4" .. expectedResourceName .. " ^0version number is higher than expected | Current Version: ^3" .. oldVersion .. " ^0| Expected Version: ^2" .. newVersion .. " ^0|")
|
||||||
|
else
|
||||||
|
local newVersion = string.sub(githubVersion, 1, 1) .. "." .. string.sub(githubVersion, 2, 2) .. "." .. string.sub(githubVersion, 3, 3)
|
||||||
|
print("^4" .. expectedResourceName .. " ^0is up to date | Current Version: ^2" .. newVersion .. " ^0|")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
NDCore.functions:versionChecker("ND_Core", GetCurrentResourceName(), "https://github.com/Andyyy7666/ND_Framework", "https://raw.githubusercontent.com/Andyyy7666/ND_Framework/main/ND_Core/fxmanifest.lua")
|
||||||
10
ND_Core/server/main.lua
Normal file
10
ND_Core/server/main.lua
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||||
|
|
||||||
|
NDCore = {}
|
||||||
|
NDCore.players = {}
|
||||||
|
NDCore.functions = {}
|
||||||
|
NDCore.config = config
|
||||||
|
|
||||||
|
function GetCoreObject()
|
||||||
|
return NDCore
|
||||||
|
end
|
||||||
@@ -1,266 +0,0 @@
|
|||||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
|
||||||
|
|
||||||
local selectedCharacter
|
|
||||||
local characterAmount = 0
|
|
||||||
|
|
||||||
function SetDisplay(bool, typeName, bg)
|
|
||||||
if not bg then
|
|
||||||
background = config.backgrounds[math.random(1, #config.backgrounds)]
|
|
||||||
end
|
|
||||||
SetNuiFocus(bool, bool)
|
|
||||||
SendNUIMessage({
|
|
||||||
type = typeName,
|
|
||||||
background = background,
|
|
||||||
status = bool,
|
|
||||||
serverName = config.serverName,
|
|
||||||
characterAmount = characterAmount .. "/" .. config.characterLimit
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
function getCharacterInfo()
|
|
||||||
return selectedCharacter
|
|
||||||
end
|
|
||||||
|
|
||||||
function start(switch)
|
|
||||||
TriggerServerEvent("checkPerms")
|
|
||||||
TriggerServerEvent("getCharacters")
|
|
||||||
TriggerServerEvent("getAop")
|
|
||||||
Citizen.Wait(100)
|
|
||||||
if switch then
|
|
||||||
local ped = PlayerPedId()
|
|
||||||
SwitchOutPlayer(ped, 0, 1)
|
|
||||||
FreezeEntityPosition(ped, true)
|
|
||||||
SetEntityVisible(ped, false, 0)
|
|
||||||
end
|
|
||||||
SendNUIMessage({
|
|
||||||
type = "onStart",
|
|
||||||
enableMoneySystem = config.enableMoneySystem,
|
|
||||||
maxStartingBank = config.maxStartingBank,
|
|
||||||
maxStartingCash = config.maxStartingCash
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
AddEventHandler("onResourceStart", function(resourceName)
|
|
||||||
if (GetCurrentResourceName() ~= resourceName) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
Citizen.Wait(1000)
|
|
||||||
start(false)
|
|
||||||
end)
|
|
||||||
|
|
||||||
AddEventHandler("playerSpawned", function()
|
|
||||||
print("^0This framework is created by ^5Andyyy#7666 ^0for support you can join the ^5discord: ^0https://discord.gg/Z9Mxu72zZ6")
|
|
||||||
start(true)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- This is used to add department drop down on the ui.
|
|
||||||
RegisterNetEvent("permsChecked")
|
|
||||||
AddEventHandler("permsChecked", function(allowedRoles)
|
|
||||||
for _, dept in pairs(allowedRoles) do
|
|
||||||
SendNUIMessage({
|
|
||||||
type = "givePerms",
|
|
||||||
deptRole = dept
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Notification when you recieve money.
|
|
||||||
RegisterNetEvent("receiveBank")
|
|
||||||
AddEventHandler("receiveBank", function(amount, playerSending, playerId)
|
|
||||||
BeginTextCommandThefeedPost("STRING")
|
|
||||||
AddTextComponentSubstringPlayerName("Received $" .. amount .. " from " .. playerSending .. " [".. playerId .."]")
|
|
||||||
EndTextCommandThefeedPostMessagetext("CHAR_BANK_FLEECA", "CHAR_BANK_FLEECA", true, 9,"FleecaBank", "")
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Notification when you receive cash.
|
|
||||||
RegisterNetEvent("receiveCash")
|
|
||||||
AddEventHandler("receiveCash", function(amount, playerSending, playerId)
|
|
||||||
BeginTextCommandThefeedPost("STRING")
|
|
||||||
AddTextComponentSubstringPlayerName(playerSending .. " gave you $" .. amount .. ".")
|
|
||||||
EndTextCommandThefeedPostMessagetext("CHAR_DEFAULT", "CHAR_DEFAULT", true, 9, playerSending .. " [".. playerId .."]", "")
|
|
||||||
end)
|
|
||||||
|
|
||||||
RegisterNetEvent("updateMoney")
|
|
||||||
AddEventHandler("updateMoney", function(cash, bank)
|
|
||||||
selectedCharacter.cash = cash
|
|
||||||
selectedCharacter.bank = bank
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Gets all the characters and displays them on the ui.
|
|
||||||
RegisterNetEvent("returnCharacters")
|
|
||||||
AddEventHandler("returnCharacters", function(characters)
|
|
||||||
characterAmount = 0
|
|
||||||
SendNUIMessage({
|
|
||||||
type = "refresh"
|
|
||||||
})
|
|
||||||
for _, character in pairs(characters) do
|
|
||||||
SendNUIMessage({
|
|
||||||
type = "character",
|
|
||||||
id = character.id,
|
|
||||||
firstName = character.firstName,
|
|
||||||
lastName = character.lastName,
|
|
||||||
dateOfBirth = character.dob,
|
|
||||||
gender = character.gender,
|
|
||||||
twtName = character.twt,
|
|
||||||
department = character.department,
|
|
||||||
startingCash = character.cash,
|
|
||||||
startingBank = character.bank
|
|
||||||
})
|
|
||||||
characterAmount = characterAmount + 1
|
|
||||||
end
|
|
||||||
SetDisplay(true, "ui", background)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Selecting a player from the iu.
|
|
||||||
RegisterNUICallback("setMainCharacter", function(data)
|
|
||||||
selectedCharacter = {
|
|
||||||
firstName = data.firstName,
|
|
||||||
lastName = data.lastName,
|
|
||||||
dob = data.dateOfBirth,
|
|
||||||
gender = data.gender,
|
|
||||||
twt = data.twtName,
|
|
||||||
department = data.department,
|
|
||||||
cash = data.startingCash,
|
|
||||||
bank = data.startingBank,
|
|
||||||
id = data.character
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, spawn in pairs(config.spawns[selectedCharacter.department]) do
|
|
||||||
SendNUIMessage({
|
|
||||||
type = "setSpawns",
|
|
||||||
x = spawn.x,
|
|
||||||
y = spawn.y,
|
|
||||||
z = spawn.z,
|
|
||||||
name = spawn.name
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
TriggerServerEvent("characterOnline", selectedCharacter.id)
|
|
||||||
TriggerEvent("characterChanged", selectedCharacter)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Creating a character from the ui.
|
|
||||||
RegisterNUICallback("newCharacter", function(data)
|
|
||||||
if characterAmount < config.characterLimit then
|
|
||||||
TriggerServerEvent("newCharacter", {
|
|
||||||
firstName = data.firstName,
|
|
||||||
lastName = data.lastName,
|
|
||||||
dateOfBirth = data.dateOfBirth,
|
|
||||||
gender = data.gender,
|
|
||||||
twtName = data.twtName,
|
|
||||||
department = data.department,
|
|
||||||
startingCash = data.startingCash,
|
|
||||||
startingBank = data.startingBank
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- editing a character from the ui.
|
|
||||||
RegisterNUICallback("editCharacter", function(data)
|
|
||||||
TriggerServerEvent("editCharacter", {
|
|
||||||
firstName = data.firstName,
|
|
||||||
lastName = data.lastName,
|
|
||||||
dateOfBirth = data.dateOfBirth,
|
|
||||||
gender = data.gender,
|
|
||||||
twtName = data.twtName,
|
|
||||||
department = data.department,
|
|
||||||
id = data.id
|
|
||||||
})
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- deleting a character from the ui.
|
|
||||||
RegisterNUICallback("delCharacter", function(data)
|
|
||||||
TriggerServerEvent("delCharacter", data.character)
|
|
||||||
characterAmount = characterAmount -1
|
|
||||||
SendNUIMessage({
|
|
||||||
characterAmount = characterAmount .. "/" .. config.characterLimit
|
|
||||||
})
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Quit button from ui.
|
|
||||||
RegisterNUICallback("exitGame", function(data)
|
|
||||||
TriggerServerEvent("exitGame")
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Teleporting using ui.
|
|
||||||
RegisterNUICallback("tpToLocation", function(data)
|
|
||||||
local ped = PlayerPedId()
|
|
||||||
FreezeEntityPosition(ped, false)
|
|
||||||
SetEntityCoords(ped, tonumber(data.x), tonumber(data.y), tonumber(data.z), false, false, false, false)
|
|
||||||
FreezeEntityPosition(ped, true)
|
|
||||||
SwitchInPlayer(ped)
|
|
||||||
Citizen.Wait(500)
|
|
||||||
SetDisplay(false, "ui")
|
|
||||||
Citizen.Wait(500)
|
|
||||||
FreezeEntityPosition(ped, false)
|
|
||||||
SetEntityVisible(ped, true, 0)
|
|
||||||
TriggerServerEvent("getMoney", selectedCharacter.id)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Choosing the do not tp button.
|
|
||||||
RegisterNUICallback("tpDoNot", function()
|
|
||||||
local ped = PlayerPedId()
|
|
||||||
SwitchInPlayer(ped)
|
|
||||||
Citizen.Wait(500)
|
|
||||||
SetDisplay(false, "ui")
|
|
||||||
Citizen.Wait(500)
|
|
||||||
SetEntityVisible(ped, true, 0)
|
|
||||||
FreezeEntityPosition(ped, false)
|
|
||||||
TriggerServerEvent("getMoney", selectedCharacter.id)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- discord rich presence will show on a users profile.
|
|
||||||
if config.enableRichPresence then
|
|
||||||
Citizen.CreateThread(function()
|
|
||||||
while true do
|
|
||||||
SetDiscordAppId(config.appId)
|
|
||||||
if selectedCharacter then
|
|
||||||
SetRichPresence(" Playing : " .. config.serverName .. " as " .. selectedCharacter.firstName .. " " .. selectedCharacter.lastName)
|
|
||||||
SetDiscordRichPresenceAsset(config.largeLogo)
|
|
||||||
SetDiscordRichPresenceAssetText("Playing: " .. config.serverName)
|
|
||||||
SetDiscordRichPresenceAssetSmall(config.smallLogo)
|
|
||||||
SetDiscordRichPresenceAssetSmallText("Playing as: " .. selectedCharacter.firstName .. " " .. selectedCharacter.lastName)
|
|
||||||
SetDiscordRichPresenceAction(0, config.firstButtonName, config.firstButtonLink)
|
|
||||||
SetDiscordRichPresenceAction(1, config.secondButtonName, config.secondButtonLink)
|
|
||||||
end
|
|
||||||
Citizen.Wait(config.updateIntervall * 1000)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- show server name, first name, last name, and the amount of money the character has in the pause menu.
|
|
||||||
if config.customPauseMenu then
|
|
||||||
Citizen.CreateThread(function()
|
|
||||||
while true do
|
|
||||||
Citizen.Wait(0)
|
|
||||||
if selectedCharacter then
|
|
||||||
if IsPauseMenuActive() then
|
|
||||||
BeginScaleformMovieMethodOnFrontendHeader("SET_HEADING_DETAILS")
|
|
||||||
AddTextEntry("FE_THDR_GTAO", config.serverName)
|
|
||||||
ScaleformMovieMethodAddParamPlayerNameString(selectedCharacter.firstName .. " " .. selectedCharacter.lastName)
|
|
||||||
if config.enableMoneySystem then
|
|
||||||
PushScaleformMovieFunctionParameterString("Cash: $" .. tostring(selectedCharacter.cash))
|
|
||||||
PushScaleformMovieFunctionParameterString("Bank: $" .. tostring(selectedCharacter.bank))
|
|
||||||
end
|
|
||||||
EndScaleformMovieMethod()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Change character command
|
|
||||||
RegisterCommand(config.changeCharacterCommand, function()
|
|
||||||
SwitchOutPlayer(PlayerPedId(), 0, 1)
|
|
||||||
Citizen.Wait(2000)
|
|
||||||
FreezeEntityPosition(ped, true)
|
|
||||||
SetEntityVisible(ped, false, 0)
|
|
||||||
SetDisplay(true, "ui")
|
|
||||||
end, false)
|
|
||||||
|
|
||||||
-- chat suggestions
|
|
||||||
TriggerEvent("chat:addSuggestion", "/" .. config.changeCharacterCommand, "Switch your framework character.")
|
|
||||||
if config.enableMoneySystem then
|
|
||||||
TriggerEvent("chat:addSuggestion", "/" .. config.payCommand, "Transfer money to player", {{name="id", help="Player server id" }, {name="amount", help="amount to pay"}})
|
|
||||||
TriggerEvent("chat:addSuggestion", "/" .. config.giveCommand, "Give money to closeby player", {{name="amount", help="amount to give"}})
|
|
||||||
end
|
|
||||||
@@ -1,404 +0,0 @@
|
|||||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
|
||||||
|
|
||||||
expectedName = "ND_Core" -- This is the resource and is not suggested to be changed.
|
|
||||||
resource = GetCurrentResourceName()
|
|
||||||
|
|
||||||
-- check if resource is renamed
|
|
||||||
if resource ~= expectedName then
|
|
||||||
print("^1[^4" .. expectedName .. "^1] WARNING^0")
|
|
||||||
print("Change the resource name to ^4" .. expectedName .. " ^0or else it won't work!")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- add dots to version.
|
|
||||||
function fixVersion(version)
|
|
||||||
return string.sub(version, 1, 1) .. "." .. string.sub(version, 2, 2) .. "." .. string.sub(version, 3, 3)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- check if resource version is up to date
|
|
||||||
PerformHttpRequest("https://raw.githubusercontent.com/Andyyy7666/ND_Framework/main/ND_Core/fxmanifest.lua", function(errorCode, resultData, resultHeaders)
|
|
||||||
i, j = string.find(tostring(resultData), "version")
|
|
||||||
resultData = string.sub(tostring(resultData), i, j + 12)
|
|
||||||
resultData = string.gsub(resultData, "version \"", "")
|
|
||||||
i, j = string.find(resultData, "\"")
|
|
||||||
resultData = string.sub(resultData, 1, i - 1)
|
|
||||||
local githubVersion = string.gsub(resultData, "%.", "")
|
|
||||||
local fileVersion = string.gsub(GetResourceMetadata(expectedName, "version", 0), "%.", "")
|
|
||||||
githubVersion = tonumber(githubVersion)
|
|
||||||
fileVersion = tonumber(fileVersion)
|
|
||||||
|
|
||||||
if githubVersion and fileVersion then
|
|
||||||
if githubVersion > fileVersion then
|
|
||||||
print("^1[^4" .. expectedName .. "^1] WARNING^0")
|
|
||||||
print("^4" .. expectedName .. " ^0is outdated. Please update it from ^5https://github.com/Andyyy7666/ND_Framework ^0| Current Version: ^1" .. fixVersion(fileVersion) .. " ^0| New Version: ^2" .. fixVersion(githubVersion) .. " ^0|")
|
|
||||||
elseif githubVersion < fileVersion then
|
|
||||||
print("^1[^4" .. expectedName .. "^1] WARNING^0")
|
|
||||||
print("^4" .. expectedName .. " ^0version number is higher than expected | Current Version: ^3" .. fixVersion(fileVersion) .. " ^0| Expected Version: ^2" .. fixVersion(githubVersion) .. " ^0|")
|
|
||||||
else
|
|
||||||
print("^4" .. expectedName .. " ^0is up to date | Current Version: ^2" .. fixVersion(fileVersion) .. " ^0|")
|
|
||||||
end
|
|
||||||
else
|
|
||||||
print("^1[^4" .. expectedName .. "^1] WARNING^0")
|
|
||||||
print("You may not have the latest version of ^4" .. expectedName .. "^0. A newer, improved version may be present at ^5https://github.com/Andyyy7666/ND_Framework^0")
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Used to retrive the players discord server nickname, discord name and tag, and the roles.
|
|
||||||
function getUserDiscordInfo(discordUserId)
|
|
||||||
local data
|
|
||||||
PerformHttpRequest("https://discordapp.com/api/guilds/" .. server_config.guildId .. "/members/" .. discordUserId, function(errorCode, resultData, resultHeaders)
|
|
||||||
if errorCode ~= 200 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local result = json.decode(resultData)
|
|
||||||
local roles = {}
|
|
||||||
for _, roleId in pairs(result.roles) do
|
|
||||||
roles[roleId] = roleId
|
|
||||||
end
|
|
||||||
data = {
|
|
||||||
nickname = result.nick,
|
|
||||||
discordTag = tostring(result.user.username) .. "#" .. tostring(result.user.discriminator),
|
|
||||||
roles = roles
|
|
||||||
}
|
|
||||||
end, "GET", "", {["Content-Type"] = "application/json", ["Authorization"] = "Bot " .. server_config.discordServerToken})
|
|
||||||
while not data do
|
|
||||||
Citizen.Wait(0)
|
|
||||||
end
|
|
||||||
return data
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Get player any identifier, available types: steam, license, xbl, ip, discord, live.
|
|
||||||
function GetPlayerIdentifierFromType(type, source)
|
|
||||||
local identifierCount = GetNumPlayerIdentifiers(source)
|
|
||||||
for count = 0, identifierCount do
|
|
||||||
local identifier = GetPlayerIdentifier(source, count)
|
|
||||||
if identifier and string.find(identifier, type) then
|
|
||||||
return identifier
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
function validateMoney(cash, bank)
|
|
||||||
if tonumber(cash) > config.maxStartingCash or tonumber(bank) > config.maxStartingBank then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function validateDepartment(player, department)
|
|
||||||
local departmentExists = config.departments[department]
|
|
||||||
if departmentExists then
|
|
||||||
local discordUserId = string.gsub(GetPlayerIdentifierFromType("discord", player), "discord:", "")
|
|
||||||
local roles = getUserDiscordInfo(discordUserId).roles
|
|
||||||
|
|
||||||
for _, roleId in pairs(departmentExists) do
|
|
||||||
if roles[roleId] or roleId == 0 or roleId == "0" then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
RegisterNetEvent("checkPerms")
|
|
||||||
AddEventHandler("checkPerms", function()
|
|
||||||
local player = source
|
|
||||||
local discordUserId = string.gsub(GetPlayerIdentifierFromType("discord", player), "discord:", "")
|
|
||||||
local allowedRoles = {}
|
|
||||||
local roles = getUserDiscordInfo(discordUserId).roles
|
|
||||||
|
|
||||||
for dept, roleTable in pairs(config.departments) do
|
|
||||||
for _, roleId in pairs(roleTable) do
|
|
||||||
if roles[roleId] or roleId == 0 or roleId == "0" then
|
|
||||||
table.insert(allowedRoles, dept)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
TriggerClientEvent("permsChecked", player, allowedRoles)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Inserting the players characters into characters table
|
|
||||||
RegisterNetEvent("getCharacters")
|
|
||||||
AddEventHandler("getCharacters", function()
|
|
||||||
local player = source
|
|
||||||
local characters = {}
|
|
||||||
exports.oxmysql:query("SELECT * FROM characters WHERE license = ?", {GetPlayerIdentifierFromType("license", player)}, function(result)
|
|
||||||
if result then
|
|
||||||
for i = 1, #result do
|
|
||||||
temp = result[i]
|
|
||||||
characters[temp.character_id] = {id = temp.character_id, firstName = temp.first_name, lastName = temp.last_name, dob = temp.dob, gender = temp.gender, twt = temp.twt, department = temp.department, cash = temp.cash, bank = temp.bank}
|
|
||||||
end
|
|
||||||
TriggerClientEvent("returnCharacters", player, characters)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Creating a new character and increasing the character id.
|
|
||||||
RegisterNetEvent("newCharacter")
|
|
||||||
AddEventHandler("newCharacter", function(newCharacter)
|
|
||||||
local player = source
|
|
||||||
local license = GetPlayerIdentifierFromType("license", player)
|
|
||||||
|
|
||||||
-- validate that the person has permission to use the department.
|
|
||||||
local departmentCheck = validateDepartment(player, newCharacter.department)
|
|
||||||
if not departmentCheck then return end
|
|
||||||
|
|
||||||
local startingCash = newCharacter.startingCash
|
|
||||||
local startingBank = newCharacter.startingBank
|
|
||||||
|
|
||||||
if config.enableMoneySystem then
|
|
||||||
-- Don't trust the client, validate maximum amounts.
|
|
||||||
local moneyCheck = validateMoney(startingCash, startingBank)
|
|
||||||
|
|
||||||
-- Set money to maximum amount in the config .
|
|
||||||
-- Only triggers if the client is sending an amount that exceeds the maximum.
|
|
||||||
if not moneyCheck then
|
|
||||||
startingCash = config.maxStartingCash
|
|
||||||
startingBank = config.maxStartingBank
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
exports.oxmysql:query("SELECT character_id FROM characters WHERE license = ?", {GetPlayerIdentifierFromType("license", player)}, function(result)
|
|
||||||
if (result) and (config.characterLimit > #result) then
|
|
||||||
exports.oxmysql:query("INSERT INTO characters (license, first_name, last_name, dob, gender, twt, department, cash, bank) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", {license, newCharacter.firstName, newCharacter.lastName, newCharacter.dateOfBirth, newCharacter.gender, newCharacter.twtName, newCharacter.department, startingCash, startingBank}, function(id)
|
|
||||||
if id then
|
|
||||||
exports.oxmysql:query("SELECT * FROM characters WHERE license = ?", {GetPlayerIdentifierFromType("license", player)}, function(result)
|
|
||||||
if result then
|
|
||||||
characters = {}
|
|
||||||
for i = 1, #result do
|
|
||||||
temp = result[i]
|
|
||||||
characters[temp.character_id] = {id = temp.character_id, firstName = temp.first_name, lastName = temp.last_name, dob = temp.dob, gender = temp.gender, twt = temp.twt, department = temp.department, cash = temp.cash, bank = temp.bank}
|
|
||||||
end
|
|
||||||
TriggerClientEvent("returnCharacters", player, characters)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Delete character from database.
|
|
||||||
RegisterNetEvent("delCharacter")
|
|
||||||
AddEventHandler("delCharacter", function(character_id)
|
|
||||||
local player = source
|
|
||||||
local license = GetPlayerIdentifierFromType("license", player)
|
|
||||||
exports.oxmysql:query("DELETE FROM characters WHERE license = ? AND character_id = ?", {license, character_id})
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Update the character info when edited.
|
|
||||||
RegisterNetEvent("editCharacter")
|
|
||||||
AddEventHandler("editCharacter", function(newCharacter)
|
|
||||||
local player = source
|
|
||||||
|
|
||||||
-- validate that the person has permission to use the department.
|
|
||||||
local departmentCheck = validateDepartment(player, newCharacter.department)
|
|
||||||
if not departmentCheck then return end
|
|
||||||
|
|
||||||
exports.oxmysql:query("UPDATE characters SET first_name = ?, last_name = ?, dob = ?, gender = ?, twt = ?, department = ? WHERE license = ? AND character_id = ?", {newCharacter.firstName, newCharacter.lastName, newCharacter.dateOfBirth, newCharacter.gender, newCharacter.twtName, newCharacter.department, GetPlayerIdentifierFromType("license", player), newCharacter.id})
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- onlinePlayers table, this is used to store all the players current character info on the server.
|
|
||||||
onlinePlayers = {}
|
|
||||||
|
|
||||||
-- add a player to the table.
|
|
||||||
RegisterNetEvent("characterOnline")
|
|
||||||
AddEventHandler("characterOnline", function(id)
|
|
||||||
local player = source
|
|
||||||
local license = GetPlayerIdentifierFromType("license", player)
|
|
||||||
exports.oxmysql:query("SELECT * FROM characters WHERE license = ? AND character_id = ?", {license, id}, function(result)
|
|
||||||
if result then
|
|
||||||
local i = result[1]
|
|
||||||
onlinePlayers[player] = {
|
|
||||||
characterId = id,
|
|
||||||
firstName = i.first_name,
|
|
||||||
lastName = i.last_name,
|
|
||||||
dob = i.dob,
|
|
||||||
gender = i.gender,
|
|
||||||
twt = i.twt,
|
|
||||||
dept = i.department,
|
|
||||||
cash = i.cash,
|
|
||||||
bank = i.bank
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Remove player from onlinePlayers table when they leave.
|
|
||||||
AddEventHandler("playerDropped", function(reason)
|
|
||||||
local player = source
|
|
||||||
onlinePlayers[player] = nil
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Disconnecting a player
|
|
||||||
RegisterNetEvent("exitGame")
|
|
||||||
AddEventHandler("exitGame", function()
|
|
||||||
local player = source
|
|
||||||
DropPlayer(player, "Disconnected using framework.")
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- this is for the exports
|
|
||||||
function getCharacterTable()
|
|
||||||
return onlinePlayers
|
|
||||||
end
|
|
||||||
|
|
||||||
function updateMoney(player)
|
|
||||||
local player = tonumber(player)
|
|
||||||
local license = GetPlayerIdentifierFromType("license", player)
|
|
||||||
exports.oxmysql:query("SELECT cash, bank FROM characters WHERE license = ? AND character_id = ?", {license, onlinePlayers[player].characterId}, function(result)
|
|
||||||
if result then
|
|
||||||
local cash = result[1].cash
|
|
||||||
local bank = result[1].bank
|
|
||||||
onlinePlayers[player].cash = cash
|
|
||||||
onlinePlayers[player].bank = bank
|
|
||||||
TriggerClientEvent("updateMoney", player, cash, bank)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
function transferBank(amount, player, target)
|
|
||||||
local amount = tonumber(amount)
|
|
||||||
local player = tonumber(player)
|
|
||||||
local target = tonumber(target)
|
|
||||||
if player == target then
|
|
||||||
TriggerClientEvent("chat:addMessage", player, {
|
|
||||||
color = {255, 0, 0},
|
|
||||||
args = {"Error", "You can't send money to yourself."}
|
|
||||||
})
|
|
||||||
return false
|
|
||||||
elseif GetPlayerPing(target) == 0 then
|
|
||||||
TriggerClientEvent("chat:addMessage", player, {
|
|
||||||
color = {255, 0, 0},
|
|
||||||
args = {"Error", "That player does not exist."}
|
|
||||||
})
|
|
||||||
return false
|
|
||||||
elseif onlinePlayers[player].bank < amount then
|
|
||||||
TriggerClientEvent("chat:addMessage", player, {
|
|
||||||
color = {255, 0, 0},
|
|
||||||
args = {"Error", "You don't have enough money."}
|
|
||||||
})
|
|
||||||
return false
|
|
||||||
else
|
|
||||||
exports.oxmysql:query("UPDATE characters SET bank = bank - ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
|
||||||
updateMoney(player)
|
|
||||||
exports.oxmysql:query("UPDATE characters SET bank = bank + ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", target), onlinePlayers[target].characterId})
|
|
||||||
updateMoney(target)
|
|
||||||
|
|
||||||
TriggerClientEvent("chat:addMessage", player, {
|
|
||||||
color = {0, 255, 0},
|
|
||||||
args = {"Success", "You paid " .. onlinePlayers[target].firstName .. " " .. onlinePlayers[target].lastName .. " $" .. amount .. "."}
|
|
||||||
})
|
|
||||||
TriggerClientEvent("receiveBank", target, amount, onlinePlayers[player].firstName .. " " .. onlinePlayers[player].lastName, player)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function giveCashToClosestTarget(amount, player)
|
|
||||||
local amount = tonumber(amount)
|
|
||||||
local player = tonumber(player)
|
|
||||||
local playerFound = false
|
|
||||||
local playerCoords = GetEntityCoords(GetPlayerPed(player))
|
|
||||||
if onlinePlayers[player].cash < amount then
|
|
||||||
TriggerClientEvent("chat:addMessage", player, {
|
|
||||||
color = {255, 0, 0},
|
|
||||||
args = {"Error", "You don't have enough money."}
|
|
||||||
})
|
|
||||||
return false
|
|
||||||
else
|
|
||||||
for targetId, targetInfo in pairs(onlinePlayers) do
|
|
||||||
local targetCoords = GetEntityCoords(GetPlayerPed(targetId))
|
|
||||||
if (#(playerCoords - targetCoords) < 2.0) and (targetId ~= player) and not playerFound then
|
|
||||||
exports.oxmysql:query("UPDATE characters SET cash = cash - ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
|
||||||
updateMoney(player)
|
|
||||||
exports.oxmysql:query("UPDATE characters SET cash = cash + ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", targetId), tonumber(targetInfo.characterId)})
|
|
||||||
updateMoney(targetId)
|
|
||||||
playerFound = true
|
|
||||||
TriggerClientEvent("chat:addMessage", player, {
|
|
||||||
color = {0, 255, 0},
|
|
||||||
args = {"Success", "You gave " .. onlinePlayers[targetId].firstName .. " " .. onlinePlayers[targetId].lastName .. " $" .. amount .. "."}
|
|
||||||
})
|
|
||||||
TriggerClientEvent("receiveCash", targetId, amount, onlinePlayers[player].firstName .. " " .. onlinePlayers[player].lastName, player)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if not playerFound then
|
|
||||||
TriggerClientEvent("chat:addMessage", player, {
|
|
||||||
color = {255, 0, 0},
|
|
||||||
args = {"Error", "No players nearby."}
|
|
||||||
})
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
playerFound = false
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function withdrawMoney(amount, player)
|
|
||||||
local amount = tonumber(amount)
|
|
||||||
local player = tonumber(player)
|
|
||||||
if onlinePlayers[player].bank >= amount then
|
|
||||||
exports.oxmysql:query("UPDATE characters SET bank = bank - ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
|
||||||
exports.oxmysql:query("UPDATE characters SET cash = cash + ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
|
||||||
Citizen.Wait(500)
|
|
||||||
updateMoney(player)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
function depositMoney(amount, player)
|
|
||||||
local amount = tonumber(amount)
|
|
||||||
local player = tonumber(player)
|
|
||||||
if onlinePlayers[player].cash >= amount then
|
|
||||||
exports.oxmysql:query("UPDATE characters SET cash = cash - ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
|
||||||
exports.oxmysql:query("UPDATE characters SET bank = bank + ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
|
||||||
Citizen.Wait(500)
|
|
||||||
updateMoney(player)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
function deductMoney(amount, player, from)
|
|
||||||
local amount = tonumber(amount)
|
|
||||||
local player = tonumber(player)
|
|
||||||
if from == "bank" then
|
|
||||||
exports.oxmysql:query("UPDATE characters SET bank = bank - ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
|
||||||
Citizen.Wait(500)
|
|
||||||
updateMoney(player)
|
|
||||||
elseif from == "cash" then
|
|
||||||
exports.oxmysql:query("UPDATE characters SET cash = cash - ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
|
||||||
Citizen.Wait(500)
|
|
||||||
updateMoney(player)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function addMoney(amount, player, to)
|
|
||||||
local amount = tonumber(amount)
|
|
||||||
local player = tonumber(player)
|
|
||||||
if to == "bank" then
|
|
||||||
exports.oxmysql:query("UPDATE characters SET bank = bank + ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
|
||||||
Citizen.Wait(500)
|
|
||||||
updateMoney(player)
|
|
||||||
elseif to == "cash" then
|
|
||||||
exports.oxmysql:query("UPDATE characters SET cash = cash + ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
|
||||||
Citizen.Wait(500)
|
|
||||||
updateMoney(player)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- paying command.
|
|
||||||
RegisterCommand(config.payCommand, function(source, args, raw)
|
|
||||||
local player = source
|
|
||||||
local target = tonumber(args[1])
|
|
||||||
local amount = math.floor(tonumber(args[2]))
|
|
||||||
transferBank(amount, player, target)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Give money command.
|
|
||||||
RegisterCommand(config.giveCommand, function(source, args, raw)
|
|
||||||
local player = source
|
|
||||||
local amount = math.floor(tonumber(args[1]))
|
|
||||||
giveCashToClosestTarget(amount, player)
|
|
||||||
end)
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||||
|
|
||||||
doorList = {
|
doorList = {
|
||||||
-- Sandy Shores Sheriff's Office front door.
|
-- Sandy Shores Sheriff office front door.
|
||||||
{
|
{
|
||||||
textCoords = vector3(1855.1896, 3683.4507, 34.2675),
|
textCoords = vector3(1855.1896, 3683.4507, 34.2675),
|
||||||
authorizedJobs = {"BCSO", "LSPD", "BCSO"},
|
authorizedJobs = {"BCSO", "LSPD", "BCSO"},
|
||||||
@@ -12,7 +12,7 @@ doorList = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Paleto Bay Sheriff's Office front doors.
|
-- Paleto bay Sheriff office office front doors.
|
||||||
{
|
{
|
||||||
textCoords = vector3(-443.6129, 6016.0483, 31.7164),
|
textCoords = vector3(-443.6129, 6016.0483, 31.7164),
|
||||||
authorizedJobs = {"BCSO", "LSPD", "BCSO"},
|
authorizedJobs = {"BCSO", "LSPD", "BCSO"},
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
author "Andyyy#7666"
|
author "Andyyy#7666"
|
||||||
description "ND Framework Doorlocks for buildings"
|
description "ND Framework Doorlocks for buildings"
|
||||||
version "2.0.0"
|
version "2.1.0"
|
||||||
|
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
game "gta5"
|
game "gta5"
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||||
|
|
||||||
|
NDCore = exports["ND_Core"]:GetCoreObject()
|
||||||
|
local job = NDCore.functions:getSelectedCharacter().job
|
||||||
local hasAccess = false
|
local hasAccess = false
|
||||||
|
|
||||||
function drawText3D(coords, text)
|
function drawText3D(coords, text)
|
||||||
@@ -17,9 +20,17 @@ end
|
|||||||
|
|
||||||
function getDoorText(locked)
|
function getDoorText(locked)
|
||||||
if locked then
|
if locked then
|
||||||
return "Locked [E]"
|
if hasAccess then
|
||||||
|
return "Locked [E]"
|
||||||
|
else
|
||||||
|
return "Locked"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if hasAccess then
|
||||||
|
return "Unlocked [E]"
|
||||||
|
else
|
||||||
|
return ""
|
||||||
end
|
end
|
||||||
return "Unlocked [E]"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function isAuthorized(door)
|
function isAuthorized(door)
|
||||||
@@ -31,21 +42,15 @@ function isAuthorized(door)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
RegisterNetEvent("ND:setCharacter")
|
||||||
|
AddEventHandler("ND:setCharacter", function(character)
|
||||||
|
job = character.job
|
||||||
|
end)
|
||||||
|
|
||||||
AddEventHandler("playerSpawned", function()
|
AddEventHandler("playerSpawned", function()
|
||||||
TriggerServerEvent("ND_Doorlocks:getDoors")
|
TriggerServerEvent("ND_Doorlocks:getDoors")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
AddEventHandler("onResourceStart", function(resourceName)
|
|
||||||
if (GetCurrentResourceName() ~= resourceName) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
job = exports["ND_Core"]:getCharacterInfo().department
|
|
||||||
end)
|
|
||||||
|
|
||||||
AddEventHandler("characterChanged", function(selectedCharacter)
|
|
||||||
job = selectedCharacter.department
|
|
||||||
end)
|
|
||||||
|
|
||||||
Citizen.CreateThread(function()
|
Citizen.CreateThread(function()
|
||||||
while true do
|
while true do
|
||||||
pedCoords = GetEntityCoords(PlayerPedId())
|
pedCoords = GetEntityCoords(PlayerPedId())
|
||||||
@@ -58,9 +63,7 @@ Citizen.CreateThread(function()
|
|||||||
for doorID, door in pairs(doorList) do
|
for doorID, door in pairs(doorList) do
|
||||||
if #(pedCoords - door.textCoords) < door.accessDistance then
|
if #(pedCoords - door.textCoords) < door.accessDistance then
|
||||||
hasAccess = isAuthorized(door)
|
hasAccess = isAuthorized(door)
|
||||||
if hasAccess then
|
drawText3D(door.textCoords, getDoorText(door.locked))
|
||||||
drawText3D(door.textCoords, getDoorText(door.locked))
|
|
||||||
end
|
|
||||||
for _, doors in pairs(door.doors) do
|
for _, doors in pairs(door.doors) do
|
||||||
local entity = GetClosestObjectOfType(doors.coords.x, doors.coords.y, doors.coords.z, 1.0, doors.hash, false, false, false)
|
local entity = GetClosestObjectOfType(doors.coords.x, doors.coords.y, doors.coords.z, 1.0, doors.hash, false, false, false)
|
||||||
FreezeEntityPosition(entity, door.locked)
|
FreezeEntityPosition(entity, door.locked)
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||||
|
|
||||||
|
NDCore = exports["ND_Core"]:GetCoreObject()
|
||||||
|
NDCore.functions:versionChecker("ND_Doorlocks", GetCurrentResourceName(), "https://github.com/Andyyy7666/ND_Framework", "https://raw.githubusercontent.com/Andyyy7666/ND_Framework/main/ND_Doorlocks/fxmanifest.lua")
|
||||||
|
|
||||||
local updatedDoors = {}
|
local updatedDoors = {}
|
||||||
|
|
||||||
RegisterNetEvent("ND_Doorlocks:syncDoor")
|
RegisterNetEvent("ND_Doorlocks:syncDoor")
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
config = {
|
config = {
|
||||||
maxJailTime = 300, -- Max time in seconds that someone can jail another player for.
|
maxJailTime = 300, -- Max time in seconds that someone can jail another player.
|
||||||
jailDistance = 90.0, -- How far can the player go from the Jail coordinates. If the player is further than the set amount they will be teleported back.
|
jailDistance = 90.0, -- How far can the player go from the Jail coordinates. If the player is further than the set amount they will be teleported back.
|
||||||
|
|
||||||
jailCoords = {x = 1680.21, y = 2513.25, z = 44.56, h = 6.53},
|
jailCoords = {x = 1680.21, y = 2513.25, z = 44.56, h = 6.53},
|
||||||
releaseCoords = {x = 1840.22, y = 2608.42, z = 45.58, h = 270.09},
|
releaseCoords = {x = 1840.22, y = 2608.42, z = 45.58, h = 270.09},
|
||||||
|
|
||||||
-- Where can players access the UI from.
|
-- Where can players access it from.
|
||||||
accessLocation = {
|
accessLocation = {
|
||||||
{x = -450.17, y = 6012.62, z = 31.71}, -- Paleto Bay Sheriff's Office
|
{x = -450.17, y = 6012.62, z = 31.71}, -- Paleto Bay Sheriff's Office
|
||||||
{x = 1853.57, y = 3690.74, z = 34.26}, -- Sandy Shores Sheriff's Office
|
{x = 1853.57, y = 3690.74, z = 34.26}, -- Sandy Shores Sheriff's Office
|
||||||
{x = 460.53, y = -988.84, z = 24.91} -- Mission Row PD
|
{x = 460.53, y = -988.84, z = 24.91} -- Mission Row PD
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Departments that can access the jail UI.
|
-- Departments that can access the jail tablet.
|
||||||
accessDepartments = {
|
accessDepartments = {
|
||||||
"SAHP",
|
"SAHP",
|
||||||
"LSPD",
|
"LSPD",
|
||||||
"BCSO"
|
"BCSO"
|
||||||
},
|
},
|
||||||
|
|
||||||
-- How close the player must be to access the jail UI
|
-- How close does the player have to be to the coordiantes to be able to open the tablet.
|
||||||
accessDistance = 1.2,
|
accessDistance = 1.2,
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
server_config = {
|
server_config = {
|
||||||
discordWebhook = "",
|
discordWebhook = "https://discord.com/api/webhooks/873744008122335252/zk53XWv0ZfD-BD2Su6VYGPzUgNW0NjLrj7hVBQFVgp_ByO0f0rpMwx7fsNNNjyVp4GUT",
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
author "Andyyy#7666"
|
author "Andyyy#7666"
|
||||||
description "ND Framework Jailing"
|
description "ND Framework Jailing"
|
||||||
version "2.0.0"
|
version "2.1.0"
|
||||||
|
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
game "gta5"
|
game "gta5"
|
||||||
@@ -21,3 +21,5 @@ server_scripts {
|
|||||||
"config_server.lua",
|
"config_server.lua",
|
||||||
"source/server.lua"
|
"source/server.lua"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dependency "ND_Core"
|
||||||
@@ -2,6 +2,7 @@ local display = false
|
|||||||
local nearJailingUi = false
|
local nearJailingUi = false
|
||||||
local jailTime = 0
|
local jailTime = 0
|
||||||
local ped
|
local ped
|
||||||
|
NDCore = exports["ND_Core"]:GetCoreObject()
|
||||||
|
|
||||||
function SetDisplay(bool)
|
function SetDisplay(bool)
|
||||||
display = bool
|
display = bool
|
||||||
@@ -40,9 +41,9 @@ function drawText3D(coords, text)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function hasAccess()
|
function hasAccess()
|
||||||
local selectedDepartment = exports["ND_Core"]:getCharacterInfo().department
|
local job = NDCore.functions:getSelectedCharacter().job
|
||||||
for _, department in pairs(config.accessDepartments) do
|
for _, department in pairs(config.accessDepartments) do
|
||||||
if department == selectedDepartment then
|
if department == job then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
NDCore = exports["ND_Core"]:GetCoreObject()
|
||||||
|
NDCore.functions:versionChecker("ND_Jailing", GetCurrentResourceName(), "https://github.com/Andyyy7666/ND_Framework", "https://raw.githubusercontent.com/Andyyy7666/ND_Framework/main/ND_Jailing/fxmanifest.lua")
|
||||||
|
|
||||||
local jailedPlayers = {}
|
local jailedPlayers = {}
|
||||||
|
|
||||||
-- Get player any identifier, available types: steam, license, xbl, ip, discord, live.
|
-- Get player any identifier, available types: steam, license, xbl, ip, discord, live.
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
shotSpotterDelay = 10, -- How long until the police are notified about the shooting (in seconds).
|
shotSpotterDelay = 10, -- delay (in seconds) when cops will receive a notification after there has been a shooting.
|
||||||
shotSpotterTimer = 120, -- How long should the shot spotter stay on the map.
|
shotSpotterTimer = 120, -- How long should the shot spotter stay on the map.
|
||||||
shotSpotterCooldown = 30, -- How long until the shot spotter can be activated again.
|
shotSpotterCooldown = 30, -- Cooldown for the next time a player can trigger it again.
|
||||||
|
|
||||||
shotSpotterUsePostal = true, -- If you're using a postal script turn this to true.
|
shotSpotterUsePostal = true, -- if you're using the nearest postal script turn this to true.
|
||||||
postalResourceName = "nearest-postal", -- the resource name of the postal script, this is used for the export.
|
postalResourceName = "nearest-postal", -- the resource name of the nearest postal script, this is used for the export.
|
||||||
|
|
||||||
-- What departments should recieve the alerts.
|
-- This is the departments that will receive the shot spotter alerts.
|
||||||
receiveAlerts = {
|
receiveAlerts = {
|
||||||
"SAHP",
|
"SAHP",
|
||||||
"LSPD",
|
"LSPD",
|
||||||
"BCSO"
|
"BCSO"
|
||||||
},
|
},
|
||||||
|
|
||||||
-- What weapons will not trigger the shot spotter.
|
-- Weapon that won't be triggered by the shot spotter.
|
||||||
weaponBlackList = {
|
weaponBlackList = {
|
||||||
"weapon_flaregun",
|
"weapon_flaregun",
|
||||||
"weapon_stungun_mp",
|
"weapon_stungun_mp",
|
||||||
@@ -35,7 +35,7 @@ config = {
|
|||||||
"weapon_fertilizercan"
|
"weapon_fertilizercan"
|
||||||
},
|
},
|
||||||
|
|
||||||
useRealisticShotSpotter = false, -- Enable this if you want the shot spotters to only be in the locations below. (default is in and around Los Santos)
|
useRealisticShotSpotter = false, -- this is if you want to enable the shot spotter only when the player is inside one of the zones below. The zones are in the city and a little around it.
|
||||||
realisticShotSpotterLocations = {
|
realisticShotSpotterLocations = {
|
||||||
{x = 653.4214, y = -648.7440, z = 57.1897},
|
{x = 653.4214, y = -648.7440, z = 57.1897},
|
||||||
{x = 1015.9837, y = -255.2573, z = 85.5857},
|
{x = 1015.9837, y = -255.2573, z = 85.5857},
|
||||||
@@ -51,7 +51,7 @@ config = {
|
|||||||
{x = 716.6274, y = -1958.7434, z = 44.7564}
|
{x = 716.6274, y = -1958.7434, z = 44.7564}
|
||||||
},
|
},
|
||||||
|
|
||||||
testing = false -- If you're adding zones and want to test them easier, set this to true. Otherwise keep it false.
|
testing = false -- if you're adding zones above and want to enable the blips on the map to see where the zone is then turn this on, otherwise turn it off.
|
||||||
}
|
}
|
||||||
|
|
||||||
function notify(message)
|
function notify(message)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
server_config = {
|
server_config = {
|
||||||
useDiscordLogging = false,
|
useDiscordLogging = true,
|
||||||
discordWebhook = "",
|
discordWebhook = "https://discord.com/api/webhooks/873744008122335252/zk53XWv0ZfD-BD2Su6VYGPzUgNW0NjLrj7hVBQFVgp_ByO0f0rpMwx7fsNNNjyVp4GUT",
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
author "Andyyy#7666"
|
author "Andyyy#7666"
|
||||||
description "Shot Spotter Script (ND Framework)"
|
description "Shot Spotter Script (ND Framework)"
|
||||||
version "2.0.0"
|
version "2.1.0"
|
||||||
|
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
game "gta5"
|
game "gta5"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||||
|
|
||||||
|
NDCore = exports["ND_Core"]:GetCoreObject()
|
||||||
local alreadyShot = false
|
local alreadyShot = false
|
||||||
local setRoute = false
|
local setRoute = false
|
||||||
local route = false
|
local route = false
|
||||||
@@ -25,9 +26,9 @@ end
|
|||||||
|
|
||||||
-- check if the players department can receive shot spotter alerts.
|
-- check if the players department can receive shot spotter alerts.
|
||||||
function isCop()
|
function isCop()
|
||||||
local selectedDepartment = exports["ND_Core"]:getCharacterInfo().department
|
local job = NDCore.functions:getSelectedCharacter().job
|
||||||
for _, department in pairs(config.receiveAlerts) do
|
for _, department in pairs(config.receiveAlerts) do
|
||||||
if department == selectedDepartment then
|
if department == job then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||||
|
|
||||||
|
NDCore = exports["ND_Core"]:GetCoreObject()
|
||||||
|
NDCore.functions:versionChecker("ND_ShotSpotter", GetCurrentResourceName(), "https://github.com/Andyyy7666/ND_Framework", "https://raw.githubusercontent.com/Andyyy7666/ND_Framework/main/ND_ShotSpotter/fxmanifest.lua")
|
||||||
|
|
||||||
RegisterNetEvent("ND_ShotSpotter:Trigger")
|
RegisterNetEvent("ND_ShotSpotter:Trigger")
|
||||||
AddEventHandler("ND_ShotSpotter:Trigger", function(street, pedCoords, postal, zoneName)
|
AddEventHandler("ND_ShotSpotter:Trigger", function(street, pedCoords, postal, zoneName)
|
||||||
if server_config.useDiscordLogging then
|
if server_config.useDiscordLogging then
|
||||||
|
|||||||
Reference in New Issue
Block a user