diff --git a/ND_Core/source/server/commands.lua b/ND_Core/source/server/commands.lua deleted file mode 100644 index 10d1e64..0000000 --- a/ND_Core/source/server/commands.lua +++ /dev/null @@ -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 = " {0}: {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) diff --git a/ND_Core/source/server/discord.lua b/ND_Core/source/server/discord.lua deleted file mode 100644 index 6028908..0000000 --- a/ND_Core/source/server/discord.lua +++ /dev/null @@ -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)