PL/getBodyPartName

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Ta funkcja służy do pobrania nazwy części ciała gracza.

Składnia

string getBodyPartName ( int bodyPartID )

Wymagane argumenty

  • bodyPartID: Liczba całkowita reprezentująca część ciała którego nazwę chcesz pobrać.
  • 3: Torso
  • 4: Ass
  • 5: Left Arm
  • 6: Right Arm
  • 7: Left Leg
  • 8: Right Leg
  • 9: Head

Wartości zwrotne

Funkcja zwraca nazwę części ciała jeśli ID jest prawidłowe, w innym przypadu zwraca false.

Przykład

Przykład wyświetla zabójcę i część ciała po wywołaniu zdarzenia onPlayerWasted

function deathMessageOnWasted ( ammo, attacker, weapon, bodypart )
  if ( attacker ) then                                    -- jeśli jest atakujący
    if ( getElementType ( attacker ) == "player" ) then   -- upewnijmy się że zabójca to gracz
      tempString = getPlayerName ( attacker ) .. " zabija " .. getPlayerName ( source ) .. " (" .. getWeaponNameFromID ( weapon ) .. ")"
      if ( bodypart == 9 ) then -- jeśli strzał był w głowę
        tempString = tempString .. " (HEADSHOT!)"
      else
        tempString = tempString .. " (" .. getBodyPartName ( bodypart ) .. ")"
      end
      outputChatBox ( tempString )
    else
      outputChatBox ( getPlayerName ( source ) .. " umiera. (" .. getWeaponNameFromID ( weapon ) .. ") (" .. getBodyPartName ( bodypart ) .. ")" )
    end
  else
    outputChatBox ( getPlayerName ( source ) .. " umiera. (" .. getWeaponNameFromID ( weapon ) .. ") (" .. getBodyPartName ( bodypart ) .. ")" )
  end
end
addEventHandler ( "onPlayerWasted", root, deathMessageOnWasted )

Zobacz także