SetRainLevel: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Improve example and description.)
 
(2 intermediate revisions by 2 users not shown)
Line 10: Line 10:
===Required Arguments===  
===Required Arguments===  
*'''level:''' A floating point number representing the rain level. 1 represents the maximum rain level usually available in GTA, but higher values are accepted.
*'''level:''' A floating point number representing the rain level. 1 represents the maximum rain level usually available in GTA, but higher values are accepted.
** '''Note:''' The level value is clamped between 0.0 and 10.0 to avoid gameplay issues.


===Returns===
===Returns===
Line 16: Line 17:
==Example==  
==Example==  
<section name="Client" class="client" show="true">
<section name="Client" class="client" show="true">
This example will make it rain when you enter a vehicle and stop it when you leave the vehicle.  
This example will make it rain when player or ped enters a vehicle, and stop once it leaves.  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function startRaining()
function startRaining()
         setRainLevel(5)
         setRainLevel(5)
end
end
addEventHandler("onClientVehicleEnter", getRootElement(), startRaining)
addEventHandler("onClientVehicleEnter", root, startRaining)


function stopRaining()
function stopRaining()
         resetRainLevel()
         resetRainLevel()
end
end
addEventHandler("onClientVehicleExit", getRootElement(), stopRaining)
addEventHandler("onClientVehicleExit", root, stopRaining)
 
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>

Latest revision as of 08:18, 16 September 2021

This function sets the rain level to any weather available in GTA. Use resetRainLevel to undo the changes.

Syntax

bool setRainLevel ( float level )

Required Arguments

  • level: A floating point number representing the rain level. 1 represents the maximum rain level usually available in GTA, but higher values are accepted.
    • Note: The level value is clamped between 0.0 and 10.0 to avoid gameplay issues.

Returns

Returns true if the rain level was set, false otherwise.

Example

Click to collapse [-]
Client

This example will make it rain when player or ped enters a vehicle, and stop once it leaves.

function startRaining()
         setRainLevel(5)
end
addEventHandler("onClientVehicleEnter", root, startRaining)

function stopRaining()
         resetRainLevel()
end
addEventHandler("onClientVehicleExit", root, stopRaining)

See Also