From 5febdb31997ca7f518544d7772a22b84f0e430eb Mon Sep 17 00:00:00 2001 From: Andyyy7666 <86536434+Andyyy7666@users.noreply.github.com> Date: Sat, 9 Jul 2022 00:06:36 +0200 Subject: [PATCH] Add files via upload --- ND_Chat/config.lua | 24 +++++++++++ ND_Chat/fxmanifest.lua | 14 +++++++ ND_Chat/source/client.lua | 45 ++++++++++++++++++++ ND_Chat/source/server.lua | 87 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 170 insertions(+) create mode 100644 ND_Chat/config.lua create mode 100644 ND_Chat/fxmanifest.lua create mode 100644 ND_Chat/source/client.lua create mode 100644 ND_Chat/source/server.lua diff --git a/ND_Chat/config.lua b/ND_Chat/config.lua new file mode 100644 index 0000000..95aea36 --- /dev/null +++ b/ND_Chat/config.lua @@ -0,0 +1,24 @@ +config = { + ["/me"] = true, + ["/gme"] = true, + ["/ooc"] = true, + ["/twt"] = true, + ["/darkweb"] = { + enabled = true, + canNotSee = { + "LSPD", + "BCSO", + "SAHP", + "LSFD" + } + }, + ["/911"] = { + enabled = true, + callTo = { + "LSPD", + "BCSO", + "SAHP", + "LSFD" + } + } +} \ No newline at end of file diff --git a/ND_Chat/fxmanifest.lua b/ND_Chat/fxmanifest.lua new file mode 100644 index 0000000..bc33f9e --- /dev/null +++ b/ND_Chat/fxmanifest.lua @@ -0,0 +1,14 @@ +-- For support join my discord: https://discord.gg/Z9Mxu72zZ6 +author "Andyyy#7666" +description "ND Chat commands" +version "2.0.0" + +fx_version "cerulean" +game "gta5" +lua54 "yes" + +shared_script "config.lua" +client_script "source/client.lua" +server_script "source/server.lua" + +dependency "ND_Core" \ No newline at end of file diff --git a/ND_Chat/source/client.lua b/ND_Chat/source/client.lua new file mode 100644 index 0000000..904a8ce --- /dev/null +++ b/ND_Chat/source/client.lua @@ -0,0 +1,45 @@ +if config["/me"] then + TriggerEvent("chat:addSuggestion", "/me", "Send message in the third person (Proximity Chat).", {{ name="Action", help="Describe your action."}}) +end + +if config["/gme"] then + TriggerEvent("chat:addSuggestion", "/gme", "Send message in the third person (Global Chat).", {{ name="Action", help="Describe your action."}}) +end + +if config["/ooc"] then + TriggerEvent("chat:addSuggestion", "/ooc", "Out Of Character chat Message (Global Chat).", {{name="Message", help="Put your questions or help request."}}) +end + +if config["/twt"] then + TriggerEvent("chat:addSuggestion", "/twt", "Send a Twotter in game. (Global Chat)", {{name="Message", help="Twotter Message."}}) +end + +if config["/darkweb"].enabled then + TriggerEvent("chat:addSuggestion", "/darkweb", "Send a anonymous message in game (Global Chat).", {{ name="Message", help=""}}) +end + +if config["/911"].enabled then + RegisterNetEvent("ND_Chat:911") + AddEventHandler("ND_Chat:911", function(coords, callDescription) + local selectedCharacter = exports["ND_Core"]:getCharacterInfo() + for _, department in pairs(config["/911"].callTo) do + if selectedCharacter.department == department then + local location = GetStreetNameFromHashKey(GetStreetNameAtCoord(coords.x, coords.y, coords.z)) + TriggerEvent("chat:addMessage", { + color = {255, 0, 0}, + args = {"^*[911] ^3Location: " .. location .. " ^1| Call infomation^0", callDescription} + }) + local blip = AddBlipForCoord(coords.x, coords.y, coords.z) + SetBlipSprite(blip, 817) + SetBlipAsShortRange(blip, true) + BeginTextCommandSetBlipName("STRING") + SetBlipColour(blip, 1) + AddTextComponentString("911 CALL: " .. location) + EndTextCommandSetBlipName(blip) + Citizen.Wait(60 * 1000) + RemoveBlip(blip) + break + end + end + end) +end \ No newline at end of file diff --git a/ND_Chat/source/server.lua b/ND_Chat/source/server.lua new file mode 100644 index 0000000..485e1f3 --- /dev/null +++ b/ND_Chat/source/server.lua @@ -0,0 +1,87 @@ +if config["/me"] then + RegisterCommand("me", function(source, args, rawCommand) + local player = source + local players = exports["ND_Core"]:getCharacterTable() + local playerCoords = GetEntityCoords(GetPlayerPed(player)) + for serverPlayer, _ in pairs(players) do + local targetCoords = GetEntityCoords(GetPlayerPed(serverPlayer)) + if (#(playerCoords - targetCoords) < 20.0) then + TriggerClientEvent("chat:addMessage", serverPlayer, { + color = {255, 0, 0}, + args = {"^*ME | ^0" .. players[player].firstName .. " " .. players[player].lastName .. " (#" .. player .. ")", table.concat(args, " ")} + }) + end + end + end, false) +end + +if config["/gme"] then + RegisterCommand("gme", function(source, args, rawCommand) + local player = source + local players = exports["ND_Core"]:getCharacterTable() + TriggerClientEvent("chat:addMessage", -1, { + color = {255, 0, 0}, + args = {"^*GME | ^0" .. players[player].firstName .. " " .. players[player].lastName .. " (#" .. player .. ")", table.concat(args, " ")} + }) + end, false) +end + +if config["/ooc"] then + RegisterCommand("ooc", function(source, args, rawCommand) + local player = source + TriggerClientEvent("chat:addMessage", -1, { + color = {150, 150, 150}, + args = {"^*OOC | ^0" .. GetPlayerName(player) .. " (#" .. player .. ")", table.concat(args, " ")} + }) + end, false) +end + +if config["/twt"] then + RegisterCommand("twt", function(source, args, rawCommand) + local player = source + local players = exports["ND_Core"]:getCharacterTable() + TriggerClientEvent("chat:addMessage", -1, { + template = " {0}: {1}", + multiline = true, + args = {"^4@" .. players[player].twt .. " (#" .. player .. ")", table.concat(args, " ")} + }) + end, false) +end + +function hasDarkWebPermission(player, players, args) + for _, department in pairs(config["/darkweb"].canNotSee) do + if players[player].dept == department then + TriggerClientEvent("chat:addMessage", player, { + color = {255, 0, 0}, + args = {"^*Error", players[player].dept .. " cannot access this command."} + }) + return false + end + end + for serverPlayer, playerInfo in pairs(players) do + for _, department in pairs(config["/darkweb"].canNotSee) do + if playerInfo.dept == department then + return false + end + end + TriggerClientEvent("chat:addMessage", serverPlayer, { + color = {0, 0, 0}, + args = {"^*Dark web | ^0Anonymous (#" .. player .. ")", table.concat(args, " ")} + }) + end +end + +if config["/darkweb"].enabled then + RegisterCommand("darkweb", function(source, args, rawCommand) + local player = source + local players = exports["ND_Core"]:getCharacterTable() + hasDarkWebPermission(player, players, args) + end, false) +end + +if config["/911"].enabled then + RegisterCommand("911", function(source, args, rawCommand) + local player = source + TriggerClientEvent("ND_Chat:911", -1, GetEntityCoords(GetPlayerPed(player)), table.concat(args, " ")) + end, false) +end \ No newline at end of file