From 6711fdf17b995b2fae1ec50f1a8ef3063336ddd2 Mon Sep 17 00:00:00 2001 From: Vyast <67253117+Vyast@users.noreply.github.com> Date: Mon, 22 Feb 2021 00:50:04 -0700 Subject: [PATCH 01/17] Delete PiggyBack directory --- PiggyBack/README.md | 6 -- PiggyBack/cl_piggyback.lua | 120 ------------------------------------- PiggyBack/fxmanifest.lua | 10 ---- PiggyBack/sv_piggyback.lua | 44 -------------- 4 files changed, 180 deletions(-) delete mode 100644 PiggyBack/README.md delete mode 100644 PiggyBack/cl_piggyback.lua delete mode 100644 PiggyBack/fxmanifest.lua delete mode 100644 PiggyBack/sv_piggyback.lua diff --git a/PiggyBack/README.md b/PiggyBack/README.md deleted file mode 100644 index 110a8b2..0000000 --- a/PiggyBack/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Piggyback Riding by Robbster - -Instructions on how to use: -/piggyback close to someone then either person can cancel by again doing /piggyback - -Feel free to make improvements with PRs diff --git a/PiggyBack/cl_piggyback.lua b/PiggyBack/cl_piggyback.lua deleted file mode 100644 index dd9e1f0..0000000 --- a/PiggyBack/cl_piggyback.lua +++ /dev/null @@ -1,120 +0,0 @@ - -local piggyback = { - InProgress = false, - targetSrc = -1, - type = "", - personPiggybacking = { - animDict = "anim@arena@celeb@flat@paired@no_props@", - anim = "piggyback_c_player_a", - flag = 49, - }, - personBeingPiggybacked = { - animDict = "anim@arena@celeb@flat@paired@no_props@", - anim = "piggyback_c_player_b", - attachX = 0.0, - attachY = -0.07, - attachZ = 0.45, - flag = 33, - } -} - -local function drawNativeNotification(text) - SetTextComponentFormat("STRING") - AddTextComponentString(text) - DisplayHelpTextFromStringLabel(0, 0, 1, -1) -end - -local function GetClosestPlayer(radius) - local players = GetActivePlayers() - local closestDistance = -1 - local closestPlayer = -1 - local playerPed = PlayerPedId() - local playerCoords = GetEntityCoords(playerPed) - - for _,playerId in ipairs(players) do - local targetPed = GetPlayerPed(playerId) - if targetPed ~= playerPed then - local targetCoords = GetEntityCoords(targetPed) - local distance = #(targetCoords-playerCoords) - if closestDistance == -1 or closestDistance > distance then - closestPlayer = playerId - closestDistance = distance - end - end - end - if closestDistance ~= -1 and closestDistance <= radius then - return closestPlayer - else - return nil - end -end - -local function ensureAnimDict(animDict) - if not HasAnimDictLoaded(animDict) then - RequestAnimDict(animDict) - while not HasAnimDictLoaded(animDict) do - Wait(0) - end - end - return animDict -end - -RegisterCommand("piggyback",function(source, args) - if not piggyback.InProgress then - local closestPlayer = GetClosestPlayer(3) - if closestPlayer then - local targetSrc = GetPlayerServerId(closestPlayer) - if targetSrc ~= -1 then - piggyback.InProgress = true - piggyback.targetSrc = targetSrc - TriggerServerEvent("Piggyback:sync",targetSrc) - ensureAnimDict(piggyback.personPiggybacking.animDict) - piggyback.type = "piggybacking" - else - drawNativeNotification("~r~No one nearby to piggyback!") - end - else - drawNativeNotification("~r~No one nearby to piggyback!") - end - else - piggyback.InProgress = false - ClearPedSecondaryTask(PlayerPedId()) - DetachEntity(PlayerPedId(), true, false) - TriggerServerEvent("Piggyback:stop",piggyback.targetSrc) - piggyback.targetSrc = 0 - end -end,false) - -RegisterNetEvent("Piggyback:syncTarget") -AddEventHandler("Piggyback:syncTarget", function(targetSrc) - local playerPed = PlayerPedId() - local targetPed = GetPlayerPed(GetPlayerFromServerId(targetSrc)) - piggyback.InProgress = true - ensureAnimDict(piggyback.personBeingPiggybacked.animDict) - AttachEntityToEntity(PlayerPedId(), targetPed, 0, piggyback.personBeingPiggybacked.attachX, piggyback.personBeingPiggybacked.attachY, piggyback.personBeingPiggybacked.attachZ, 0.5, 0.5, 180, false, false, false, false, 2, false) - piggyback.type = "beingPiggybacked" -end) - -RegisterNetEvent("Piggyback:cl_stop") -AddEventHandler("Piggyback:cl_stop", function() - piggyback.InProgress = false - ClearPedSecondaryTask(PlayerPedId()) - DetachEntity(PlayerPedId(), true, false) -end) - -Citizen.CreateThread(function() - while true do - if piggyback.InProgress then - if piggyback.type == "beingPiggybacked" then - if not IsEntityPlayingAnim(PlayerPedId(), piggyback.personBeingPiggybacked.animDict, piggyback.personBeingPiggybacked.anim, 3) then - TaskPlayAnim(PlayerPedId(), piggyback.personBeingPiggybacked.animDict, piggyback.personBeingPiggybacked.anim, 8.0, -8.0, 100000, piggyback.personBeingPiggybacked.flag, 0, false, false, false) - end - elseif piggyback.type == "piggybacking" then - if not IsEntityPlayingAnim(PlayerPedId(), piggyback.personPiggybacking.animDict, piggyback.personPiggybacking.anim, 3) then - TaskPlayAnim(PlayerPedId(), piggyback.personPiggybacking.animDict, piggyback.personPiggybacking.anim, 8.0, -8.0, 100000, piggyback.personPiggybacking.flag, 0, false, false, false) - end - end - end - Wait(0) - end -end) \ No newline at end of file diff --git a/PiggyBack/fxmanifest.lua b/PiggyBack/fxmanifest.lua deleted file mode 100644 index 542f7a8..0000000 --- a/PiggyBack/fxmanifest.lua +++ /dev/null @@ -1,10 +0,0 @@ --- Resource Metadata -fx_version 'bodacious' -games { 'gta5' } - -author 'rubbertoe98' -description 'PiggyBack' -version '1.0.0' - -client_script "cl_piggyback.lua" -server_script "sv_piggyback.lua" diff --git a/PiggyBack/sv_piggyback.lua b/PiggyBack/sv_piggyback.lua deleted file mode 100644 index 856d86b..0000000 --- a/PiggyBack/sv_piggyback.lua +++ /dev/null @@ -1,44 +0,0 @@ -local piggybacking = {} ---piggybacking[source] = targetSource, source is piggybacking targetSource -local beingPiggybacked = {} ---beingPiggybacked[targetSource] = source, targetSource is beingPiggybacked by source - -RegisterServerEvent("Piggyback:sync") -AddEventHandler("Piggyback:sync", function(targetSrc) - local source = source - - TriggerClientEvent("Piggyback:syncTarget", targetSrc, source) - piggybacking[source] = targetSrc - beingPiggybacked[targetSrc] = source -end) - -RegisterServerEvent("Piggyback:stop") -AddEventHandler("Piggyback:stop", function(targetSrc) - local source = source - - if piggybacking[source] then - TriggerClientEvent("Piggyback:cl_stop", targetSrc) - piggybacking[source] = nil - beingPiggybacked[targetSrc] = nil - elseif beingPiggybacked[source] then - TriggerClientEvent("Piggyback:cl_stop", beingPiggybacked[source]) - beingPiggybacked[source] = nil - piggybacking[beingPiggybacked[source]] = nil - end -end) - -AddEventHandler('playerDropped', function(reason) - local source = source - - if piggybacking[source] then - TriggerClientEvent("Piggyback:cl_stop", piggybacking[source]) - beingPiggybacked[piggybacking[source]] = nil - piggybacking[source] = nil - end - - if beingPiggybacked[source] then - TriggerClientEvent("Piggyback:cl_stop", beingPiggybacked[source]) - piggybacking[beingPiggybacked[source]] = nil - beingPiggybacked[source] = nil - end -end) \ No newline at end of file From f194d7f740c36e1cf594849bcd6f36f06d358679 Mon Sep 17 00:00:00 2001 From: Vyast <67253117+Vyast@users.noreply.github.com> Date: Mon, 22 Feb 2021 00:50:10 -0700 Subject: [PATCH 02/17] Delete IDsAboveHead directory --- IDsAboveHead/cl_idsabovehead.lua | 69 -------------------------------- IDsAboveHead/fxmanifest.lua | 9 ----- 2 files changed, 78 deletions(-) delete mode 100644 IDsAboveHead/cl_idsabovehead.lua delete mode 100644 IDsAboveHead/fxmanifest.lua diff --git a/IDsAboveHead/cl_idsabovehead.lua b/IDsAboveHead/cl_idsabovehead.lua deleted file mode 100644 index 2854311..0000000 --- a/IDsAboveHead/cl_idsabovehead.lua +++ /dev/null @@ -1,69 +0,0 @@ -local disPlayerNames = 5 -local playerDistances = {} - -local function DrawText3D(position, text, r,g,b) - local onScreen,_x,_y=World3dToScreen2d(position.x,position.y,position.z+1) - local dist = #(GetGameplayCamCoords()-position) - - local scale = (1/dist)*2 - local fov = (1/GetGameplayCamFov())*100 - local scale = scale*fov - - if onScreen then - if not useCustomScale then - SetTextScale(0.0*scale, 0.55*scale) - else - SetTextScale(0.0*scale, customScale) - end - SetTextFont(0) - SetTextProportional(1) - SetTextColour(r, g, b, 255) - SetTextDropshadow(0, 0, 0, 0, 255) - SetTextEdge(2, 0, 0, 0, 150) - SetTextDropShadow() - SetTextOutline() - SetTextEntry("STRING") - SetTextCentre(1) - AddTextComponentString(text) - DrawText(_x,_y) - end -end - -Citizen.CreateThread(function() - Wait(500) - while true do - for _, id in ipairs(GetActivePlayers()) do - local targetPed = GetPlayerPed(id) - if targetPed ~= PlayerPedId() then - if playerDistances[id] then - if playerDistances[id] < disPlayerNames then - local targetPedCords = GetEntityCoords(targetPed) - if NetworkIsPlayerTalking(id) then - DrawText3D(targetPedCords, GetPlayerServerId(id), 247,124,24) - DrawMarker(27, targetPedCords.x, targetPedCords.y, targetPedCords.z-0.97, 0, 0, 0, 0, 0, 0, 1.001, 1.0001, 0.5001, 173, 216, 230, 100, 0, 0, 0, 0) - else - DrawText3D(targetPedCords, GetPlayerServerId(id), 255,255,255) - end - end - end - end - end - Citizen.Wait(0) - end -end) - -Citizen.CreateThread(function() - while true do - local playerPed = PlayerPedId() - local playerCoords = GetEntityCoords(playerPed) - - for _, id in ipairs(GetActivePlayers()) do - local targetPed = GetPlayerPed(id) - if targetPed ~= playerPed then - local distance = #(playerCoords-GetEntityCoords(targetPed)) - playerDistances[id] = distance - end - end - Wait(1000) - end -end) \ No newline at end of file diff --git a/IDsAboveHead/fxmanifest.lua b/IDsAboveHead/fxmanifest.lua deleted file mode 100644 index 7577086..0000000 --- a/IDsAboveHead/fxmanifest.lua +++ /dev/null @@ -1,9 +0,0 @@ --- Resource Metadata -fx_version 'bodacious' -games { 'gta5' } - -author 'rubbertoe98' -description 'IDsAboveHead' -version '1.0.0' - -client_script "cl_idsabovehead.lua" From 5625bdbe0f2be9c39c2a1aec42abd19f9424c463 Mon Sep 17 00:00:00 2001 From: Vyast <67253117+Vyast@users.noreply.github.com> Date: Mon, 22 Feb 2021 00:50:15 -0700 Subject: [PATCH 03/17] Delete AntiVDM directory --- AntiVDM/cl_antivdm.lua | 6 ------ AntiVDM/fxmanifest.lua | 9 --------- 2 files changed, 15 deletions(-) delete mode 100644 AntiVDM/cl_antivdm.lua delete mode 100644 AntiVDM/fxmanifest.lua diff --git a/AntiVDM/cl_antivdm.lua b/AntiVDM/cl_antivdm.lua deleted file mode 100644 index 40d03a6..0000000 --- a/AntiVDM/cl_antivdm.lua +++ /dev/null @@ -1,6 +0,0 @@ -Citizen.CreateThread(function() - while true do - SetWeaponDamageModifier(-1553120962, 0.0) - Wait(0) - end -end) \ No newline at end of file diff --git a/AntiVDM/fxmanifest.lua b/AntiVDM/fxmanifest.lua deleted file mode 100644 index 234fdb1..0000000 --- a/AntiVDM/fxmanifest.lua +++ /dev/null @@ -1,9 +0,0 @@ --- Resource Metadata -fx_version 'bodacious' -games { 'gta5' } - -author 'rubbertoe98' -description 'AntiVDM' -version '1.0.0' - -client_script "cl_antivdm.lua" From 9357fd31dc7221cbdf031415d1f8f4cd60ced2a2 Mon Sep 17 00:00:00 2001 From: Vyast <67253117+Vyast@users.noreply.github.com> Date: Mon, 22 Feb 2021 00:50:24 -0700 Subject: [PATCH 04/17] Delete vrp_punishments directory --- vrp_punishments/README.md | 71 ------------- vrp_punishments/cl_warningsystem.lua | 147 --------------------------- vrp_punishments/sv_warningsystem.lua | 114 --------------------- 3 files changed, 332 deletions(-) delete mode 100644 vrp_punishments/README.md delete mode 100644 vrp_punishments/cl_warningsystem.lua delete mode 100644 vrp_punishments/sv_warningsystem.lua diff --git a/vrp_punishments/README.md b/vrp_punishments/README.md deleted file mode 100644 index 3d35d27..0000000 --- a/vrp_punishments/README.md +++ /dev/null @@ -1,71 +0,0 @@ -# vrp_punishmentslog created by Robbster - -## Installation: - -###### 1) Dependancies: GHMattiMySQL - -Ensure you have GHMattiMySQL installed and correctly configured to your database -```https://github.com/GHMatti/FiveM-MySQL``` - -###### 2) Create your new database table by executing the following SQL in your database - -```SQL -CREATE TABLE cmg_warnings ( - warning_id INT, - user_id INT, - warning_type VARCHAR(25), - duration INT, - admin VARCHAR(100), - warning_date DATE, - reason VARCHAR(2000), - PRIMARY KEY (warning_id) -) -``` - -###### 3) Go to vrp/modules/admin.lua -and find the ch_kick function (CTRL-F "ch_kick") -Place this line just before the line starting with "vRP.kick". -```lua -saveKickLog(id,GetPlayerName(player),reason) -``` - - -###### 4) Replace the ch_ban function with the following code - -```lua -local function ch_ban(player,choice) - local user_id = vRP.getUserId(player) - if user_id ~= nil and vRP.hasPermission(user_id,"player.ban") then - vRP.prompt(player,"User id to ban: ","",function(player,id) - id = parseInt(id) - vRP.prompt(player,"Reason: ","",function(player,reason) - local source = vRP.getUserSource(id) - vRP.prompt(player,"Hours: ","",function(player,duration) - if tonumber(duration) then - vRPclient.notify(player,{"banned user "..id}) - saveBanLog(id,GetPlayerName(player),reason,duration) - vRP.ban(source,reason) - else - vRPclient.notify(player,{"~r~Invalid ban time!"}) - end - end) - end) - end) - end -end -``` - -###### 5) Place sv_warningsystem.lua in vrp/modules/ and cl_warningsystem.lua in vrp/client/ - -###### 6) Update your vrp/__resource.lua by putting adding the file names cl_warningsystem.lua & sv_warningsystem.lua in the appropriate section - -## How to use: - -* F10 to open up the warning sytem -* /showwarnings [user_id] to show someone's punishment log (i.e /showwarnings 1) -* /warn to give a warning -* Kicks & Bans are automatically added to someones punishment log when you ban/kick them through your phone - -Feel free to make improvements with PRs - - diff --git a/vrp_punishments/cl_warningsystem.lua b/vrp_punishments/cl_warningsystem.lua deleted file mode 100644 index 67598d2..0000000 --- a/vrp_punishments/cl_warningsystem.lua +++ /dev/null @@ -1,147 +0,0 @@ ---type,duration(hours),admin_name,date,reason -CMGWarnings = { - [0] = {"Ban","48","Robbster","10-10-19","You VDM'd x2"}, - [1] = {"Warning","24","Rob","1-10-19","You VDM'd x4"}, -} - -showWarningSystem = false - -xoffset = 0.031 -rowcounter = 0 -warningColourR = 0 -warningColourG = 0 -warningColourB = 0 - --- RegisterCommand("tempwarn",function() - -- showWarningSystem = not showWarningSystem --- end) - -RegisterNetEvent("CMG:showWarningsOfUser") -AddEventHandler("CMG:showWarningsOfUser",function(cmgwarningstables) - print("got to showWarningsOfUser") - showWarningSystem = true - CMGWarnings = cmgwarningstables -end) - -RegisterNetEvent("CMG:recievedRefreshedWarningData") -AddEventHandler("CMG:recievedRefreshedWarningData",function(cmgwarningstables) - print("got to recievedRefreshedWarningData") - CMGWarnings = cmgwarningstables -end) - - -Citizen.CreateThread(function() - while true do - if IsControlJustPressed(0,57) then - print("toggling warning system") - showWarningSystem = not showWarningSystem - if showWarningSystem then - TriggerServerEvent("CMG:refreshWarningSystem") - end - Wait(250) - end - Wait(0) - end -end) - -Citizen.CreateThread(function() - while true do - if showWarningSystem then - DrawRect(0.498, 0.482, 0.615, 0.636, 0, 0, 0, 150) - DrawRect(0.498, 0.197, 0.615, 0.066, 0, 0, 0, 135) - DrawAdvancedText(0.59, 0.198, 0.005, 0.0028, 0.619, "CMG Warning System", 255, 255, 255, 255, 7, 0) - DrawRect(0.498, 0.232, 0.615, -0.0040000000000001, 0, 168, 255, 204) - DrawRect(0.498, 0.285, 0.535, -0.0040000000000001, 0, 168, 255, 204) - DrawAdvancedText(0.344, 0.27, 0.005, 0.0028, 0.4, "Type", 255, 255, 255, 255, 6, 0) - DrawAdvancedText(0.379, 0.271, 0.005, 0.0028, 0.4, "Duration", 255, 255, 255, 255, 6, 0) - DrawAdvancedText(0.417, 0.271, 0.005, 0.0028, 0.4, "Admin", 255, 255, 255, 255, 6, 0) - DrawAdvancedText(0.463, 0.271, 0.005, 0.0028, 0.4, "Date", 255, 255, 255, 255, 6, 0) - DrawAdvancedText(0.672, 0.271, 0.005, 0.0028, 0.4, "Reason", 255, 255, 255, 255, 6, 0) - for warningID,warningTable in pairs(CMGWarnings) do - --type,duration,admin,date,reason = table.unpack(warningTable) - local warning_type,duration,admin,date,reason = warningTable["warning_type"],warningTable["duration"],warningTable["admin"],warningTable["warning_date"],warningTable["reason"] - --print("warning_type showing: " .. tostring(warning_type)) - --print("duration showing: " .. tostring(duration)) - if warning_type == "Warning" then - warningColourR = 255 - warningColourG = 255 - warningColourB = 102 - elseif warning_type == "Kick" then - warningColourR = 255 - warningColourG = 123 - warningColourB = 0 - elseif warning_type == "Ban" then - warningColourR = 255 - warningColourG = 44 - warningColourB = 44 - end - DrawAdvancedText(0.344, 0.309+(rowcounter*xoffset), 0.005, 0.0028, 0.4, warning_type, warningColourR, warningColourG, warningColourB, 255, 6, 0) - DrawAdvancedText(0.379, 0.309+(rowcounter*xoffset), 0.005, 0.0028, 0.4, tostring(duration) .. "hrs", 255, 255, 255, 255, 6, 0) - DrawAdvancedText(0.417, 0.309+(rowcounter*xoffset), 0.005, 0.0028, 0.4, admin, 255, 255, 255, 255, 6, 0) - DrawAdvancedText(0.463, 0.309+(rowcounter*xoffset), 0.005, 0.0028, 0.4, date, 255, 255, 255, 255, 6, 0) - DrawAdvancedText(0.672, 0.309+(rowcounter*xoffset), 0.005, 0.0028, 0.4, reason, 255, 255, 255, 255, 6, 0) - rowcounter = rowcounter + 1 - end - rowcounter = 0 - end - Wait(0) - end -end) - -RegisterCommand("warn",function() - --get a dialog box open - --get ID - --get warning msg - --send to server to update the database - userIDtoWarn = getWarningUserID() - userWarningMessage = getWarningUserMsg() - - TriggerServerEvent("CMG:warnPlayer",tonumber(userIDtoWarn),GetPlayerName(PlayerId()),userWarningMessage) -end) - -function getWarningUserID() - AddTextEntry('FMMC_MPM_NA', "Enter ID of the player you want to warn?") - DisplayOnscreenKeyboard(1, "FMMC_MPM_NA", "Enter ID of the player you want to warn?", "1", "", "", "", 30) - while (UpdateOnscreenKeyboard() == 0) do - DisableAllControlActions(0); - Wait(0); - end - if (GetOnscreenKeyboardResult()) then - local result = GetOnscreenKeyboardResult() - if result then - return result - end - end - return false -end - -function getWarningUserMsg() - AddTextEntry('FMMC_MPM_NA', "Enter warning message") - DisplayOnscreenKeyboard(1, "FMMC_MPM_NA", "Enter warning message", "", "", "", "", 30) - while (UpdateOnscreenKeyboard() == 0) do - DisableAllControlActions(0); - Wait(0); - end - if (GetOnscreenKeyboardResult()) then - local result = GetOnscreenKeyboardResult() - if result then - return result - end - end - return false -end - -function DrawAdvancedText(x,y ,w,h,sc, text, r,g,b,a,font,jus) - SetTextFont(font) - SetTextProportional(0) - SetTextScale(sc, sc) - N_0x4e096588b13ffeca(jus) - SetTextColour(r, g, b, a) - SetTextDropShadow(0, 0, 0, 0,255) - SetTextEdge(1, 0, 0, 0, 255) - SetTextDropShadow() - -- SetTextOutline() - SetTextEntry("STRING") - AddTextComponentString(text) - DrawText(x - 0.1+w, y - 0.02+h) -end \ No newline at end of file diff --git a/vrp_punishments/sv_warningsystem.lua b/vrp_punishments/sv_warningsystem.lua deleted file mode 100644 index 4c20acc..0000000 --- a/vrp_punishments/sv_warningsystem.lua +++ /dev/null @@ -1,114 +0,0 @@ --- CREATE TALBE cmg_warnings ( - -- warning_id INT, - -- user_id INT, - -- warning_type VARCHAR(25), - -- duration INT, - -- admin VARCHAR(100), - -- warning_date DATE, - -- reason VARCHAT(2000), - -- PRIMARY KEY (warning_id) --- ) - ---TODO ---Fix date DONE ---/warn DONE ---make primary key auto_increment DONE ---getCurrentDate function DONE ---bans auto go on log menu DONE ---kicks auto go on log menu DONE ---Whitelist to staff DONE ---Change crossarms key bind DONE ---change requests DONE ---ban duration column needs to show (hrs) DONE ---ban duration not working DONE ---bar colour DONE ---verify kicks work DONE - -AddEventHandler('chatMessage', function(player, color, message) - user_id = vRP.getUserId(player) - if message:sub(1, 13) == '/showwarnings' then - local permID = tonumber(message:sub(14, 20)) - if permID ~= nil then - --check if staff - if vRP.hasPermission(user_id,"player.kick") then - --print("Getting warnings of ID: " .. tostring(permID)) - cmgwarningstables = getCMGWarnings(permID,player) - --print("sending to source: " .. tostring(source)) - TriggerClientEvent("CMG:showWarningsOfUser",player,cmgwarningstables) - end - else - --print("Error couldn't get ID: " .. tostring(message:sub(14, 20))) - end - end - CancelEvent() -end) - ---print("start:"..dump(testdate).."end") --- testTime = 1561845600000 --- testTime = testTime / 1000 --- print(os.date('%Y-%m-%d', testTime)) - -function getCMGWarnings(user_id,source) - cmgwarningstables = exports['GHMattiMySQL']:QueryResult("SELECT * FROM cmg_warnings WHERE user_id = @uid", {uid = user_id}) - print("Triggering CMG:showWarningsOfUser") - --print(dump(cmgwarningstables)) - for warningID,warningTable in pairs(cmgwarningstables) do - --print(warningTable["warning_date"]) - date = warningTable["warning_date"] - --print("date1:" .. tostring(date)) - newdate = tonumber(date) / 1000 - --print("date3:" .. tostring(newdate)) - newdate = os.date('%Y-%m-%d', newdate) - --print("date4:" .. tostring(newdate)) - warningTable["warning_date"] = newdate - end - return cmgwarningstables -end - -RegisterServerEvent("CMG:refreshWarningSystem") -AddEventHandler("CMG:refreshWarningSystem",function() - local source = source - local user_id = vRP.getUserId(source) - --local user_id = 1 - - cmgwarningstables = getCMGWarnings(user_id,source) - TriggerClientEvent("CMG:recievedRefreshedWarningData",source,cmgwarningstables) -end) - -RegisterServerEvent("CMG:warnPlayer") -AddEventHandler("CMG:warnPlayer",function(target_id,adminName,warningReason) - local source = source - local user_id = vRP.getUserId(source) - if vRP.hasPermission(user_id,"player.kick") then - warning = "Warning" - warningDate = getCurrentDate() - exports['GHMattiMySQL']:QueryAsync("INSERT INTO cmg_warnings (`warning_id`, `user_id`, `warning_type`, `duration`, `admin`, `warning_date`, `reason`) VALUES (NULL, @user_id, @warning_type, 0, @admin, @warning_date,@reason);", {user_id = target_id,warning_type = warning, admin = adminName, warning_date = warningDate, reason = warningReason}, function() end) - else - vRPclient.notify(player,{"~r~no perms to warn player"}) - end -end) - -function saveKickLog(target_id,adminName,warningReason) - warning = "Kick" - warningDate = getCurrentDate() - exports['GHMattiMySQL']:QueryAsync("INSERT INTO cmg_warnings (`warning_id`, `user_id`, `warning_type`, `duration`, `admin`, `warning_date`, `reason`) VALUES (NULL, @user_id, @warning_type, 0, @admin, @warning_date,@reason);", {user_id = target_id,warning_type = warning, admin = adminName, warning_date = warningDate, reason = warningReason}, function() end) - -end - -function saveBanLog(target_id,adminName,warningReason,warning_duration) - warning = "Ban" - warningDate = getCurrentDate() - exports['GHMattiMySQL']:QueryAsync("INSERT INTO cmg_warnings (`warning_id`, `user_id`, `warning_type`, `duration`, `admin`, `warning_date`, `reason`) VALUES (NULL, @user_id, @warning_type, @duration, @admin, @warning_date,@reason);", {user_id = target_id,warning_type = warning, admin = adminName, duration = warning_duration, warning_date = warningDate, reason = warningReason}, function() end) -end - - -function getCurrentDate() - date = os.date("%Y/%m/%d") - - return date -end - --- CMGWarnings = { - -- [0] = {"Ban","48","Rolex","10-10-19","You VDM'd x2"}, - -- [1] = {"Warning","24","Rob","1-10-19","You VDM'd x4"}, --- } \ No newline at end of file From 7ff45aefd80b89fdeed770de1e6d5dab498d8172 Mon Sep 17 00:00:00 2001 From: Vyast <67253117+Vyast@users.noreply.github.com> Date: Mon, 22 Feb 2021 00:50:31 -0700 Subject: [PATCH 05/17] Delete VisualWeatherVoter directory --- VisualWeatherVoter/README.md | 5 - VisualWeatherVoter/cl_vote.lua | 232 ------------------------------ VisualWeatherVoter/fxmanifest.lua | 10 -- VisualWeatherVoter/sv_vote.lua | 39 ----- 4 files changed, 286 deletions(-) delete mode 100644 VisualWeatherVoter/README.md delete mode 100644 VisualWeatherVoter/cl_vote.lua delete mode 100644 VisualWeatherVoter/fxmanifest.lua delete mode 100644 VisualWeatherVoter/sv_vote.lua diff --git a/VisualWeatherVoter/README.md b/VisualWeatherVoter/README.md deleted file mode 100644 index dfbf167..0000000 --- a/VisualWeatherVoter/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Visual-Weather-Voter-FiveM- - -You can change the cooldown between each vote and the default weather in sv_vote.lua - -Any improvements, just make a pull request. diff --git a/VisualWeatherVoter/cl_vote.lua b/VisualWeatherVoter/cl_vote.lua deleted file mode 100644 index 0ee39fe..0000000 --- a/VisualWeatherVoter/cl_vote.lua +++ /dev/null @@ -1,232 +0,0 @@ -defaultWeather = "CLEAR" -currentWeather = defaultWeather -showWeatherVoteGUI = false -voteInProgress = false -voted = false -timer = 60 - -votesTable = { - ["CLEAR"] = 0, - ["EXTRASUNNY"] = 0, - ["CLOUDS"] = 0, - ["OVERCAST"] = 0, - ["RAIN"] = 0, - ["THUNDER"] = 0, - ["CLEARING"] = 0, - ["SMOG"] = 0, - ["FOGGY"] = 0, - ["XMAS"] = 0, - ["SNOWLIGHT"] = 0, - ["BLIZZARD"] = 0 -} - -function sorted_iter(t) - local i = {} - for k in next, t do - table.insert(i, k) - end - table.sort(i) - return function() - local k = table.remove(i) - if k ~= nil then - return k, t[k] - end - end -end - - -function DrawAdvancedText(x,y ,w,h,sc, text, r,g,b,a,font,jus) - SetTextFont(font) - SetTextScale(sc, sc) - N_0x4e096588b13ffeca(jus) - SetTextColour(r, g, b, a) - SetTextEntry("STRING") - AddTextComponentString(text) - DrawText(x - 0.1+w, y - 0.02+h) -end - -function voteWeather(weatherType) - print("voteInProgress: " .. tostring(voteInProgress)) - if voteInProgress then - if not voted then - TriggerServerEvent("CMG:vote", weatherType) - voted = true - TriggerEvent("chatMessage","Vote sent!",{0, 255, 0}) - else - TriggerEvent("chatMessage","You have already voted!",{255, 0, 0}) - end - else - TriggerEvent("chatMessage","Vote not in progress!",{255, 0, 0}) - end -end - - -function changeWeather() - highestWeather = defaultWeather - highestCounter = 0 - for k,v in sorted_iter(votesTable) do - if v > highestCounter then - highestWeather = k - highestCounter = v - end - end - currentWeather = highestWeather - TriggerServerEvent("CMG:setCurrentWeather",highestWeather) -end - -RegisterNetEvent("CMG:voteFinished") -AddEventHandler("CMG:voteFinished", function(newWeather) - currentWeather = newWeather -end) - -RegisterNetEvent("CMG:startWeatherVote") -AddEventHandler("CMG:startWeatherVote", function() - voteInProgress = true - TriggerEvent("chatMessage","Weather vote has started! Type /[weather] e.g /snow or /rain to vote.",{0, 250, 50}) - TriggerEvent("chatMessage","Weather types are in bottom left & /voteweather to start a vote",{0, 250, 50}) -end) - -RegisterNetEvent("CMG:voteStateChange") -AddEventHandler("CMG:voteStateChange",function(type) - votesTable[type] = votesTable[type] + 1 -end) - -RegisterCommand("voteweather", function() - TriggerServerEvent("CMG:tryStartWeatherVote") -end, false) - -RegisterCommand("clear", function() - voteWeather("CLEAR") -end, false) - -RegisterCommand("extrasunny", function() - voteWeather("EXTRASUNNY") -end, false) - -RegisterCommand("cloudy", function() - voteWeather("CLOUDS") -end, false) - -RegisterCommand("overcast", function() - voteWeather("OVERCAST") -end, false) - -RegisterCommand("rain", function() - voteWeather("RAIN") -end, false) - -RegisterCommand("thunder", function() - voteWeather("THUNDER") -end, false) - -RegisterCommand("clearing", function() - voteWeather("CLEARING") -end, false) - -RegisterCommand("smog", function() - voteWeather("SMOG") -end, false) - -RegisterCommand("foggy", function() - voteWeather("FOGGY") -end, false) - -RegisterCommand("snow", function() - voteWeather("XMAS") -end, false) - -RegisterCommand("snowlight", function() - voteWeather("SNOWLIGHT") -end, false) - -RegisterCommand("blizzard", function() - voteWeather("BLIZZARD") -end, false) - -Citizen.CreateThread(function() - while true do - SetWeatherTypePersist(currentWeather) - SetWeatherTypeNowPersist(currentWeather) - SetWeatherTypeNow(currentWeather) - SetOverrideWeather(currentWeather) - Wait(1000) - end -end) - -Citizen.CreateThread(function() - while true do - if voteInProgress then - DrawAdvancedText(0.27, 0.96, 0.005, 0.0028, 0.318, "Time Left:", 0, 208, 104, 255, 4, 0) - DrawAdvancedText(0.29, 0.96, 0.005, 0.0028, 0.29, tostring(timer), 255, 74, 53, 255, 0, 0) - DrawAdvancedText(0.297, 0.827, 0.005, 0.0028, 0.38, "Weather Voter", 0, 208, 104, 255, 4, 0) - - DrawAdvancedText(0.2645, 0.848, 0.005, 0.0028, 0.318, "Clear", 255, 255, 255, 255, 4, 0) - DrawAdvancedText(0.2728, 0.866, 0.005, 0.0028, 0.318, "ExtraSunny", 255, 255, 255, 255, 4, 0) - DrawAdvancedText(0.266, 0.884, 0.005, 0.0028, 0.318, "Cloudy", 255, 255, 255, 255, 4, 0) - DrawAdvancedText(0.269, 0.902, 0.005, 0.0028, 0.318, "Overcast", 255, 255, 255, 255, 4, 0) - DrawAdvancedText(0.263, 0.920, 0.005, 0.0028, 0.318, "Rain", 255, 255, 255, 255, 4, 0) - DrawAdvancedText(0.268, 0.938, 0.005, 0.0028, 0.318, "Thunder", 255, 255, 255, 255, 4, 0) - - DrawAdvancedText(0.293, 0.848, 0.005, 0.0028, 0.25, tostring(votesTable["CLEAR"]), 255, 74, 53, 255, 0, 0) - DrawAdvancedText(0.293, 0.866, 0.005, 0.0028, 0.25, tostring(votesTable["EXTRASUNNY"]), 255, 74, 53, 255, 0, 0) - DrawAdvancedText(0.293, 0.884, 0.005, 0.0028, 0.25, tostring(votesTable["CLOUDS"]), 255, 74, 53, 255, 0, 0) - DrawAdvancedText(0.293, 0.902, 0.005, 0.0028, 0.25, tostring(votesTable["OVERCAST"]), 255, 74, 53, 255, 0, 0) - DrawAdvancedText(0.293, 0.920, 0.005, 0.0028, 0.25, tostring(votesTable["RAIN"]), 255, 74, 53, 255, 0, 0) - DrawAdvancedText(0.293, 0.938, 0.005, 0.0028, 0.25, tostring(votesTable["THUNDER"]), 255, 74, 53, 255, 0, 0) - - DrawAdvancedText(0.315, 0.848, 0.005, 0.0028, 0.318, "Clearing", 255, 255, 255, 255, 4, 0) - DrawAdvancedText(0.315, 0.866, 0.005, 0.0028, 0.318, "Smog", 255, 255, 255, 255, 4, 0) - DrawAdvancedText(0.314, 0.884, 0.005, 0.0028, 0.318, "Snow", 255, 255, 255, 255, 4, 0) - DrawAdvancedText(0.315, 0.902, 0.005, 0.0028, 0.318, "Blizzard", 255, 255, 255, 255, 4, 0) - DrawAdvancedText(0.315, 0.920, 0.005, 0.0028, 0.318, "Snowlight", 255, 255, 255, 255, 4, 0) - DrawAdvancedText(0.315, 0.938, 0.005, 0.0028, 0.318, "Foggy", 255, 255, 255, 255, 4, 0) - - DrawAdvancedText(0.333, 0.848, 0.005, 0.0028, 0.25, tostring(votesTable["CLEARING"]), 255, 74, 53, 255, 0, 0) - DrawAdvancedText(0.333, 0.866, 0.005, 0.0028, 0.25, tostring(votesTable["SMOG"]), 255, 74, 53, 255, 0, 0) - DrawAdvancedText(0.333, 0.884, 0.005, 0.0028, 0.25, tostring(votesTable["XMAS"]), 255, 74, 53, 255, 0, 0) - DrawAdvancedText(0.333, 0.902, 0.005, 0.0028, 0.25, tostring(votesTable["BLIZZARD"]), 255, 74, 53, 255, 0, 0) - DrawAdvancedText(0.333, 0.920, 0.005, 0.0028, 0.25, tostring(votesTable["SNOWLIGHT"]), 255, 74, 53, 255, 0, 0) - DrawAdvancedText(0.333, 0.938, 0.005, 0.0028, 0.25, tostring(votesTable["FOGGY"]), 255, 74, 53, 255, 0, 0) - end - Wait(0) - end -end) - - -Citizen.CreateThread(function() - while true do - if voteInProgress then - timer = timer - 1 - if timer == 0 then - voteInProgress = false - timer = 60 - voted = false - changeWeather() - resetVotes() - end - end - Wait(1000) - end -end) - -AddEventHandler('playerSpawned', function(spawn) - TriggerServerEvent("CMG:getCurrentWeather") - -end) - -function resetVotes() - votesTable = { - ["CLEAR"] = 0, - ["EXTRASUNNY"] = 0, - ["CLOUDS"] = 0, - ["OVERCAST"] = 0, - ["RAIN"] = 0, - ["THUNDER"] = 0, - ["CLEARING"] = 0, - ["SMOG"] = 0, - ["FOGGY"] = 0, - ["XMAS"] = 0, - ["SNOWLIGHT"] = 0, - ["BLIZZARD"] = 0 - } -end diff --git a/VisualWeatherVoter/fxmanifest.lua b/VisualWeatherVoter/fxmanifest.lua deleted file mode 100644 index 131fa2b..0000000 --- a/VisualWeatherVoter/fxmanifest.lua +++ /dev/null @@ -1,10 +0,0 @@ --- Resource Metadata -fx_version 'bodacious' -games { 'gta5' } - -author 'rubbertoe98' -description 'VisualWeatherVoter' -version '1.0.0' - -client_script "cl_vote.lua" -server_script "sv_vote.lua" diff --git a/VisualWeatherVoter/sv_vote.lua b/VisualWeatherVoter/sv_vote.lua deleted file mode 100644 index 463a0d4..0000000 --- a/VisualWeatherVoter/sv_vote.lua +++ /dev/null @@ -1,39 +0,0 @@ -voteCooldown = 1800 -currentWeather = "CLEAR" - -weatherVoterCooldown = voteCooldown - -RegisterServerEvent("CMG:vote") -AddEventHandler("CMG:vote", function(weatherType) - TriggerClientEvent("CMG:voteStateChange",-1,weatherType) -end) - -RegisterServerEvent("CMG:tryStartWeatherVote") -AddEventHandler("CMG:tryStartWeatherVote", function() - local source = source - if weatherVoterCooldown >= voteCooldown then - TriggerClientEvent("CMG:startWeatherVote", -1) - weatherVoterCooldown = 0 - else - TriggerClientEvent("chatMessage",source,"Another vote can be started in " .. tostring(voteCooldown-weatherVoterCooldown) .. " seconds!",{255, 0, 0}) - end -end) - -RegisterServerEvent("CMG:getCurrentWeather") -AddEventHandler("CMG:getCurrentWeather", function() - local source = source - TriggerClientEvent("CMG:voteFinished",source,currentWeather) -end) - -RegisterServerEvent("CMG:setCurrentWeather") -AddEventHandler("CMG:setCurrentWeather", function(newWeather) - currentWeather = newWeather -end) - -Citizen.CreateThread(function() - while true do - weatherVoterCooldown = weatherVoterCooldown + 1 - Citizen.Wait(1000) - end -end) - From b78dfc4a635fea7a4dfca0472dc5ddce1ecc33f1 Mon Sep 17 00:00:00 2001 From: Vyast <67253117+Vyast@users.noreply.github.com> Date: Mon, 22 Feb 2021 00:50:37 -0700 Subject: [PATCH 06/17] Delete CarryPeople directory --- CarryPeople/README.md | 6 -- CarryPeople/cl_carry.lua | 119 ------------------------------------- CarryPeople/fxmanifest.lua | 10 ---- CarryPeople/sv_carry.lua | 44 -------------- 4 files changed, 179 deletions(-) delete mode 100644 CarryPeople/README.md delete mode 100644 CarryPeople/cl_carry.lua delete mode 100644 CarryPeople/fxmanifest.lua delete mode 100644 CarryPeople/sv_carry.lua diff --git a/CarryPeople/README.md b/CarryPeople/README.md deleted file mode 100644 index edfad42..0000000 --- a/CarryPeople/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Carry People by Robbster - -Instructions on how to use: -Type /carry close to someone then either person can cancel by again doing /carry - -Feel free to make improvements with PRs diff --git a/CarryPeople/cl_carry.lua b/CarryPeople/cl_carry.lua deleted file mode 100644 index 84cd9e3..0000000 --- a/CarryPeople/cl_carry.lua +++ /dev/null @@ -1,119 +0,0 @@ - -local carry = { - InProgress = false, - targetSrc = -1, - type = "", - personCarrying = { - animDict = "missfinale_c2mcs_1", - anim = "fin_c2_mcs_1_camman", - flag = 49, - }, - personCarried = { - animDict = "nm", - anim = "firemans_carry", - attachX = 0.27, - attachY = 0.15, - attachZ = 0.63, - flag = 33, - } -} - -local function drawNativeNotification(text) - SetTextComponentFormat("STRING") - AddTextComponentString(text) - DisplayHelpTextFromStringLabel(0, 0, 1, -1) -end - -local function GetClosestPlayer(radius) - local players = GetActivePlayers() - local closestDistance = -1 - local closestPlayer = -1 - local playerPed = PlayerPedId() - local playerCoords = GetEntityCoords(playerPed) - - for _,playerId in ipairs(players) do - local targetPed = GetPlayerPed(playerId) - if targetPed ~= playerPed then - local targetCoords = GetEntityCoords(targetPed) - local distance = #(targetCoords-playerCoords) - if closestDistance == -1 or closestDistance > distance then - closestPlayer = playerId - closestDistance = distance - end - end - end - if closestDistance ~= -1 and closestDistance <= radius then - return closestPlayer - else - return nil - end -end - -local function ensureAnimDict(animDict) - if not HasAnimDictLoaded(animDict) then - RequestAnimDict(animDict) - while not HasAnimDictLoaded(animDict) do - Wait(0) - end - end - return animDict -end - -RegisterCommand("carry",function(source, args) - if not carry.InProgress then - local closestPlayer = GetClosestPlayer(3) - if closestPlayer then - local targetSrc = GetPlayerServerId(closestPlayer) - if targetSrc ~= -1 then - carry.InProgress = true - carry.targetSrc = targetSrc - TriggerServerEvent("CarryPeople:sync",targetSrc) - ensureAnimDict(carry.personCarrying.animDict) - carry.type = "carrying" - else - drawNativeNotification("~r~No one nearby to carry!") - end - else - drawNativeNotification("~r~No one nearby to carry!") - end - else - carry.InProgress = false - ClearPedSecondaryTask(PlayerPedId()) - DetachEntity(PlayerPedId(), true, false) - TriggerServerEvent("CarryPeople:stop",carry.targetSrc) - carry.targetSrc = 0 - end -end,false) - -RegisterNetEvent("CarryPeople:syncTarget") -AddEventHandler("CarryPeople:syncTarget", function(targetSrc) - local targetPed = GetPlayerPed(GetPlayerFromServerId(targetSrc)) - carry.InProgress = true - ensureAnimDict(carry.personCarried.animDict) - AttachEntityToEntity(PlayerPedId(), targetPed, 0, carry.personCarried.attachX, carry.personCarried.attachY, carry.personCarried.attachZ, 0.5, 0.5, 180, false, false, false, false, 2, false) - carry.type = "beingcarried" -end) - -RegisterNetEvent("CarryPeople:cl_stop") -AddEventHandler("CarryPeople:cl_stop", function() - carry.InProgress = false - ClearPedSecondaryTask(PlayerPedId()) - DetachEntity(PlayerPedId(), true, false) -end) - -Citizen.CreateThread(function() - while true do - if carry.InProgress then - if carry.type == "beingcarried" then - if not IsEntityPlayingAnim(PlayerPedId(), carry.personCarried.animDict, carry.personCarried.anim, 3) then - TaskPlayAnim(PlayerPedId(), carry.personCarried.animDict, carry.personCarried.anim, 8.0, -8.0, 100000, carry.personCarried.flag, 0, false, false, false) - end - elseif carry.type == "carrying" then - if not IsEntityPlayingAnim(PlayerPedId(), carry.personCarrying.animDict, carry.personCarrying.anim, 3) then - TaskPlayAnim(PlayerPedId(), carry.personCarrying.animDict, carry.personCarrying.anim, 8.0, -8.0, 100000, carry.personCarrying.flag, 0, false, false, false) - end - end - end - Wait(0) - end -end) \ No newline at end of file diff --git a/CarryPeople/fxmanifest.lua b/CarryPeople/fxmanifest.lua deleted file mode 100644 index 5f538a0..0000000 --- a/CarryPeople/fxmanifest.lua +++ /dev/null @@ -1,10 +0,0 @@ --- Resource Metadata -fx_version 'bodacious' -games { 'gta5' } - -author 'rubbertoe98' -description 'CarryPeople' -version '1.0.0' - -client_script "cl_carry.lua" -server_script "sv_carry.lua" diff --git a/CarryPeople/sv_carry.lua b/CarryPeople/sv_carry.lua deleted file mode 100644 index b86e263..0000000 --- a/CarryPeople/sv_carry.lua +++ /dev/null @@ -1,44 +0,0 @@ -local carrying = {} ---carrying[source] = targetSource, source is carrying targetSource -local carried = {} ---carried[targetSource] = source, targetSource is being carried by source - -RegisterServerEvent("CarryPeople:sync") -AddEventHandler("CarryPeople:sync", function(targetSrc) - local source = source - - TriggerClientEvent("CarryPeople:syncTarget", targetSrc, source) - carrying[source] = targetSrc - carried[targetSrc] = source -end) - -RegisterServerEvent("CarryPeople:stop") -AddEventHandler("CarryPeople:stop", function(targetSrc) - local source = source - - if carrying[source] then - TriggerClientEvent("CarryPeople:cl_stop", targetSrc) - carrying[source] = nil - carried[targetSrc] = nil - elseif carried[source] then - TriggerClientEvent("CarryPeople:cl_stop", carried[source]) - carrying[carried[source]] = nil - carried[source] = nil - end -end) - -AddEventHandler('playerDropped', function(reason) - local source = source - - if carrying[source] then - TriggerClientEvent("CarryPeople:cl_stop", carrying[source]) - carried[carrying[source]] = nil - carrying[source] = nil - end - - if carried[source] then - TriggerClientEvent("CarryPeople:cl_stop", carried[source]) - carrying[carried[source]] = nil - carried[source] = nil - end -end) From a3df543efa506143026e462d17ae8cd4f14f6e18 Mon Sep 17 00:00:00 2001 From: Vyast <67253117+Vyast@users.noreply.github.com> Date: Mon, 22 Feb 2021 00:51:41 -0700 Subject: [PATCH 07/17] Update README.md --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index aaf0227..3222e66 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ -# FiveM-Scripts -Compilation of my publicly released code +Take Hostage Script Made By: rubbertoe98 +Edited & Patched By: Vyast -Feel free to make improvements with PRs - - -My personal dev discord -https://discord.gg/dnZTpUh +Instructions on how to use: +Type /takehostage, a valid weapon is needed(Add or remove weapons in client.lua) +Then press G to release the hostage or H to kill the hostage! From f26a265b0cf539134df4676c38daa61e5f98512a Mon Sep 17 00:00:00 2001 From: Vyast <67253117+Vyast@users.noreply.github.com> Date: Mon, 22 Feb 2021 00:52:25 -0700 Subject: [PATCH 08/17] Update fxmanifest.lua --- TakeHostage/fxmanifest.lua | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/TakeHostage/fxmanifest.lua b/TakeHostage/fxmanifest.lua index 09eccf3..ab6c930 100644 --- a/TakeHostage/fxmanifest.lua +++ b/TakeHostage/fxmanifest.lua @@ -1,10 +1,6 @@ --- Resource Metadata fx_version 'bodacious' -games { 'gta5' } +game 'gta5' -author 'rubbertoe98' -description 'TakeHostage' -version '1.0.0' +client_script "client.lua" -client_script "cl_takehostage.lua" -server_script "sv_takehostage.lua" +server_script "server.lua" From f51fba89a0effe38ec0c36d3563f8c5e277e93ec Mon Sep 17 00:00:00 2001 From: Vyast <67253117+Vyast@users.noreply.github.com> Date: Mon, 22 Feb 2021 00:52:33 -0700 Subject: [PATCH 09/17] Delete sv_takehostage.lua --- TakeHostage/sv_takehostage.lua | 60 ---------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 TakeHostage/sv_takehostage.lua diff --git a/TakeHostage/sv_takehostage.lua b/TakeHostage/sv_takehostage.lua deleted file mode 100644 index d89390d..0000000 --- a/TakeHostage/sv_takehostage.lua +++ /dev/null @@ -1,60 +0,0 @@ -local takingHostage = {} ---takingHostage[source] = targetSource, source is takingHostage targetSource -local takenHostage = {} ---takenHostage[targetSource] = source, targetSource is being takenHostage by source - -RegisterServerEvent("TakeHostage:sync") -AddEventHandler("TakeHostage:sync", function(targetSrc) - local source = source - - TriggerClientEvent("TakeHostage:syncTarget", targetSrc, source) - takingHostage[source] = targetSrc - takenHostage[targetSrc] = source -end) - -RegisterServerEvent("TakeHostage:releaseHostage") -AddEventHandler("TakeHostage:releaseHostage", function(targetSrc) - local source = source - TriggerClientEvent("TakeHostage:releaseHostage", targetSrc, source) - takingHostage[source] = nil - takenHostage[targetSrc] = nil -end) - -RegisterServerEvent("TakeHostage:killHostage") -AddEventHandler("TakeHostage:killHostage", function(targetSrc) - local source = source - TriggerClientEvent("TakeHostage:killHostage", targetSrc, source) - takingHostage[source] = nil - takenHostage[targetSrc] = nil -end) - -RegisterServerEvent("TakeHostage:stop") -AddEventHandler("TakeHostage:stop", function(targetSrc) - local source = source - - if takingHostage[source] then - TriggerClientEvent("TakeHostage:cl_stop", targetSrc) - takingHostage[source] = nil - takenHostage[targetSrc] = nil - elseif takenHostage[source] then - TriggerClientEvent("TakeHostage:cl_stop", targetSrc) - takenHostage[source] = nil - takingHostage[targetSrc] = nil - end -end) - -AddEventHandler('playerDropped', function(reason) - local source = source - - if takingHostage[source] then - TriggerClientEvent("TakeHostage:cl_stop", takingHostage[source]) - takenHostage[takingHostage[source]] = nil - takingHostage[source] = nil - end - - if takenHostage[source] then - TriggerClientEvent("TakeHostage:cl_stop", takenHostage[source]) - takingHostage[takenHostage[source]] = nil - takenHostage[source] = nil - end -end) \ No newline at end of file From 13d7f0ec67f4a2cd0c7246430b585cead9113d1c Mon Sep 17 00:00:00 2001 From: Vyast <67253117+Vyast@users.noreply.github.com> Date: Mon, 22 Feb 2021 00:53:06 -0700 Subject: [PATCH 10/17] Add files via upload --- TakeHostage/server.lua | 123 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 TakeHostage/server.lua diff --git a/TakeHostage/server.lua b/TakeHostage/server.lua new file mode 100644 index 0000000..018a6f3 --- /dev/null +++ b/TakeHostage/server.lua @@ -0,0 +1,123 @@ +--Original Author: rubbertoe98 +--Edited & Patched By: Vyast + +local takingHostage, takenHostage = {}, {} + +local function log(info) + print(info) +end + +local function getCoords(player) + local coords = nil + if player ~= nil then + local ped = GetPlayerPed(player) + if ped ~= nil then + coords = GetEntityCoords(ped) + end + end + return coords +end + +local function getName(player) + local name = nil + if player ~= nil then + name = GetPlayerName(player) + end + return name +end + +RegisterServerEvent("TakeHostage:sync") +AddEventHandler("TakeHostage:sync", function(target) + local src = source + if src ~= nil and target ~= nil and target ~= -1 then + local srcName = getName(src) + if srcName ~= nil then + local srcCoords, tgtCoords = getCoords(src), getCoords(target) + if srcCoords ~= nil and tgtCoords ~= nil then + local dist = #(srcCoords - tgtCoords) + if dist <= 5.0 then + TriggerClientEvent("TakeHostage:syncTarget", target, src) + takingHostage[src] = target + takenHostage[target] = src + else + log('^2TakeHostage: ^1'..srcName..'['..tonumber(src)..']^0 is attempting to exploit the event "sync"! Their distance from the target player is ^1'..dist..'^0.') + end + end + end + end +end) + +RegisterServerEvent("TakeHostage:releaseHostage") +AddEventHandler("TakeHostage:releaseHostage", function(target) + local src = source + if src ~= nil and target ~= nil and target ~= -1 then + local srcName = getName(src) + if srcName ~= nil then + local srcCoords, tgtCoords = getCoords(src), getCoords(target) + if srcCoords ~= nil and tgtCoords ~= nil then + local dist = #(srcCoords - tgtCoords) + if dist <= 5.0 then + TriggerClientEvent("TakeHostage:releaseHostage", target, src) + takingHostage[src] = nil + takenHostage[target] = nil + else + log('^2TakeHostage: ^1'..srcName..'['..tonumber(src)..']^0 is attempting to exploit the event "releaseHostage"! Their distance from the target player is ^1'..dist..'^0.') + end + end + end + end +end) + +RegisterServerEvent("TakeHostage:killHostage") +AddEventHandler("TakeHostage:killHostage", function(target) + local src = source + if src ~= nil and target ~= nil and target ~= -1 then + local srcName = getName(src) + if srcName ~= nil then + local srcCoords, tgtCoords = getCoords(src), getCoords(target) + if srcCoords ~= nil and tgtCoords ~= nil then + local dist = #(srcCoords - tgtCoords) + if dist <= 5.0 then + TriggerClientEvent("TakeHostage:killHostage", target, src) + takingHostage[src] = nil + takenHostage[target] = nil + else + log('^2TakeHostage: ^1'..srcName..'['..tonumber(src)..']^0 is attempting to exploit the event "killHostage"! Their distance from the target player is ^1'..dist..'^0.') + end + end + end + end +end) + +RegisterServerEvent("TakeHostage:stop") +AddEventHandler("TakeHostage:stop", function(target) + local src = source + if src ~= nil and target ~= nil and target ~= -1 then + if takingHostage[src] then + TriggerClientEvent("TakeHostage:cl_stop", target) + takingHostage[src] = nil + takenHostage[target] = nil + elseif takenHostage[src] then + TriggerClientEvent("TakeHostage:cl_stop", target) + takenHostage[src] = nil + takingHostage[target] = nil + end + end +end) + +AddEventHandler('playerDropped', function(reason) + local src = source + if src ~= nil then + if takingHostage[src] then + TriggerClientEvent("TakeHostage:cl_stop", takingHostage[src]) + takenHostage[takingHostage[src]] = nil + takingHostage[src] = nil + end + + if takenHostage[src] then + TriggerClientEvent("TakeHostage:cl_stop", takenHostage[src]) + takingHostage[takenHostage[src]] = nil + takenHostage[src] = nil + end + end +end) \ No newline at end of file From 408d8c4ee30740fb889d15baa10faf942511a846 Mon Sep 17 00:00:00 2001 From: Vyast <67253117+Vyast@users.noreply.github.com> Date: Mon, 22 Feb 2021 00:53:14 -0700 Subject: [PATCH 11/17] Delete cl_takehostage.lua --- TakeHostage/cl_takehostage.lua | 238 --------------------------------- 1 file changed, 238 deletions(-) delete mode 100644 TakeHostage/cl_takehostage.lua diff --git a/TakeHostage/cl_takehostage.lua b/TakeHostage/cl_takehostage.lua deleted file mode 100644 index 15fb6e0..0000000 --- a/TakeHostage/cl_takehostage.lua +++ /dev/null @@ -1,238 +0,0 @@ ------------------------------------------------------------------ ---TakeHostage by Robbster, do not redistrbute without permission-- ------------------------------------------------------------------- - -local takeHostage = { - allowedWeapons = { - `WEAPON_PISTOL`, - `WEAPON_COMBATPISTOL`, - --etc add guns you want - }, - InProgress = false, - type = "", - targetSrc = -1, - agressor = { - animDict = "anim@gangops@hostage@", - anim = "perp_idle", - flag = 49, - }, - hostage = { - animDict = "anim@gangops@hostage@", - anim = "victim_idle", - attachX = -0.24, - attachY = 0.11, - attachZ = 0.0, - flag = 49, - } -} - -local function drawNativeNotification(text) - SetTextComponentFormat("STRING") - AddTextComponentString(text) - DisplayHelpTextFromStringLabel(0, 0, 1, -1) -end - -local function GetClosestPlayer(radius) - local players = GetActivePlayers() - local closestDistance = -1 - local closestPlayer = -1 - local playerPed = PlayerPedId() - local playerCoords = GetEntityCoords(playerPed) - - for _,playerId in ipairs(players) do - local targetPed = GetPlayerPed(playerId) - if targetPed ~= playerPed then - local targetCoords = GetEntityCoords(targetPed) - local distance = #(targetCoords-playerCoords) - if closestDistance == -1 or closestDistance > distance then - closestPlayer = playerId - closestDistance = distance - end - end - end - if closestDistance ~= -1 and closestDistance <= radius then - return closestPlayer - else - return nil - end -end - -local function ensureAnimDict(animDict) - if not HasAnimDictLoaded(animDict) then - RequestAnimDict(animDict) - while not HasAnimDictLoaded(animDict) do - Wait(0) - end - end - return animDict -end - -local function drawNativeText(str) - SetTextEntry_2("STRING") - AddTextComponentString(str) - EndTextCommandPrint(1000, 1) -end - -RegisterCommand("takehostage",function() - callTakeHostage() -end) - -RegisterCommand("th",function() - callTakeHostage() -end) - -function callTakeHostage() - ClearPedSecondaryTask(PlayerPedId()) - DetachEntity(PlayerPedId(), true, false) - - local canTakeHostage = false - for i=1, #takeHostage.allowedWeapons do - if HasPedGotWeapon(PlayerPedId(), takeHostage.allowedWeapons[i], false) then - if GetAmmoInPedWeapon(PlayerPedId(), takeHostage.allowedWeapons[i]) > 0 then - canTakeHostage = true - foundWeapon = takeHostage.allowedWeapons[i] - break - end - end - end - - if not canTakeHostage then - drawNativeNotification("You need a pistol with ammo to take a hostage at gunpoint!") - end - - if not takeHostage.InProgress and canTakeHostage then - local closestPlayer = GetClosestPlayer(3) - if closestPlayer then - local targetSrc = GetPlayerServerId(closestPlayer) - if targetSrc ~= -1 then - SetCurrentPedWeapon(PlayerPedId(), foundWeapon, true) - takeHostage.InProgress = true - takeHostage.targetSrc = targetSrc - TriggerServerEvent("TakeHostage:sync",targetSrc) - ensureAnimDict(takeHostage.agressor.animDict) - takeHostage.type = "agressor" - else - drawNativeNotification("~r~No one nearby to take as hostage!") - end - else - drawNativeNotification("~r~No one nearby to take as hostage!") - end - end -end - -RegisterNetEvent("TakeHostage:syncTarget") -AddEventHandler("TakeHostage:syncTarget", function(target) - local targetPed = GetPlayerPed(GetPlayerFromServerId(target)) - takeHostage.InProgress = true - ensureAnimDict(takeHostage.hostage.animDict) - AttachEntityToEntity(PlayerPedId(), targetPed, 0, takeHostage.hostage.attachX, takeHostage.hostage.attachY, takeHostage.hostage.attachZ, 0.5, 0.5, 0.0, false, false, false, false, 2, false) - takeHostage.type = "hostage" -end) - -RegisterNetEvent("TakeHostage:releaseHostage") -AddEventHandler("TakeHostage:releaseHostage", function() - takeHostage.InProgress = false - takeHostage.type = "" - DetachEntity(PlayerPedId(), true, false) - ensureAnimDict("reaction@shove") - TaskPlayAnim(PlayerPedId(), "reaction@shove", "shoved_back", 8.0, -8.0, -1, 0, 0, false, false, false) - Wait(250) - ClearPedSecondaryTask(PlayerPedId()) -end) - -RegisterNetEvent("TakeHostage:killHostage") -AddEventHandler("TakeHostage:killHostage", function() - takeHostage.InProgress = false - takeHostage.type = "" - SetEntityHealth(PlayerPedId(),0) - DetachEntity(PlayerPedId(), true, false) - ensureAnimDict("anim@gangops@hostage@") - TaskPlayAnim(PlayerPedId(), "anim@gangops@hostage@", "victim_fail", 8.0, -8.0, -1, 168, 0, false, false, false) -end) - -RegisterNetEvent("TakeHostage:cl_stop") -AddEventHandler("TakeHostage:cl_stop", function() - takeHostage.InProgress = false - takeHostage.type = "" - ClearPedSecondaryTask(PlayerPedId()) - DetachEntity(PlayerPedId(), true, false) -end) - -Citizen.CreateThread(function() - while true do - if takeHostage.type == "agressor" then - if not IsEntityPlayingAnim(PlayerPedId(), takeHostage.agressor.animDict, takeHostage.agressor.anim, 3) then - TaskPlayAnim(PlayerPedId(), takeHostage.agressor.animDict, takeHostage.agressor.anim, 8.0, -8.0, 100000, takeHostage.agressor.flag, 0, false, false, false) - end - elseif takeHostage.type == "hostage" then - if not IsEntityPlayingAnim(PlayerPedId(), takeHostage.hostage.animDict, takeHostage.hostage.anim, 3) then - TaskPlayAnim(PlayerPedId(), takeHostage.hostage.animDict, takeHostage.hostage.anim, 8.0, -8.0, 100000, takeHostage.hostage.flag, 0, false, false, false) - end - end - Wait(0) - end -end) - -Citizen.CreateThread(function() - while true do - if takeHostage.type == "agressor" then - DisableControlAction(0,24,true) -- disable attack - DisableControlAction(0,25,true) -- disable aim - DisableControlAction(0,47,true) -- disable weapon - DisableControlAction(0,58,true) -- disable weapon - DisableControlAction(0,21,true) -- disable sprint - DisablePlayerFiring(PlayerPedId(),true) - drawNativeText("Press [G] to release, [H] to kill") - - if IsEntityDead(PlayerPedId()) then - takeHostage.type = "" - takeHostage.InProgress = false - ensureAnimDict("reaction@shove") - TaskPlayAnim(PlayerPedId(), "reaction@shove", "shove_var_a", 8.0, -8.0, -1, 168, 0, false, false, false) - TriggerServerEvent("TakeHostage:releaseHostage", takeHostage.targetSrc) - end - - if IsDisabledControlJustPressed(0,47) then --release - takeHostage.type = "" - takeHostage.InProgress = false - ensureAnimDict("reaction@shove") - TaskPlayAnim(PlayerPedId(), "reaction@shove", "shove_var_a", 8.0, -8.0, -1, 168, 0, false, false, false) - TriggerServerEvent("TakeHostage:releaseHostage", takeHostage.targetSrc) - elseif IsDisabledControlJustPressed(0,74) then --kill - takeHostage.type = "" - takeHostage.InProgress = false - ensureAnimDict("anim@gangops@hostage@") - TaskPlayAnim(PlayerPedId(), "anim@gangops@hostage@", "perp_fail", 8.0, -8.0, -1, 168, 0, false, false, false) - TriggerServerEvent("TakeHostage:killHostage", takeHostage.targetSrc) - TriggerServerEvent("TakeHostage:stop",takeHostage.targetSrc) - Wait(100) - SetPedShootsAtCoord(PlayerPedId(), 0.0, 0.0, 0.0, 0) - end - elseif takeHostage.type == "hostage" then - DisableControlAction(0,21,true) -- disable sprint - DisableControlAction(0,24,true) -- disable attack - DisableControlAction(0,25,true) -- disable aim - DisableControlAction(0,47,true) -- disable weapon - DisableControlAction(0,58,true) -- disable weapon - DisableControlAction(0,263,true) -- disable melee - DisableControlAction(0,264,true) -- disable melee - DisableControlAction(0,257,true) -- disable melee - DisableControlAction(0,140,true) -- disable melee - DisableControlAction(0,141,true) -- disable melee - DisableControlAction(0,142,true) -- disable melee - DisableControlAction(0,143,true) -- disable melee - DisableControlAction(0,75,true) -- disable exit vehicle - DisableControlAction(27,75,true) -- disable exit vehicle - DisableControlAction(0,22,true) -- disable jump - DisableControlAction(0,32,true) -- disable move up - DisableControlAction(0,268,true) - DisableControlAction(0,33,true) -- disable move down - DisableControlAction(0,269,true) - DisableControlAction(0,34,true) -- disable move left - DisableControlAction(0,270,true) - DisableControlAction(0,35,true) -- disable move right - DisableControlAction(0,271,true) - end - Wait(0) - end -end) \ No newline at end of file From d0e8e6bd07097791d7c4d5b910e81400469087c7 Mon Sep 17 00:00:00 2001 From: Vyast <67253117+Vyast@users.noreply.github.com> Date: Mon, 22 Feb 2021 00:53:22 -0700 Subject: [PATCH 12/17] Add files via upload --- TakeHostage/client.lua | 253 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 253 insertions(+) create mode 100644 TakeHostage/client.lua diff --git a/TakeHostage/client.lua b/TakeHostage/client.lua new file mode 100644 index 0000000..3a5ff52 --- /dev/null +++ b/TakeHostage/client.lua @@ -0,0 +1,253 @@ +--Original Author: rubbertoe98 +--Edited & Patched By: Vyast + +local takeHostage = { + allowedWeapons = { + `WEAPON_PISTOL`, + `WEAPON_COMBATPISTOL`, + `WEAPON_APPISTOL`, + --etc add guns you want + }, + InProgress = false, + type = "", + targetSrc = -1, + agressor = { + animDict = "anim@gangops@hostage@", + anim = "perp_idle", + flag = 49, + }, + hostage = { + animDict = "anim@gangops@hostage@", + anim = "victim_idle", + attachX = -0.24, + attachY = 0.11, + attachZ = 0.0, + flag = 49, + } +} + +local function drawNativeNotification(text) + SetTextComponentFormat("STRING") + AddTextComponentString(text) + DisplayHelpTextFromStringLabel(0, 0, 1, -1) +end + +local function playerPed() + return PlayerPedId() +end + +local function GetClosestPlayer(radius) + local closestDistance, closestPlayer = -1, -1 + local playerPed = playerPed() + local playerCoords = GetEntityCoords(playerPed) + + for k, v in ipairs(GetActivePlayers()) do + local targetPed = GetPlayerPed(v) + if targetPed ~= playerPed then + local targetCoords = GetEntityCoords(targetPed) + local distance = #(targetCoords - playerCoords) + if closestDistance == -1 or closestDistance > distance then + closestPlayer = v + closestDistance = distance + end + end + end + + if closestDistance ~= -1 and closestDistance <= radius then + return closestPlayer + else + return nil + end +end + +local function ensureAnimDict(animDict) + if not HasAnimDictLoaded(animDict) then + RequestAnimDict(animDict) + while not HasAnimDictLoaded(animDict) do + Wait(0) + end + end + return animDict +end + +local function drawNativeText(str) + SetTextEntry_2("STRING") + AddTextComponentString(str) + EndTextCommandPrint(1000, 1) +end + +RegisterCommand("takehostage", function() + callTakeHostage() +end) + +RegisterCommand("th", function() + callTakeHostage() +end) + +function callTakeHostage() + local ped = playerPed() + if not IsEntityDead(ped) then + ClearPedSecondaryTask(ped) + DetachEntity(ped, true, false) + + local canTakeHostage = false + for i=1, #takeHostage.allowedWeapons do + if HasPedGotWeapon(ped, takeHostage.allowedWeapons[i], false) then + if GetAmmoInPedWeapon(ped, takeHostage.allowedWeapons[i]) > 0 then + canTakeHostage = true + foundWeapon = takeHostage.allowedWeapons[i] + break + end + end + end + + if not canTakeHostage then + drawNativeNotification("You need a pistol with ammo to take a hostage at gunpoint!") + end + + if not takeHostage.InProgress and canTakeHostage then + local closestPlayer = GetClosestPlayer(3) + if closestPlayer then + local targetSrc = GetPlayerServerId(closestPlayer) + if targetSrc ~= -1 then + SetCurrentPedWeapon(ped, foundWeapon, true) + takeHostage.InProgress = true + takeHostage.targetSrc = targetSrc + TriggerServerEvent("TakeHostage:sync", targetSrc) + ensureAnimDict(takeHostage.agressor.animDict) + takeHostage.type = "agressor" + else + drawNativeNotification("~r~No one nearby to take as hostage!") + end + else + drawNativeNotification("~r~No one nearby to take as hostage!") + end + end + else + drawNativeNotification("~r~You cannot do that while you are dead!") + end +end + +RegisterNetEvent("TakeHostage:syncTarget") +AddEventHandler("TakeHostage:syncTarget", function(target) + local targetPed = GetPlayerPed(GetPlayerFromServerId(target)) + takeHostage.InProgress = true + ensureAnimDict(takeHostage.hostage.animDict) + AttachEntityToEntity(playerPed(), targetPed, 0, takeHostage.hostage.attachX, takeHostage.hostage.attachY, takeHostage.hostage.attachZ, 0.5, 0.5, 0.0, false, false, false, false, 2, false) + takeHostage.type = "hostage" +end) + +RegisterNetEvent("TakeHostage:releaseHostage") +AddEventHandler("TakeHostage:releaseHostage", function() + local ped = playerPed() + takeHostage.InProgress = false + takeHostage.type = "" + DetachEntity(ped, true, false) + ensureAnimDict("reaction@shove") + TaskPlayAnim(ped, "reaction@shove", "shoved_back", 8.0, -8.0, -1, 0, 0, false, false, false) + Citizen.Wait(250) + ClearPedSecondaryTask(ped) +end) + +RegisterNetEvent("TakeHostage:killHostage") +AddEventHandler("TakeHostage:killHostage", function() + local ped = playerPed() + takeHostage.InProgress = false + takeHostage.type = "" + SetEntityHealth(ped, 0) + DetachEntity(ped, true, false) + ensureAnimDict("anim@gangops@hostage@") + TaskPlayAnim(ped, "anim@gangops@hostage@", "victim_fail", 8.0, -8.0, -1, 168, 0, false, false, false) +end) + +RegisterNetEvent("TakeHostage:cl_stop") +AddEventHandler("TakeHostage:cl_stop", function() + local ped = playerPed() + takeHostage.InProgress = false + takeHostage.type = "" + ClearPedSecondaryTask(ped) + DetachEntity(ped, true, false) +end) + +Citizen.CreateThread(function() + while true do + Citizen.Wait(0) + local ped = playerPed() + + if takeHostage.type == "agressor" then + if not IsEntityPlayingAnim(ped, takeHostage.agressor.animDict, takeHostage.agressor.anim, 3) then + TaskPlayAnim(ped, takeHostage.agressor.animDict, takeHostage.agressor.anim, 8.0, -8.0, 100000, takeHostage.agressor.flag, 0, false, false, false) + end + elseif takeHostage.type == "hostage" then + if not IsEntityPlayingAnim(ped, takeHostage.hostage.animDict, takeHostage.hostage.anim, 3) then + TaskPlayAnim(ped, takeHostage.hostage.animDict, takeHostage.hostage.anim, 8.0, -8.0, 100000, takeHostage.hostage.flag, 0, false, false, false) + end + end + end +end) + +Citizen.CreateThread(function() + while true do + Citizen.Wait(0) + local ped = playerPed() + + if takeHostage.type == "agressor" then + DisableControlAction(0, 24, true) -- disable attack + DisableControlAction(0, 25, true) -- disable aim + DisableControlAction(0, 47, true) -- disable weapon + DisableControlAction(0, 58, true) -- disable weapon + DisableControlAction(0, 21, true) -- disable sprint + DisablePlayerFiring(ped, true) + drawNativeText("Press [G] to release, [H] to kill") + + if IsEntityDead(ped) then + takeHostage.type = "" + takeHostage.InProgress = false + ensureAnimDict("reaction@shove") + TaskPlayAnim(ped, "reaction@shove", "shove_var_a", 8.0, -8.0, -1, 168, 0, false, false, false) + TriggerServerEvent("TakeHostage:releaseHostage", takeHostage.targetSrc) + end + + if IsDisabledControlJustPressed(0,47) then --release + takeHostage.type = "" + takeHostage.InProgress = false + ensureAnimDict("reaction@shove") + TaskPlayAnim(ped, "reaction@shove", "shove_var_a", 8.0, -8.0, -1, 168, 0, false, false, false) + TriggerServerEvent("TakeHostage:releaseHostage", takeHostage.targetSrc) + elseif IsDisabledControlJustPressed(0,74) then --kill + takeHostage.type = "" + takeHostage.InProgress = false + ensureAnimDict("anim@gangops@hostage@") + TaskPlayAnim(ped, "anim@gangops@hostage@", "perp_fail", 8.0, -8.0, -1, 168, 0, false, false, false) + TriggerServerEvent("TakeHostage:killHostage", takeHostage.targetSrc) + TriggerServerEvent("TakeHostage:stop",takeHostage.targetSrc) + Wait(100) + SetPedShootsAtCoord(ped, 0.0, 0.0, 0.0, 0) + end + elseif takeHostage.type == "hostage" then + DisableControlAction(0,21,true) -- disable sprint + DisableControlAction(0,24,true) -- disable attack + DisableControlAction(0,25,true) -- disable aim + DisableControlAction(0,47,true) -- disable weapon + DisableControlAction(0,58,true) -- disable weapon + DisableControlAction(0,263,true) -- disable melee + DisableControlAction(0,264,true) -- disable melee + DisableControlAction(0,257,true) -- disable melee + DisableControlAction(0,140,true) -- disable melee + DisableControlAction(0,141,true) -- disable melee + DisableControlAction(0,142,true) -- disable melee + DisableControlAction(0,143,true) -- disable melee + DisableControlAction(0,75,true) -- disable exit vehicle + DisableControlAction(27,75,true) -- disable exit vehicle + DisableControlAction(0,22,true) -- disable jump + DisableControlAction(0,32,true) -- disable move up + DisableControlAction(0,268,true) + DisableControlAction(0,33,true) -- disable move down + DisableControlAction(0,269,true) + DisableControlAction(0,34,true) -- disable move left + DisableControlAction(0,270,true) + DisableControlAction(0,35,true) -- disable move right + DisableControlAction(0,271,true) + end + end +end) \ No newline at end of file From 4086c1c9e16c7fc4e275629fa2a3c596ab29beaa Mon Sep 17 00:00:00 2001 From: Vyast <67253117+Vyast@users.noreply.github.com> Date: Mon, 22 Feb 2021 00:59:14 -0700 Subject: [PATCH 13/17] Update README.md --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3222e66..04d1a8f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ -Take Hostage Script Made By: rubbertoe98 -Edited & Patched By: Vyast +Original Take Hostage Script Made By: rubbertoe98 + +Edited & Patched By: Vyast#0001 + +A few very exploitable server-sided events: 'TakeHostage:sync', 'TakeHostage:releaseHostage', 'TakeHostage:killHostage', which could be manipulated & used by modders in multiple ways to do different things such as take an entire server full of players hostage all at once, kill an entire server of players all at once, and more have been fully patched and protected by adding a distance check from the source player to the target player to further verify legitness. + +Minor client sided optimizations & changes. Instructions on how to use: Type /takehostage, a valid weapon is needed(Add or remove weapons in client.lua) From 2356f4b76e2da10113643d300d15ca2362110f3f Mon Sep 17 00:00:00 2001 From: Aspect <90366824+AsepctDEVS@users.noreply.github.com> Date: Mon, 27 Sep 2021 18:14:07 -0500 Subject: [PATCH 14/17] Added Discord Logs Adding config next --- TakeHostage/server.lua | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/TakeHostage/server.lua b/TakeHostage/server.lua index 018a6f3..c27e19f 100644 --- a/TakeHostage/server.lua +++ b/TakeHostage/server.lua @@ -2,6 +2,22 @@ --Edited & Patched By: Vyast local takingHostage, takenHostage = {}, {} +-- Credits to discord docs for the api ref +function SendToDiscord(name, msg, col) + local embed = { + { + ["color"] = 9109247, -- If you have an issue with the string like this change it to "9109247" + ["title"] = "**"..name.."**", + ["description"] = msg, + ["footer"] = { + ["text"] = "discord.gg/Example" + }, + } + } + PerformHttpRequest(Config.WebhookURL, function(err, text, headers) end, 'POST', json.encode({username = "Exploit Log", embeds = embed, avatar_url = "https://cdn.discordapp.com/attachments/891828087912796190/892186680839254086/fcdev.png"}), {['Content-Type'] = 'application/json'}) +end +-- (Example of discord log) SendToDiscord("Cheater Kicked", "**"..GetPlayerName(source).."** (ID: "..source..") has been Kicked for exploiting.\n**EventName:** 'eventhere'\n**Resource:** "..GetCurrentResourceName()) + local function log(info) print(info) @@ -40,6 +56,8 @@ AddEventHandler("TakeHostage:sync", function(target) takingHostage[src] = target takenHostage[target] = src else + SendToDiscord("Cheater Kicked", "**"..GetPlayerName(source).."** (ID: "..source..") has been Kicked for exploiting.\n**EventName:** 'sync'\n**Resource:** "..GetCurrentResourceName()) + log('^2TakeHostage: ^1'..srcName..'['..tonumber(src)..']^0 is attempting to exploit the event "sync"! Their distance from the target player is ^1'..dist..'^0.') end end @@ -61,6 +79,7 @@ AddEventHandler("TakeHostage:releaseHostage", function(target) takingHostage[src] = nil takenHostage[target] = nil else + SendToDiscord("Cheater Kicked", "**"..GetPlayerName(source).."** (ID: "..source..") has been Kicked for exploiting.\n**EventName:** 'releaseHostage'\n**Resource:** "..GetCurrentResourceName()) log('^2TakeHostage: ^1'..srcName..'['..tonumber(src)..']^0 is attempting to exploit the event "releaseHostage"! Their distance from the target player is ^1'..dist..'^0.') end end @@ -82,6 +101,7 @@ AddEventHandler("TakeHostage:killHostage", function(target) takingHostage[src] = nil takenHostage[target] = nil else + SendToDiscord("Cheater Kicked", "**"..GetPlayerName(source).."** (ID: "..source..") has been Kicked for exploiting.\n**EventName:** 'killHostage'\n**Resource:** "..GetCurrentResourceName()) log('^2TakeHostage: ^1'..srcName..'['..tonumber(src)..']^0 is attempting to exploit the event "killHostage"! Their distance from the target player is ^1'..dist..'^0.') end end @@ -120,4 +140,4 @@ AddEventHandler('playerDropped', function(reason) takenHostage[src] = nil end end -end) \ No newline at end of file +end) From 2aca0132c434019e289ee556cc2bc9b9746a8c46 Mon Sep 17 00:00:00 2001 From: Aspect <90366824+AsepctDEVS@users.noreply.github.com> Date: Mon, 27 Sep 2021 18:14:50 -0500 Subject: [PATCH 15/17] Create config.lua --- TakeHostage/config.lua | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 TakeHostage/config.lua diff --git a/TakeHostage/config.lua b/TakeHostage/config.lua new file mode 100644 index 0000000..d41061d --- /dev/null +++ b/TakeHostage/config.lua @@ -0,0 +1,2 @@ +Config = {} +Config.WebhookURL = "" -- Webhook Here This will log bad cheaters From 64915b29b7d5d41dceb5cc9c1e18972c0adfd96c Mon Sep 17 00:00:00 2001 From: Aspect <90366824+AsepctDEVS@users.noreply.github.com> Date: Mon, 27 Sep 2021 18:16:30 -0500 Subject: [PATCH 16/17] Update fxmanifest.lua --- TakeHostage/fxmanifest.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/TakeHostage/fxmanifest.lua b/TakeHostage/fxmanifest.lua index ab6c930..af1c286 100644 --- a/TakeHostage/fxmanifest.lua +++ b/TakeHostage/fxmanifest.lua @@ -3,4 +3,7 @@ game 'gta5' client_script "client.lua" -server_script "server.lua" +server_scripts { +"server.lua", + "config.lua" +} From 6630fd2c346faa2638de5fab953ceca9b508230c Mon Sep 17 00:00:00 2001 From: Aspect <90366824+AsepctDEVS@users.noreply.github.com> Date: Mon, 27 Sep 2021 18:52:30 -0500 Subject: [PATCH 17/17] Add files via upload --- AntiVDM/cl_antivdm.lua | 6 + AntiVDM/fxmanifest.lua | 9 ++ CarryPeople/README.md | 6 + CarryPeople/cl_carry.lua | 119 ++++++++++++++ CarryPeople/fxmanifest.lua | 10 ++ CarryPeople/sv_carry.lua | 49 ++++++ IDsAboveHead/cl_idsabovehead.lua | 69 ++++++++ IDsAboveHead/fxmanifest.lua | 9 ++ PiggyBack/README.md | 6 + PiggyBack/cl_piggyback.lua | 120 ++++++++++++++ PiggyBack/fxmanifest.lua | 10 ++ PiggyBack/sv_piggyback.lua | 49 ++++++ VisualWeatherVoter/README.md | 5 + VisualWeatherVoter/cl_vote.lua | 232 +++++++++++++++++++++++++++ VisualWeatherVoter/fxmanifest.lua | 10 ++ VisualWeatherVoter/sv_vote.lua | 39 +++++ vrp_punishments/README.md | 71 ++++++++ vrp_punishments/cl_warningsystem.lua | 147 +++++++++++++++++ vrp_punishments/sv_warningsystem.lua | 114 +++++++++++++ 19 files changed, 1080 insertions(+) create mode 100644 AntiVDM/cl_antivdm.lua create mode 100644 AntiVDM/fxmanifest.lua create mode 100644 CarryPeople/README.md create mode 100644 CarryPeople/cl_carry.lua create mode 100644 CarryPeople/fxmanifest.lua create mode 100644 CarryPeople/sv_carry.lua create mode 100644 IDsAboveHead/cl_idsabovehead.lua create mode 100644 IDsAboveHead/fxmanifest.lua create mode 100644 PiggyBack/README.md create mode 100644 PiggyBack/cl_piggyback.lua create mode 100644 PiggyBack/fxmanifest.lua create mode 100644 PiggyBack/sv_piggyback.lua create mode 100644 VisualWeatherVoter/README.md create mode 100644 VisualWeatherVoter/cl_vote.lua create mode 100644 VisualWeatherVoter/fxmanifest.lua create mode 100644 VisualWeatherVoter/sv_vote.lua create mode 100644 vrp_punishments/README.md create mode 100644 vrp_punishments/cl_warningsystem.lua create mode 100644 vrp_punishments/sv_warningsystem.lua diff --git a/AntiVDM/cl_antivdm.lua b/AntiVDM/cl_antivdm.lua new file mode 100644 index 0000000..40d03a6 --- /dev/null +++ b/AntiVDM/cl_antivdm.lua @@ -0,0 +1,6 @@ +Citizen.CreateThread(function() + while true do + SetWeaponDamageModifier(-1553120962, 0.0) + Wait(0) + end +end) \ No newline at end of file diff --git a/AntiVDM/fxmanifest.lua b/AntiVDM/fxmanifest.lua new file mode 100644 index 0000000..234fdb1 --- /dev/null +++ b/AntiVDM/fxmanifest.lua @@ -0,0 +1,9 @@ +-- Resource Metadata +fx_version 'bodacious' +games { 'gta5' } + +author 'rubbertoe98' +description 'AntiVDM' +version '1.0.0' + +client_script "cl_antivdm.lua" diff --git a/CarryPeople/README.md b/CarryPeople/README.md new file mode 100644 index 0000000..edfad42 --- /dev/null +++ b/CarryPeople/README.md @@ -0,0 +1,6 @@ +# Carry People by Robbster + +Instructions on how to use: +Type /carry close to someone then either person can cancel by again doing /carry + +Feel free to make improvements with PRs diff --git a/CarryPeople/cl_carry.lua b/CarryPeople/cl_carry.lua new file mode 100644 index 0000000..84cd9e3 --- /dev/null +++ b/CarryPeople/cl_carry.lua @@ -0,0 +1,119 @@ + +local carry = { + InProgress = false, + targetSrc = -1, + type = "", + personCarrying = { + animDict = "missfinale_c2mcs_1", + anim = "fin_c2_mcs_1_camman", + flag = 49, + }, + personCarried = { + animDict = "nm", + anim = "firemans_carry", + attachX = 0.27, + attachY = 0.15, + attachZ = 0.63, + flag = 33, + } +} + +local function drawNativeNotification(text) + SetTextComponentFormat("STRING") + AddTextComponentString(text) + DisplayHelpTextFromStringLabel(0, 0, 1, -1) +end + +local function GetClosestPlayer(radius) + local players = GetActivePlayers() + local closestDistance = -1 + local closestPlayer = -1 + local playerPed = PlayerPedId() + local playerCoords = GetEntityCoords(playerPed) + + for _,playerId in ipairs(players) do + local targetPed = GetPlayerPed(playerId) + if targetPed ~= playerPed then + local targetCoords = GetEntityCoords(targetPed) + local distance = #(targetCoords-playerCoords) + if closestDistance == -1 or closestDistance > distance then + closestPlayer = playerId + closestDistance = distance + end + end + end + if closestDistance ~= -1 and closestDistance <= radius then + return closestPlayer + else + return nil + end +end + +local function ensureAnimDict(animDict) + if not HasAnimDictLoaded(animDict) then + RequestAnimDict(animDict) + while not HasAnimDictLoaded(animDict) do + Wait(0) + end + end + return animDict +end + +RegisterCommand("carry",function(source, args) + if not carry.InProgress then + local closestPlayer = GetClosestPlayer(3) + if closestPlayer then + local targetSrc = GetPlayerServerId(closestPlayer) + if targetSrc ~= -1 then + carry.InProgress = true + carry.targetSrc = targetSrc + TriggerServerEvent("CarryPeople:sync",targetSrc) + ensureAnimDict(carry.personCarrying.animDict) + carry.type = "carrying" + else + drawNativeNotification("~r~No one nearby to carry!") + end + else + drawNativeNotification("~r~No one nearby to carry!") + end + else + carry.InProgress = false + ClearPedSecondaryTask(PlayerPedId()) + DetachEntity(PlayerPedId(), true, false) + TriggerServerEvent("CarryPeople:stop",carry.targetSrc) + carry.targetSrc = 0 + end +end,false) + +RegisterNetEvent("CarryPeople:syncTarget") +AddEventHandler("CarryPeople:syncTarget", function(targetSrc) + local targetPed = GetPlayerPed(GetPlayerFromServerId(targetSrc)) + carry.InProgress = true + ensureAnimDict(carry.personCarried.animDict) + AttachEntityToEntity(PlayerPedId(), targetPed, 0, carry.personCarried.attachX, carry.personCarried.attachY, carry.personCarried.attachZ, 0.5, 0.5, 180, false, false, false, false, 2, false) + carry.type = "beingcarried" +end) + +RegisterNetEvent("CarryPeople:cl_stop") +AddEventHandler("CarryPeople:cl_stop", function() + carry.InProgress = false + ClearPedSecondaryTask(PlayerPedId()) + DetachEntity(PlayerPedId(), true, false) +end) + +Citizen.CreateThread(function() + while true do + if carry.InProgress then + if carry.type == "beingcarried" then + if not IsEntityPlayingAnim(PlayerPedId(), carry.personCarried.animDict, carry.personCarried.anim, 3) then + TaskPlayAnim(PlayerPedId(), carry.personCarried.animDict, carry.personCarried.anim, 8.0, -8.0, 100000, carry.personCarried.flag, 0, false, false, false) + end + elseif carry.type == "carrying" then + if not IsEntityPlayingAnim(PlayerPedId(), carry.personCarrying.animDict, carry.personCarrying.anim, 3) then + TaskPlayAnim(PlayerPedId(), carry.personCarrying.animDict, carry.personCarrying.anim, 8.0, -8.0, 100000, carry.personCarrying.flag, 0, false, false, false) + end + end + end + Wait(0) + end +end) \ No newline at end of file diff --git a/CarryPeople/fxmanifest.lua b/CarryPeople/fxmanifest.lua new file mode 100644 index 0000000..5f538a0 --- /dev/null +++ b/CarryPeople/fxmanifest.lua @@ -0,0 +1,10 @@ +-- Resource Metadata +fx_version 'bodacious' +games { 'gta5' } + +author 'rubbertoe98' +description 'CarryPeople' +version '1.0.0' + +client_script "cl_carry.lua" +server_script "sv_carry.lua" diff --git a/CarryPeople/sv_carry.lua b/CarryPeople/sv_carry.lua new file mode 100644 index 0000000..408eafd --- /dev/null +++ b/CarryPeople/sv_carry.lua @@ -0,0 +1,49 @@ +local carrying = {} +--carrying[source] = targetSource, source is carrying targetSource +local carried = {} +--carried[targetSource] = source, targetSource is being carried by source + +RegisterServerEvent("CarryPeople:sync") +AddEventHandler("CarryPeople:sync", function(targetSrc) + local source = source + local sourcePed = GetPlayerPed(source) + local sourceCoords = GetEntityCoords(sourcePed) + local targetPed = GetPlayerPed(targetSrc) + local targetCoords = GetEntityCoords(targetPed) + if #(sourceCoords - targetCoords) <= 3.0 then + TriggerClientEvent("CarryPeople:syncTarget", targetSrc, source) + carrying[source] = targetSrc + carried[targetSrc] = source + end +end) + +RegisterServerEvent("CarryPeople:stop") +AddEventHandler("CarryPeople:stop", function(targetSrc) + local source = source + + if carrying[source] then + TriggerClientEvent("CarryPeople:cl_stop", targetSrc) + carrying[source] = nil + carried[targetSrc] = nil + elseif carried[source] then + TriggerClientEvent("CarryPeople:cl_stop", carried[source]) + carrying[carried[source]] = nil + carried[source] = nil + end +end) + +AddEventHandler('playerDropped', function(reason) + local source = source + + if carrying[source] then + TriggerClientEvent("CarryPeople:cl_stop", carrying[source]) + carried[carrying[source]] = nil + carrying[source] = nil + end + + if carried[source] then + TriggerClientEvent("CarryPeople:cl_stop", carried[source]) + carrying[carried[source]] = nil + carried[source] = nil + end +end) diff --git a/IDsAboveHead/cl_idsabovehead.lua b/IDsAboveHead/cl_idsabovehead.lua new file mode 100644 index 0000000..2854311 --- /dev/null +++ b/IDsAboveHead/cl_idsabovehead.lua @@ -0,0 +1,69 @@ +local disPlayerNames = 5 +local playerDistances = {} + +local function DrawText3D(position, text, r,g,b) + local onScreen,_x,_y=World3dToScreen2d(position.x,position.y,position.z+1) + local dist = #(GetGameplayCamCoords()-position) + + local scale = (1/dist)*2 + local fov = (1/GetGameplayCamFov())*100 + local scale = scale*fov + + if onScreen then + if not useCustomScale then + SetTextScale(0.0*scale, 0.55*scale) + else + SetTextScale(0.0*scale, customScale) + end + SetTextFont(0) + SetTextProportional(1) + SetTextColour(r, g, b, 255) + SetTextDropshadow(0, 0, 0, 0, 255) + SetTextEdge(2, 0, 0, 0, 150) + SetTextDropShadow() + SetTextOutline() + SetTextEntry("STRING") + SetTextCentre(1) + AddTextComponentString(text) + DrawText(_x,_y) + end +end + +Citizen.CreateThread(function() + Wait(500) + while true do + for _, id in ipairs(GetActivePlayers()) do + local targetPed = GetPlayerPed(id) + if targetPed ~= PlayerPedId() then + if playerDistances[id] then + if playerDistances[id] < disPlayerNames then + local targetPedCords = GetEntityCoords(targetPed) + if NetworkIsPlayerTalking(id) then + DrawText3D(targetPedCords, GetPlayerServerId(id), 247,124,24) + DrawMarker(27, targetPedCords.x, targetPedCords.y, targetPedCords.z-0.97, 0, 0, 0, 0, 0, 0, 1.001, 1.0001, 0.5001, 173, 216, 230, 100, 0, 0, 0, 0) + else + DrawText3D(targetPedCords, GetPlayerServerId(id), 255,255,255) + end + end + end + end + end + Citizen.Wait(0) + end +end) + +Citizen.CreateThread(function() + while true do + local playerPed = PlayerPedId() + local playerCoords = GetEntityCoords(playerPed) + + for _, id in ipairs(GetActivePlayers()) do + local targetPed = GetPlayerPed(id) + if targetPed ~= playerPed then + local distance = #(playerCoords-GetEntityCoords(targetPed)) + playerDistances[id] = distance + end + end + Wait(1000) + end +end) \ No newline at end of file diff --git a/IDsAboveHead/fxmanifest.lua b/IDsAboveHead/fxmanifest.lua new file mode 100644 index 0000000..7577086 --- /dev/null +++ b/IDsAboveHead/fxmanifest.lua @@ -0,0 +1,9 @@ +-- Resource Metadata +fx_version 'bodacious' +games { 'gta5' } + +author 'rubbertoe98' +description 'IDsAboveHead' +version '1.0.0' + +client_script "cl_idsabovehead.lua" diff --git a/PiggyBack/README.md b/PiggyBack/README.md new file mode 100644 index 0000000..110a8b2 --- /dev/null +++ b/PiggyBack/README.md @@ -0,0 +1,6 @@ +# Piggyback Riding by Robbster + +Instructions on how to use: +/piggyback close to someone then either person can cancel by again doing /piggyback + +Feel free to make improvements with PRs diff --git a/PiggyBack/cl_piggyback.lua b/PiggyBack/cl_piggyback.lua new file mode 100644 index 0000000..dd9e1f0 --- /dev/null +++ b/PiggyBack/cl_piggyback.lua @@ -0,0 +1,120 @@ + +local piggyback = { + InProgress = false, + targetSrc = -1, + type = "", + personPiggybacking = { + animDict = "anim@arena@celeb@flat@paired@no_props@", + anim = "piggyback_c_player_a", + flag = 49, + }, + personBeingPiggybacked = { + animDict = "anim@arena@celeb@flat@paired@no_props@", + anim = "piggyback_c_player_b", + attachX = 0.0, + attachY = -0.07, + attachZ = 0.45, + flag = 33, + } +} + +local function drawNativeNotification(text) + SetTextComponentFormat("STRING") + AddTextComponentString(text) + DisplayHelpTextFromStringLabel(0, 0, 1, -1) +end + +local function GetClosestPlayer(radius) + local players = GetActivePlayers() + local closestDistance = -1 + local closestPlayer = -1 + local playerPed = PlayerPedId() + local playerCoords = GetEntityCoords(playerPed) + + for _,playerId in ipairs(players) do + local targetPed = GetPlayerPed(playerId) + if targetPed ~= playerPed then + local targetCoords = GetEntityCoords(targetPed) + local distance = #(targetCoords-playerCoords) + if closestDistance == -1 or closestDistance > distance then + closestPlayer = playerId + closestDistance = distance + end + end + end + if closestDistance ~= -1 and closestDistance <= radius then + return closestPlayer + else + return nil + end +end + +local function ensureAnimDict(animDict) + if not HasAnimDictLoaded(animDict) then + RequestAnimDict(animDict) + while not HasAnimDictLoaded(animDict) do + Wait(0) + end + end + return animDict +end + +RegisterCommand("piggyback",function(source, args) + if not piggyback.InProgress then + local closestPlayer = GetClosestPlayer(3) + if closestPlayer then + local targetSrc = GetPlayerServerId(closestPlayer) + if targetSrc ~= -1 then + piggyback.InProgress = true + piggyback.targetSrc = targetSrc + TriggerServerEvent("Piggyback:sync",targetSrc) + ensureAnimDict(piggyback.personPiggybacking.animDict) + piggyback.type = "piggybacking" + else + drawNativeNotification("~r~No one nearby to piggyback!") + end + else + drawNativeNotification("~r~No one nearby to piggyback!") + end + else + piggyback.InProgress = false + ClearPedSecondaryTask(PlayerPedId()) + DetachEntity(PlayerPedId(), true, false) + TriggerServerEvent("Piggyback:stop",piggyback.targetSrc) + piggyback.targetSrc = 0 + end +end,false) + +RegisterNetEvent("Piggyback:syncTarget") +AddEventHandler("Piggyback:syncTarget", function(targetSrc) + local playerPed = PlayerPedId() + local targetPed = GetPlayerPed(GetPlayerFromServerId(targetSrc)) + piggyback.InProgress = true + ensureAnimDict(piggyback.personBeingPiggybacked.animDict) + AttachEntityToEntity(PlayerPedId(), targetPed, 0, piggyback.personBeingPiggybacked.attachX, piggyback.personBeingPiggybacked.attachY, piggyback.personBeingPiggybacked.attachZ, 0.5, 0.5, 180, false, false, false, false, 2, false) + piggyback.type = "beingPiggybacked" +end) + +RegisterNetEvent("Piggyback:cl_stop") +AddEventHandler("Piggyback:cl_stop", function() + piggyback.InProgress = false + ClearPedSecondaryTask(PlayerPedId()) + DetachEntity(PlayerPedId(), true, false) +end) + +Citizen.CreateThread(function() + while true do + if piggyback.InProgress then + if piggyback.type == "beingPiggybacked" then + if not IsEntityPlayingAnim(PlayerPedId(), piggyback.personBeingPiggybacked.animDict, piggyback.personBeingPiggybacked.anim, 3) then + TaskPlayAnim(PlayerPedId(), piggyback.personBeingPiggybacked.animDict, piggyback.personBeingPiggybacked.anim, 8.0, -8.0, 100000, piggyback.personBeingPiggybacked.flag, 0, false, false, false) + end + elseif piggyback.type == "piggybacking" then + if not IsEntityPlayingAnim(PlayerPedId(), piggyback.personPiggybacking.animDict, piggyback.personPiggybacking.anim, 3) then + TaskPlayAnim(PlayerPedId(), piggyback.personPiggybacking.animDict, piggyback.personPiggybacking.anim, 8.0, -8.0, 100000, piggyback.personPiggybacking.flag, 0, false, false, false) + end + end + end + Wait(0) + end +end) \ No newline at end of file diff --git a/PiggyBack/fxmanifest.lua b/PiggyBack/fxmanifest.lua new file mode 100644 index 0000000..542f7a8 --- /dev/null +++ b/PiggyBack/fxmanifest.lua @@ -0,0 +1,10 @@ +-- Resource Metadata +fx_version 'bodacious' +games { 'gta5' } + +author 'rubbertoe98' +description 'PiggyBack' +version '1.0.0' + +client_script "cl_piggyback.lua" +server_script "sv_piggyback.lua" diff --git a/PiggyBack/sv_piggyback.lua b/PiggyBack/sv_piggyback.lua new file mode 100644 index 0000000..b39d652 --- /dev/null +++ b/PiggyBack/sv_piggyback.lua @@ -0,0 +1,49 @@ +local piggybacking = {} +--piggybacking[source] = targetSource, source is piggybacking targetSource +local beingPiggybacked = {} +--beingPiggybacked[targetSource] = source, targetSource is beingPiggybacked by source + +RegisterServerEvent("Piggyback:sync") +AddEventHandler("Piggyback:sync", function(targetSrc) + local source = source + local sourcePed = GetPlayerPed(source) + local sourceCoords = GetEntityCoords(sourcePed) + local targetPed = GetPlayerPed(targetSrc) + local targetCoords = GetEntityCoords(targetPed) + if #(sourceCoords - targetCoords) <= 3.0 then + TriggerClientEvent("Piggyback:syncTarget", targetSrc, source) + piggybacking[source] = targetSrc + beingPiggybacked[targetSrc] = source + end +end) + +RegisterServerEvent("Piggyback:stop") +AddEventHandler("Piggyback:stop", function(targetSrc) + local source = source + + if piggybacking[source] then + TriggerClientEvent("Piggyback:cl_stop", targetSrc) + piggybacking[source] = nil + beingPiggybacked[targetSrc] = nil + elseif beingPiggybacked[source] then + TriggerClientEvent("Piggyback:cl_stop", beingPiggybacked[source]) + beingPiggybacked[source] = nil + piggybacking[beingPiggybacked[source]] = nil + end +end) + +AddEventHandler('playerDropped', function(reason) + local source = source + + if piggybacking[source] then + TriggerClientEvent("Piggyback:cl_stop", piggybacking[source]) + beingPiggybacked[piggybacking[source]] = nil + piggybacking[source] = nil + end + + if beingPiggybacked[source] then + TriggerClientEvent("Piggyback:cl_stop", beingPiggybacked[source]) + piggybacking[beingPiggybacked[source]] = nil + beingPiggybacked[source] = nil + end +end) diff --git a/VisualWeatherVoter/README.md b/VisualWeatherVoter/README.md new file mode 100644 index 0000000..dfbf167 --- /dev/null +++ b/VisualWeatherVoter/README.md @@ -0,0 +1,5 @@ +# Visual-Weather-Voter-FiveM- + +You can change the cooldown between each vote and the default weather in sv_vote.lua + +Any improvements, just make a pull request. diff --git a/VisualWeatherVoter/cl_vote.lua b/VisualWeatherVoter/cl_vote.lua new file mode 100644 index 0000000..0ee39fe --- /dev/null +++ b/VisualWeatherVoter/cl_vote.lua @@ -0,0 +1,232 @@ +defaultWeather = "CLEAR" +currentWeather = defaultWeather +showWeatherVoteGUI = false +voteInProgress = false +voted = false +timer = 60 + +votesTable = { + ["CLEAR"] = 0, + ["EXTRASUNNY"] = 0, + ["CLOUDS"] = 0, + ["OVERCAST"] = 0, + ["RAIN"] = 0, + ["THUNDER"] = 0, + ["CLEARING"] = 0, + ["SMOG"] = 0, + ["FOGGY"] = 0, + ["XMAS"] = 0, + ["SNOWLIGHT"] = 0, + ["BLIZZARD"] = 0 +} + +function sorted_iter(t) + local i = {} + for k in next, t do + table.insert(i, k) + end + table.sort(i) + return function() + local k = table.remove(i) + if k ~= nil then + return k, t[k] + end + end +end + + +function DrawAdvancedText(x,y ,w,h,sc, text, r,g,b,a,font,jus) + SetTextFont(font) + SetTextScale(sc, sc) + N_0x4e096588b13ffeca(jus) + SetTextColour(r, g, b, a) + SetTextEntry("STRING") + AddTextComponentString(text) + DrawText(x - 0.1+w, y - 0.02+h) +end + +function voteWeather(weatherType) + print("voteInProgress: " .. tostring(voteInProgress)) + if voteInProgress then + if not voted then + TriggerServerEvent("CMG:vote", weatherType) + voted = true + TriggerEvent("chatMessage","Vote sent!",{0, 255, 0}) + else + TriggerEvent("chatMessage","You have already voted!",{255, 0, 0}) + end + else + TriggerEvent("chatMessage","Vote not in progress!",{255, 0, 0}) + end +end + + +function changeWeather() + highestWeather = defaultWeather + highestCounter = 0 + for k,v in sorted_iter(votesTable) do + if v > highestCounter then + highestWeather = k + highestCounter = v + end + end + currentWeather = highestWeather + TriggerServerEvent("CMG:setCurrentWeather",highestWeather) +end + +RegisterNetEvent("CMG:voteFinished") +AddEventHandler("CMG:voteFinished", function(newWeather) + currentWeather = newWeather +end) + +RegisterNetEvent("CMG:startWeatherVote") +AddEventHandler("CMG:startWeatherVote", function() + voteInProgress = true + TriggerEvent("chatMessage","Weather vote has started! Type /[weather] e.g /snow or /rain to vote.",{0, 250, 50}) + TriggerEvent("chatMessage","Weather types are in bottom left & /voteweather to start a vote",{0, 250, 50}) +end) + +RegisterNetEvent("CMG:voteStateChange") +AddEventHandler("CMG:voteStateChange",function(type) + votesTable[type] = votesTable[type] + 1 +end) + +RegisterCommand("voteweather", function() + TriggerServerEvent("CMG:tryStartWeatherVote") +end, false) + +RegisterCommand("clear", function() + voteWeather("CLEAR") +end, false) + +RegisterCommand("extrasunny", function() + voteWeather("EXTRASUNNY") +end, false) + +RegisterCommand("cloudy", function() + voteWeather("CLOUDS") +end, false) + +RegisterCommand("overcast", function() + voteWeather("OVERCAST") +end, false) + +RegisterCommand("rain", function() + voteWeather("RAIN") +end, false) + +RegisterCommand("thunder", function() + voteWeather("THUNDER") +end, false) + +RegisterCommand("clearing", function() + voteWeather("CLEARING") +end, false) + +RegisterCommand("smog", function() + voteWeather("SMOG") +end, false) + +RegisterCommand("foggy", function() + voteWeather("FOGGY") +end, false) + +RegisterCommand("snow", function() + voteWeather("XMAS") +end, false) + +RegisterCommand("snowlight", function() + voteWeather("SNOWLIGHT") +end, false) + +RegisterCommand("blizzard", function() + voteWeather("BLIZZARD") +end, false) + +Citizen.CreateThread(function() + while true do + SetWeatherTypePersist(currentWeather) + SetWeatherTypeNowPersist(currentWeather) + SetWeatherTypeNow(currentWeather) + SetOverrideWeather(currentWeather) + Wait(1000) + end +end) + +Citizen.CreateThread(function() + while true do + if voteInProgress then + DrawAdvancedText(0.27, 0.96, 0.005, 0.0028, 0.318, "Time Left:", 0, 208, 104, 255, 4, 0) + DrawAdvancedText(0.29, 0.96, 0.005, 0.0028, 0.29, tostring(timer), 255, 74, 53, 255, 0, 0) + DrawAdvancedText(0.297, 0.827, 0.005, 0.0028, 0.38, "Weather Voter", 0, 208, 104, 255, 4, 0) + + DrawAdvancedText(0.2645, 0.848, 0.005, 0.0028, 0.318, "Clear", 255, 255, 255, 255, 4, 0) + DrawAdvancedText(0.2728, 0.866, 0.005, 0.0028, 0.318, "ExtraSunny", 255, 255, 255, 255, 4, 0) + DrawAdvancedText(0.266, 0.884, 0.005, 0.0028, 0.318, "Cloudy", 255, 255, 255, 255, 4, 0) + DrawAdvancedText(0.269, 0.902, 0.005, 0.0028, 0.318, "Overcast", 255, 255, 255, 255, 4, 0) + DrawAdvancedText(0.263, 0.920, 0.005, 0.0028, 0.318, "Rain", 255, 255, 255, 255, 4, 0) + DrawAdvancedText(0.268, 0.938, 0.005, 0.0028, 0.318, "Thunder", 255, 255, 255, 255, 4, 0) + + DrawAdvancedText(0.293, 0.848, 0.005, 0.0028, 0.25, tostring(votesTable["CLEAR"]), 255, 74, 53, 255, 0, 0) + DrawAdvancedText(0.293, 0.866, 0.005, 0.0028, 0.25, tostring(votesTable["EXTRASUNNY"]), 255, 74, 53, 255, 0, 0) + DrawAdvancedText(0.293, 0.884, 0.005, 0.0028, 0.25, tostring(votesTable["CLOUDS"]), 255, 74, 53, 255, 0, 0) + DrawAdvancedText(0.293, 0.902, 0.005, 0.0028, 0.25, tostring(votesTable["OVERCAST"]), 255, 74, 53, 255, 0, 0) + DrawAdvancedText(0.293, 0.920, 0.005, 0.0028, 0.25, tostring(votesTable["RAIN"]), 255, 74, 53, 255, 0, 0) + DrawAdvancedText(0.293, 0.938, 0.005, 0.0028, 0.25, tostring(votesTable["THUNDER"]), 255, 74, 53, 255, 0, 0) + + DrawAdvancedText(0.315, 0.848, 0.005, 0.0028, 0.318, "Clearing", 255, 255, 255, 255, 4, 0) + DrawAdvancedText(0.315, 0.866, 0.005, 0.0028, 0.318, "Smog", 255, 255, 255, 255, 4, 0) + DrawAdvancedText(0.314, 0.884, 0.005, 0.0028, 0.318, "Snow", 255, 255, 255, 255, 4, 0) + DrawAdvancedText(0.315, 0.902, 0.005, 0.0028, 0.318, "Blizzard", 255, 255, 255, 255, 4, 0) + DrawAdvancedText(0.315, 0.920, 0.005, 0.0028, 0.318, "Snowlight", 255, 255, 255, 255, 4, 0) + DrawAdvancedText(0.315, 0.938, 0.005, 0.0028, 0.318, "Foggy", 255, 255, 255, 255, 4, 0) + + DrawAdvancedText(0.333, 0.848, 0.005, 0.0028, 0.25, tostring(votesTable["CLEARING"]), 255, 74, 53, 255, 0, 0) + DrawAdvancedText(0.333, 0.866, 0.005, 0.0028, 0.25, tostring(votesTable["SMOG"]), 255, 74, 53, 255, 0, 0) + DrawAdvancedText(0.333, 0.884, 0.005, 0.0028, 0.25, tostring(votesTable["XMAS"]), 255, 74, 53, 255, 0, 0) + DrawAdvancedText(0.333, 0.902, 0.005, 0.0028, 0.25, tostring(votesTable["BLIZZARD"]), 255, 74, 53, 255, 0, 0) + DrawAdvancedText(0.333, 0.920, 0.005, 0.0028, 0.25, tostring(votesTable["SNOWLIGHT"]), 255, 74, 53, 255, 0, 0) + DrawAdvancedText(0.333, 0.938, 0.005, 0.0028, 0.25, tostring(votesTable["FOGGY"]), 255, 74, 53, 255, 0, 0) + end + Wait(0) + end +end) + + +Citizen.CreateThread(function() + while true do + if voteInProgress then + timer = timer - 1 + if timer == 0 then + voteInProgress = false + timer = 60 + voted = false + changeWeather() + resetVotes() + end + end + Wait(1000) + end +end) + +AddEventHandler('playerSpawned', function(spawn) + TriggerServerEvent("CMG:getCurrentWeather") + +end) + +function resetVotes() + votesTable = { + ["CLEAR"] = 0, + ["EXTRASUNNY"] = 0, + ["CLOUDS"] = 0, + ["OVERCAST"] = 0, + ["RAIN"] = 0, + ["THUNDER"] = 0, + ["CLEARING"] = 0, + ["SMOG"] = 0, + ["FOGGY"] = 0, + ["XMAS"] = 0, + ["SNOWLIGHT"] = 0, + ["BLIZZARD"] = 0 + } +end diff --git a/VisualWeatherVoter/fxmanifest.lua b/VisualWeatherVoter/fxmanifest.lua new file mode 100644 index 0000000..131fa2b --- /dev/null +++ b/VisualWeatherVoter/fxmanifest.lua @@ -0,0 +1,10 @@ +-- Resource Metadata +fx_version 'bodacious' +games { 'gta5' } + +author 'rubbertoe98' +description 'VisualWeatherVoter' +version '1.0.0' + +client_script "cl_vote.lua" +server_script "sv_vote.lua" diff --git a/VisualWeatherVoter/sv_vote.lua b/VisualWeatherVoter/sv_vote.lua new file mode 100644 index 0000000..463a0d4 --- /dev/null +++ b/VisualWeatherVoter/sv_vote.lua @@ -0,0 +1,39 @@ +voteCooldown = 1800 +currentWeather = "CLEAR" + +weatherVoterCooldown = voteCooldown + +RegisterServerEvent("CMG:vote") +AddEventHandler("CMG:vote", function(weatherType) + TriggerClientEvent("CMG:voteStateChange",-1,weatherType) +end) + +RegisterServerEvent("CMG:tryStartWeatherVote") +AddEventHandler("CMG:tryStartWeatherVote", function() + local source = source + if weatherVoterCooldown >= voteCooldown then + TriggerClientEvent("CMG:startWeatherVote", -1) + weatherVoterCooldown = 0 + else + TriggerClientEvent("chatMessage",source,"Another vote can be started in " .. tostring(voteCooldown-weatherVoterCooldown) .. " seconds!",{255, 0, 0}) + end +end) + +RegisterServerEvent("CMG:getCurrentWeather") +AddEventHandler("CMG:getCurrentWeather", function() + local source = source + TriggerClientEvent("CMG:voteFinished",source,currentWeather) +end) + +RegisterServerEvent("CMG:setCurrentWeather") +AddEventHandler("CMG:setCurrentWeather", function(newWeather) + currentWeather = newWeather +end) + +Citizen.CreateThread(function() + while true do + weatherVoterCooldown = weatherVoterCooldown + 1 + Citizen.Wait(1000) + end +end) + diff --git a/vrp_punishments/README.md b/vrp_punishments/README.md new file mode 100644 index 0000000..3d35d27 --- /dev/null +++ b/vrp_punishments/README.md @@ -0,0 +1,71 @@ +# vrp_punishmentslog created by Robbster + +## Installation: + +###### 1) Dependancies: GHMattiMySQL + +Ensure you have GHMattiMySQL installed and correctly configured to your database +```https://github.com/GHMatti/FiveM-MySQL``` + +###### 2) Create your new database table by executing the following SQL in your database + +```SQL +CREATE TABLE cmg_warnings ( + warning_id INT, + user_id INT, + warning_type VARCHAR(25), + duration INT, + admin VARCHAR(100), + warning_date DATE, + reason VARCHAR(2000), + PRIMARY KEY (warning_id) +) +``` + +###### 3) Go to vrp/modules/admin.lua +and find the ch_kick function (CTRL-F "ch_kick") +Place this line just before the line starting with "vRP.kick". +```lua +saveKickLog(id,GetPlayerName(player),reason) +``` + + +###### 4) Replace the ch_ban function with the following code + +```lua +local function ch_ban(player,choice) + local user_id = vRP.getUserId(player) + if user_id ~= nil and vRP.hasPermission(user_id,"player.ban") then + vRP.prompt(player,"User id to ban: ","",function(player,id) + id = parseInt(id) + vRP.prompt(player,"Reason: ","",function(player,reason) + local source = vRP.getUserSource(id) + vRP.prompt(player,"Hours: ","",function(player,duration) + if tonumber(duration) then + vRPclient.notify(player,{"banned user "..id}) + saveBanLog(id,GetPlayerName(player),reason,duration) + vRP.ban(source,reason) + else + vRPclient.notify(player,{"~r~Invalid ban time!"}) + end + end) + end) + end) + end +end +``` + +###### 5) Place sv_warningsystem.lua in vrp/modules/ and cl_warningsystem.lua in vrp/client/ + +###### 6) Update your vrp/__resource.lua by putting adding the file names cl_warningsystem.lua & sv_warningsystem.lua in the appropriate section + +## How to use: + +* F10 to open up the warning sytem +* /showwarnings [user_id] to show someone's punishment log (i.e /showwarnings 1) +* /warn to give a warning +* Kicks & Bans are automatically added to someones punishment log when you ban/kick them through your phone + +Feel free to make improvements with PRs + + diff --git a/vrp_punishments/cl_warningsystem.lua b/vrp_punishments/cl_warningsystem.lua new file mode 100644 index 0000000..67598d2 --- /dev/null +++ b/vrp_punishments/cl_warningsystem.lua @@ -0,0 +1,147 @@ +--type,duration(hours),admin_name,date,reason +CMGWarnings = { + [0] = {"Ban","48","Robbster","10-10-19","You VDM'd x2"}, + [1] = {"Warning","24","Rob","1-10-19","You VDM'd x4"}, +} + +showWarningSystem = false + +xoffset = 0.031 +rowcounter = 0 +warningColourR = 0 +warningColourG = 0 +warningColourB = 0 + +-- RegisterCommand("tempwarn",function() + -- showWarningSystem = not showWarningSystem +-- end) + +RegisterNetEvent("CMG:showWarningsOfUser") +AddEventHandler("CMG:showWarningsOfUser",function(cmgwarningstables) + print("got to showWarningsOfUser") + showWarningSystem = true + CMGWarnings = cmgwarningstables +end) + +RegisterNetEvent("CMG:recievedRefreshedWarningData") +AddEventHandler("CMG:recievedRefreshedWarningData",function(cmgwarningstables) + print("got to recievedRefreshedWarningData") + CMGWarnings = cmgwarningstables +end) + + +Citizen.CreateThread(function() + while true do + if IsControlJustPressed(0,57) then + print("toggling warning system") + showWarningSystem = not showWarningSystem + if showWarningSystem then + TriggerServerEvent("CMG:refreshWarningSystem") + end + Wait(250) + end + Wait(0) + end +end) + +Citizen.CreateThread(function() + while true do + if showWarningSystem then + DrawRect(0.498, 0.482, 0.615, 0.636, 0, 0, 0, 150) + DrawRect(0.498, 0.197, 0.615, 0.066, 0, 0, 0, 135) + DrawAdvancedText(0.59, 0.198, 0.005, 0.0028, 0.619, "CMG Warning System", 255, 255, 255, 255, 7, 0) + DrawRect(0.498, 0.232, 0.615, -0.0040000000000001, 0, 168, 255, 204) + DrawRect(0.498, 0.285, 0.535, -0.0040000000000001, 0, 168, 255, 204) + DrawAdvancedText(0.344, 0.27, 0.005, 0.0028, 0.4, "Type", 255, 255, 255, 255, 6, 0) + DrawAdvancedText(0.379, 0.271, 0.005, 0.0028, 0.4, "Duration", 255, 255, 255, 255, 6, 0) + DrawAdvancedText(0.417, 0.271, 0.005, 0.0028, 0.4, "Admin", 255, 255, 255, 255, 6, 0) + DrawAdvancedText(0.463, 0.271, 0.005, 0.0028, 0.4, "Date", 255, 255, 255, 255, 6, 0) + DrawAdvancedText(0.672, 0.271, 0.005, 0.0028, 0.4, "Reason", 255, 255, 255, 255, 6, 0) + for warningID,warningTable in pairs(CMGWarnings) do + --type,duration,admin,date,reason = table.unpack(warningTable) + local warning_type,duration,admin,date,reason = warningTable["warning_type"],warningTable["duration"],warningTable["admin"],warningTable["warning_date"],warningTable["reason"] + --print("warning_type showing: " .. tostring(warning_type)) + --print("duration showing: " .. tostring(duration)) + if warning_type == "Warning" then + warningColourR = 255 + warningColourG = 255 + warningColourB = 102 + elseif warning_type == "Kick" then + warningColourR = 255 + warningColourG = 123 + warningColourB = 0 + elseif warning_type == "Ban" then + warningColourR = 255 + warningColourG = 44 + warningColourB = 44 + end + DrawAdvancedText(0.344, 0.309+(rowcounter*xoffset), 0.005, 0.0028, 0.4, warning_type, warningColourR, warningColourG, warningColourB, 255, 6, 0) + DrawAdvancedText(0.379, 0.309+(rowcounter*xoffset), 0.005, 0.0028, 0.4, tostring(duration) .. "hrs", 255, 255, 255, 255, 6, 0) + DrawAdvancedText(0.417, 0.309+(rowcounter*xoffset), 0.005, 0.0028, 0.4, admin, 255, 255, 255, 255, 6, 0) + DrawAdvancedText(0.463, 0.309+(rowcounter*xoffset), 0.005, 0.0028, 0.4, date, 255, 255, 255, 255, 6, 0) + DrawAdvancedText(0.672, 0.309+(rowcounter*xoffset), 0.005, 0.0028, 0.4, reason, 255, 255, 255, 255, 6, 0) + rowcounter = rowcounter + 1 + end + rowcounter = 0 + end + Wait(0) + end +end) + +RegisterCommand("warn",function() + --get a dialog box open + --get ID + --get warning msg + --send to server to update the database + userIDtoWarn = getWarningUserID() + userWarningMessage = getWarningUserMsg() + + TriggerServerEvent("CMG:warnPlayer",tonumber(userIDtoWarn),GetPlayerName(PlayerId()),userWarningMessage) +end) + +function getWarningUserID() + AddTextEntry('FMMC_MPM_NA', "Enter ID of the player you want to warn?") + DisplayOnscreenKeyboard(1, "FMMC_MPM_NA", "Enter ID of the player you want to warn?", "1", "", "", "", 30) + while (UpdateOnscreenKeyboard() == 0) do + DisableAllControlActions(0); + Wait(0); + end + if (GetOnscreenKeyboardResult()) then + local result = GetOnscreenKeyboardResult() + if result then + return result + end + end + return false +end + +function getWarningUserMsg() + AddTextEntry('FMMC_MPM_NA', "Enter warning message") + DisplayOnscreenKeyboard(1, "FMMC_MPM_NA", "Enter warning message", "", "", "", "", 30) + while (UpdateOnscreenKeyboard() == 0) do + DisableAllControlActions(0); + Wait(0); + end + if (GetOnscreenKeyboardResult()) then + local result = GetOnscreenKeyboardResult() + if result then + return result + end + end + return false +end + +function DrawAdvancedText(x,y ,w,h,sc, text, r,g,b,a,font,jus) + SetTextFont(font) + SetTextProportional(0) + SetTextScale(sc, sc) + N_0x4e096588b13ffeca(jus) + SetTextColour(r, g, b, a) + SetTextDropShadow(0, 0, 0, 0,255) + SetTextEdge(1, 0, 0, 0, 255) + SetTextDropShadow() + -- SetTextOutline() + SetTextEntry("STRING") + AddTextComponentString(text) + DrawText(x - 0.1+w, y - 0.02+h) +end \ No newline at end of file diff --git a/vrp_punishments/sv_warningsystem.lua b/vrp_punishments/sv_warningsystem.lua new file mode 100644 index 0000000..4c20acc --- /dev/null +++ b/vrp_punishments/sv_warningsystem.lua @@ -0,0 +1,114 @@ +-- CREATE TALBE cmg_warnings ( + -- warning_id INT, + -- user_id INT, + -- warning_type VARCHAR(25), + -- duration INT, + -- admin VARCHAR(100), + -- warning_date DATE, + -- reason VARCHAT(2000), + -- PRIMARY KEY (warning_id) +-- ) + +--TODO +--Fix date DONE +--/warn DONE +--make primary key auto_increment DONE +--getCurrentDate function DONE +--bans auto go on log menu DONE +--kicks auto go on log menu DONE +--Whitelist to staff DONE +--Change crossarms key bind DONE +--change requests DONE +--ban duration column needs to show (hrs) DONE +--ban duration not working DONE +--bar colour DONE +--verify kicks work DONE + +AddEventHandler('chatMessage', function(player, color, message) + user_id = vRP.getUserId(player) + if message:sub(1, 13) == '/showwarnings' then + local permID = tonumber(message:sub(14, 20)) + if permID ~= nil then + --check if staff + if vRP.hasPermission(user_id,"player.kick") then + --print("Getting warnings of ID: " .. tostring(permID)) + cmgwarningstables = getCMGWarnings(permID,player) + --print("sending to source: " .. tostring(source)) + TriggerClientEvent("CMG:showWarningsOfUser",player,cmgwarningstables) + end + else + --print("Error couldn't get ID: " .. tostring(message:sub(14, 20))) + end + end + CancelEvent() +end) + +--print("start:"..dump(testdate).."end") +-- testTime = 1561845600000 +-- testTime = testTime / 1000 +-- print(os.date('%Y-%m-%d', testTime)) + +function getCMGWarnings(user_id,source) + cmgwarningstables = exports['GHMattiMySQL']:QueryResult("SELECT * FROM cmg_warnings WHERE user_id = @uid", {uid = user_id}) + print("Triggering CMG:showWarningsOfUser") + --print(dump(cmgwarningstables)) + for warningID,warningTable in pairs(cmgwarningstables) do + --print(warningTable["warning_date"]) + date = warningTable["warning_date"] + --print("date1:" .. tostring(date)) + newdate = tonumber(date) / 1000 + --print("date3:" .. tostring(newdate)) + newdate = os.date('%Y-%m-%d', newdate) + --print("date4:" .. tostring(newdate)) + warningTable["warning_date"] = newdate + end + return cmgwarningstables +end + +RegisterServerEvent("CMG:refreshWarningSystem") +AddEventHandler("CMG:refreshWarningSystem",function() + local source = source + local user_id = vRP.getUserId(source) + --local user_id = 1 + + cmgwarningstables = getCMGWarnings(user_id,source) + TriggerClientEvent("CMG:recievedRefreshedWarningData",source,cmgwarningstables) +end) + +RegisterServerEvent("CMG:warnPlayer") +AddEventHandler("CMG:warnPlayer",function(target_id,adminName,warningReason) + local source = source + local user_id = vRP.getUserId(source) + if vRP.hasPermission(user_id,"player.kick") then + warning = "Warning" + warningDate = getCurrentDate() + exports['GHMattiMySQL']:QueryAsync("INSERT INTO cmg_warnings (`warning_id`, `user_id`, `warning_type`, `duration`, `admin`, `warning_date`, `reason`) VALUES (NULL, @user_id, @warning_type, 0, @admin, @warning_date,@reason);", {user_id = target_id,warning_type = warning, admin = adminName, warning_date = warningDate, reason = warningReason}, function() end) + else + vRPclient.notify(player,{"~r~no perms to warn player"}) + end +end) + +function saveKickLog(target_id,adminName,warningReason) + warning = "Kick" + warningDate = getCurrentDate() + exports['GHMattiMySQL']:QueryAsync("INSERT INTO cmg_warnings (`warning_id`, `user_id`, `warning_type`, `duration`, `admin`, `warning_date`, `reason`) VALUES (NULL, @user_id, @warning_type, 0, @admin, @warning_date,@reason);", {user_id = target_id,warning_type = warning, admin = adminName, warning_date = warningDate, reason = warningReason}, function() end) + +end + +function saveBanLog(target_id,adminName,warningReason,warning_duration) + warning = "Ban" + warningDate = getCurrentDate() + exports['GHMattiMySQL']:QueryAsync("INSERT INTO cmg_warnings (`warning_id`, `user_id`, `warning_type`, `duration`, `admin`, `warning_date`, `reason`) VALUES (NULL, @user_id, @warning_type, @duration, @admin, @warning_date,@reason);", {user_id = target_id,warning_type = warning, admin = adminName, duration = warning_duration, warning_date = warningDate, reason = warningReason}, function() end) +end + + +function getCurrentDate() + date = os.date("%Y/%m/%d") + + return date +end + +-- CMGWarnings = { + -- [0] = {"Ban","48","Rolex","10-10-19","You VDM'd x2"}, + -- [1] = {"Warning","24","Rob","1-10-19","You VDM'd x4"}, +-- } \ No newline at end of file