You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If i use the function NPC_PutInVehicle, the npc gets always the skinid 0.
Even if i set the skin to something else, after NPC_PutInVehicle, it gets set to 0.
But with NPC_EnterVehicle its working.
Expected behavior
It should have his current skinid
Found the cause. NPC::putInVehicle calls spawn() when the NPC isn't on foot, and spawn() puts the class skin back (0 by default), sets health to 100, takes the weapon away and calls OnNPCSpawn again. NPC_EnterVehicle doesn't go through that, which is why it keeps the skin.
On master (72bf89c), with skin 100, health 50 and a Deagle set first, it happens in two cases:
NPC_PutInVehicle right after NPC_Spawn, where the state is still PlayerState_Spawned
the NPC is already in a car and gets NPC_PutInVehicle into another one
#1282 already skips PlayerState_Spawned there, so it fixes the first one (tested, skin 100 and OnNPCSpawn once), but the second still ends up with skin 0, health 100, no weapon and a second OnNPCSpawn.
Only spawning when the NPC isn't spawned yet or is dead covers both. On top of #1282:
- if (state != PlayerState_OnFoot && state != PlayerState_Spawned && spawning_ == false)+ if ((state == PlayerState_None || state == PlayerState_Wasted) && spawning_ == false)
With that both cases keep skin 100, health 50 and the Deagle, a dead NPC still gets spawned into the car, and the crash cases from #1282 still pass. In the "seated in A, put into B, OnPlayerSpawn destroys B" case it now just moves the NPC into B, since there's no spawn anymore, instead of returning false. @r4sheed maybe worth folding into #1282?
Activity
GuiBoneVowt commentedon Nov 22, 2026
Found the cause. NPC::putInVehicle calls spawn() when the NPC isn't on foot, and spawn() puts the class skin back (0 by default), sets health to 100, takes the weapon away and calls OnNPCSpawn again. NPC_EnterVehicle doesn't go through that, which is why it keeps the skin.
On master (72bf89c), with skin 100, health 50 and a Deagle set first, it happens in two cases:
#1282 already skips PlayerState_Spawned there, so it fixes the first one (tested, skin 100 and OnNPCSpawn once), but the second still ends up with skin 0, health 100, no weapon and a second OnNPCSpawn.
Only spawning when the NPC isn't spawned yet or is dead covers both. On top of #1282:
With that both cases keep skin 100, health 50 and the Deagle, a dead NPC still gets spawned into the car, and the crash cases from #1282 still pass. In the "seated in A, put into B, OnPlayerSpawn destroys B" case it now just moves the NPC into B, since there's no spawn anymore, instead of returning false. @r4sheed maybe worth folding into #1282?