Peds spawn problem


#1

I need some help here with NPC/Peds spawn

When i trigger this : CreatePed(4, 0x22911304, 122.702, -1308.935, 29.227, 0, false, true)
it spawns a ped for every player thats online, is there a way to only spawn 1 ped that every online player can see?


#2

If you look at the code signature of CREATE_PED…

Ped CREATE_PED(int pedType, Hash modelHash, float x, float y, float z, float heading, BOOL isNetwork, BOOL thisScriptCheck);

You will notice that it has an “isNetwork” flag. Since you are always setting that to false, there is no way that ped gets send over the network.


#3

even if i put that on true it still spawns a npc pr user, i use this to trigger the spawn could this be the reason?
TriggerClientEvent(“test:test”, -1)


#4

So ALL the clients spawn that ped? Are you using the server to send an event to the client to spawn that ped?


#5

Yes i´am, and thats the reason why it spawns 1 for every player online


#6

Then you probably need some logic to prevent this from happening, what would be conditions that a client must spawn a ped?


#7

I have a timer that that runs every 1 min (Test purpose), my plan is that i want a npc to change location every once a while, but right now the problem is that it spawns one pr player online.

So that question is is there a work around so it will only spawn 1 npc for the whole server.


#8

Trigger the client event to only 1 player, not every player


#9

Then other players wont be able to see the npc


#10

Like he said, just put “isNetwork” to true and other player will see it