GetWaveHeight: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (fix oop)
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server client function}}
This function returns the current wave height.
This function returns the current wave height.


Line 6: Line 7:
float getWaveHeight()
float getWaveHeight()
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[Water]].getWaveHeight||setWaveHeight}}


===Returns===
===Returns===
Line 11: Line 14:


==Example==  
==Example==  
<section name="Server" class="server" show="true">
This example changes the wave height to the given amount.
This example changes the wave height to the given amount.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function scriptWave ( player, command, height )
function scriptWave ( thePlayer, command, height )
  local oldHeight = getWaveHeight()
local oldHeight = getWaveHeight()
  height = tonumber ( height )
height = tonumber ( height )
  success = setWaveHeight ( height )
success = setWaveHeight ( height )
  if ( success ) then
if ( success ) then
    outputChatBox ( "The old wave height was: " .. oldHeight .. "; " .. getClientName ( player ) .. " set it to: " .. height )
outputChatBox ( "The old wave height was: " .. oldHeight .. "; " .. getPlayerName ( thePlayer ) .. " set it to: " .. height )
  else outputChatBox ( "Invalid number." )
else
  end
outputChatBox ( "Invalid number." )
end
end
end
addCommandHandler ( "setwave", scriptWave )
addCommandHandler ( "setwave", scriptWave )
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{World functions}}
{{Water functions}}

Latest revision as of 15:07, 7 August 2016

This function returns the current wave height.

Syntax

float getWaveHeight()


OOP Syntax Help! I don't understand this!

Method: Water.getWaveHeight(...)
Counterpart: setWaveHeight


Returns

Returns the height as a float, false otherwise.

Example

Click to collapse [-]
Server

This example changes the wave height to the given amount.

function scriptWave ( thePlayer, command, height )
	local oldHeight = getWaveHeight()
	height = tonumber ( height )
	success = setWaveHeight ( height )
	if ( success ) then
		outputChatBox ( "The old wave height was: " .. oldHeight .. "; " .. getPlayerName ( thePlayer ) .. " set it to: " .. height )
	else
		outputChatBox ( "Invalid number." )
	end
end
addCommandHandler ( "setwave", scriptWave )

See Also