Can you help me with that? i’m tring to make a laboratory zone with guarding NPC. Let me know if you can help me because I’m still getting dual NPC with isNetwork true, and false it will attack each client individual. I’m using npclife script for this, i’m an id1ot on .lua, Thanks!
-- Switch Network FiveM Server Content (https://switchnetwork.co)
-- NPC Life Script: Add NPCs to set co-ordinates with many variables.
-------------------------------------------------------------------------------------------------
---------------------------------- DON'T EDIT THESES LINES --------------------------------------
-------------------------------------------------------------------------------------------------
local generalLoaded = false
local PlayingAnim = false
-------------------------------------------------------------------------------------------------
----------------------------------- YOU CAN EDIT THIS LINES -------------------------------------
-------------------------------------------------------------------------------------------------
RequestModel( GetHashKey( "S_M_Y_Dealer_01" ) )
while ( not HasModelLoaded( GetHashKey( "S_M_Y_Dealer_01" ) ) ) do
Citizen.Wait( 1 )
end
local ShopClerk = {
-- ID: id of NPC | name: Name of Blip | BlipID: Icone of Blip | VoiceName: NPC Talk When near it | Ambiance: Ambiance of Shop | Weapon: Hash of Weapon | modelHash: Model | X: Position x | Y: Position Y | Z: Position Z | heading: Where Npc look
{id = 1, name = "Dealer", BlipID = 52, VoiceName = "SHOP_BANTER_FRANKLIN", Ambiance = "AMMUCITY", Weapon = 0x1D073A89, modelHash = "S_M_Y_Dealer_01", x = -1227.4739990234, y = -1234.9270019531, z = 7.0508131980896, heading = 31.0},
{id = 2, name = "MissionRowPD", BlipID = 52, VoiceName = "GENERIC_HOWS_IT_GOING", Ambiance = "AMMUCITY", Weapon = 0x1D073A89, modelHash = "S_M_Y_Cop_01", x = 440.83297729492, y = -978.85131835938, z = 30.689601898193, heading = 184.0},
{id = 3, name = "PDArmory", BlipID = 52, VoiceName = "GENERIC_HOWS_IT_GOING", Ambiance = "ALIENS", Weapon = 0x2BE6766B, modelHash = "a_m_m_og_boss_01", x = -65.478691101074, y = 6239.8149414063, z = 31.091032028198, heading = 50.0},
-- Spawn NPC
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if (not generalLoaded) then
for i=1, #ShopClerk do
RequestModel(GetHashKey(ShopClerk[i].modelHash))
while not HasModelLoaded(GetHashKey(ShopClerk[i].modelHash)) do
Wait(1)
end
Wait(4)
ShopClerk[i].id = CreatePed(1, ShopClerk[i].modelHash, ShopClerk[i].x, ShopClerk[i].y, ShopClerk[i].z, ShopClerk[i].heading, true, false)
SetPedFleeAttributes(ShopClerk[i].id, 0, 0)
SetAmbientVoiceName(ShopClerk[i].id, ShopClerk[i].Ambiance)
SetPedDropsWeaponsWhenDead(ShopClerk[i].id, false)
SetPedDiesWhenInjured(ShopClerk[i].id, false)
GiveWeaponToPed(ShopClerk[i].id, ShopClerk[i].Weapon, 2800, false, true)
SetPedAccuracy(ShopClerk[i].id, 50)
SetPedCombatMovement(ShopClerk[i].id, 2)
SetPedSeeingRange(ShopClerk[i].id, 6.0)
SetPedHearingRange(ShopClerk[i].id, 5.0)
SetPedCombatAttributes(ShopClerk[i].id, 46, true)
SetPedRelationshipGroupHash(ShopClerk[i].id, 0x6F0783F5)
SetRelationshipBetweenGroups(5,0x6F0783F5, GetHashKey("PLAYER"))
SetRelationshipBetweenGroups(5,GetHashKey("PLAYER"), 0x6F0783F5)
SetEntityAsMissionEntity(ShopClerk[i].id,true,true)
end
generalLoaded = true
end
end
end)
-------------------------------------------------------------------------------------------------
---------------------------------- DON'T EDIT THESES LINES --------------------------------------
-------------------------------------------------------------------------------------------------
-- Action when player Near NPC (or not)
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
RequestAnimDict("random@shop_gunstore")
while (not HasAnimDictLoaded("random@shop_gunstore")) do
Citizen.Wait(0)
end
for i=1, #ShopClerk do
distance = GetDistanceBetweenCoords(ShopClerk[i].x, ShopClerk[i].y, ShopClerk[i].z, GetEntityCoords(GetPlayerPed(-1)))
if distance < 5 and PlayingAnim ~= true then
TaskPlayAnim(ShopClerk[i].id,"random@shop_gunstore","_greeting", 1.0, -1.0, 4000, 0, 1, true, true, true)
PlayAmbientSpeech1(ShopClerk[i].id, "DYING_MOAN", "SPEECH_PARAMS_FORCE", 1)
PlayingAnim = true
SetPedAsEnemy(ShopClerk[i].id, true)
Citizen.Wait(4000)
if PlayingAnim == true then
TaskPlayAnim(ShopClerk[i].id,"random@shop_gunstore","_idle_b", 1.0, -1.0, -1, 0, 1, true, true, true)
Citizen.Wait(40000)
end
else
--don't touch this
--TaskPlayAnim(ShopClerk[i].id,"random@shop_gunstore","_idle", 1.0, -1.0, -1, 0, 1, true, true, true)
end
if distance > 5.5 and distance < 6 then
PlayingAnim = false
end
end
end
end)
I’ve tried with and without native SetEntityAsMissionEntity and i dont see a difference.