RemoveCommandHandler: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 8: Line 8:


===Required Arguments===  
===Required Arguments===  
*'''key:''' description
*'''commandName:''' The string of the command you wish to remove
 
===Optional Arguments===
{{OptionalArg}}
*'''argumentName2:''' descriptiona
*'''argumentName3:''' description


===Returns===
===Returns===
Returns ''true'' if blah, ''false'' otherwise.
Returns ''true'' if the operation was successful, ''false'' otherwise.


==Example==  
==Example==  
This example does...
This example prevents using a 'nitro' command if you are in a caddy, otherwise it adds the command to allow you to use the nitro command.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
addEventHandler ( "onPlayerEnterVehicle", root, "onPlayerEnterVehicle" )
blabhalbalhb --abababa
function onPlayerEnterVehicle ( vehicle, seat, jacked )
--This line does this...
    if vehicle == 457 then
mooo
        removeCommandHandler ( nitro )
    else
        addCommandHandler ( nitro, givenitro )
    end
end
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Server_Functions}}
{{Server_functions}}
[[Category:Incomplete]]

Revision as of 19:56, 13 August 2006

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 virtual machine that it is called in.

Syntax

bool removeCommandHandler ( string commandName )              

Required Arguments

  • commandName: The string of the command you wish to remove

Returns

Returns true if the operation was successful, false otherwise.

Example

This example prevents using a 'nitro' command if you are in a caddy, otherwise it adds the command to allow you to use the nitro command.

addEventHandler ( "onPlayerEnterVehicle", root, "onPlayerEnterVehicle" )
function onPlayerEnterVehicle ( vehicle, seat, jacked )
    if vehicle == 457 then
        removeCommandHandler ( nitro )
    else
        addCommandHandler ( nitro, givenitro )
    end
end

See Also