StopObject: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 26: Line 26:
addCommandHandler ( "toggleobjectmove", "objectMoveControl" )
addCommandHandler ( "toggleobjectmove", "objectMoveControl" )
function objectMoveControl ( player, commandName, state )
function objectMoveControl ( player, commandName, state )
--This command handler activate on text "toggleobjectmove" in
--On "toggleobjectmove" in console, activate this command, which
--the console. It also asks that the player define the varible
--also asks for a value for the varible 'state' e
--'state' after the commandname
if state == "on" then
if state == "on" then
outputChatBox ( "Moving object randomly" )
outputChatBox ( "Moving object randomly" )
mytimer = setTimer ( "randomObjectMovement", 2250, 0 )
mytimer = setTimer ( "randomObjectMovement", 2250, 0 )
--if player type "on" for state, then we turn on the timer that
--if player types "on" for the state varible, turn on the timer,
--triggers the function randomObjectMovement. It triggers the
--which triggers the function randomObjectMovement that makes
--function every 2 1/4 seconds for an infinite amount of times,
        the object move in random directions. The tiemer runs every 2 1/4
--since times is defined as 0. This part of the script is not displayed,
        seconds for 0 times, which means it runs infintely.
        --but it continuously moves the object in random directions.
elseif state == "off" then
elseif state == "off" then
outputChatBox ( "Stopping object movement" )
outputChatBox ( "Stopping object movement" )
killTimer ( mytimer )
killTimer ( mytimer )
stopObject ( myobject )
stopObject ( myobject )
--If player typed "off" for state, then stop the object movement
--If player typed "off" for state, stop the object movement
--immediately and kill the random object movement timer, which
--immediately and kill the random object movement timer, which
--triggers the randomObjectMovement function
--triggers the randomObjectMovement function

Revision as of 03:05, 12 April 2007

Dialog-information.png This article needs checking.

Reason(s): This had stuff put by someone else that said it stops elements but its called stopobject so I wrote it for objects and see also is defined as object category. Not sure? --Ransom 20:54, 11 April 2007 (CDT)


This will allow you to stop an object that is currently moving.

Syntax

bool stopObject ( object theobject )

Required Arguments

  • theobject: This is the object whose movement you wish to stop

Returns

Returns true if successful, false otherwise.

Example

This will allow you to toggle the random movement of a staircase object model and stop it immediately with the stopObject command.

addCommandHandler ( "toggleobjectmove", "objectMoveControl" )
function objectMoveControl ( player, commandName, state )
--On "toggleobjectmove" in console, activate this command, which
--also asks for a value for the varible 'state' e 
	if state == "on" then
	outputChatBox ( "Moving object randomly" )
	mytimer = setTimer ( "randomObjectMovement", 2250, 0 )
	--if player types "on" for the state varible, turn on the timer,
	--which triggers the function randomObjectMovement that makes
        the object move in random directions. The tiemer runs every 2 1/4
        seconds for 0 times, which means it runs infintely.
	elseif state == "off" then
	outputChatBox ( "Stopping object movement" )
	killTimer ( mytimer )
	stopObject ( myobject )
	--If player typed "off" for state, stop the object movement
	--immediately and kill the random object movement timer, which
	--triggers the randomObjectMovement function
	else
        outputChatBox ( "must define object state as 'on' or 'off'" )
        --If player said something besides "on" or "off" for state, do nothing
 	end
end

See Also