HU/getBodyPartName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Server client function}} __NOTOC__ This function is used to get the name of a body part on a player. ==Syntax== <syntaxhighlight lang="lua"> string getBodyPartName ( int bo...")
 
No edit summary
Line 1: Line 1:
{{Server client function}}
{{Shared function hu}}
__NOTOC__
__NOTOC__
This function is used to get the name of a body part on a player.
This function is used to get the name of a body part on a player.


==Syntax==
==Szintaxis==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string getBodyPartName ( int bodyPartID )
string getBodyPartName ( int bodyPartID )
</syntaxhighlight>
</syntaxhighlight>


===Required Arguments===
===Kötelező paraméterek===
*'''bodyPartID''': An integer representing the body part ID you wish to retrieve the name of.
*'''bodyPartID''': An integer representing the body part ID you wish to retrieve the name of.
{{BodyParts}}
{{BodyParts}}


==Returns==
==Visszatérési érték==
This function returns a string containing the body part name if the ID is valid, ''false'' otherwise.
This function returns a string containing the body part name if the ID is valid, ''false'' otherwise.


==Example==
==Példa==
This example prints the killer and body part to the chat on the wasted/kill event.
This example prints the killer and body part to the chat on the wasted/kill event.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 40: Line 40:
==Lásd még==
==Lásd még==
{{Clothes and body functions}}
{{Clothes and body functions}}
==Fordította==
* '''''[https://wiki.multitheftauto.com/wiki/User:Surge Surge]'''''


[[en:getBodyPartName]]
[[en:getBodyPartName]]
[[PL:GetBodyPartName]]
[[PL:GetBodyPartName]]

Revision as of 21:45, 17 September 2018

This function is used to get the name of a body part on a player.

Szintaxis

string getBodyPartName ( int bodyPartID )

Kötelező paraméterek

  • bodyPartID: An integer representing the body part ID you wish to retrieve the name of.
  • 3: Torso
  • 4: Ass
  • 5: Left Arm
  • 6: Right Arm
  • 7: Left Leg
  • 8: Right Leg
  • 9: Head

Visszatérési érték

This function returns a string containing the body part name if the ID is valid, false otherwise.

Példa

This example prints the killer and body part to the chat on the wasted/kill event.

function deathMessageOnWasted ( ammo, attacker, weapon, bodypart )
  if ( attacker ) then                                    -- if we have an attacker
    if ( getElementType ( attacker ) == "player" ) then   -- make sure the element that killed him was a player
      tempString = getPlayerName ( attacker ) .. " killed " .. getPlayerName ( source ) .. " (" .. getWeaponNameFromID ( weapon ) .. ")"
      if ( bodypart == 9 ) then -- if he was shot in the head
        tempString = tempString .. " (HEADSHOT!)"
      else
        tempString = tempString .. " (" .. getBodyPartName ( bodypart ) .. ")"
      end
      outputChatBox ( tempString )
    else
      outputChatBox ( getPlayerName ( source ) .. " died. (" .. getWeaponNameFromID ( weapon ) .. ") (" .. getBodyPartName ( bodypart ) .. ")" )
    end
  else
    outputChatBox ( getPlayerName ( source ) .. " died. (" .. getWeaponNameFromID ( weapon ) .. ") (" .. getBodyPartName ( bodypart ) .. ")" )
  end
end
addEventHandler ( "onPlayerWasted", root, deathMessageOnWasted )

Lásd még


Fordította