mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
Delete ND_Core/source/server directory
This commit is contained in:
@@ -1,149 +0,0 @@
|
||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||
|
||||
if config.enableAopCommand then
|
||||
local aop = config.defaultAop
|
||||
RegisterNetEvent("getAop")
|
||||
AddEventHandler("getAop", function()
|
||||
local player = source
|
||||
TriggerClientEvent("returnAop", player, aop)
|
||||
end)
|
||||
RegisterCommand(config.aopCommand, function(source, args, rawCommand)
|
||||
local player = source
|
||||
local canChangeAOP = false
|
||||
for role, _ in pairs(config.canChangeAOP) do
|
||||
if IsRolePresent(player, role, config.canChangeAOP) then
|
||||
canChangeAOP = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if canChangeAOP then
|
||||
aop = string.sub(rawCommand, string.len(config.aopCommand) + 1, string.len(rawCommand))
|
||||
TriggerClientEvent("setAop", -1, aop)
|
||||
else
|
||||
TriggerClientEvent("chat:addMessage", player, {
|
||||
args = {"~r~You don't have permission to set the aop."}
|
||||
})
|
||||
end
|
||||
end, false)
|
||||
end
|
||||
|
||||
if config.enablePriorityCooldown then
|
||||
local priority = "Priority Status: ~g~Available"
|
||||
RegisterNetEvent("getPriority")
|
||||
AddEventHandler("getPriority", function() -- update priority
|
||||
local player = source
|
||||
TriggerClientEvent("returnPriority", player, priority)
|
||||
end)
|
||||
RegisterCommand(config.startPriorityCommand, function(source, args, rawCommand) -- start a priority & update.
|
||||
local player = source
|
||||
priority = "Priority Status: ~r~Active ~c~(" .. GetPlayerName(player) .. ")"
|
||||
TriggerClientEvent("returnPriority", -1, priority)
|
||||
end, false)
|
||||
RegisterCommand(config.stopPriorityCommand, function(source, args, rawCommand) -- stop the priority & update.
|
||||
priorityCooldown(config.cooldownAfterPriority)
|
||||
end, false)
|
||||
RegisterCommand(config.cooldownPriorityCommand, function(source, args, rawCommand)
|
||||
local time = tonumber(args[1])
|
||||
if time then
|
||||
priorityCooldown(time)
|
||||
end
|
||||
end, false)
|
||||
RegisterCommand(config.joinPriorityCommand, function(source, args, rawCommand)
|
||||
if string.find(priority, "Active") then
|
||||
if not string.find(priority, GetPlayerName(source)) then
|
||||
priority = string.gsub(priority, "%)", "")
|
||||
priority = priority .. ", " .. GetPlayerName(source) .. ")"
|
||||
TriggerClientEvent("returnPriority", -1, priority)
|
||||
end
|
||||
end
|
||||
end, false)
|
||||
RegisterCommand(config.leavePriorityCommand, function(source, args, rawCommand)
|
||||
if string.find(priority, "Active") then
|
||||
if string.find(priority, GetPlayerName(source)) then
|
||||
priority = string.gsub(priority, ", " .. GetPlayerName(source), "")
|
||||
priority = string.gsub(priority, GetPlayerName(source), "")
|
||||
TriggerClientEvent("returnPriority", -1, priority)
|
||||
end
|
||||
end
|
||||
end, false)
|
||||
|
||||
-- Priority count down and updates.
|
||||
function priorityCooldown(time)
|
||||
for cooldown = time, 1, -1 do
|
||||
if cooldown > 1 then
|
||||
priority = "Priority Cooldown: ~c~" .. cooldown .. " minutes"
|
||||
else
|
||||
priority = "Priority Cooldown: ~c~" .. cooldown .. " minute"
|
||||
end
|
||||
TriggerClientEvent("returnPriority", -1, priority)
|
||||
Citizen.Wait(60000)
|
||||
end
|
||||
priority = "Priority Status: ~g~Available"
|
||||
TriggerClientEvent("returnPriority", -1, priority)
|
||||
end
|
||||
end
|
||||
|
||||
-- Twotter command
|
||||
RegisterCommand("twt", function(source, args, rawCommand)
|
||||
local player = source
|
||||
local twtName = onlinePlayers[player].twt
|
||||
TriggerClientEvent("chat:addMessage", -1, {
|
||||
template = "<img src='data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxz%0D%0AdmcKICB2aWV3Ym94PSIwIDAgMjAwMCAxNjI1LjM2IgogIHdpZHRoPSIyMDAwIgogIGhlaWdodD0i%0D%0AMTYyNS4zNiIKICB2ZXJzaW9uPSIxLjEiCiAgeG1sb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NzUuNjYgLTMzLjEyMTEsMCAtNjUuNzg1%0D%0AMSwtMS45NDkgLTk3Ljg4MjgsLTUuNzM4IDE4MS41ODYsMTE2LjQxNzYgMzk3LjI3LDE4NC4zNTkg%0D%0ANjI4Ljk4OCwxODQuMzU5IDc1NC43MzIsMCAxMTY3LjQ2MiwtNjI1LjIzOCAxMTY3LjQ2MiwtMTE2%0D%0ANy40NyAwLC0xNy43OSAtMC40MSwtMzUuNDggLTEuMiwtNTMuMDggODAuMTc5OSwtNTcuODYgMTQ5%0D%0ALjczOTksLTEzMC4xMiAyMDQuNzQ5OSwtMjEyLjQxIgogICAgc3R5bGU9ImZpbGw6IzAwYWNlZCIv%0D%0APgo8L3N2Zz4K' height='16'> <b>{0}</b>: {1}",
|
||||
multiline = true,
|
||||
args = {"^4@" .. twtName .. " (#" .. player .. ")", string.sub(rawCommand, 4, string.len(rawCommand))}
|
||||
})
|
||||
end, false)
|
||||
|
||||
-- Me command
|
||||
RegisterCommand("me", function(source, args, rawCommand)
|
||||
local player = source
|
||||
local playerCoords = GetEntityCoords(GetPlayerPed(player))
|
||||
for k, _ in pairs(onlinePlayers) do
|
||||
local targetCoords = GetEntityCoords(GetPlayerPed(k))
|
||||
if (#(playerCoords - targetCoords) < 19.999) then
|
||||
local name = onlinePlayers[player].firstName .. " " .. onlinePlayers[player].lastName
|
||||
TriggerClientEvent("chat:addMessage", k, {
|
||||
color = {255, 0, 0},
|
||||
args = {"^*ME | ^0" .. name .. " (#" .. player .. ")", string.sub(rawCommand, 3, string.len(rawCommand))}
|
||||
})
|
||||
end
|
||||
end
|
||||
end, false)
|
||||
|
||||
-- OOC command event
|
||||
RegisterCommand("ooc", function(source, args, rawCommand)
|
||||
local player = source
|
||||
TriggerClientEvent("chat:addMessage", -1, {
|
||||
color = {150, 150, 150},
|
||||
args = {"^*OOC | ^0" .. GetPlayerName(player) .. " (#" .. player .. ")", string.sub(rawCommand, 4, string.len(rawCommand))}
|
||||
})
|
||||
end, false)
|
||||
|
||||
-- Darkweb command event
|
||||
if config.enableDarkweb then
|
||||
RegisterCommand("darkweb", function(source, args, rawCommand)
|
||||
local player = source
|
||||
for playerId, playerData in pairs(onlinePlayers) do
|
||||
for _, department in pairs(config.canSeeDarkweb) do
|
||||
if playerData.dept == department then
|
||||
TriggerClientEvent("chat:addMessage", playerId, {
|
||||
color = {0, 0, 0},
|
||||
args = {"^*Dark web | ^0Anonymous (#" .. player .. ")", string.sub(rawCommand, 8, string.len(rawCommand))}
|
||||
})
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end, false)
|
||||
end
|
||||
|
||||
-- 911 command event
|
||||
RegisterCommand("911", function(source, args, rawCommand)
|
||||
local player = source
|
||||
for k, v in pairs(onlinePlayers) do
|
||||
if v.department ~= "CIV" then
|
||||
local coords = GetEntityCoords(GetPlayerPed(player))
|
||||
TriggerClientEvent("911", k, coords, rawCommand)
|
||||
end
|
||||
end
|
||||
end, false)
|
||||
@@ -1,71 +0,0 @@
|
||||
-- This is a edited version of discord-roles, original discord-roles resource: https://forum.cfx.re/t/discord-roles-for-permissions-im-creative-i-know/233805?u=andyyy7666
|
||||
local FormattedToken = "Bot " .. server_config.DiscordToken
|
||||
|
||||
function DiscordRequest(method, endpoint, jsondata)
|
||||
local data = nil
|
||||
PerformHttpRequest("https://discordapp.com/api/"..endpoint, function(errorCode, resultData, resultHeaders)
|
||||
data = {data=resultData, code=errorCode, headers=resultHeaders}
|
||||
end, method, #jsondata > 0 and json.encode(jsondata) or "", {["Content-Type"] = "application/json", ["Authorization"] = FormattedToken})
|
||||
|
||||
while data == nil do
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
|
||||
return data
|
||||
end
|
||||
|
||||
function IsRolePresent(user, role, theTable, type)
|
||||
local discordId = nil
|
||||
local theRole = nil
|
||||
|
||||
for _, id in ipairs(GetPlayerIdentifiers(user)) do
|
||||
if string.match(id, "discord:") then
|
||||
discordId = string.gsub(id, "discord:", "")
|
||||
--print("Found discord id: "..discordId)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if type == "start" then
|
||||
theRole = theTable
|
||||
else
|
||||
theRole = theTable[role]
|
||||
end
|
||||
|
||||
if theRole == "0" then
|
||||
--print("Role Given (0 in server_config)")
|
||||
return true
|
||||
elseif discordId then
|
||||
local endpoint = ("guilds/%s/members/%s"):format(server_config.GuildId, discordId)
|
||||
local member = DiscordRequest("GET", endpoint, {})
|
||||
if member.code == 200 then
|
||||
local data = json.decode(member.data)
|
||||
local roles = data.roles
|
||||
local found = true
|
||||
for i=1, #roles do
|
||||
if roles[i] == theRole then
|
||||
--print("Found role")
|
||||
return true
|
||||
end
|
||||
end
|
||||
--print("Not found!")
|
||||
return false
|
||||
else
|
||||
--print("Error occurred, maybe they are not in discord?")
|
||||
return false
|
||||
end
|
||||
else
|
||||
--print("missing identifier")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
local guild = DiscordRequest("GET", "guilds/" .. server_config.GuildId, {})
|
||||
if guild.code == 200 then
|
||||
local data = json.decode(guild.data)
|
||||
print("[source/server/discord.lua] Permission system guild set to: "..data.name.." ("..data.id..")")
|
||||
else
|
||||
print("[source/server/discord.lua] An error occured, please check your server_config and ensure everything is correct (You might not have a valid token). Error: "..(guild.data or guild.code))
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user