Skip to content

Fix inverted seat guard in Native_PlayerExitDrone#6

Open
brandons209 wants to merge 1 commit into
Ivory42:Releasefrom
brandons209:fix/playerexitdrone-occupied-guard
Open

Fix inverted seat guard in Native_PlayerExitDrone#6
brandons209 wants to merge 1 commit into
Ivory42:Releasefrom
brandons209:fix/playerexitdrone-occupied-guard

Conversation

@brandons209

Copy link
Copy Markdown

Problem

Native_PlayerExitDrone guards the exit with the same condition as the enter native:

if (!seat.Occupied && !seat.AIControlled)
    PlayerExitVehicle(client, seat, drone);

A seated player has seat.Occupied == true (set by PlayerEnterVehicle), so !seat.Occupied is always false on exit and PlayerExitVehicle never runs. The player is never properly removed from the seat, and the resupply/respawn that PlayerExitVehicle schedules (which restores the player's weapons) never fires — the player is left weaponless.

This only affects callers that leave a seat through the PlayerExitDrone native; in-game paths that call PlayerExitVehicle directly (death, +inspect_server, drone destruction) were unaffected, which is why it went unnoticed.

Fix

Exit should run when the seat is occupied by a human:

if (seat.Occupied && !seat.AIControlled)
    PlayerExitVehicle(client, seat, drone);

One-character/condition fix, mirrors the correct intent of the enter native (which correctly requires the seat to be free).

Testing

Reproduced and verified the fix with a plugin that pilots a drone via the natives (a map prop editor): before, exiting via the native left the pilot with no weapons; after, weapons are restored on exit as expected. Normal drone gameplay (direct-exit paths) is unchanged.

Native_PlayerExitDrone guarded PlayerExitVehicle with
`if (!seat.Occupied && !seat.AIControlled)` — copy-pasted from the enter
native. A seated player has seat.Occupied == true, so the guard was always
false and PlayerExitVehicle never ran: the player was never properly
removed from the drone and the resupply/respawn that restores their
weapons never fired.

Exit should run when the seat IS occupied by a human, so the condition
should be `seat.Occupied && !seat.AIControlled`.

In-game callers that exit via PlayerExitVehicle directly were unaffected;
this only bit consumers using the PlayerExitDrone native to leave a seat.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant