SetWaterColor: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
m (fix oop)
 
(9 intermediate revisions by 5 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Server client function}}
This function changes the water color of the GTA world.
This function changes the water color of the GTA world.


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setWaterColor ( int red, int blue, int green, [ int alpha = 200 ] )
bool setWaterColor ( int red, int green, int blue, [ int alpha = 200 ] )
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP||[[water]]:setColor||getWaterColor}}


===Required Arguments===  
===Required Arguments===  
Line 25: Line 27:
function changeWaterColor ( commandName, red, green, blue, alpha )
function changeWaterColor ( commandName, red, green, blue, alpha )
     -- if alpha is input, then include it too
     -- if alpha is input, then include it too
     alpha = alpha or 200
     alpha = tonumber ( alpha ) or 200
    red = tonumber ( red )
    green = tonumber ( green )
    blue = tonumber ( blue )
     -- check if the colour values for red, green and blue are valid
     -- check if the colour values for red, green and blue are valid
     if tonumber ( red ) and tonumber ( green ) and tonumber ( blue ) then
     if red and green and blue then
         setWaterColor ( red, green, blue, alpha )
         setWaterColor ( red, green, blue, alpha )
     else
     else
Line 37: Line 42:


==See Also==
==See Also==
{{Client world functions}}
{{Client water functions}}

Latest revision as of 15:02, 7 August 2016

This function changes the water color of the GTA world.

Syntax

bool setWaterColor ( int red, int green, int blue, [ int alpha = 200 ] )


OOP Syntax Help! I don't understand this!

Method: water:setColor(...)
Counterpart: getWaterColor


Required Arguments

  • red: The red value of the water, from 0 to 255.
  • green: The green value of the water, from 0 to 255.
  • blue: The blue value of the water, from 0 to 255.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • alpha: The alpha (visibility) value of the water, from 0 to 255. Defaults to 200 if not declared.

Returns

Returns true if water color was set correctly, false if invalid values were passed.

Example

This example adds a command watercolor with which a player can change the water colour.

function changeWaterColor ( commandName, red, green, blue, alpha )
    -- if alpha is input, then include it too
    alpha = tonumber ( alpha ) or 200
    red = tonumber ( red )
    green = tonumber ( green )
    blue = tonumber ( blue )
    -- check if the colour values for red, green and blue are valid
    if red and green and blue then
        setWaterColor ( red, green, blue, alpha )
    else
        outputChatBox ( "Failed to change the water colour!" )
    end
end
addCommandHandler ( "watercolor", changeWaterColor )

See Also