Skip to content

Fix ped.dead OOP property killing peds when set to false - #5551

Open
DrWellsy wants to merge 1 commit into
multitheftauto:masterfrom
DrWellsy:fix/ped-dead-oop-kill
Open

DrWellsy wants to merge 1 commit into
multitheftauto:masterfrom
DrWellsy:fix/ped-dead-oop-kill

Conversation

@DrWellsy

Copy link
Copy Markdown

Summary of Changes

Previously, the dead property in the Server OOP Ped class mapped directly to killPed as its setter without verifying the assigned boolean value (lua_classvariable(luaVM, "dead", "killPed", "isPedDead")).

Because killPed expects (element ped, [element killer, int weapon, int bodypart, bool stealth]), assigning false (e.g. ped.dead = false) passed false into the killer argument, causing the ped to be killed regardless.

This PR:

  1. Introduces CLuaPedDefs::OOP_KillPed (declared via LUA_DECLARE_OOP(KillPed)).
  2. Ensures that ped.dead = true safely calls KillPed(pElement).
  3. Ensures that ped.dead = false does not kill the ped, and outputs a descriptive warning (Cannot set 'dead' property to false).
  4. Resolves the TODO(qaisjp) comment in CLuaPedDefs.cpp.

Testing

  • Successfully compiled Deathmatch.vcxproj (Release Win32) with 0 errors and 0 warnings.
  • Verified parameter reading and assignment logic via CScriptArgReader.

Setting the dead property on peds previously invoked killPed directly regardless of the boolean value passed, causing ped.dead = false to kill the ped instead of keeping them alive.

This introduces OOP_KillPed to ensure that setting ped.dead only kills the ped when passed true, and logs a warning when attempting to set it to false (as peds cannot be revived via this property).

Resolves TODO left in CLuaPedDefs.cpp.
Copilot AI balanced review requested due to automatic review settings November 10, 2026 17:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@FileEX FileEX added the bugfix Solution to a bug of any kind label Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Solution to a bug of any kind

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants