From 65219c473b7672e08d487157481ed668b1ef08ac Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 00:18:50 +0200 Subject: [PATCH 01/24] Update fxmanifest.lua --- fxmanifest.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/fxmanifest.lua b/fxmanifest.lua index 27a313b0..3b8a2bbe 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -14,15 +14,16 @@ ui_page 'html/index.html' -- ui_page 'http://localhost:3000/' --for dev client_script { - 'client/**', + 'client/**', +} +server_scripts { + "@oxmysql/lib/MySQL.lua", + "server/**", } -server_script { - "server/**", - } shared_script { - "shared/**", - } + "shared/**", +} files { - 'html/**', + 'html/**', } From 3e63cf7bf87fbd7bf2a71b4531b642cccee8c9ca Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 00:31:35 +0200 Subject: [PATCH 02/24] Locales support --- fxmanifest.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fxmanifest.lua b/fxmanifest.lua index 3b8a2bbe..f1376bcf 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -21,6 +21,8 @@ server_scripts { "server/**", } shared_script { + '@qb-core/shared/locale.lua', + 'locales/en.lua', "shared/**", } From f6a8cab7e90fcc05104ed52cead6e6170b68552e Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 00:32:09 +0200 Subject: [PATCH 03/24] Create en.lua --- locales/en.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 locales/en.lua diff --git a/locales/en.lua b/locales/en.lua new file mode 100644 index 00000000..fd9ddf29 --- /dev/null +++ b/locales/en.lua @@ -0,0 +1,17 @@ +local Translations = { + error = { + ["u_veh_owner"] = "This vehicle is already yours..", + }, + success = { + ["veh_owner"] = "The vehicle is now yours!", + }, + info = { + + }, + +} + +Lang = Locale:new({ + phrases = Translations, + warnOnMissing = true +}) From c6936df2a48872d5d68ffa3ffc4e17661b69db2e Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 00:34:27 +0200 Subject: [PATCH 04/24] Admincar --- client/actions.lua | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/client/actions.lua b/client/actions.lua index 5f152c5e..d86908ed 100644 --- a/client/actions.lua +++ b/client/actions.lua @@ -1,8 +1,32 @@ QBCore = exports['qb-core']:GetCoreObject() -- Admin Car +local function getVehicleFromVehList(hash) + for _, v in pairs(QBCore.Shared.Vehicles) do + if hash == v.hash then + return v.model + end + end +end RegisterNetEvent('ps-adminmenu:client:Admincar', function(data) print("AdminCarTriggerd") + local ped = PlayerPedId() + local veh = GetVehiclePedIsIn(ped) + + if veh ~= nil and veh ~= 0 then + local plate = QBCore.Functions.GetPlate(veh) + local props = QBCore.Functions.GetVehicleProperties(veh) + local hash = props.model + local vehname = getVehicleFromVehList(hash) + if QBCore.Shared.Vehicles[vehname] ~= nil and next(QBCore.Shared.Vehicles[vehname]) ~= nil then + TriggerServerEvent('ps-adminmenu:server:SaveCar', props, QBCore.Shared.Vehicles[vehname], GetHashKey(veh), plate) + else + QBCore.Functions.Notify(Lang:t("error.cannot_store_veh"), 'error') + + end + else + QBCore.Functions.Notify(Lang:t("error.not_in_veh"), 'error') + end end) -- Invisible @@ -15,4 +39,4 @@ RegisterNetEvent('ps-adminmenu:client:ToggleInvisible', function(data) invisible = false SetEntityVisible(ped, true, 0) end -end) \ No newline at end of file +end) From a5cf0cf2142c557424b0a07a59c9c8fd085c612a Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 00:34:50 +0200 Subject: [PATCH 05/24] Admin car --- server/server.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/server/server.lua b/server/server.lua index 9ec0d1dd..94716ae6 100644 --- a/server/server.lua +++ b/server/server.lua @@ -35,3 +35,28 @@ RegisterNetEvent('ps-adminmenu:server:changeResourceState', function(name, state StartResource(name) end end) + + +RegisterNetEvent('ps-adminmenu:server:SaveCar', function(mods, vehicle, _, plate) + local src = source + if QBCore.Functions.HasPermission(src, 'admin') or IsPlayerAceAllowed(src, 'command') then + local Player = QBCore.Functions.GetPlayer(src) + local result = MySQL.query.await('SELECT plate FROM player_vehicles WHERE plate = ?', { plate }) + if result[1] == nil then + MySQL.insert('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, state) VALUES (?, ?, ?, ?, ?, ?, ?)', { + Player.PlayerData.license, + Player.PlayerData.citizenid, + vehicle.model, + vehicle.hash, + json.encode(mods), + plate, + 0 + }) + TriggerClientEvent('QBCore:Notify', src, Lang:t("success.veh_owner"), 'success', 5000) + else + TriggerClientEvent('QBCore:Notify', src, Lang:t("error.u_veh_owner"), 'error', 3000) + end + else + BanPlayer(src) + end +end) From 700bd1c4c3c4aaaa202933eb4d4602ad524c7856 Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 00:35:36 +0200 Subject: [PATCH 06/24] admincar locales --- locales/en.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/locales/en.lua b/locales/en.lua index fd9ddf29..bc6bc0bc 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -1,6 +1,8 @@ local Translations = { error = { ["u_veh_owner"] = "This vehicle is already yours..", + ['cannot_store_veh'] = "Cannot store this car in your garage", + ["not_in_veh"] = "You are not in a vehicle..", }, success = { ["veh_owner"] = "The vehicle is now yours!", From 294e073ba83ec3a86f03551c6bb362569a8e2a7e Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 02:18:45 +0200 Subject: [PATCH 07/24] Update actions.lua --- client/actions.lua | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/client/actions.lua b/client/actions.lua index d86908ed..e9c95ebd 100644 --- a/client/actions.lua +++ b/client/actions.lua @@ -9,7 +9,6 @@ local function getVehicleFromVehList(hash) end end RegisterNetEvent('ps-adminmenu:client:Admincar', function(data) - print("AdminCarTriggerd") local ped = PlayerPedId() local veh = GetVehiclePedIsIn(ped) @@ -34,9 +33,36 @@ RegisterNetEvent('ps-adminmenu:client:ToggleInvisible', function(data) local ped = PlayerPedId() if not invisible then invisible = true + QBCore.Functions.Notify(Lang:t("info.invisible", {value = "on"}), 'inform') SetEntityVisible(ped, false, 0) else invisible = false SetEntityVisible(ped, true, 0) + QBCore.Functions.Notify(Lang:t("info.invisible", {value = "off"}), 'inform') end end) + +-- godmode +local Godmode = false +RegisterNetEvent('ps-adminmenu:client:ToggleGodmode', function(data) + godmode = not godmode + + if godmode then + QBCore.Functions.Notify(Lang:t("info.godmode", {value = "enabled"}), 'inform') + while godmode do + Wait(0) + SetPlayerInvincible(PlayerId(), true) + end + SetPlayerInvincible(PlayerId(), false) + QBCore.Functions.Notify(Lang:t("info.godmode", {value = "disabled"}), 'inform') + end +end) + + + +-- weather +RegisterNetEvent('ps-adminmenu:client:ChangeWeather', function(data) + local weatherType = inputData["Wheather"] + TriggerServerEvent('qb-weathersync:server:setWeather', weatherType) + QBCore.Functions.Notify(Lang:t("info.weatherType", {value = weatherType})) +end) From 35593a54b51aa420c0ec98af99b180753db11777 Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 02:19:08 +0200 Subject: [PATCH 08/24] Update config.lua --- shared/config.lua | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/shared/config.lua b/shared/config.lua index be8abacb..5f270d01 100644 --- a/shared/config.lua +++ b/shared/config.lua @@ -30,12 +30,29 @@ Config.Actions = { }, { label = "Change Weather", - event = "ps-adminmenu:client:ChangeWeather", type = "client", perms = "mod", dropdown = { - { label = "Wheather", type = "input", inputtype = "normal" }, - { label = "Change", type = "button", event = "" }, + { label = "Wheather", type = "input", inputtype = "options", + options = { + { label = "Extrasunny", value = "Extrasunny"}, + { label = "Clear", value = "Clear"}, + { label = "Neutral", value = "Neutral"}, + { label = "Smog", value = "Smog"}, + { label = "Foggy", value = "Foggy"}, + { label = "Overcast", value = "Overcast"}, + { label = "Clouds", value = "Clouds"}, + { label = "Clearing", value = "Clearing"}, + { label = "Rain", value = "Rain"}, + { label = "Thunder", value = "Thunder"}, + { label = "Snow", value = "Snow"}, + { label = "Blizzard", value = "Blizzard"}, + { label = "Snowlight", value = "Snowlight"}, + { label = "Xmas", value = "Xmas"}, + { label = "Halloween", value = "Halloween"}, + }, + }, + { label = "Change", type = "button", event = "ps-adminmenu:client:ChangeWeather" }, }, }, { From 3d1b57242b8bbdedf75d4843991989c701c52b59 Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 02:19:20 +0200 Subject: [PATCH 09/24] Update en.lua --- locales/en.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/locales/en.lua b/locales/en.lua index bc6bc0bc..bd8906d3 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -3,12 +3,16 @@ local Translations = { ["u_veh_owner"] = "This vehicle is already yours..", ['cannot_store_veh'] = "Cannot store this car in your garage", ["not_in_veh"] = "You are not in a vehicle..", + ["no_perms"] = "You do not have permission to do this", }, success = { ["veh_owner"] = "The vehicle is now yours!", }, info = { - + ["godmode"] = "Godmode is %{value}", + ["invisible"] = "Invisible: %{value}", + ["banreason"] = 'Reason: %{reason}, until %{lenght}', + ["weatherType"] = "Weather is changed to: %{value}", }, } From d40e2310fcc7003b849dfb37db86d627edbf03d1 Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 02:56:10 +0200 Subject: [PATCH 10/24] Update actions.lua --- client/actions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/actions.lua b/client/actions.lua index e9c95ebd..d036eebe 100644 --- a/client/actions.lua +++ b/client/actions.lua @@ -61,7 +61,7 @@ end) -- weather -RegisterNetEvent('ps-adminmenu:client:ChangeWeather', function(data) +RegisterNetEvent('ps-adminmenu:client:ChangeWeather', function(inputData) local weatherType = inputData["Wheather"] TriggerServerEvent('qb-weathersync:server:setWeather', weatherType) QBCore.Functions.Notify(Lang:t("info.weatherType", {value = weatherType})) From f4242868a9c75b7a3286ac8e3306cefd29b57052 Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 03:00:31 +0200 Subject: [PATCH 11/24] Update actions.lua --- client/actions.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/client/actions.lua b/client/actions.lua index d036eebe..86355d61 100644 --- a/client/actions.lua +++ b/client/actions.lua @@ -66,3 +66,16 @@ RegisterNetEvent('ps-adminmenu:client:ChangeWeather', function(inputData) TriggerServerEvent('qb-weathersync:server:setWeather', weatherType) QBCore.Functions.Notify(Lang:t("info.weatherType", {value = weatherType})) end) + +-- Ban +RegisterNetEvent('ps-adminmenu:client:banplayer', function(inputData) + local playerid = inputData["Player ID"] + local reason = inputData["Reason"] + local time = inputData["Time"].Time + if playerid and reason and time then + print("ID: " .. playerid) + print("Reason: " .. reason) + print("Time: " .. time) + TriggerServerEvent("ps-adminmenu:server:banplayer", playerid, time, reason) + end +end) From 9622e1598017d0f55380be416b79acdff57a2c70 Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 03:00:51 +0200 Subject: [PATCH 12/24] Update server.lua --- server/server.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/server/server.lua b/server/server.lua index 94716ae6..d111abe4 100644 --- a/server/server.lua +++ b/server/server.lua @@ -60,3 +60,30 @@ RegisterNetEvent('ps-adminmenu:server:SaveCar', function(mods, vehicle, _, plate BanPlayer(src) end end) + +RegisterNetEvent('ps-adminmenu:server:banplayer', function(player, time, reason) + local src = source + if not QBCore.Functions.HasPermission(src, "mod") or IsPlayerAceAllowed(src, 'command') then NoPerms(src) return end + time = tonumber(time) + local banTime = tonumber(os.time() + time) + if banTime > 2147483647 then + banTime = 2147483647 + end + local timeTable = os.date('*t', banTime) + MySQL.insert('INSERT INTO bans (name, license, discord, ip, reason, expire, bannedby) VALUES (?, ?, ?, ?, ?, ?, ?)', { + GetPlayerName(player.id), + QBCore.Functions.GetIdentifier(player.id, 'license'), + QBCore.Functions.GetIdentifier(player.id, 'discord'), + QBCore.Functions.GetIdentifier(player.id, 'ip'), + reason, + banTime, + GetPlayerName(src) + }) + if banTime >= 2147483647 then + DropPlayer(player.id, Lang:t("info.banned") .. '\n' .. reason .. Lang:t("info.ban_perm") .. QBCore.Config.Server.Discord) + else + DropPlayer(player.id, Lang:t("info.banned") .. '\n' .. reason .. Lang:t("info.ban_expires") .. timeTable['day'] .. '/' .. timeTable['month'] .. '/' .. timeTable['year'] .. ' ' .. timeTable['hour'] .. ':' .. timeTable['min'] .. '\n🔸 Check our Discord for more information: ' .. QBCore.Config.Server.Discord) + end + +end) + From bf3e495b6025feb00ce7c6d9a95fbef46e8099c9 Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 04:13:41 +0200 Subject: [PATCH 13/24] Update actions.lua --- client/actions.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/actions.lua b/client/actions.lua index 86355d61..34b7c7f8 100644 --- a/client/actions.lua +++ b/client/actions.lua @@ -9,6 +9,7 @@ local function getVehicleFromVehList(hash) end end RegisterNetEvent('ps-adminmenu:client:Admincar', function(data) + print("AdminCarTriggerd") local ped = PlayerPedId() local veh = GetVehiclePedIsIn(ped) @@ -62,12 +63,15 @@ end) -- weather RegisterNetEvent('ps-adminmenu:client:ChangeWeather', function(inputData) - local weatherType = inputData["Wheather"] + local weatherType = inputData["Weather"] + -- print(weatherType) TriggerServerEvent('qb-weathersync:server:setWeather', weatherType) QBCore.Functions.Notify(Lang:t("info.weatherType", {value = weatherType})) end) --- Ban + + +-- Ban RegisterNetEvent('ps-adminmenu:client:banplayer', function(inputData) local playerid = inputData["Player ID"] local reason = inputData["Reason"] From da2d7991e295c0cfb27ab3e49e824591e16de4ce Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 04:14:00 +0200 Subject: [PATCH 14/24] Update server.lua --- server/server.lua | 76 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 21 deletions(-) diff --git a/server/server.lua b/server/server.lua index d111abe4..a2233407 100644 --- a/server/server.lua +++ b/server/server.lua @@ -1,5 +1,9 @@ QBCore = exports['qb-core']:GetCoreObject() +local function NoPerms(source) + QBCore.Functions.Notify(source, Lang:t('error.no_perms'), 'error') +end + RegisterNetEvent('ps-adminmenu:client:Getresources', function(data) local totalResources = GetNumResources() -- print("total " .. totalResources) @@ -35,35 +39,33 @@ RegisterNetEvent('ps-adminmenu:server:changeResourceState', function(name, state StartResource(name) end end) - - +--admincar RegisterNetEvent('ps-adminmenu:server:SaveCar', function(mods, vehicle, _, plate) local src = source - if QBCore.Functions.HasPermission(src, 'admin') or IsPlayerAceAllowed(src, 'command') then - local Player = QBCore.Functions.GetPlayer(src) - local result = MySQL.query.await('SELECT plate FROM player_vehicles WHERE plate = ?', { plate }) - if result[1] == nil then - MySQL.insert('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, state) VALUES (?, ?, ?, ?, ?, ?, ?)', { - Player.PlayerData.license, - Player.PlayerData.citizenid, - vehicle.model, - vehicle.hash, - json.encode(mods), - plate, - 0 - }) - TriggerClientEvent('QBCore:Notify', src, Lang:t("success.veh_owner"), 'success', 5000) - else - TriggerClientEvent('QBCore:Notify', src, Lang:t("error.u_veh_owner"), 'error', 3000) - end + if not QBCore.Functions.HasPermission(src, "mod") then NoPerms(src) return end + local Player = QBCore.Functions.GetPlayer(src) + local result = MySQL.query.await('SELECT plate FROM player_vehicles WHERE plate = ?', { plate }) + if result[1] == nil then + MySQL.insert('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, state) VALUES (?, ?, ?, ?, ?, ?, ?)', { + Player.PlayerData.license, + Player.PlayerData.citizenid, + vehicle.model, + vehicle.hash, + json.encode(mods), + plate, + 0 + }) + TriggerClientEvent('QBCore:Notify', src, Lang:t("success.veh_owner"), 'success', 5000) else - BanPlayer(src) + TriggerClientEvent('QBCore:Notify', src, Lang:t("error.u_veh_owner"), 'error', 3000) end + end) +--ban player RegisterNetEvent('ps-adminmenu:server:banplayer', function(player, time, reason) local src = source - if not QBCore.Functions.HasPermission(src, "mod") or IsPlayerAceAllowed(src, 'command') then NoPerms(src) return end + if not QBCore.Functions.HasPermission(src, "mod") then NoPerms(src) return end time = tonumber(time) local banTime = tonumber(os.time() + time) if banTime > 2147483647 then @@ -87,3 +89,35 @@ RegisterNetEvent('ps-adminmenu:server:banplayer', function(player, time, reason) end) +-- bring player +RegisterNetEvent('ps-adminmenu:server:BringPlayer', function(inputData) + local src = source + local targetPed = inputData["Player ID"] + + if not QBCore.Functions.HasPermission(src, "mod") then NoPerms(src) return end + local admin = GetPlayerPed(src) + local coords = GetEntityCoords(admin) + local target = GetPlayerPed(targetPed) + SetEntityCoords(target, coords) + +end) + +-- heal player +RegisterNetEvent('ps-adminmenu:server:Revive', function(inputData) + local src = source + local id = inputData["Player ID"] + if not QBCore.Functions.HasPermission(src, "mod") then NoPerms(src) return end + if type(id) ~= 'string' and type(id) ~= 'number' then + return + end + id = tonumber(id) + + TriggerClientEvent('hospital:client:Revive', id) +end) + +-- heal all players +RegisterNetEvent('ps-adminmenu:server:ReviveAll', function() + local src = source + if not QBCore.Functions.HasPermission(src, "admin") then NoPerms(src) return end + TriggerClientEvent('hospital:client:Revive', -1) +end) From 752d6b3febd4a11e97c77b9e12ba66d7007dd1d2 Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 04:14:25 +0200 Subject: [PATCH 15/24] Update config.lua --- shared/config.lua | 63 ++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/shared/config.lua b/shared/config.lua index 5f270d01..b225930d 100644 --- a/shared/config.lua +++ b/shared/config.lua @@ -14,18 +14,29 @@ Config.Actions = { dropdown = { { label = "Player ID", type = "input", inputtype = "normal" }, { label = "Reason", type = "input", inputtype = "normal" }, - { label = "Time", type = "input", inputtype = "normal" }, + { label = "Time", type = "options", + options = { + { label = "10 Minutes", value = "600"}, + { label = "30 Minutes", value = "1800"}, + { label = "1 Hour", value = "3600"}, + { label = "6 Hours", value = "21600"}, + { label = "12 Hours", value = "43200"}, + { label = "1 Day", value = "86400"}, + { label = "3 Days", value = "259200"}, + { label = "1 Week", value = "604800"}, + { label = "Permanent", value = "315360000"}, + }, + }, { label = "Ban", type = "button", event = "ps-adminmenu:client:banplayer" }, }, }, { label = "Bring Player", - event = "ps-adminmenu:client:BringPlayer", - type = "client", + type = "server", perms = "mod", dropdown = { { label = "Player ID", type = "input", inputtype = "normal" }, - { label = "Bring", type = "button", event = "" }, + { label = "Bring", type = "button", event = "ps-adminmenu:server:BringPlayer" }, }, }, { @@ -33,23 +44,23 @@ Config.Actions = { type = "client", perms = "mod", dropdown = { - { label = "Wheather", type = "input", inputtype = "options", - options = { - { label = "Extrasunny", value = "Extrasunny"}, - { label = "Clear", value = "Clear"}, - { label = "Neutral", value = "Neutral"}, - { label = "Smog", value = "Smog"}, - { label = "Foggy", value = "Foggy"}, - { label = "Overcast", value = "Overcast"}, - { label = "Clouds", value = "Clouds"}, - { label = "Clearing", value = "Clearing"}, - { label = "Rain", value = "Rain"}, - { label = "Thunder", value = "Thunder"}, - { label = "Snow", value = "Snow"}, - { label = "Blizzard", value = "Blizzard"}, - { label = "Snowlight", value = "Snowlight"}, - { label = "Xmas", value = "Xmas"}, - { label = "Halloween", value = "Halloween"}, + { label = "Weather", type = "options", + options = { + { label = "Extrasunny", value = "Extrasunny"}, + { label = "Clear", value = "Clear"}, + { label = "Neutral", value = "Neutral"}, + { label = "Smog", value = "Smog"}, + { label = "Foggy", value = "Foggy"}, + { label = "Overcast", value = "Overcast"}, + { label = "Clouds", value = "Clouds"}, + { label = "Clearing", value = "Clearing"}, + { label = "Rain", value = "Rain"}, + { label = "Thunder", value = "Thunder"}, + { label = "Snow", value = "Snow"}, + { label = "Blizzard", value = "Blizzard"}, + { label = "Snowlight", value = "Snowlight"}, + { label = "Xmas", value = "Xmas"}, + { label = "Halloween", value = "Halloween"}, }, }, { label = "Change", type = "button", event = "ps-adminmenu:client:ChangeWeather" }, @@ -169,18 +180,18 @@ Config.Actions = { }, { label = "Revive Player", - event = "ps-adminmenu:client:Revive Player", - type = "client", + + type = "server", perms = "mod", dropdown = { { label = "Player ID", type = "input", inputtype = "normal" }, - { label = "Revive", type = "button", event = "ps-adminmenu:client:banplayer" }, + { label = "Revive", type = "button", event = "ps-adminmenu:server:Revive" }, }, }, { label = "Revive All", - event = "ps-adminmenu:client:ReviveAll", - type = "client" + event = "ps-adminmenu:server:ReviveAll", + type = "server" }, { label = "Revive Radius", From 3f5f739fc2b177f92350dd0cbfc9781f07015f4c Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 05:08:18 +0200 Subject: [PATCH 16/24] Update actions.lua --- client/actions.lua | 129 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 127 insertions(+), 2 deletions(-) diff --git a/client/actions.lua b/client/actions.lua index 34b7c7f8..ecde3aec 100644 --- a/client/actions.lua +++ b/client/actions.lua @@ -61,6 +61,13 @@ end) +-- Time +RegisterNetEvent('ps-adminmenu:client:ChangeTime', function(inputData) + local time = inputData["Time"] + print(time) + TriggerServerEvent('qb-weathersync:server:setTime', time) +end) + -- weather RegisterNetEvent('ps-adminmenu:client:ChangeWeather', function(inputData) local weatherType = inputData["Weather"] @@ -69,8 +76,6 @@ RegisterNetEvent('ps-adminmenu:client:ChangeWeather', function(inputData) QBCore.Functions.Notify(Lang:t("info.weatherType", {value = weatherType})) end) - - -- Ban RegisterNetEvent('ps-adminmenu:client:banplayer', function(inputData) local playerid = inputData["Player ID"] @@ -83,3 +88,123 @@ RegisterNetEvent('ps-adminmenu:client:banplayer', function(inputData) TriggerServerEvent("ps-adminmenu:server:banplayer", playerid, time, reason) end end) + +-- Teleport back +local function teleport(vehicle, x, y, z) + local ped = PlayerPedId() + if vehicle then + return SetPedCoordsKeepVehicle(ped, x, y, z) + end + SetEntityCoords(ped, x, y, z, false, false, false, false) +end + +local lastCoords +RegisterNetEvent('ps-adminmenu:client:TeleportBack', function(coords) + local ped = PlayerPedId() + local vehicle = GetVehiclePedIsIn(ped, false) + if lastCoords then + local currentCoords = GetEntityCoords(ped) + teleport(vehicle, lastCoords.x, lastCoords.y, lastCoords.z) + lastCoords = currentCoords + end +end) +-- tp to player +RegisterNetEvent('ps-adminmenu:client:TeleportToPlayer', function(coords) + local ped = PlayerPedId() + lastCoords = GetEntityCoords(ped) + SetPedCoordsKeepVehicle(ped, coords.x, coords.y, coords.z) +end) +-- tp to coords +RegisterNetEvent('ps-adminmenu:client:TeleportToCoords', function(x, y, z, h) + local ped = PlayerPedId() + lastCoords = GetEntityCoords(ped) + SetPedCoordsKeepVehicle(ped, x, y, z) + SetEntityHeading(ped, h or GetEntityHeading(ped)) +end) +-- tp to marker +RegisterNetEvent('ps-adminmenu:client:TeleportToMarker', function() + local PlayerPedId = PlayerPedId + local GetEntityCoords = GetEntityCoords + local GetGroundZFor_3dCoord = GetGroundZFor_3dCoord + + local blipMarker = GetFirstBlipInfoId(8) + if not DoesBlipExist(blipMarker) then + QBCore.Functions.Notify(Lang:t("error.no_waypoint"), "error", 5000) + return 'marker' + end + + -- Fade screen to hide how clients get teleported. + DoScreenFadeOut(650) + while not IsScreenFadedOut() do + Wait(0) + end + + local ped, coords = PlayerPedId(), GetBlipInfoIdCoord(blipMarker) + local vehicle = GetVehiclePedIsIn(ped, false) + local oldCoords = GetEntityCoords(ped) + lastCoords = GetEntityCoords(ped) + + -- Unpack coords instead of having to unpack them while iterating. + -- 825.0 seems to be the max a player can reach while 0.0 being the lowest. + local x, y, groundZ, Z_START = coords['x'], coords['y'], 850.0, 950.0 + local found = false + if vehicle > 0 then + FreezeEntityPosition(vehicle, true) + else + FreezeEntityPosition(ped, true) + end + + for i = Z_START, 0, -25.0 do + local z = i + if (i % 2) ~= 0 then + z = Z_START - i + end + + NewLoadSceneStart(x, y, z, x, y, z, 50.0, 0) + local curTime = GetGameTimer() + while IsNetworkLoadingScene() do + if GetGameTimer() - curTime > 1000 then + break + end + Wait(0) + end + NewLoadSceneStop() + SetPedCoordsKeepVehicle(ped, x, y, z) + + while not HasCollisionLoadedAroundEntity(ped) do + RequestCollisionAtCoord(x, y, z) + if GetGameTimer() - curTime > 1000 then + break + end + Wait(0) + end + + -- Get ground coord. As mentioned in the natives, this only works if the client is in render distance. + found, groundZ = GetGroundZFor_3dCoord(x, y, z, false); + if found then + Wait(0) + SetPedCoordsKeepVehicle(ped, x, y, groundZ) + break + end + Wait(0) + end + + -- Remove black screen once the loop has ended. + DoScreenFadeIn(650) + if vehicle > 0 then + FreezeEntityPosition(vehicle, false) + else + FreezeEntityPosition(ped, false) + end + + if not found then + -- If we can't find the coords, set the coords to the old ones. + -- We don't unpack them before since they aren't in a loop and only called once. + SetPedCoordsKeepVehicle(ped, oldCoords['x'], oldCoords['y'], oldCoords['z'] - 1.0) + QBCore.Functions.Notify(Lang:t("error.tp_error"), "error", 5000) + end + + -- If Z coord was found, set coords in found coords. + SetPedCoordsKeepVehicle(ped, x, y, groundZ) + QBCore.Functions.Notify(Lang:t("success.teleported_waypoint"), "success", 5000) +end) From 785c82c9e0bc9f48832fe93879e2dc7587c4cbd2 Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 05:08:35 +0200 Subject: [PATCH 17/24] Update server.lua --- server/server.lua | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/server/server.lua b/server/server.lua index a2233407..a38fc25e 100644 --- a/server/server.lua +++ b/server/server.lua @@ -65,8 +65,9 @@ end) --ban player RegisterNetEvent('ps-adminmenu:server:banplayer', function(player, time, reason) local src = source - if not QBCore.Functions.HasPermission(src, "mod") then NoPerms(src) return end + if not QBCore.Functions.HasPermission(src, "admin") then NoPerms(src) return end time = tonumber(time) + print("tet") local banTime = tonumber(os.time() + time) if banTime > 2147483647 then banTime = 2147483647 @@ -102,9 +103,44 @@ RegisterNetEvent('ps-adminmenu:server:BringPlayer', function(inputData) end) +-- teleport to player +RegisterNetEvent('ps-adminmenu:server:TeleportToPlayer', function(inputData) + local src = source + + if not QBCore.Functions.HasPermission(src, "mod") then NoPerms(src) return end + local target = GetPlayerPed(tonumber(inputData["Player ID"])) + if target ~= 0 then + local coords = GetEntityCoords(target) + TriggerClientEvent('ps-adminmenu:client:TeleportToPlayer', src, coords) + else + TriggerClientEvent('QBCore:Notify', src, Lang:t('error.not_online'), 'error') + end +end) + +-- teleport to coords +RegisterNetEvent('ps-adminmenu:server:TeleportToCoords', function(inputData) + local src = source + local xdata = inputData["X"] + local ydata = inputData["Y"] + local zdata = inputData["Z"] + + if not QBCore.Functions.HasPermission(src, "mod") then NoPerms(src) return end + if xdata and ydata and zdata then + local x = tonumber((xdata:gsub(",",""))) + .0 + local y = tonumber((ydata:gsub(",",""))) + .0 + local z = tonumber((zdata:gsub(",",""))) + .0 + TriggerClientEvent('ps-adminmenu:client:TeleportToCoords', src, x, y, z) + + else + TriggerClientEvent('QBCore:Notify', src, Lang:t('error.missing_args'), 'error') + end + +end) + -- heal player RegisterNetEvent('ps-adminmenu:server:Revive', function(inputData) local src = source + print(inputData) local id = inputData["Player ID"] if not QBCore.Functions.HasPermission(src, "mod") then NoPerms(src) return end if type(id) ~= 'string' and type(id) ~= 'number' then From e755ba30fefa311076ddbc81abcd482d18211242 Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 05:09:09 +0200 Subject: [PATCH 18/24] Update config.lua --- shared/config.lua | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/shared/config.lua b/shared/config.lua index b225930d..b76cb45f 100644 --- a/shared/config.lua +++ b/shared/config.lua @@ -66,6 +66,15 @@ Config.Actions = { { label = "Change", type = "button", event = "ps-adminmenu:client:ChangeWeather" }, }, }, + { + label = "Change Time", + type = "client", + perms = "mod", + dropdown = { + { label = "Time", type = "input", inputtype = "normal" }, + { label = "Change", type = "button", event = "ps-adminmenu:client:ChangeTime" }, + }, + }, { label = "Clear Inventory", event = "ps-adminmenu:client:ClearInventory", @@ -180,7 +189,6 @@ Config.Actions = { }, { label = "Revive Player", - type = "server", perms = "mod", dropdown = { @@ -232,22 +240,22 @@ Config.Actions = { }, { label = "Teleport To Player", - event = "ps-adminmenu:client:TeleportToPlayer", - type = "client", + type = "server", perms = "mod", dropdown = { { label = "Player ID", type = "input", inputtype = "normal" }, - { label = "Teleport", type = "button", event = "ps-adminmenu:client:banplayer" }, + { label = "Teleport", type = "button", event = "ps-adminmenu:server:TeleportToPlayer" }, }, }, { - label = "Teleport To Coordinates", - event = "ps-adminmenu:client:TeleportToCoords", - type = "client", + label = "Teleport To Coordinates", + type = "server", perms = "mod", dropdown = { - { label = "Coordinates", type = "input", inputtype = "normal" }, - { label = "Teleport", type = "button", event = "ps-adminmenu:client:banplayer" }, + { label = "X", type = "input", inputtype = "normal" }, + { label = "Y", type = "input", inputtype = "normal" }, + { label = "Z", type = "input", inputtype = "normal" }, + { label = "Teleport", type = "button", event = "ps-adminmenu:server:TeleportToCoords" }, }, }, { @@ -255,6 +263,11 @@ Config.Actions = { event = "ps-adminmenu:client:TeleportToMarker", type = "client" }, + { + label = "Teleport Back", + event = "ps-adminmenu:client:TeleportBack", + type = "client" + }, { label = "Unban Player", event = "ps-adminmenu:client:UnbanPlayer", From b309a9d5fdf43188d0fd76799a8a6dd7b4f63b82 Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 05:09:24 +0200 Subject: [PATCH 19/24] Update en.lua --- locales/en.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/locales/en.lua b/locales/en.lua index bd8906d3..5df64f75 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -4,9 +4,14 @@ local Translations = { ['cannot_store_veh'] = "Cannot store this car in your garage", ["not_in_veh"] = "You are not in a vehicle..", ["no_perms"] = "You do not have permission to do this", + ["missing_args"] = 'Not every argument has been entered (x, y, z)', + ["not_online"] = 'Player not online', + ['no_waypoint'] = 'No Waypoint Set.', + ["tp_error"] = 'Error While Teleporting.', }, success = { ["veh_owner"] = "The vehicle is now yours!", + ["teleported_waypoint"] = 'Teleported To Waypoint.', }, info = { ["godmode"] = "Godmode is %{value}", From 3fc750731eb18f58c30b5486cae73b97c8fc13f0 Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 05:11:41 +0200 Subject: [PATCH 20/24] Update actions.lua --- client/actions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/actions.lua b/client/actions.lua index ecde3aec..4662ff3e 100644 --- a/client/actions.lua +++ b/client/actions.lua @@ -80,7 +80,7 @@ end) RegisterNetEvent('ps-adminmenu:client:banplayer', function(inputData) local playerid = inputData["Player ID"] local reason = inputData["Reason"] - local time = inputData["Time"].Time + local time = inputData["Time"] if playerid and reason and time then print("ID: " .. playerid) print("Reason: " .. reason) From eaa6c953348df611da036fbae417798984f9f6a2 Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 05:18:21 +0200 Subject: [PATCH 21/24] Update actions.lua --- client/actions.lua | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/client/actions.lua b/client/actions.lua index 4662ff3e..00eb9144 100644 --- a/client/actions.lua +++ b/client/actions.lua @@ -76,19 +76,6 @@ RegisterNetEvent('ps-adminmenu:client:ChangeWeather', function(inputData) QBCore.Functions.Notify(Lang:t("info.weatherType", {value = weatherType})) end) --- Ban -RegisterNetEvent('ps-adminmenu:client:banplayer', function(inputData) - local playerid = inputData["Player ID"] - local reason = inputData["Reason"] - local time = inputData["Time"] - if playerid and reason and time then - print("ID: " .. playerid) - print("Reason: " .. reason) - print("Time: " .. time) - TriggerServerEvent("ps-adminmenu:server:banplayer", playerid, time, reason) - end -end) - -- Teleport back local function teleport(vehicle, x, y, z) local ped = PlayerPedId() From 8eb70cad57c483f9085cd687c8d4eac3ed738501 Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 05:18:50 +0200 Subject: [PATCH 22/24] Update server.lua --- server/server.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/server/server.lua b/server/server.lua index a38fc25e..12737482 100644 --- a/server/server.lua +++ b/server/server.lua @@ -63,29 +63,31 @@ RegisterNetEvent('ps-adminmenu:server:SaveCar', function(mods, vehicle, _, plate end) --ban player -RegisterNetEvent('ps-adminmenu:server:banplayer', function(player, time, reason) +RegisterNetEvent('ps-adminmenu:server:BanPlayer', function(inputData) local src = source + local playerid = inputData["Player ID"] + local reason = inputData["Reason"] + local time = inputData["Time"] if not QBCore.Functions.HasPermission(src, "admin") then NoPerms(src) return end time = tonumber(time) - print("tet") local banTime = tonumber(os.time() + time) if banTime > 2147483647 then banTime = 2147483647 end local timeTable = os.date('*t', banTime) MySQL.insert('INSERT INTO bans (name, license, discord, ip, reason, expire, bannedby) VALUES (?, ?, ?, ?, ?, ?, ?)', { - GetPlayerName(player.id), - QBCore.Functions.GetIdentifier(player.id, 'license'), - QBCore.Functions.GetIdentifier(player.id, 'discord'), - QBCore.Functions.GetIdentifier(player.id, 'ip'), + GetPlayerName(playerid), + QBCore.Functions.GetIdentifier(playerid, 'license'), + QBCore.Functions.GetIdentifier(playerid, 'discord'), + QBCore.Functions.GetIdentifier(playerid, 'ip'), reason, banTime, GetPlayerName(src) }) if banTime >= 2147483647 then - DropPlayer(player.id, Lang:t("info.banned") .. '\n' .. reason .. Lang:t("info.ban_perm") .. QBCore.Config.Server.Discord) + DropPlayer(playerid, Lang:t("info.banned") .. '\n' .. reason .. Lang:t("info.ban_perm") .. QBCore.Config.Server.Discord) else - DropPlayer(player.id, Lang:t("info.banned") .. '\n' .. reason .. Lang:t("info.ban_expires") .. timeTable['day'] .. '/' .. timeTable['month'] .. '/' .. timeTable['year'] .. ' ' .. timeTable['hour'] .. ':' .. timeTable['min'] .. '\n🔸 Check our Discord for more information: ' .. QBCore.Config.Server.Discord) + DropPlayer(playerid, Lang:t("info.banned") .. '\n' .. reason .. Lang:t("info.ban_expires") .. timeTable['day'] .. '/' .. timeTable['month'] .. '/' .. timeTable['year'] .. ' ' .. timeTable['hour'] .. ':' .. timeTable['min'] .. '\n🔸 Check our Discord for more information: ' .. QBCore.Config.Server.Discord) end end) From bd32537036a3b6fc271115cc34d79c12045541c5 Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 05:19:01 +0200 Subject: [PATCH 23/24] Update en.lua --- locales/en.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/locales/en.lua b/locales/en.lua index 5df64f75..12b70bfa 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -18,6 +18,9 @@ local Translations = { ["invisible"] = "Invisible: %{value}", ["banreason"] = 'Reason: %{reason}, until %{lenght}', ["weatherType"] = "Weather is changed to: %{value}", + ["ban_perm"] = "\n\nYour ban is permanent.\n🔸 Check our Discord for more information: ", + ["ban_expires"] = "\n\nBan expires: ", + ["banned"] = "You have been banned:", }, } From 0c8298ff809fb24bc50eea9fa62d6b79744ccc90 Mon Sep 17 00:00:00 2001 From: Lenzh Date: Sun, 21 May 2023 05:19:18 +0200 Subject: [PATCH 24/24] Update config.lua --- shared/config.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/config.lua b/shared/config.lua index b76cb45f..e412bcf5 100644 --- a/shared/config.lua +++ b/shared/config.lua @@ -27,7 +27,7 @@ Config.Actions = { { label = "Permanent", value = "315360000"}, }, }, - { label = "Ban", type = "button", event = "ps-adminmenu:client:banplayer" }, + { label = "Ban", type = "button", event = "ps-adminmenu:server:BanPlayer" }, }, }, {