SetPlayerChoking

From Multi Theft Auto: Wiki
Revision as of 21:36, 20 April 2011 by Arran Fortuna (talk | contribs)
Jump to navigation Jump to search

Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions, but there should be a more generic way to perform what it does.


Please use setPedChoking

This function can be used to force the player to do the choking animation (teargas etc...) until he respawns or toggled off using this function. The animation can not be cancelled by the player and he will not loose health.

Syntax

bool setPlayerChoking ( player thePlayer, bool choking )


Required Arguments

  • thePlayer: Define the player whose choking status to toggle
  • choking: Use true to make the player 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 ()
    setPlayerChoking ( root, true )
end
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), ResourceStart, true )

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

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

See Also