Repository navigation
Description
1. NPC_SetPos may remove bot from vehicle
The first issue with NPC_SetPos native: when you teleported an NPC which was in car by FCNPC plugin, this bot always teleported right with his vehicle and continued to be in it on the new position set: https://github.com/ziggi/FCNPC/blob/master/src/CPlayerData.cpp#L997-L1004
But in omp implementation, an NPC may be either teleported without the vehicle or the vehicle may stay at the old position until re-stream, and it cannot be solved by using SetVehiclePos because this function doesn't work when NPC is a driver of the vehicle. So NPC_SetPos must always teleport an NPC who's a driver of this vehicle together with this vehicle, just like in FCNPC.
Test script where you can compare the behavior in-game: FCNPC / omp NPCs variant
2. NPC doesn't call vehicle events like death or respawn
If you apply NPC_SetVehicleHealth for a driver NPC and set any low health value for his vehicle like 150.0 or 0.0 when it starts firing and finally explode, still no OnVehicleDeath will be called, nor OnVehicleSpawn after a while too. Looks like this vehicle will explode and disappear only clientside, but not serverside. NPC will just stay at the same place without a car, moreover without his own death and respawn.
Test script where you can compare the behavior in-game: FCNPC / omp NPCs variant
3. NPC_EnableInfiniteAmmo has no effect if NPC_SetAmmo wasn't used
If an NPC has weapon with 0 ammo and you try to use NPC_EnableInfiniteAmmo, he still won't shoot any bullets:
NPC_SetWeapon(npcid, random(3) + 22);
NPC_EnableInfiniteAmmo(npcid, true);
NPC_AimAtPlayer(npcid, playerid, .shoot = true);but when you set this NPC at least 1 or more bullets with NPC_SetAmmo, he immediately start shooting:
NPC_SetWeapon(npcid, random(3) + 22);
NPC_SetAmmo(npcid, 1); // or 5, or 999
NPC_EnableInfiniteAmmo(npcid, true);
NPC_AimAtPlayer(npcid, playerid, .shoot = true);while FCNPC correctly handle even the first case
Activity
[-]NPC_SetPos removed bot from vehicle[/-][+]NPC_SetPos removes bot from vehicle[/+][-]NPC_SetPos removes bot from vehicle[/-][+]A couple of issues found with new NPCs[/+]ziggi commentedon Dec 28, 2025
Isn't that how SetPlayerPos works? I think the implementation in FCNPC is incorrect.
NexiusTailer commentedon Dec 28, 2025
Sure, but we have a different case with players comparing to NPCs:
As I already mentioned above, we cannot use SetVehiclePos on a vehicle with NPC as driver. So the easiest fix is to let teleporting NPCs with their vehicle by existing NPC_SetPos (and thus we will actually have to eject NPC from car to teleport just him without this car, like it is in FCNPC now), or make the logic identical as when working with players and add new
NPC_SetVehiclePosfunction.Anyway thanks for notice as now there's some choice of how to solve this better.
ziggi commentedon Dec 28, 2025
If it is not possible to change the behavior of the SetVehiclePos function to support NPC as driver (for compatibility reasons or something else), then yes, it is better to add something like
NPC_SetVehiclePos.AmyrAhmady commentedon Jan 7, 2026
can you please test this for NPC_SetVehiclePos? (and NPC_SetVehicleRot)
https://github.com/openmultiplayer/open.mp/actions/runs/20794996896
NexiusTailer commentedon Jan 8, 2026
Tested the build #1182 and now can say that
NPC_SetVehiclePosandNPC_SetVehicleRotworks good.But
NPC_SetPosseems broken now: it doesn't teleport an NPC which is in vehicle, now at all. Visually this NPC keep staying in his vehicle on the previous vehicle position. Also if I look at sobeit custom nametags which show NPCs, he starts eing "AFK" in this vehicle afterNPC_SetPoswas used on him.My current test script: https://pastebin.com/NPTN1iFz
NexiusTailer commentedon Jan 28, 2026
Issue with
NPC_SetPosapplied to NPC vehicle driver now solved after #1182, but since there wereNPC_SetVehiclePosandNPC_SetVehicleRotadded, would be great to also have their counterparts (getter functions)AmyrAhmady commentedon Jan 28, 2026
Create a new issue for getter functions, I'm going to close this one