ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. getWeaponIDFromName

Function

getWeaponIDFromName

Server and clientWeaponsIdentical to MTA:SA

Returns a weapon ID from its name. Case does not matter, and a numeric string ("30") works too.

Syntax

int getWeaponIDFromName(string name)

Arguments

namestring
Weapon name, e.g. "M4".

Returns

Weapon ID or false.

Example

addCommandHandler("bron", function(player, cmd, name)
    local id = getWeaponIDFromName(name or "")
    if id then
        giveWeapon(player, id, 200, true)
    else
        outputChatBox("Nie znam takiej broni.", player)
    end
end)

See also