GetWaterColor: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 18: Line 18:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function waterColor ()
function waterColor ()
local r,g,b,a = getWaterColor ()
    local r,g,b,a = getWaterColor ()
if ( r and g and b and a ) then
    if ( r and g and b and a ) then -- If color is true
outputChatBox ( "The color of water is: "..math.ceil(r)..", "..math.ceil(g)..", "..math.ceil(b)..", "..math.ceil(a).."", r, g, b )
          -- Output of the value of the water color to the chat
        outputChatBox ( "The color of water is: "..math.ceil(r)..", "..math.ceil(g)..", "..math.ceil(b)..", "..math.ceil(a).."", r, g, b )
     else
     else
          -- Notify the player if the value of the colors is false
         outputChatBox ( "Failed to get the color of water!" )
         outputChatBox ( "Failed to get the color of water!" )
     end
     end
end
end
  -- Add command handler for the function
addCommandHandler("watercolor", waterColor )
addCommandHandler("watercolor", waterColor )
</syntaxhighlight>
</syntaxhighlight>
Line 32: Line 35:
function waterColor ()
function waterColor ()
local r,g,b,a = getWaterColor ()
local r,g,b,a = getWaterColor ()
if ( r and g and b and a ) then
if ( r and g and b and a ) then -- If color is true
          -- Output of the value of the water color to the chat
outputChatBox ( "The color of water is: "..math.ceil(r)..", "..math.ceil(g)..", "..math.ceil(b)..", "..math.ceil(a).."", getRootElement(), r, g, b )
outputChatBox ( "The color of water is: "..math.ceil(r)..", "..math.ceil(g)..", "..math.ceil(b)..", "..math.ceil(a).."", getRootElement(), r, g, b )
     else
     else
          -- Notify the player if the value of the colors is false
         outputChatBox ( "Failed to get the color of water!" )
         outputChatBox ( "Failed to get the color of water!" )
     end
     end
end
end
  -- Add command handler for the function
addCommandHandler("watercolor", waterColor )
addCommandHandler("watercolor", waterColor )
</syntaxhighlight>
</syntaxhighlight>

Revision as of 06:48, 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 -- If color is true
          -- Output of the value of the water color to the chat
        outputChatBox ( "The color of water is: "..math.ceil(r)..", "..math.ceil(g)..", "..math.ceil(b)..", "..math.ceil(a).."", r, g, b )
    else
          -- Notify the player if the value of the colors is false
        outputChatBox ( "Failed to get the color of water!" )
    end
end
  -- Add command handler for the function
addCommandHandler("watercolor", waterColor )
Click to collapse [-]
Server
function waterColor ()
	local r,g,b,a = getWaterColor ()
	if ( r and g and b and a ) then -- If color is true
          -- Output of the value of the water color to the chat
		outputChatBox ( "The color of water is: "..math.ceil(r)..", "..math.ceil(g)..", "..math.ceil(b)..", "..math.ceil(a).."", getRootElement(), r, g, b )
    else
          -- Notify the player if the value of the colors is false
        outputChatBox ( "Failed to get the color of water!" )
    end
end
  -- Add command handler for the function
addCommandHandler("watercolor", waterColor )

See Also