setWaterColor
Client-side
Server-side
Shared
Pair: getWaterColor
Manual Review Required
Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.
This function changes the water color of the GTA world.
OOP Syntax Help! I don't understand this!
- Method:water:setColor(...)
Syntax
bool setWaterColor ( int red, int green, int blue, [ int alpha = 200 ] )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.
- alpha (default: 200): The alpha (visibility) value of the water, from 0 to 255. Defaults to 200 if not declared.
Returns
- bool: value
Returns true if water color was set correctly, false if invalid values were passed.
Code Examples
shared
This example adds a commandwatercolorwith 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!" ) endendaddCommandHandler ( "watercolor", changeWaterColor )