-- Shark
Citizen.CreateThread(function()
RequestModel(GetHashKey("a_c_sharktiger"))
while not HasModelLoaded(GetHashKey("a_c_sharktiger")) do
Wait(1)
end
if Config.EnableNightclubs then
for _, item in pairs(Config.Shark) do
local npc = CreatePed(28, 0x06C3F072, item.x, item.y, item.z, item.heading, false, false)
FreezeEntityPosition(npc, false)
SetEntityInvincible(npc, false)
end
end
end)
i try to create a shark. it working for spawn a shark. but i got a problem when try to make them attack player. i try with TaskWanderStandard but it only swim around. even with TaskCombatHatedTargetsAroundPed still not working. any help?
Once a PED is spawned it will stand there and do nothing until you give it orders. If you want to make it attack the person that is swimming near it… in the client script you would need to use the function i mentioned something like
TaskCombatPed(npc, GetPlayerPed(-1), 0, 16)
This should make the shark attack the client… but you will need to but some checks in there as well… as in how far away in the client from the shark so its not trying to attack every client that gets in render distance of the shark.
So something like
sharkCoords = GetEntityCoords(npc, false)
plyCoords = GetEntityCoords(GetPlayerPed(-1), false)
dist = Vdist(plyCoords.x, plyCoords.y, plyCoords.z, npc.x, npc.y , npc.z)
if dist <= 2.0 then
TaskCombatPed(npc, GetPlayerPed(-1), 0, 16)
end
That should make the shark attack any clients that get within 2.0m but without the entire code im just going from memory this should point you in the right direction.
-- Shark
Citizen.CreateThread(function()
local model = 0x06C3F072
RequestModel(model)
while not HasModelLoaded(model) do
Citizen.Wait(10)
end
if Config.EnableNightclubs then
for _, item in pairs(Config.Shark) do
local npc = CreatePed(4, model, item.x, item.y, item.z, item.heading, false, false)
FreezeEntityPosition(npc, false)
SetEntityInvincible(npc, false)
sharkCoords = GetEntityCoords(npc, false)
plyCoords = GetEntityCoords(GetPlayerPed(-1), false)
dist = Vdist(plyCoords.x, plyCoords.y, plyCoords.z, sharkCoords.x, sharkCoords.y , sharkCoords.z)
if dist <= 20.0 then
SetPedSeeingRange(npc, 100.0)
SetPedHearingRange(npc, 80.0)
SetPedCombatAttributes(npc, 46, 1)
SetPedFleeAttributes(npc, 0, 0)
SetPedCombatRange(npc,2)
SetPedRelationshipGroupHash(npc, GetHashKey(0x06C3F072))
SetPedDiesInWater(npc, false)
SetRelationshipBetweenGroups(5,GetHashKey("PLAYER"),GetHashKey("0x06C3F072"))
SetRelationshipBetweenGroups(5,GetHashKey("0x06C3F072"),GetHashKey("PLAYER"))
TaskCombatPed(npc, GetPlayerPed(-1), 0, 16)
end
end
end
end)
i try to create a shark to attack player. but it not work. do you know how to fix it ?