Skip to content

Commit

Permalink
Merge pull request #978 from bitpredator/dev
Browse files Browse the repository at this point in the history
fix:  removed the GiveWeaponToPed
  • Loading branch information
bitpredator authored Feb 9, 2025
2 parents 71e9573 + 9afcda9 commit 7bde9c3
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ if GetResourceState('es_extended') ~= 'started' then return end

local ESX = exports["es_extended"]:getSharedObject()

function isBlacklistedJob(jobs)
function IsBlacklistedJob(jobs)
local Player = ESX.GetPlayerData()
if type(jobs) == 'table' then
for x = 1, #jobs do
Expand Down
19 changes: 11 additions & 8 deletions server-data/resources/[esx_addons]/xt-robnpcs/bridge/client/ox.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
if GetResourceState('ox_core') ~= 'started' then return end
if GetResourceState("ox_core") ~= "started" then
return
end

local file = ('imports/%s.lua'):format(IsDuplicityVersion() and 'server' or 'client')
local import = LoadResourceFile('ox_core', file)
local chunk = assert(load(import, ('@@ox_core/%s'):format(file)))
local file = ("imports/%s.lua"):format(IsDuplicityVersion() and "server" or "client")
local import = LoadResourceFile("ox_core", file)
local chunk = assert(load(import, ("@@ox_core/%s"):format(file)))
local player
chunk()

function isBlacklistedJob(jobs)
function IsBlacklistedJob(jobs)
return player.hasGroup(jobs)
end

AddEventHandler('ox:playerLogout', function()
TriggerEvent('xt-robnpcs:client:onUnload')
end)
AddEventHandler("ox:playerLogout", function()
TriggerEvent("xt-robnpcs:client:onUnload")
end)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ if GetResourceState('qb-core') ~= 'started' then return end

local QBCore = exports['qb-core']:GetCoreObject()

function isBlacklistedJob(jobs)
function IsBlacklistedJob(jobs)
local Player = QBCore.Functions.GetPlayerData()
if type(jobs) == 'table' then
for x = 1, #jobs do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
if GetResourceState('ox_core') ~= 'started' then return end
if GetResourceState("ox_core") ~= "started" then
return
end

local file = ('imports/%s.lua'):format(IsDuplicityVersion() and 'server' or 'client')
local import = LoadResourceFile('ox_core', file)
local chunk = assert(load(import, ('@@ox_core/%s'):format(file)))
local file = ("imports/%s.lua"):format(IsDuplicityVersion() and "server" or "client")
local import = LoadResourceFile("ox_core", file)
local chunk = assert(load(import, ("@@ox_core/%s"):format(file)))
chunk()

function getPlayer(id)
Expand All @@ -12,4 +14,4 @@ end
function getPlayerJob(src)
local player = getPlayer(src)
return player and player.getGroup() or nil
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ end

-- Handlers --
lib.onCache('weapon', function(newWeapon)
if not newWeapon or not isAllowedWeapon(newWeapon) or isBlacklistedJob(config.blacklistedJobs) then return end
if not newWeapon or not isAllowedWeapon(newWeapon) or IsBlacklistedJob(config.blacklistedJobs) then return end

aimAtPedsLoop(newWeapon)
end)
Expand Down
13 changes: 6 additions & 7 deletions server-data/resources/[esx_addons]/xt-robnpcs/client/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,19 @@ function attackingPed(entity)
ClearPedTasksImmediately(entity)
end

SetPedFleeAttributes(entity, 0, 0)
SetPedCombatAttributes(entity, 46, 1) -- BF_CanFightArmedPedsWhenNotArmed
SetPedCombatAttributes(entity, 17, 0) -- BF_AlwaysFlee
SetPedCombatAttributes(entity, 5, 1) -- BF_AlwaysFight
SetPedCombatAttributes(entity, 58, 1) -- BF_DisableFleeFromCombat
SetPedFleeAttributes(entity, 0, false)
SetPedCombatAttributes(entity, 46, true) -- BF_CanFightArmedPedsWhenNotArmed
SetPedCombatAttributes(entity, 17, false) -- BF_AlwaysFlee
SetPedCombatAttributes(entity, 5, true) -- BF_AlwaysFight
SetPedCombatAttributes(entity, 58, true) -- BF_DisableFleeFromCombat
SetPedCombatRange(entity, 3)
SetPedRelationshipGroupHash(entity, joaat('HATES_PLAYER'))
TaskCombatHatedTargetsAroundPed(entity, 50, 0)

local weaponChance = math.random(config.chancePedIsArmedWhileFighting.min, config.chancePedIsArmedWhileFighting.max)
local randomChance2 = math.random(100)
if randomChance2 <= weaponChance then
local randomWeapon = math.random(#config.pedWeapons)
GiveWeaponToPed(entity, config.pedWeapons[randomWeapon], false, false)
local _ = math.random(#config.pedWeapons)
end

TaskCombatHatedTargetsAroundPed(entity, 50, 0)
Expand Down

0 comments on commit 7bde9c3

Please sign in to comment.