Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Take Hostage Exploit Stoper #28

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
13 changes: 9 additions & 4 deletions CarryPeople/sv_carry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ local carried = {}
RegisterServerEvent("CarryPeople:sync")
AddEventHandler("CarryPeople:sync", function(targetSrc)
local source = source

TriggerClientEvent("CarryPeople:syncTarget", targetSrc, source)
carrying[source] = targetSrc
carried[targetSrc] = 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")
Expand Down
15 changes: 10 additions & 5 deletions PiggyBack/sv_piggyback.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ local beingPiggybacked = {}
RegisterServerEvent("Piggyback:sync")
AddEventHandler("Piggyback:sync", function(targetSrc)
local source = source

TriggerClientEvent("Piggyback:syncTarget", targetSrc, source)
piggybacking[source] = targetSrc
beingPiggybacked[targetSrc] = 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")
Expand Down Expand Up @@ -41,4 +46,4 @@ AddEventHandler('playerDropped', function(reason)
piggybacking[beingPiggybacked[source]] = nil
beingPiggybacked[source] = nil
end
end)
end)
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# FiveM-Scripts
Compilation of my publicly released code
Original Take Hostage Script Made By: rubbertoe98

Feel free to make improvements with PRs
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.

My personal dev discord
https://discord.gg/dnZTpUh
Minor client sided optimizations & changes.

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!
151 changes: 83 additions & 68 deletions TakeHostage/cl_takehostage.lua → TakeHostage/client.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
-----------------------------------------------------------------
--TakeHostage by Robbster, do not redistrbute without permission--
------------------------------------------------------------------
--Original Author: rubbertoe98
--Edited & Patched By: Vyast

local takeHostage = {
allowedWeapons = {
`WEAPON_PISTOL`,
`WEAPON_COMBATPISTOL`,
`WEAPON_APPISTOL`,
--etc add guns you want
},
InProgress = false,
Expand All @@ -32,24 +32,27 @@ local function drawNativeNotification(text)
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
end

local function playerPed()
return PlayerPedId()
end

local function GetClosestPlayer(radius)
local players = GetActivePlayers()
local closestDistance = -1
local closestPlayer = -1
local playerPed = PlayerPedId()
local closestDistance, closestPlayer = -1, -1
local playerPed = playerPed()
local playerCoords = GetEntityCoords(playerPed)

for _,playerId in ipairs(players) do
local targetPed = GetPlayerPed(playerId)
for k, v in ipairs(GetActivePlayers()) do
local targetPed = GetPlayerPed(v)
if targetPed ~= playerPed then
local targetCoords = GetEntityCoords(targetPed)
local distance = #(targetCoords-playerCoords)
local distance = #(targetCoords - playerCoords)
if closestDistance == -1 or closestDistance > distance then
closestPlayer = playerId
closestPlayer = v
closestDistance = distance
end
end
end

if closestDistance ~= -1 and closestDistance <= radius then
return closestPlayer
else
Expand All @@ -73,50 +76,55 @@ local function drawNativeText(str)
EndTextCommandPrint(1000, 1)
end

RegisterCommand("takehostage",function()
RegisterCommand("takehostage", function()
callTakeHostage()
end)

RegisterCommand("th",function()
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
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
end

if not canTakeHostage then
drawNativeNotification("You need a pistol with ammo to take a hostage at gunpoint!")
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"
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
else
drawNativeNotification("~r~No one nearby to take as hostage!")
end
else
drawNativeNotification("~r~You cannot do that while you are dead!")
end
end

Expand All @@ -125,88 +133,96 @@ 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)
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(PlayerPedId(), true, false)
DetachEntity(ped, 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())
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(PlayerPedId(),0)
DetachEntity(PlayerPedId(), true, false)
SetEntityHealth(ped, 0)
DetachEntity(ped, true, false)
ensureAnimDict("anim@gangops@hostage@")
TaskPlayAnim(PlayerPedId(), "anim@gangops@hostage@", "victim_fail", 8.0, -8.0, -1, 168, 0, false, false, false)
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(PlayerPedId())
DetachEntity(PlayerPedId(), true, false)
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(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)
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(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)
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
Wait(0)
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(PlayerPedId(),true)
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(PlayerPedId()) then
if IsEntityDead(ped) 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)
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(PlayerPedId(), "reaction@shove", "shove_var_a", 8.0, -8.0, -1, 168, 0, false, false, false)
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(PlayerPedId(), "anim@gangops@hostage@", "perp_fail", 8.0, -8.0, -1, 168, 0, false, false, false)
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(PlayerPedId(), 0.0, 0.0, 0.0, 0)
SetPedShootsAtCoord(ped, 0.0, 0.0, 0.0, 0)
end
elseif takeHostage.type == "hostage" then
DisableControlAction(0,21,true) -- disable sprint
Expand All @@ -233,6 +249,5 @@ Citizen.CreateThread(function()
DisableControlAction(0,35,true) -- disable move right
DisableControlAction(0,271,true)
end
Wait(0)
end
end)
2 changes: 2 additions & 0 deletions TakeHostage/config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Config = {}
Config.WebhookURL = "" -- Webhook Here This will log bad cheaters
13 changes: 6 additions & 7 deletions TakeHostage/fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
-- 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_scripts {
"server.lua",
"config.lua"
}
Loading