c
Hello there. I'm kinda new to NPCs. I'm using FCNPC. My question is, is there any way to stop/pause the NPC's vehicle when a player stands in front of them? More like they'd avoid accidents with players. I can't seem to figure out the problem.
f
You must create a timer that get front position of vehicle and check if any player in range of this position then using FCNPC_Stop/FCNPC_PausePlayingNode/FCNPC_PausePlayingPlayback (depend on your npc move method) to make it stop and resume after there is no player in front of this npc path
I suggest using per npc timer, about 50-80miliseconds per timer is good if you want they have good react time
c
Can you tell me how to get "front position of vehicle". Also, what did you mean by per npc timer?
f
For front position of npc, you can use this function stock GetXYInFrontOfNPC(npcid, &Float:x, &Float:y, Float:distance) { // Created by Y_Less new Float:a, vehid = FCNPC_GetVehicleID(npcid); FCNPC_GetPosition(npcid, x, y, a); if(!vehid) a = FCNPC_GetAngle(npcid); else GetVehicleZAngle(vehid, a); x += (distance * floatsin(-a, degrees)); y += (distance * floatcos(-a, degrees)); }
And per npc timer mean you create one timer per npc you use in game, instead of loop through them pool with one timer. Like you have 50 npc in sv and 20 of these is driving npc, have to create 20 timer which run when ever they spawn and destroy the timer when ever they despawn or something
2 Views