RU/getWeaponNameFromID: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 20: Line 20:
function scriptOnPlayerWasted ( totalammo, killer, killerweapon, bodypart ) --когда игрок умирает
function scriptOnPlayerWasted ( totalammo, killer, killerweapon, bodypart ) --когда игрок умирает
local causeOfDeath = getWeaponNameFromID ( killerweapon ) --получаем оружие убийцы ('killerweapon') и объявляем его как причину смерти ('causeOfDeath')
local causeOfDeath = getWeaponNameFromID ( killerweapon ) --получаем оружие убийцы ('killerweapon') и объявляем его как причину смерти ('causeOfDeath')
local killedPerson = getClientName ( source ) --get the name of the player who died and define it as 'killedPerson'
local killedPerson = getClientName ( source ) --получаем имя убитого игрока и объявляем его как 'killedPerson'
if ( killer ) then --if there was a killer
if ( killer ) then -- если игрок убит убийцей
local killerPerson = getClientName ( killer ) --get the name of the killer and define it as 'killerPerson'
local killerPerson = getClientName ( killer ) --получаем имя убийцы и объявляем его как '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 --если убийца является и убитым одновременно, то он убил сам себя(самоубийство)
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
else --if the killer is not the same as the person who died
else --if the killer is not the same as the person who died

Revision as of 09:02, 9 July 2009

Эта функция позволяет получить название оружия из его ID. Примечание: она также позволяет получить причину смерти, такие как Разбился и Утонул.

Синтаксис

string getWeaponNameFromID ( int id )            

Необходимые аргументы

  • id: ID оружия название которого хотите получить.

Возвращает

Возвращает строку с названием оружия, в противном случае false.

Пример

Click to collapse [-]
Server

Пример показывает вывод сообщения о смерти игрока в виде: "* Убийца убил жертву (Оружие)"

function scriptOnPlayerWasted ( totalammo, killer, killerweapon, bodypart ) --когда игрок умирает
	local causeOfDeath = getWeaponNameFromID ( killerweapon ) --получаем оружие убийцы ('killerweapon') и объявляем его как причину смерти ('causeOfDeath')
	local killedPerson = getClientName ( source ) --получаем имя убитого игрока и объявляем его как 'killedPerson'
	if ( killer ) then -- если игрок убит убийцей
	local killerPerson = getClientName ( killer ) --получаем имя убийцы и объявляем его как 'killerPerson'
		if ( killer == source ) then --если убийца является и убитым одновременно, то он убил сам себя(самоубийство)
			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

См. также

Список ID оружия

Серверные функции

  • giveWeapon - дает указанное оружие игроку или пешеходу
  • takeAllWeapons - удаляет всё оружие с указанного игрока или пешехода
  • takeWeapon - удаляет указанное оружие или боеприпасы с игрока или пешехода
ДО ВЕРСИИ 1.3.1 :
  • takeWeaponAmmo - удаляет определённое кол-во боеприпасов у игрока для указанного оружия
  • giveWeaponAmmo - даёт определённое кол-во боеприпасов игроку для указанного оружия

Клиентские функции

Общие функции

  • getOriginalWeaponProperty - получает исходное свойство указанного типа оружия
  • getPickupWeapon - получает ID оружия из указанного пикапа
  • getSlotFromWeapon - получает слот к которому принадлежит оружие
  • getWeaponIDFromName - получает ID оружия из его названия
  • getWeaponNameFromID - получает название оружия или причину смерти из его ID
  • getWeaponProperty - получает свойство указанного оружия
  • setWeaponAmmo - устанавливает определенное кол-во боеприпасов для указанного оружия
  • setWeaponProperty - устанавливает свойство указанного типа оружия