SetPedChoking: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Added OOP pair)
Line 23: Line 23:
     setPedChoking ( root, true )
     setPedChoking ( root, true )
end
end
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), ResourceStart, true )
addEventHandler ( "onResourceStart", getResourceRootElement (), ResourceStart, true )


-- Unchoke all the players when the resource stops
-- Unchoke all the players when the resource stops
Line 29: Line 29:
     setPedChoking ( root, false )
     setPedChoking ( root, false )
end
end
addEventHandler ( "onResourceStop", getResourceRootElement ( getThisResource () ), ResourceStop, true )
addEventHandler ( "onResourceStop", getResourceRootElement (), ResourceStop, true )


-- Choke players spawning
-- Choke players spawning

Revision as of 16:44, 11 February 2015

This function can be used to force the ped to do the choking (coughing) animation until he respawns or toggled off using this function. The animation can not be cancelled by a player it's applied to, and he will not loose health.

Syntax

bool setPedChoking ( ped thePed, bool choking )

OOP Syntax Help! I don't understand this!

Method: ped:setChoking(...)
Variable: .choking
Counterpart: isPedChoking


Required Arguments

  • thePed: The ped whose choking status to toggle
  • choking: true to make the ped choke, false to no longer force his choking animation

Returns

Returns true if successful, false otherwise (e.g. player handle is invalid)

Example

This script will make all players choke on resource start

-- Choke all the players when the resource starts
function ResourceStart ()
    setPedChoking ( root, true )
end
addEventHandler ( "onResourceStart", getResourceRootElement (), ResourceStart, true )

-- Unchoke all the players when the resource stops
function ResourceStop ()
    setPedChoking ( root, false )
end
addEventHandler ( "onResourceStop", getResourceRootElement (), ResourceStop, true )

-- Choke players spawning
function PlayerSpawn ()
    setPedChoking ( source, true )
end
addEventHandler ( "onPlayerSpawn", root, PlayerSpawn )

See Also