Scripting/Server/Functions/GetWeaponID

(v0.3-r2+) Reverse of GetWeaponName / GetVehicleName: the weapon id (0-12, or 13-64 for the custom weapons of a <weapon> tag, by their name) or the vehicle model id from a name. Case, spaces and punctuation do not matter: GetWeaponID("AK-47") = 5, GetWeaponID("baseball bat") = 1, GetVehicleModel("BF Injection") = 114, GetVehicleModel("VEH_BANSHEE") = 119. Plain numbers and the WEP_ / VEH_ prefixes are accepted. Returns -1 when nothing matches.

Syntax

GetWeaponID(name)
GetVehicleModel(name)

Arguments

Returns

integer

Example

function onPlayerCommand( player, cmd, params )
{
	if ( cmd == "getweaponid" )
	{
		local result = GetWeaponID( "Example" );
		MessagePlayer( "GetWeaponID returned: " + result, player );
	}
}

This sample was generated from the signature – adapt the values to your gamemode.

Section: Maths and strings

Categories: Server functions | Maths and strings