RU/getWeaponIDFromName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
{{Translate}}
{{Server client function}}
{{Server client function}}
Эта функция позволяет получить ID оружия из его названия.
Эта функция позволяет получить ID оружия из его названия.
Line 38: Line 39:
</section>
</section>


==See Also==
==См. также==
{{RU/Weapon functions}}
{{RU/Weapon functions}}

Revision as of 08:15, 9 July 2009

Warning.png This page requires local translation. If page will remain not translated in reasonable period of time it would be deleted.
After translating the page completely, please remove the ‎{{translate}}‎ tag from the page.

Эта функция позволяет получить ID оружия из его названия.

Синтаксис

int getWeaponIDFromName ( string name )             

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

  • name: строка содержащая название оружия.

Возвращает

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

Пример

Click to collapse [-]
Server

This example will give the player the weapon they specify 20 ammo whenever they type "weapon name" into the console.

-- Define our function that will handle this command
function consoleGiveWeapon ( playerSource, commandName, weapName )
	-- If a player triggered it (rather than the admin) then
	if ( playerSource ) then
		-- Get the weapon ID from the name
		local weapID = getWeaponIDFromName ( weapName )
		-- If it's a valid weapon
		if ( weapID ) then
		 	-- Give the weapon to the player
			giveWeapon ( playerSource, weapID, 20 )
			-- Output it in the chat box
			outputChatBox ( "You got a " .. weapName, playerSource )
		else outputChatBox ( "Invalid weapon name." )
		end
	end
end
-- Register the command handler and attach it to the 'consoleGiveWeapon' function
addCommandHandler ( "weapon", consoleGiveWeapon )

См. также

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

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

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

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

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