GetCameraShakeLevel: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Documented the function)
 
mNo edit summary
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__NOTOC__
{{Client function}}
{{Client function}}
__NOTOC__
{{Deprecated|getCameraDrunkLevel|Deprecated as of 1.6.0 r21795.}}
{{New feature/item|3.0150|1.5|7344|
{{New feature/item|3.0150|1.5|7344|
This function gets the camera shake level set by [[setCameraShakeLevel]].}}
This function gets the camera shake level set by [[setCameraShakeLevel]].}}
Line 10: Line 11:


===Returns===
===Returns===
Returns an integer representing the camera shake level, from 0 (no shaking effect) to 255 (maximum shaking effect).
Returns an integer representing the camera shake level, from 0 (no shaking effect) to 255 (maximum shaking effect). By default, the camera has no shaking effect.


==Example==  
==Example==  
Line 21: Line 22:
         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)
         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
     end
    lastDrunkLevel = currentDrunkLevel
end
end
addEventHandler("onClientRender", root, warnPlayerAboutDrunkenness)
addEventHandler("onClientRender", root, warnPlayerAboutDrunkenness)
Line 27: Line 29:
==See also==
==See also==
{{Client_camera_functions}}
{{Client_camera_functions}}
[[hu:getCameraShakeLevel]]
[[RO:getCameraShakeLevel]]

Latest revision as of 14:27, 11 June 2023

Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions.

Please use getCameraDrunkLevel instead. Deprecated as of 1.6.0 r21795.

This function gets the camera shake level set by setCameraShakeLevel.

Syntax

int getCameraShakeLevel ( )

Returns

Returns an integer representing the camera shake level, from 0 (no shaking effect) to 255 (maximum shaking effect). By default, the camera has no shaking effect.

Example

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

local lastDrunkLevel = getCameraShakeLevel()
local function warnPlayerAboutDrunkenness()
    local currentDrunkLevel = getCameraShakeLevel()
    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