Scripting/Squirrel/Functions/Player.GetAmmoAtSlot

From Vice City Multiplayer
Revision as of 14:09, 2 October 2018 by Human. (talk | contribs) (Created page with "This function is used to get the ammo of the weapon that player is carrying at the entered slot ID. == Syntax == <pre>Player.GetAmmoAtSlot( 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 ammo of the weapon that player is carrying at the entered slot ID.

Syntax

Player.GetAmmoAtSlot( slot );

Arguments

  • int slot - The weapon slot ID.

Example

/* 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 onPlayerCommand( player, cmd, text )
{
	if ( cmd == "myweps" || cmd == "mywep" )
	{
		local wepID, wepAmmo;

		for (local i = 0; i <= 8; i++)// Loops from slot 0 to 8.
		{
			wepID = player.GetWeaponAtSlot(i); // Will return the weapon's ID
			wepAmmo = player.GetAmmoAtSlot(i); // Will return the weapon's ammo

			// Displays the weapon's name and ammo of each slot( 0 - 8 )
			MessagePlayer( "Weapon at slot " + i + ": "+ GetWeaponName(wepID) +" (ammo: "+ wepAmmo +")", player ); 
		} 
	}
}

Notes

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