Scripting/Squirrel/Functions/Misc/GetWeaponID

From VC-MP Wiki

Jump to: navigation, search

This function returns the weapon ID from the name.

Syntax

int GetWeaponID( string weapon )

Arguments

  • weapon This is the name of the weapon

Example

This command gives player the weapon they request when they type '/c wep minigun'.

function onPlayerCommand( player, cmd, text )
{
     if ( cmd == "wep" )
     {
          local wepid = GetWeaponID( text );
          
          player.SetWeapon( wepid, 1000 );
          MessagePlayer( "You have been given a " + GetWeaponName( wepid ) + " with 1000 ammo.", player );
     }
}

Notes

The functions MessagePlayer, player.SetWeapon, GetWeaponName and call onPlayerCommand were used in in this example. More info about them in corresponding pages.

Related Functions

Personal tools
squirrel scripting