Scripting/Squirrel/Functions/Player.GiveWeapon

From Vice City Multiplayer [MIRROR]
Jump to: navigation, search

Syntax

player.GiveWeapon( WeaponID, Ammo );

Arguments

> Player - The player instance.

  • integer WeaponID - The ID of weapon you want. you can get IDs here Weapons
  • integer Ammo - The Ammo amount you want.

<source lang=squirrel> function onPlayerCommand( player, cmd, text ); { else if ( cmd == "givewep" )

   {
   if(!text) MessagePlayer( "[#ffffff]syntax - /givewep <playerName> <wepID>", player );
   else
   {
   local params = split( text, " " ), plr = FindPlayer( params[0] ), wep = params[1];
   if(!plr) MessagePlayer( "[#ffffff]Error - invalid player", player );
   else if(!wep || GetWeaponName(wep.tointeger()) == "Unknown") MessagePlayer( "[#ffffff]Error - invalid wep ID", player );

else

{
               plr.GiveWeapon(wep.tointeger(), 500);
               MessagePlayer( "[#DC26FF]"+GetWeaponName(wep.tointeger())+" has given to you",plr);
               MessagePlayer( "[#DC26FF]"+GetWeaponName(wep.tointeger())+" has given to"+plr.Name,player);
           }
       }
   }

} </source>

Notes

Call onPlayerCommand were used in this example. More info about them in the corresponding pages.

Related Functions

Player Game Functions

These functions exist for compatibility with the R2 Squirrel server.