Scripting/Squirrel/Functions/Player.GetWeaponAtSlot

From Vice City Multiplayer
Revision as of 12:04, 13 March 2016 by VK.Angel.OfDeath (talk | contribs) (Created page with "This function is used to get the weapon ID of the weapon the player is carrying at the entered slot ID. == Syntax == <pre>Player.GetWeaponAtSlot( slot );</pre> == Arguments...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing

This function is used to get the weapon ID of the weapon the player is carrying at the entered slot ID.

Syntax

Player.GetWeaponAtSlot( slot );

Arguments

  • int slot - The weapon slot ID.

Example

function onPlayerCommand( player, cmd, text )
{
    if ( cmd == "wepslot" ) // Command for calling the function.
    {
		SlotWeapons(player); 
    }

}

/* Comments about what each Slot stores.

Slot 0: Hats, unarmed, Brass, etc...
Slot 1: Katana, chainsaw, hammer, etc...
Slot 2: Grenades, molotov, tear gas, etc...
Slot 3: Colt45, Python, etc...
Slot 4: Stubby, Spaz, Shotgun, etc...
Slot 5: Uzi, MP5, Ingram, etc...
Slot 6: M4, Ruger, etc...
Slot 7: M60, RPG, Minigun, etc...
Slot 8: Laser sniper, sniper, etc...

*/

function SlotWeapons(player)// A function containing the code.
{
	local WeaponID;
	for (local i = 0; i <= 8; i++)// Loops from slot 0 to 8.
	{
		WeaponID = player.GetWeaponAtSlot(i); // Will return the weapon ID
		MessagePlayer( "Player Weapon slot " + i + ": " + GetWeaponName(WeaponID), player ); // Displays the name of the weapons in each slot
	}
}

Notes

onPlayerCommand, GetWeaponName and MessagePlayer 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.