GetWaterColor: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Undo revision 26172 by Kamek (talk))
Line 14: Line 14:


==Example==  
==Example==  
These two examples adds the command ''watercolor'' which get water color(RGBA) and show in chat.
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--TODO
function waterColor ()
local r,g,b,a = getWaterColor ()
if ( r and g and b and a ) then
outputChatBox ( "The color of water is: "..math.ceil(r)..", "..math.ceil(g)..", "..math.ceil(b)..", "..math.ceil(a).."", r, g, b )
    else
        outputChatBox ( "Failed to get the color of water!" )
    end
end
addCommandHandler("watercolor", waterColor )
</syntaxhighlight>
</syntaxhighlight>
</section>
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
function waterColor ()
local r,g,b,a = getWaterColor ()
if ( r and g and b and a ) then
outputChatBox ( "The color of water is: "..math.ceil(r)..", "..math.ceil(g)..", "..math.ceil(b)..", "..math.ceil(a).."", getRootElement(), r, g, b )
    else
        outputChatBox ( "Failed to get the color of water!" )
    end
end
addCommandHandler("watercolor", waterColor )
</syntaxhighlight>
</section>


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

Revision as of 03:55, 6 April 2012

This function returns the water color of the GTA world.

Note: The server can only return the water color, if it has actually been set by script.

Syntax

int, int, int, int getWaterColor ( )

Returns

Returns 4 ints, indicating the color of the water. (RGBA)

Example

These two examples adds the command watercolor which get water color(RGBA) and show in chat.

Click to collapse [-]
Client
function waterColor ()
	local r,g,b,a = getWaterColor ()
	if ( r and g and b and a ) then
		outputChatBox ( "The color of water is: "..math.ceil(r)..", "..math.ceil(g)..", "..math.ceil(b)..", "..math.ceil(a).."", r, g, b )
    else
        outputChatBox ( "Failed to get the color of water!" )
    end
end
addCommandHandler("watercolor", waterColor )
Click to collapse [-]
Server
function waterColor ()
	local r,g,b,a = getWaterColor ()
	if ( r and g and b and a ) then
		outputChatBox ( "The color of water is: "..math.ceil(r)..", "..math.ceil(g)..", "..math.ceil(b)..", "..math.ceil(a).."", getRootElement(), r, g, b )
    else
        outputChatBox ( "Failed to get the color of water!" )
    end
end
addCommandHandler("watercolor", waterColor )

See Also