TakeWeapon: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
==Description==
This function removes a specified weapon from a certain player's inventory.
This function removes a specified weapon from a certain player's inventory. It returns a boolean value (true or false) depending on whether the function passed or failed.


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">TakeWeapon ( player, weaponid )</syntaxhighlight>
<syntaxhighlight lang="lua">bool takeWeapon ( player thePlayer, int weaponId )</syntaxhighlight>


===Required Arguments===
===Required Arguments===
*'''player''': A player object referencing the specified player.
*'''thePlayer''': A player object referencing the specified player.
*'''weaponid''': An integer (whole number) that refers to a [[Weapon]] that you wish to remove. Click weapon for a page with weapon ID listings.
*'''weaponId''': An integer that refers to a [[weapon]] that you wish to remove.
 
===Returns===
Returns a ''true'' if the weapon was removed successfully, ''false'' otherwise.


==Example==
==Example==
This example removes weapon 28 from player ID 1. If successful, it displays a message in the chat box.
<syntaxhighlight lang="lua">player = getPlayerFromID ( 1 )
<syntaxhighlight lang="lua">player = getPlayerFromID ( 1 )
if ( TakeWeapon ( player, 1 ) )
if ( TakeWeapon ( player, 28 ) )
   outputChatBox ( "Weapon 1 removed from ", getPlayerName ( player ), "." )
   outputChatBox ( "Weapon 28 removed from ", getPlayerName ( player ), "." )
end</syntaxhighlight>
end</syntaxhighlight>


==See Also==
==See Also==
{{Weapon functions}}
{{Weapon functions}}

Revision as of 13:45, 14 August 2006

This function removes a specified weapon from a certain player's inventory.

Syntax

bool takeWeapon ( player thePlayer, int weaponId )

Required Arguments

  • thePlayer: A player object referencing the specified player.
  • weaponId: An integer that refers to a weapon that you wish to remove.

Returns

Returns a true if the weapon was removed successfully, false otherwise.

Example

This example removes weapon 28 from player ID 1. If successful, it displays a message in the chat box.

player = getPlayerFromID ( 1 )
if ( TakeWeapon ( player, 28 ) )
  outputChatBox ( "Weapon 28 removed from ", getPlayerName ( player ), "." )
end

See Also