SetPlayerWeaponSlot: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(9 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
This function sets the | {{Server client function}} | ||
{{Deprecated}} | |||
Please use [[setPedWeaponSlot]] | |||
This function sets the player's weapon slot. This affects the current weapon. | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool | bool setPlayerWeaponSlot ( player theplayer, int weapon_slot ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''weapon_slot:''' weapon slot to set | *'''theplayer:''' the [[player]] whose weapon slot you want to set. In a clientside script, this can only be the local player. | ||
*'''weapon_slot:''' the weapon slot to set. | |||
{{Weapon_Slots}} | {{Weapon_Slots}} | ||
===Returns=== | ===Returns=== | ||
Returns ''true'' | Returns ''true'' if successful in setting the player's equipped weapon slot, ''false'' otherwise. | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | <section name="Server" class="server" show="true"> | ||
This example allows the player to type the command 'giveweapons', which gives the player a weapon for every slot. Instead of equipping the last given weapon, the script randomly decides which weapon to equip after all the weapons are given. | |||
<syntaxhighlight lang="lua">function givePlayerWeapons ( player, commandName ) | |||
--Give the player a weapon for each slot | |||
giveWeapon ( player, 1, 1 ) | |||
giveWeapon ( player, 2, 1 ) | |||
giveWeapon ( player, 22, 1 ) | |||
giveWeapon ( player, 25, 1 ) | |||
giveWeapon ( player, 28, 1 ) | |||
giveWeapon ( player, 30, 1 ) | |||
giveWeapon ( player, 33, 1 ) | |||
giveWeapon ( player, 35, 1 ) | |||
giveWeapon ( player, 16, 1 ) | |||
giveWeapon ( player, 42, 1 ) | |||
giveWeapon ( player, 10, 1 ) | |||
giveWeapon ( player, 44, 1 ) | |||
giveWeapon ( player, 40, 1 ) | |||
--Randomly select which weapon to equip, slots 1 through 12 | |||
setPlayerWeaponSlot ( player, math.random ( 1, 12) ) | |||
end | |||
addCommandHandler ( "giveweapons", givePlayerWeapons )</syntaxhighlight> | |||
</section> | |||
==See Also== | ==See Also== | ||
{{Player functions}} |
Latest revision as of 21:38, 20 April 2011
This function is deprecated. This means that its use is discouraged and that it might not exist in future versions, but there should be a more generic way to perform what it does. | |
Please use setPedWeaponSlot
This function sets the player's weapon slot. This affects the current weapon.
Syntax
bool setPlayerWeaponSlot ( player theplayer, int weapon_slot )
Required Arguments
- theplayer: the player whose weapon slot you want to set. In a clientside script, this can only be the local player.
- weapon_slot: the weapon slot to set.
Weapon Slots
- 0: WEAPONSLOT_TYPE_UNARMED
- 1: WEAPONSLOT_TYPE_MELEE
- 2: WEAPONSLOT_TYPE_HANDGUN
- 3: WEAPONSLOT_TYPE_SHOTGUN
- 4: WEAPONSLOT_TYPE_SMG (used for driveby's)
- 5: WEAPONSLOT_TYPE_RIFLE
- 6: WEAPONSLOT_TYPE_SNIPER
- 7: WEAPONSLOT_TYPE_HEAVY
- 8: WEAPONSLOT_TYPE_THROWN
- 9: WEAPONSLOT_TYPE_SPECIAL
- 10: WEAPONSLOT_TYPE_GIFT
- 11: WEAPONSLOT_TYPE_PARACHUTE
- 12: WEAPONSLOT_TYPE_DETONATOR
Returns
Returns true if successful in setting the player's equipped weapon slot, false otherwise.
Example
Click to collapse [-]
ServerThis example allows the player to type the command 'giveweapons', which gives the player a weapon for every slot. Instead of equipping the last given weapon, the script randomly decides which weapon to equip after all the weapons are given.
function givePlayerWeapons ( player, commandName ) --Give the player a weapon for each slot giveWeapon ( player, 1, 1 ) giveWeapon ( player, 2, 1 ) giveWeapon ( player, 22, 1 ) giveWeapon ( player, 25, 1 ) giveWeapon ( player, 28, 1 ) giveWeapon ( player, 30, 1 ) giveWeapon ( player, 33, 1 ) giveWeapon ( player, 35, 1 ) giveWeapon ( player, 16, 1 ) giveWeapon ( player, 42, 1 ) giveWeapon ( player, 10, 1 ) giveWeapon ( player, 44, 1 ) giveWeapon ( player, 40, 1 ) --Randomly select which weapon to equip, slots 1 through 12 setPlayerWeaponSlot ( player, math.random ( 1, 12) ) end addCommandHandler ( "giveweapons", givePlayerWeapons )
See Also
- getPlayerTeam
- getPlayerBlurLevel
- setPlayerBlurLevel
- getPlayerSerial
- forcePlayerMap
- getPlayerScriptDebugLevel
- getPlayerFromName
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
- getPlayerWantedLevel
- givePlayerMoney
- isPlayerMapForced
- isPlayerNametagShowing
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
- takePlayerMoney
- countPlayersInTeam
- getPlayersInTeam
- isVoiceEnabled
- setControlState
- getControlState