OnClientPlayerStuntStart: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Improve example.)
 
(2 intermediate revisions by 2 users not shown)
Line 17: Line 17:
This is a simple stunt script which tells player what stunt he/she started and finished, time the stunt taken to perform and distance travelled while stunting.
This is a simple stunt script which tells player what stunt he/she started and finished, time the stunt taken to perform and distance travelled while stunting.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addEventHandler( "onClientPlayerStuntFinish", getRootElement( ),
function onClientPlayerStuntStart(stuntType)
    function ( stuntType )
    outputChatBox("You started stunt: "..stuntType)
        outputChatBox( "You started stunt: " .. stuntType );
end
    end
addEventHandler("onClientPlayerStuntStart", localPlayer, onClientPlayerStuntStart)
);


addEventHandler( "onClientPlayerStuntFinish", getRootElement( ),
function onClientPlayerStuntFinish(stuntType, stuntTime, stuntDistance)
    function ( stuntType, stuntTime, distance )
    outputChatBox("You finished stunt: "..stuntType..", time: "..stuntTime..", distance: "..stuntDistance)
        outputChatBox( "You finished stunt: " .. stuntType ..", Time: " .. stuntTime .. ", Distance: " .. tostring( distance ) );
end
    end
addEventHandler("onClientPlayerStuntFinish", localPlayer, onClientPlayerStuntFinish)
);
</syntaxhighlight>
</syntaxhighlight>



Latest revision as of 07:58, 16 September 2021

This event is triggered whenever the local player starts doing a vehicle stunt.

Parameters

string stuntType
  • stuntType: the type of stunt the player is starting to perform. Valid types are:
    • 2wheeler
    • wheelie
    • stoppie

Source

The source of this event is the local player.

Example

This is a simple stunt script which tells player what stunt he/she started and finished, time the stunt taken to perform and distance travelled while stunting.

function onClientPlayerStuntStart(stuntType)
    outputChatBox("You started stunt: "..stuntType)
end
addEventHandler("onClientPlayerStuntStart", localPlayer, onClientPlayerStuntStart)

function onClientPlayerStuntFinish(stuntType, stuntTime, stuntDistance)
    outputChatBox("You finished stunt: "..stuntType..", time: "..stuntTime..", distance: "..stuntDistance)
end
addEventHandler("onClientPlayerStuntFinish", localPlayer, onClientPlayerStuntFinish)

See Also

Client player events


Client event functions