Skip to content

NPC_PutInVehicle resets skinid to CJ (0) #1297

Open

Description

@Mist3rx

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

Release version
v1.6.7.3218

Activity

  1. added
    bug
    on Nov 17, 2026
  2. GuiBoneVowt commented on Nov 22, 2026

    @GuiBoneVowt

    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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions