Installation
Here you will get the full Installation guide to get this script running.
Download Asset
Login in your FiveM Portal Account
To Download our Script you must login in your Fivem Portal Account
Download the Script
If you are sucessfully logged in into your Account go to Assets and search by the script hex_ffa then download it.
Download Dependencies
| Dependency | Required |
|---|---|
| es_extended | |
| oxmysql |
Start Asset
To make sure the asset start and run properly, you need to add them in the correct order inside your server.cfg. Below is an example of how it should look.
Note
You can also create a folder called [hex] inside your resources folder. If you own multiple scripts from us, you won’t need to add each one separately to your server.cfg.
# 1. Start database wrapper called oxmysql
ensure oxmysql
# 2. Start the specific framework
ensure es_extended or qb-core or qbx_core
# 3. Now start our asset singularly
ensure hex_ffa
# Or you can start all of our assets at once into a folder called [hex]
ensure [hex]Replace Death Handler
Since we use our own death handler in FFA, we need to disable the ESX death handling. You can completely replace the file with this one.
Death = {}
Death._index = Death
function Death:ResetValues()
self.killerEntity = nil
self.deathCause = nil
self.killerId = nil
self.killerServerId = nil
end
function Death:ByPlayer()
local victimCoords = GetEntityCoords(ESX.PlayerData.ped)
local killerCoords = GetEntityCoords(self.killerEntity)
local distance = #(victimCoords - killerCoords)
local data = {
victimCoords = { x = ESX.Math.Round(victimCoords.x, 1), y = ESX.Math.Round(victimCoords.y, 1), z = ESX.Math.Round(victimCoords.z, 1) },
killerCoords = { x = ESX.Math.Round(killerCoords.x, 1), y = ESX.Math.Round(killerCoords.y, 1), z = ESX.Math.Round(killerCoords.z, 1) },
killedByPlayer = true,
deathCause = self.deathCause,
distance = ESX.Math.Round(distance, 1),
killerServerId = self.killerServerId,
killerClientId = self.killerId,
}
TriggerEvent("esx:onPlayerDeath", data)
TriggerServerEvent("esx:onPlayerDeath", data)
end
function Death:Natural()
local coords = GetEntityCoords(ESX.PlayerData.ped)
local data = {
victimCoords = { x = ESX.Math.Round(coords.x, 1), y = ESX.Math.Round(coords.y, 1), z = ESX.Math.Round(coords.z, 1) },
killedByPlayer = false,
deathCause = self.deathCause,
}
TriggerEvent("esx:onPlayerDeath", data)
TriggerServerEvent("esx:onPlayerDeath", data)
end
function Death:Died()
self.killerEntity = GetPedSourceOfDeath(ESX.PlayerData.ped)
self.deathCause = GetPedCauseOfDeath(ESX.PlayerData.ped)
self.killerId = NetworkGetPlayerIndexFromPed(self.killerEntity)
self.killerServerId = GetPlayerServerId(self.killerId)
local isActive = NetworkIsPlayerActive(self.killerId)
if self.killerEntity ~= ESX.PlayerData.ped and self.killerId and isActive then
self:ByPlayer()
else
self:Natural()
end
self:ResetValues()
end
local function isInFFA()
if GetResourceState('hex_ffa') == 'started' then
if exports['hex_ffa']:isInZone() then
return true
end
end
return false
end
AddEventHandler("esx:onPlayerSpawn", function()
Citizen.CreateThreadNow(function()
while not ESX.PlayerLoaded do Wait(0) end
while ESX.PlayerLoaded and not ESX.PlayerData.dead do
if IsPedDeadOrDying(ESX.PlayerData.ped, true) or IsPedFatallyInjured(ESX.PlayerData.ped) then
if not isInFFA() then
Death:Died()
break
end
end
Citizen.Wait(250)
end
end)
end)If you are using the visn_are script.
You should override the IsPlayerDamageDisabled function
function IsPlayerDamageDisabled()
if GetResourceState("hex_ffa") == "started" and exports['hex_ffa']:isInZone() then return true end
return PlayerDamageDisabled
endAnd you should add this at the bottom of the file.
local _NetworkResurrectLocalPlayer = NetworkResurrectLocalPlayer
NetworkResurrectLocalPlayer = function(...)
if GetResourceState("hex_ffa") == "started" and exports['hex_ffa']:isInZone() then return end
_NetworkResurrectLocalPlayer(...)
end