KillPed: Difference between revisions
Jump to navigation
Jump to search
m (First example is the same thing) |
Zangomangu (talk | contribs) (Removed fixed issue) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{Shared function}} | ||
__NOTOC__ | __NOTOC__ | ||
This function kills the specified ped. | This function kills the specified ped. | ||
{{New feature/item|3.0153|1.5.3|7848| | |||
From v1.5.3 onwards this function is now available client side. Only works on client side peds. | |||
}} | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">bool killPed ( ped thePed, [ ped theKiller = nil, int weapon=255, int bodyPart=255, bool stealth = false ] )</syntaxhighlight> | <syntaxhighlight lang="lua">bool killPed ( ped thePed, [ ped theKiller = nil, int weapon=255, int bodyPart=255, bool stealth = false ] )</syntaxhighlight> | ||
{{OOP||[[ped]]:kill}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 11: | Line 16: | ||
===Optional Arguments=== | ===Optional Arguments=== | ||
* '''theKiller:''' The ped responsible for the kill | * '''theKiller:''' The ped responsible for the kill | ||
* '''weapon:''' The ID of the weapon that should appear to have killed the ped (doesn't affect how they die) | * '''weapon:''' The ID of the [[weapon]] or [[Damage Types]] that should appear to have killed the ped (doesn't affect how they die) | ||
* '''bodyPart:''' The ID of the body part that should appear to have been hit by the weapon (doesn't affect how they die) | * '''bodyPart:''' The ID of the body part that should appear to have been hit by the weapon (doesn't affect how they die) | ||
{{BodyParts}} | {{BodyParts}} |
Latest revision as of 10:28, 30 January 2022
This function kills the specified ped.
From v1.5.3 onwards this function is now available client side. Only works on client side peds.
Syntax
bool killPed ( ped thePed, [ ped theKiller = nil, int weapon=255, int bodyPart=255, bool stealth = false ] )
OOP Syntax Help! I don't understand this!
- Method: ped:kill(...)
Required Arguments
- thePed: The ped to kill
Optional Arguments
- theKiller: The ped responsible for the kill
- weapon: The ID of the weapon or Damage Types that should appear to have killed the ped (doesn't affect how they die)
- bodyPart: The ID of the body part that should appear to have been hit by the weapon (doesn't affect how they die)
- 3: Torso
- 4: Ass
- 5: Left Arm
- 6: Right Arm
- 7: Left Leg
- 8: Right Leg
- 9: Head
- stealth: Boolean value, representing whether or not this a stealth kill
Returns
Returns true if the ped was killed, false if the ped specified could not be killed or is invalid.
Example
Example 1: This simple example adds a kill command to commit suicide.
function commitSuicide ( sourcePlayer ) -- kill the player and make him responsible for it killPed ( sourcePlayer, sourcePlayer ) end -- attach our handler to the "kill" command addCommandHandler ( "kill", commitSuicide )
Example 2: This example enables 1 hit kills if a player is shot in the head.
function headshotKill ( attacker, attackerweapon, bodypart, loss ) if bodypart == 9 then --if the bodypart is the head --kill the player, emulating the correct killer, weapon and bodypart. killPed ( source, attacker, attackerweapon, bodypart ) end end addEventHandler ( "onPlayerDamage", getRootElement(), headshotKill )
See Also
- addPedClothes
- getPedClothes
- removePedClothes
- createPed
- getPedAmmoInClip
- getPedArmor
- getPedFightingStyle
- getPedOccupiedVehicle
- getPedOccupiedVehicleSeat
- getPedStat
- getPedTarget
- getPedTotalAmmo
- getPedWalkingStyle
- getPedWeapon
- getPedWeaponSlot
- getPedContactElement
- getValidPedModels
- isPedChoking
- isPedDead
- isPedDoingGangDriveby
- isPedDucked
- isPedHeadless
- isPedInVehicle
- isPedOnFire
- isPedOnGround
- isPedWearingJetpack
- killPed
- removePedFromVehicle
- setPedAnimation
- setPedAnimationProgress
- setPedAnimationSpeed
- setPedArmor
- setPedDoingGangDriveby
- setPedFightingStyle
- setPedHeadless
- setPedOnFire
- setPedStat
- setPedWalkingStyle
- setPedWeaponSlot
- warpPedIntoVehicle