Scripting/Squirrel/Functions/Players/SetWeapon
From VC-MP Wiki
This function sets a weapon for a player.
Syntax
bool player.SetWeapon( int weaponID, int ammo )
Arguments
- weaponID This is the ID of the weapon
- ammo This is the ammo to be given
Example
This command gives player the weapon they request when they type '/c wep minigun'.
function onPlayerCommand( player, cmd, text ) { if ( cmd == "wep" ) { local wepid = GetWeaponID( text ); player.SetWeapon( wepid, 1000 ); MessagePlayer( "You have been given a " + GetWeaponName( wepid ) + " with 1000 ammo.", player ); } }
Example 2
This command disarms a player.
function onPlayerCommand( player, cmd, text ) { if ( cmd == "disarm" ) { player.SetWeapon( 0, 0 ); MessagePlayer("Disarmed", player); } }
Notes
The functions MessagePlayer, GetWeaponID, GetWeaponName and call onPlayerCommand were used in in this example. More info about them in corresponding pages.
Related Functions
- FindPlayer
- Player.Angle
- Player.Armour
- Player.Cash
- Player.Class
- Player.DrivebyAbility
- Player.GetSpectating
- Player.GetSyncBlockedTo
- Player.Health
- Player.ID
- Player.IP
- Player.IsAdmin
- Player.IsFrozen
- Player.IsIgnoredBy
- Player.IsMuted
- Player.IsPassenger
- Player.IsSpawned
- Player.IsSyncBlocked
- Player.IsWeaponSyncBlocked
- Player.Keys
- Player.Name
- Player.Ping
- Player.Pos
- Player.RemoveLocalMarker
- Player.RemoveMarker
- Player.ResetGameSettings
- Player.Score
- Player.Seat
- Player.SetAnim
- Player.SetDrunkLevel
- Player.SetIgnoredBy
- Player.SetInterior
- Player.SetLocalMarker
- Player.SetMarker
- Player.SetSyncBlockedTo
- Player.WantedLevel
- Player.SetWeapon
- Player.Skin
- Player.SpawnPos
- Player.Team
- Player.Vehicle
- Player.Weapon
- Player.ShootInAir
- Player.StuntMode
- Player.Spikes
