Scripting/Squirrel/Functions/Player.GetWeaponAtSlot

From Vice City Multiplayer
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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.

Related Functions

Player Game Functions

These functions exist for compatibility with the R2 Squirrel server.