Squirrel/Server/Functions/SpawnClass/AddWeapon

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
 
Line 1: Line 1:
__NOTOC__
+
{{Squirrel/Title|SpawnClass.AddWeapon}}
 
This function adds a new spawn weapon for the given slot of a ''SpawnClass''.
 
This function adds a new spawn weapon for the given slot of a ''SpawnClass''.
  

Latest revision as of 10:39, 11 October 2010

Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events

This function adds a new spawn weapon for the given slot of a SpawnClass.

[edit] Syntax

  1. int SpawnClass.AddWeapon( int weapon [, int ammo [, int slot ] ] )

[edit] Arguments

  • weapon - The weapon model to add
  • ammo - How much ammo for the spawn weapon should be added. This is an optional argument, defaults to 100 if not used
  • slot - The slot you want to set the new weapon for. There are 12 slots available. This is an optional argument, finds the first free slot by default. Returns false if no free slots are available

[edit] Example

  1.  
  2. function onPlayerCommand( player, cmd, text )
  3. {
  4. if ( cmd == "addwep" )
  5. {
  6. if ( text ) p_SpawnClass.AddWeapon( text.tointeger(), 500 );
  7. }
  8. }
  9.  

This example will add the specified weapon, with 500 ammo to the spawn class that we found earlier in FindSpawnClass.

[edit] Notes

The call onPlayerCommand was used in in this example. More info about this in the corresponding page.

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox