SetPedCanBeKnockedOffBike: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (Add information about peds not getting knocked off bikes when it's set damage proof (The game apparently skips collisions when this is set))
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
This function controls if a ped can fall of his bike by accident - namely by banging into a wall. This function only works on players.
This function controls if a ped can fall of his bike by accident - namely by banging into a wall.
{{Note | This effect is not synced for peds. When the ped falls off, he will not have exited the vehicle. To get it working you need to call it each time the ped is streamed in & each time it gets a new syncer.}}
{{Note | The ped will not get knocked off a bike that is set damage proof through [[setVehicleDamageProof]]. Refer to the note on that method for more information.}}


==Syntax==  
==Syntax==  
Line 18: Line 20:


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function changeCanBeKnockedOff ( command )
function changeCanBeKnockedOff()
     -- The player should enter /knock
     local canBeKnocked = canPedBeKnockedOffBike(localPlayer)
    if canPedBeKnockedOffBike ( getLocalPlayer() ) then
    local knockedText = canBeKnocked and "Now you can't be knocked off your bike." or "Now you can be knocked off your bike."
        setPedCanBeKnockedOffBike ( getLocalPlayer(), false )
 
        outputChatBox ( "Now you can't be knocked off your bike." )
    setPedCanBeKnockedOffBike(localPlayer, not canBeKnocked)
    else
     outputChatBox(knockedText)
        setPedCanBeKnockedOffBike ( getLocalPlayer(), true )
        outputChatBox ( "Now you can be knocked off your bike." )
     end
end
end
addCommandHandler ( "knock", changeCanBeKnockedOff )
addCommandHandler("knock", changeCanBeKnockedOff)
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Client_ped_functions}}
{{Client_ped_functions}}

Latest revision as of 11:20, 24 October 2024

This function controls if a ped can fall of his bike by accident - namely by banging into a wall.

[[{{{image}}}|link=|]] Note: This effect is not synced for peds. When the ped falls off, he will not have exited the vehicle. To get it working you need to call it each time the ped is streamed in & each time it gets a new syncer.
[[{{{image}}}|link=|]] Note: The ped will not get knocked off a bike that is set damage proof through setVehicleDamageProof. Refer to the note on that method for more information.

Syntax

bool setPedCanBeKnockedOffBike ( ped thePed, bool canBeKnockedOffBike )         


OOP Syntax Help! I don't understand this!

Method: ped:setCanBeKnockedOffBike(...)
Counterpart: canPedBeKnockedOffBike


Required Arguments

  • thePed: the ped whose knockoffstatus is being changed
  • canBeKnockedOffBike: true or false

Example

This example adds a console command with which the local player can toggle if he can fall off bikes.

function changeCanBeKnockedOff()
    local canBeKnocked = canPedBeKnockedOffBike(localPlayer)
    local knockedText = canBeKnocked and "Now you can't be knocked off your bike." or "Now you can be knocked off your bike."

    setPedCanBeKnockedOffBike(localPlayer, not canBeKnocked)
    outputChatBox(knockedText)
end
addCommandHandler("knock", changeCanBeKnockedOff)

See Also