From 7f153e72b25fab2107109d561bf4caacfea39138 Mon Sep 17 00:00:00 2001 From: WLVF <65689785+WLVF@users.noreply.github.com> Date: Thu, 1 Sep 2022 04:11:48 -0400 Subject: [PATCH] AddEventHandler.... not needed <3 --- ND_ATMs/source/client.lua | 3 +-- ND_ATMs/source/server.lua | 6 ++---- ND_Banks/source/client.lua | 3 +-- ND_Banks/source/server.lua | 9 +++------ ND_CharacterSelection/source/client.lua | 6 ++---- ND_CharacterSelection/source/server.lua | 9 +++------ ND_Chat/source/client.lua | 3 +-- ND_Core/client/main.lua | 12 ++++-------- ND_Doorlocks/source/client.lua | 9 +++------ ND_Doorlocks/source/server.lua | 6 ++---- ND_Jailing/source/client.lua | 12 ++++-------- ND_Jailing/source/server.lua | 12 ++++-------- ND_ShotSpotter/source/client.lua | 6 ++---- ND_ShotSpotter/source/server.lua | 3 +-- 14 files changed, 33 insertions(+), 66 deletions(-) diff --git a/ND_ATMs/source/client.lua b/ND_ATMs/source/client.lua index d72b369..9e284c8 100644 --- a/ND_ATMs/source/client.lua +++ b/ND_ATMs/source/client.lua @@ -131,8 +131,7 @@ RegisterNUICallback("useATM", function(data) end) -- update the balance on the ui and confirm if the deposit/withdraw was successful. -RegisterNetEvent("ND_ATMs:update") -AddEventHandler("ND_ATMs:update", function(status) +RegisterNetEvent("ND_ATMs:update", function(status) Citizen.Wait(1000) local selectedCharacter = NDCore.Functions.GetSelectedCharacter() SendNUIMessage({ diff --git a/ND_ATMs/source/server.lua b/ND_ATMs/source/server.lua index e75a446..f28421a 100644 --- a/ND_ATMs/source/server.lua +++ b/ND_ATMs/source/server.lua @@ -1,15 +1,13 @@ NDCore = exports["ND_Core"]:GetCoreObject() 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) +RegisterNetEvent("ND_ATMs:withdraw", function(amount) local player = source local update = NDCore.Functions.WithdrawMoney(amount, player) TriggerClientEvent("ND_ATMs:update", player, update) end) -RegisterNetEvent("ND_ATMs:deposit") -AddEventHandler("ND_ATMs:deposit", function(amount) +RegisterNetEvent("ND_ATMs:deposit", function(amount) local player = source local update = NDCore.Functions.DepositMoney(amount, player) TriggerClientEvent("ND_ATMs:update", player, update) diff --git a/ND_Banks/source/client.lua b/ND_Banks/source/client.lua index 891a8fa..17f7a26 100644 --- a/ND_Banks/source/client.lua +++ b/ND_Banks/source/client.lua @@ -177,8 +177,7 @@ RegisterNUICallback("useATM", function(data) end) -- update the balance on the ui and confirm if the deposit/withdraw was successful. -RegisterNetEvent("ND_Banks:update") -AddEventHandler("ND_Banks:update", function(status) +RegisterNetEvent("ND_Banks:update", function(status) Citizen.Wait(1000) local selectedCharacter = NDCore.Functions.GetSelectedCharacter() SendNUIMessage({ diff --git a/ND_Banks/source/server.lua b/ND_Banks/source/server.lua index 3dd4723..9af2dae 100644 --- a/ND_Banks/source/server.lua +++ b/ND_Banks/source/server.lua @@ -1,22 +1,19 @@ 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") -AddEventHandler("ND_Banks:withdraw", function(amount) +RegisterNetEvent("ND_Banks:withdraw", function(amount) local player = source local update = NDCore.Functions.WithdrawMoney(amount, player) TriggerClientEvent("ND_Banks:update", player, update) end) -RegisterNetEvent("ND_Banks:deposit") -AddEventHandler("ND_Banks:deposit", function(amount) +RegisterNetEvent("ND_Banks:deposit", function(amount) local player = source local update = NDCore.Functions.DepositMoney(amount, player) TriggerClientEvent("ND_Banks:update", player, update) end) -RegisterNetEvent("ND_Banks:transfer") -AddEventHandler("ND_Banks:transfer", function(amount, target) +RegisterNetEvent("ND_Banks:transfer", function(amount, target) local player = source local update = NDCore.Functions.TransferBank(amount, player, target) TriggerClientEvent("ND_Banks:update", player, update) diff --git a/ND_CharacterSelection/source/client.lua b/ND_CharacterSelection/source/client.lua index ab6fe3d..114a296 100644 --- a/ND_CharacterSelection/source/client.lua +++ b/ND_CharacterSelection/source/client.lua @@ -113,8 +113,7 @@ AddEventHandler("playerSpawned", function() end) -- This is used to add department drop down on the ui. -RegisterNetEvent("ND_CharacterSelection:permsChecked") -AddEventHandler("ND_CharacterSelection:permsChecked", function(allowedRoles) +RegisterNetEvent("ND_CharacterSelection:permsChecked", function(allowedRoles) SendNUIMessage({ type = "givePerms", deptRoles = json.encode(allowedRoles) @@ -122,8 +121,7 @@ AddEventHandler("ND_CharacterSelection:permsChecked", function(allowedRoles) end) -- Gets all the characters and displays them on the ui. -RegisterNetEvent("ND:returnCharacters") -AddEventHandler("ND:returnCharacters", function(characters) +RegisterNetEvent("ND:returnCharacters", function(characters) local playerCharacters = {} for id, characterInfo in pairs(characters) do playerCharacters[tostring(id)] = characterInfo diff --git a/ND_CharacterSelection/source/server.lua b/ND_CharacterSelection/source/server.lua index 05a4f24..9d613aa 100644 --- a/ND_CharacterSelection/source/server.lua +++ b/ND_CharacterSelection/source/server.lua @@ -19,8 +19,7 @@ function validateDepartment(player, department) end -- Creating a new character. -RegisterNetEvent("ND_CharacterSelection:newCharacter") -AddEventHandler("ND_CharacterSelection:newCharacter", function(newCharacter) +RegisterNetEvent("ND_CharacterSelection:newCharacter", function(newCharacter) local player = source -- validate that the person has permission to use the department. @@ -32,8 +31,7 @@ AddEventHandler("ND_CharacterSelection:newCharacter", function(newCharacter) end) -- Update the character info when edited. -RegisterNetEvent("ND_CharacterSelection:editCharacter") -AddEventHandler("ND_CharacterSelection:editCharacter", function(newCharacter) +RegisterNetEvent("ND_CharacterSelection:editCharacter", function(newCharacter) local player = source -- validate that the person has permission to use the department. @@ -47,8 +45,7 @@ AddEventHandler("ND_CharacterSelection:editCharacter", function(newCharacter) TriggerClientEvent("ND:returnCharacters", player, NDCore.Functions.GetPlayerCharacters(player)) end) -RegisterNetEvent("ND_CharacterSelection:checkPerms") -AddEventHandler("ND_CharacterSelection:checkPerms", function() +RegisterNetEvent("ND_CharacterSelection:checkPerms", function() local player = source local discordUserId = NDCore.Functions.GetPlayerIdentifierFromType("discord", player):gsub("discord:", "") local allowedRoles = {} diff --git a/ND_Chat/source/client.lua b/ND_Chat/source/client.lua index 90be073..1190d89 100644 --- a/ND_Chat/source/client.lua +++ b/ND_Chat/source/client.lua @@ -21,8 +21,7 @@ if config["/darkweb"].enabled then end if config["/911"].enabled then - RegisterNetEvent("ND_Chat:911") - AddEventHandler("ND_Chat:911", function(coords, callDescription) + RegisterNetEvent("ND_Chat:911", function(coords, callDescription) local selectedCharacter NDCore.Functions.GetSelectedCharacter(function(character) selectedCharacter = character diff --git a/ND_Core/client/main.lua b/ND_Core/client/main.lua index bca3903..1112b6d 100644 --- a/ND_Core/client/main.lua +++ b/ND_Core/client/main.lua @@ -58,27 +58,23 @@ if config.customPauseMenu then end) end -RegisterNetEvent("ND:returnCharacters") -AddEventHandler("ND:returnCharacters", function(characters) +RegisterNetEvent("ND:returnCharacters", function(characters) NDCore.Characters = characters end) -- updates the money on the client. -RegisterNetEvent("ND:updateMoney") -AddEventHandler("ND:updateMoney", function(cash, bank) +RegisterNetEvent("ND:updateMoney", function(cash, bank) NDCore.SelectedCharacter.cash = cash NDCore.SelectedCharacter.bank = bank end) -- Sets main character. -RegisterNetEvent("ND:setCharacter") -AddEventHandler("ND:setCharacter", function(character) +RegisterNetEvent("ND:setCharacter", function(character) NDCore.SelectedCharacter = character end) -- Updates last lcoation. -RegisterNetEvent("ND:updateLastLocation") -AddEventHandler("ND:updateLastLocation", function(location) +RegisterNetEvent("ND:updateLastLocation", function(location) NDCore.SelectedCharacter.lastLocation = location end) diff --git a/ND_Doorlocks/source/client.lua b/ND_Doorlocks/source/client.lua index ddc61a4..048871d 100644 --- a/ND_Doorlocks/source/client.lua +++ b/ND_Doorlocks/source/client.lua @@ -42,8 +42,7 @@ function isAuthorized(door) return false end -RegisterNetEvent("ND:setCharacter") -AddEventHandler("ND:setCharacter", function(character) +RegisterNetEvent("ND:setCharacter", function(character) job = character.job end) @@ -80,8 +79,7 @@ Citizen.CreateThread(function() end end) -RegisterNetEvent("ND_Doorlocks:syncDoor") -AddEventHandler("ND_Doorlocks:syncDoor", function(doorID, state) +RegisterNetEvent("ND_Doorlocks:syncDoor", function(doorID, state) doorList[doorID].locked = state for _, doors in pairs(doorList[doorID].doors) do local entity = GetClosestObjectOfType(doors.coords.x, doors.coords.y, doors.coords.z, 1.0, doors.hash, false, false, false) @@ -90,8 +88,7 @@ AddEventHandler("ND_Doorlocks:syncDoor", function(doorID, state) end end) -RegisterNetEvent("ND_Doorlocks:returnDoors") -AddEventHandler("ND_Doorlocks:returnDoors", function(updatedDoors) +RegisterNetEvent("ND_Doorlocks:returnDoors", function(updatedDoors) for doorID, state in pairs(updatedDoors) do doorList[doorID].locked = state for _, doors in pairs(doorList[doorID].doors) do diff --git a/ND_Doorlocks/source/server.lua b/ND_Doorlocks/source/server.lua index c611699..a11c83c 100644 --- a/ND_Doorlocks/source/server.lua +++ b/ND_Doorlocks/source/server.lua @@ -5,14 +5,12 @@ NDCore.Functions.VersionChecker("ND_Doorlocks", GetCurrentResourceName(), "https local updatedDoors = {} -RegisterNetEvent("ND_Doorlocks:syncDoor") -AddEventHandler("ND_Doorlocks:syncDoor", function(doorID, state) +RegisterNetEvent("ND_Doorlocks:syncDoor", function(doorID, state) updatedDoors[doorID] = state TriggerClientEvent("ND_Doorlocks:syncDoor", -1, doorID, state) end) -RegisterNetEvent("ND_Doorlocks:getDoors") -AddEventHandler("ND_Doorlocks:getDoors", function() +RegisterNetEvent("ND_Doorlocks:getDoors", function() local player = source TriggerClientEvent("ND_Doorlocks:returnDoors", player, updatedDoors) end) \ No newline at end of file diff --git a/ND_Jailing/source/client.lua b/ND_Jailing/source/client.lua index 5018f15..3add9e6 100644 --- a/ND_Jailing/source/client.lua +++ b/ND_Jailing/source/client.lua @@ -121,8 +121,7 @@ Citizen.CreateThread(function() end) -- Return list of all players on the server and open ui. -RegisterNetEvent("ND_Jailing:returnPlayers") -AddEventHandler("ND_Jailing:returnPlayers", function(players) +RegisterNetEvent("ND_Jailing:returnPlayers", function(players) for _, player in pairs(players) do SendNUIMessage({ type = "players", @@ -159,8 +158,7 @@ function jail(time) TriggerServerEvent("ND_Jailing:updateJailing", jailTime) end -RegisterNetEvent("ND_Jailing:timeLeft") -AddEventHandler("ND_Jailing:timeLeft", function() +RegisterNetEvent("ND_Jailing:timeLeft", function() while jailTime > 0 do Citizen.Wait(0) text("Time until release: " .. tostring(jailTime), 0.5, 0.9, 0.5) @@ -168,13 +166,11 @@ AddEventHandler("ND_Jailing:timeLeft", function() end) -- Jail a player and loop to keep them in jail every second. -RegisterNetEvent("ND_Jailing:jailPlayer") -AddEventHandler("ND_Jailing:jailPlayer", function(time) +RegisterNetEvent("ND_Jailing:jailPlayer", function(time) jail(time) end) -RegisterNetEvent("ND_Jailing:unjailPlayer") -AddEventHandler("ND_Jailing:unjailPlayer", function(time) +RegisterNetEvent("ND_Jailing:unjailPlayer", function(time) jailTime = 0 end) diff --git a/ND_Jailing/source/server.lua b/ND_Jailing/source/server.lua index 2a50d4f..31ee6c5 100644 --- a/ND_Jailing/source/server.lua +++ b/ND_Jailing/source/server.lua @@ -32,8 +32,7 @@ function sendToDiscord(name, message, color) end -- Jail player discord log, trigger the even on the players client and send a message to everyone. -RegisterNetEvent("ND_Jailing:jailPlayer") -AddEventHandler("ND_Jailing:jailPlayer", function(id, time, fine, reason) +RegisterNetEvent("ND_Jailing:jailPlayer", function(id, time, fine, reason) local player = source local players = NDCore.Functions.GetPlayers() local dept = players[player].job @@ -53,8 +52,7 @@ AddEventHandler("ND_Jailing:jailPlayer", function(id, time, fine, reason) end end) -RegisterNetEvent("ND_Jailing:updateJailing") -AddEventHandler("ND_Jailing:updateJailing", function(time) +RegisterNetEvent("ND_Jailing:updateJailing", function(time) local player = source if time == 0 then jailedPlayers[GetPlayerIdentifierFromType("license", player)] = nil @@ -64,8 +62,7 @@ AddEventHandler("ND_Jailing:updateJailing", function(time) end) -- Gets all players on the server and adds them to a table. -RegisterNetEvent("ND_Jailing:getPlayers") -AddEventHandler("ND_Jailing:getPlayers", function() +RegisterNetEvent("ND_Jailing:getPlayers", function() local players = {} for _, id in pairs(GetPlayers()) do players[id] = "(" .. id .. ") " .. GetPlayerName(id) @@ -73,8 +70,7 @@ AddEventHandler("ND_Jailing:getPlayers", function() TriggerClientEvent("ND_Jailing:returnPlayers", source, players) end) -RegisterNetEvent("ND_Jailing:getJailTime") -AddEventHandler("ND_Jailing:getJailTime", function() +RegisterNetEvent("ND_Jailing:getJailTime", function() local player = source local time = jailedPlayers[GetPlayerIdentifierFromType("license", player)] if time then diff --git a/ND_ShotSpotter/source/client.lua b/ND_ShotSpotter/source/client.lua index 062578c..011b324 100644 --- a/ND_ShotSpotter/source/client.lua +++ b/ND_ShotSpotter/source/client.lua @@ -90,8 +90,7 @@ Citizen.CreateThread(function() end end) -RegisterNetEvent("ND_ShotSpotter:Report") -AddEventHandler("ND_ShotSpotter:Report", function(street, pedCoords, postal) +RegisterNetEvent("ND_ShotSpotter:Report", function(street, pedCoords, postal) -- if the player isn't a cop then they won't receive the alert. if not isCop() then return @@ -130,8 +129,7 @@ AddEventHandler("ND_ShotSpotter:Report", function(street, pedCoords, postal) end) -- set route to latest shot spotter location. -RegisterNetEvent("ND_shotSpotter:setRoute") -AddEventHandler("ND_shotSpotter:setRoute", function() +RegisterNetEvent("ND_shotSpotter:setRoute", function() while setRoute do Citizen.Wait(0) if IsControlJustPressed(0, 113) then diff --git a/ND_ShotSpotter/source/server.lua b/ND_ShotSpotter/source/server.lua index 5aaa754..876281f 100644 --- a/ND_ShotSpotter/source/server.lua +++ b/ND_ShotSpotter/source/server.lua @@ -3,8 +3,7 @@ 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") -AddEventHandler("ND_ShotSpotter:Trigger", function(street, pedCoords, postal, zoneName) +RegisterNetEvent("ND_ShotSpotter:Trigger", function(street, pedCoords, postal, zoneName) if server_config.useDiscordLogging then local embed = { {