RemoveCommandHandler: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
{{Needs_Checking|Problems in example. [[User:Erorr404|Erorr404]]}}
{{Needs_Checking|Problems in example. [[User:Erorr404|Erorr404]]}}
{{Needs_Checking|Well, I fixed the syntax issues, but its a bad example (why remove the command for everyone?). Can't think of another one though... [[User:EAi|eAi]]}}


__NOTOC__
__NOTOC__

Revision as of 12:27, 8 October 2006

Dialog-information.png This article needs checking.

Reason(s): Problems in example. Erorr404
Dialog-information.png This article needs checking.

Reason(s): Well, I fixed the syntax issues, but its a bad example (why remove the command for everyone?). Can't think of another one though... eAi


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