CreateWater: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Poor page construction JAYSDS1...)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server client function}}
{{Server client function}}
{{Needs_Checking|Use of bShallow is unknown. There was a stupid note pointing to arc_ and assuming it meant if the water is visible which is not true.}}


Creates an area of [[water]].
Creates an area of [[water]].
Line 9: Line 11:
<syntaxhighlight lang="lua">water createWater ( float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3 [, float x4, float y4, float z4 ] [, bool bShallow = false ] )</syntaxhighlight>
<syntaxhighlight lang="lua">water createWater ( float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3 [, float x4, float y4, float z4 ] [, bool bShallow = false ] )</syntaxhighlight>
[[Image:WaterAreas.jpg|thumb|Example of water quadrant.|284x230px]]
[[Image:WaterAreas.jpg|thumb|Example of water quadrant.|284x230px]]
===Required Arguments===
===Required Arguments===
For creating a water quadrant:
*'''x1, y1, z1:''' position of bottom left (south-west) corner.
*'''x1, y1, z1:''' position of bottom left (south-west) corner.
*'''x2, y2, z2:''' position of bottom right (south-east) corner.
*'''x2, y2, z2:''' position of bottom right (south-east) corner.
*'''x3, y3, z3:''' position of top left (north-west) corner.
*'''x3, y3, z3:''' position of top left (north-west) corner.
*'''x4, y4, z4:''' position of top right (north-east) corner.
''Note: Only 3 coords creates a triangle''
 
For creating a water triangle:
*'''x1, y1, z1:''' position of bottom/top left corner.
*'''x2, y2, z2:''' position of bottom/top right corner.
*'''x3, y3, z3:''' position of top/bottom corner.


===Optional Arguments===
===Optional Arguments===
*'''bShallow:''' ask arc_ ([[User:Jaysds1|Jaysds1]] Prediction: true if the water is close to the ground (It changes whether the water is visible or not))
*'''x4, y4, z4:''' position of top right (north-east) corner.
*'''bShallow:''' Need documentation...


===Returns===
===Returns===

Revision as of 07:11, 27 September 2012


Dialog-information.png This article needs checking.

Reason(s): Use of bShallow is unknown. There was a stupid note pointing to arc_ and assuming it meant if the water is visible which is not true.

Creates an area of water.

The largest possible size of a water area is 5996×5996. Also be aware that the function will change all x and y coordinates you specify into even integer numbers if necessary: this is because of a limitation of San Andreas.

Syntax

water createWater ( float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3 [, float x4, float y4, float z4 ] [, bool bShallow = false ] )
Example of water quadrant.

Required Arguments

  • x1, y1, z1: position of bottom left (south-west) corner.
  • x2, y2, z2: position of bottom right (south-east) corner.
  • x3, y3, z3: position of top left (north-west) corner.

Note: Only 3 coords creates a triangle

Optional Arguments

  • x4, y4, z4: position of top right (north-east) corner.
  • bShallow: Need documentation...

Returns

Returns a water element if successful, false otherwise. The water element can be repositioned with setElementPosition and destroyed with destroyElement.

Example

Click to collapse [-]
Client

Example code for creating a water area to cover the entire San Andreas Map (flood the cities). Also, setWaterLevel is used to raise the existing rivers and lakes.

-- Setting water properties.
height = 40
SizeVal = 2998
-- Defining variables.
southWest_X = -SizeVal
southWest_Y = -SizeVal
southEast_X = SizeVal
southEast_Y = -SizeVal
northWest_X = -SizeVal
northWest_Y = SizeVal
northEast_X = SizeVal
northEast_Y = SizeVal

-- OnClientResourceStart function that creates the water.
function thaResourceStarting( )
    water = createWater ( southWest_X, southWest_Y, height, southEast_X, southEast_Y, height, northWest_X, northWest_Y, height, northEast_X, northEast_Y, height )
    setWaterLevel ( height )
end
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), thaResourceStarting)

See Also