GetCameraDrunkLevel: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Client function}} __NOTOC__ ==Syntax== <syntaxhighlight lang="lua"> int getCameraDrunkLevel ( ) </syntaxhighlight> ===Returns=== Returns an integer representing the camera drunk level, from 0 (no drunk effect) to 255 (maximum drunk effect). By default, the camera has no drunk effect. Drunk effect is a wavy motion of the camera depicting the player being drunk. This function used to be called getCameraShakeLevel which has since been deprecated. ==Example== This...")
 
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{Client function}}
{{Client function}}
__NOTOC__
__NOTOC__
{{New feature/item|3.0161|1.6.0|21795|This function gets the camera drunk level set by [[setCameraDrunkLevel]]. This function was renamed from [[getCameraShakeLevel]].}}


==Syntax==  
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int getCameraDrunkLevel ( )
int getCameraDrunkLevel ( )

Latest revision as of 14:23, 11 June 2023

ADDED/UPDATED IN VERSION 1.6.0 r21795:
This function gets the camera drunk level set by setCameraDrunkLevel. This function was renamed from getCameraShakeLevel.

Syntax

int getCameraDrunkLevel ( )

Returns

Returns an integer representing the camera drunk level, from 0 (no drunk effect) to 255 (maximum drunk effect). By default, the camera has no drunk effect. Drunk effect is a wavy motion of the camera depicting the player being drunk. This function used to be called getCameraShakeLevel which has since been deprecated.

Example

This example checks for changes in the camera drunk level of any player every frame and outputs different messages according to it.

local lastDrunkLevel = getCameraDrunkLevel()
local function warnPlayerAboutDrunkenness()
    local currentDrunkLevel = getCameraDrunkLevel()
    if currentDrunkLevel ~= lastDrunkLevel and (currentDrunkLevel == 0 or currentDrunkLevel == 255) then
        outputChatBox(currentDrunkLevel == 255 and "You're completly drunk! You should stop drinking!" or "Now you are completely sober! You sohuld keep it like that.", currentDrunkLevel == 255 and 255 or 0, currentDrunkLevel == 0 and 255 or 0, 0)
    end
    lastDrunkLevel = currentDrunkLevel
end
addEventHandler("onClientRender", root, warnPlayerAboutDrunkenness)

See also