RemoveCommandHandler: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
Line 12: | Line 12: | ||
===Optional Arguments=== | ===Optional Arguments=== | ||
*'''handler:''' the specific handler function to remove. If not specified, all handler functions for the command (from the calling resource) will be removed. ''This argument is only available in | *'''handler:''' the specific handler function to remove. If not specified, all handler functions for the command (from the calling resource) will be removed. ''This argument is only available in 1.0 and above.'' | ||
===Returns=== | ===Returns=== | ||
Line 36: | Line 36: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
<section name="Client" class="client" show=" | <section name="Client" class="client" show="true"> | ||
This example adds a command handler that briefly shows the position of 'huntedPlayer', and removes the command handler when 'huntedPlayer' dies: | This example adds a command handler that briefly shows the position of 'huntedPlayer', and removes the command handler when 'huntedPlayer' dies: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> |
Revision as of 15:37, 4 April 2009
This function removes a command handler, that is one that has been added using addCommandHandler. This function can only remove command handlers that were added by the resource that it is called in.
Syntax
bool removeCommandHandler ( string commandName [, function handler] )
Required Arguments
- commandName: the name of the command you wish to remove.
Optional Arguments
- handler: the specific handler function to remove. If not specified, all handler functions for the command (from the calling resource) will be removed. This argument is only available in 1.0 and above.
Returns
Returns true if the command handler was removed successfully, false if the command doesn't exist.
Example
Click to collapse [-]
ServerThis example adds a command handler that briefly shows the position of 'huntedPlayer', and removes the command handler when 'huntedPlayer' dies:
-- add a command that allows players to see the position of the 'huntedPlayer' for 5 seconds: function consoleShowHuntedBlip ( thePlayer, commandName ) local x, y, z = getElementPosition ( huntedPlayer ) local huntedblip = createBlip ( x, y, z, 0, 2, 255, 0, 0, 255, thePlayer ) setTimer ( "destroyElement", 5000, 1, huntedblip ) end addCommandHandler ( "showhuntedblip", consoleShowHuntedBlip ) -- remove the command once the hunter player dies: function onHuntedPlayerWasted ( ammo, killer, killerweapon, bodypart ) removeCommandHandler ( "showhuntedblip" ) end addEventHandler ( "onPlayerWasted", huntedPlayer, onHuntedPlayerWasted )
Click to collapse [-]
ClientThis example adds a command handler that briefly shows the position of 'huntedPlayer', and removes the command handler when 'huntedPlayer' dies:
-- add a command that allows players to see the position of the 'huntedPlayer' for 5 seconds: function consoleShowHuntedBlip ( commandName ) local x, y, z = getElementPosition ( huntedPlayer ) local huntedblip = createBlip ( x, y, z, 0, 2, 255, 0, 0, 255, thePlayer ) setTimer ( "destroyElement", 5000, 1, huntedblip ) end addCommandHandler ( "showhuntedblip", consoleShowHuntedBlip ) -- remove the command once the hunter player dies: function onHuntedPlayerWasted ( killer, killerweapon, bodypart ) removeCommandHandler ( "showhuntedblip" ) end addEventHandler ( "onClientPlayerWasted", huntedPlayer, onHuntedPlayerWasted )
See Also
- getMaxPlayers
- getServerConfigSetting
- getServerHttpPort
- getServerName
- getServerPassword
- getServerPort
- isGlitchEnabled
- setGlitchEnabled
- setMaxPlayers
- setServerConfigSetting
- setServerPassword
- shutdown