RU/GetWeaponNameFromID: Difference between revisions
Jump to navigation
Jump to search
Enterprise (talk | contribs) No edit summary |
m (→Пример) |
||
Line 20: | Line 20: | ||
function scriptOnPlayerWasted ( totalammo, killer, killerweapon, bodypart ) --when a player dies | function scriptOnPlayerWasted ( totalammo, killer, killerweapon, bodypart ) --when a player dies | ||
local causeOfDeath = getWeaponNameFromID ( killerweapon ) --get the name of 'killerweapon' and define it as 'causeOfDeath' | local causeOfDeath = getWeaponNameFromID ( killerweapon ) --get the name of 'killerweapon' and define it as 'causeOfDeath' | ||
local killedPerson = | local killedPerson = getPlayerName ( source ) --get the name of the player who died and define it as 'killedPerson' | ||
if ( killer ) then --if there was a killer | if ( killer ) then --if there was a killer | ||
local killerPerson = | local killerPerson = getPlayerName ( killer ) --get the name of the killer and define it as 'killerPerson' | ||
if ( killer == source ) then --if the killer is the same as the person who died i.e. he killed himself | if ( killer == source ) then --if the killer is the same as the person who died i.e. he killed himself | ||
outputChatBox ( "* "..killerPerson.." died ("..causeOfDeath..")", getRootElement(), 255, 100, 100 ) --output in the chatbox that he died and the method he died in the brackets | outputChatBox ( "* "..killerPerson.." died ("..causeOfDeath..")", getRootElement(), 255, 100, 100 ) --output in the chatbox that he died and the method he died in the brackets |
Revision as of 12:14, 27 August 2009
Эта функция позволяет получить название оружия из его ID. Примечание: Она также позволяет получить причину смерти, например Fall и Rammed.
Синтаксис
string getWeaponNameFromID ( int id )
Необходимые аргументы
- id: ID из которого вы хотите получить название.
Returns
Возвращает string с названием оружия если успешно, в противном случае - false.
Пример
Click to collapse [-]
ServerЭтот пример показывает сообщение о смерти типа "* Вася убил Петю (Оружие)"
function scriptOnPlayerWasted ( totalammo, killer, killerweapon, bodypart ) --when a player dies local causeOfDeath = getWeaponNameFromID ( killerweapon ) --get the name of 'killerweapon' and define it as 'causeOfDeath' local killedPerson = getPlayerName ( source ) --get the name of the player who died and define it as 'killedPerson' if ( killer ) then --if there was a killer local killerPerson = getPlayerName ( killer ) --get the name of the killer and define it as 'killerPerson' if ( killer == source ) then --if the killer is the same as the person who died i.e. he killed himself outputChatBox ( "* "..killerPerson.." died ("..causeOfDeath..")", getRootElement(), 255, 100, 100 ) --output in the chatbox that he died and the method he died in the brackets else --if the killer is not the same as the person who died outputChatBox ( "* "..killerPerson.." killed "..killedPerson.." ("..causeOfDeath..")", getRootElement(), 255, 100, 100 ) --output in the chatbox that he was killed by the killer and the method in brackets end else --if there was no killer outputChatBox ( "* "..killedPerson .. " died (" ..causeOfDeath..")", getRootElement(), 255, 100, 100 ) --output in the chatbox that the person died and how he died end end addEventHandler ( "onPlayerWasted", getRootElement(), scriptOnPlayerWasted ) --add an event handler for onPlayerWasted
See Also
- getWeaponProperty
- getPickupWeapon
- getOriginalWeaponProperty
- getSlotFromWeapon
- getWeaponIDFromName
- getWeaponNameFromID
- setWeaponAmmo
- setWeaponProperty