Jump to content

getWaterLevel


Fabio(GNR)

Recommended Posts

Hello, i created a script that will raise water slowly, if it's on level 80, it will set timer to let it drain again, i used getWaterLevel but i didn't know you have to tell the location of it, but i want it to check everywhere :)

how to do that?? Thanks!!

  
  
  
height = 0.5 
SizeVal = 2998 
southWest_X = -SizeVal 
southWest_Y = -SizeVal 
southEast_X = SizeVal 
southEast_Y = -SizeVal 
northWest_X = -SizeVal 
northWest_Y = SizeVal 
northEast_X = SizeVal 
northEast_Y = SizeVal 
  
  
function createwater( ) 
    water = createWater ( southWest_X, southWest_Y, height, southEast_X, southEast_Y, height, northWest_X, northWest_Y, height, northEast_X, northEast_Y, height ) 
    setWaterLevel ( height ) 
    outputChatBox("The fun time started, water's rising!!",getRootElement(), 0,255,0) 
end 
addCommandHandler ( "water", createwater ) 
  
addCommandHandler ( "waterlevel", 
    function ( thePlayer, command, level ) 
        if level and tonumber ( level ) then  
            setWaterLevel ( tonumber( level ) )  
            outputChatBox ( "Waterlevel is now: " .. level )  
        end 
    end 
) 
  
local level = 0.5 
  
function flood() 
    level = level + 0.08 
    setWaterLevel ( level ) 
end 
  
waterdrain =  setTimer ( flood, 100, 15000 ) 
  
local level2 = 80 
  
function drainaway() 
    level = level2 - 0.03 
    setWaterLevel ( level ) 
end 
setTimer ( drainSomeWater, 100, 15000 ) 
  
function watercheck() 
if getWaterLevel = 80 then 
killTimer ( waterdrain ) 
waterdraining = setTimer ( drainaway, 130000 ) 
end   
   end 
    
   function waterstop() 
if getWaterLevel = 0 then 
killTimer ( waterdraining ) 
outputChatBox("Water is normal again",getRootElement(), 0,255,0) 
end   
   end 
  
addCommandHandler ( "water", flood ) 
  
  

Yes, i know it's mainly from wiki, but what else...

Link to comment
read wiki more carefully if you are copying examples from it ...

you dont need to create any water element if you want to modify "standard water" level.

just pass one argument to setWaterLevel and dont pass any arguments to getWaterLevel

it creates water on the whole map, thats what i want. So it will just work without argument's? ok Thankss

EDIT: btw, forgot to say it say's then expected near = at line 50 :/

Link to comment

syntax is the first thing you should know while scripting - if you got syntax error you should fix this with your eyes shut.. some programming forums (various languages) are just trashing posts with questions about syntax errors - because this is ridiculous to ask such questions!

and as i said - no need to create any water element!!

Link to comment

and as i said - no need to create any water element!!

When i set the water level it will only raise the river's and sea's but won't create water in city's etc. But you said don't pass any argument's :/, what if i want to check for the whole entire map with the water that i created in city's... https://wiki.multitheftauto.com/wiki/GetWaterLevel it say's x, y ,z but i don't have a location to check for, just everything (sorry to annoy you)

Link to comment

oh, i didnt know that ( the resource ) i'll first try myself with your help. Thanks

EDIT: Give's then expected near = at line 52. my code's now:

-- Setting water properties. 
height = 0.5 
waveheight = 5 
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 createwater( ) 
  
    water = createWater ( southWest_X, southWest_Y, height, southEast_X, southEast_Y, height, northWest_X, northWest_Y, height, northEast_X, northEast_Y, height ) 
    setWaterLevel ( water, height ) 
    outputChatBox("The fun time started, water's rising!!",getRootElement(), 0,255,0) 
    setWaveHeight ( waveheight ) 
end 
addCommandHandler ( "water", createwater ) 
  
addCommandHandler ( "waterlevel", 
    function ( thePlayer, command, level ) 
        if level and tonumber ( level ) then -- if we have input something and if it is actually a number value 
            setWaterLevel ( tonumber( level ) ) -- change the water level 
            outputChatBox ( "Waterlevel is now: " .. level ) -- send a message to everyone to inform about the change 
        end 
    end 
) 
  
local level = 0.5 
  
function flood() 
    level = level + 0.08 
    setWaterLevel ( water, level ) 
end 
  
waterdrain =  setTimer ( flood, 100, 15000 ) 
  
local level2 = 80 
  
function drainaway() 
    level = level2 - 0.03 
    setWaterLevel ( water, level ) 
end 
setTimer ( drainSomeWater, 100, 15000 ) 
  
function watercheck() 
if getWaterLevel ( water ) = 80 then 
killTimer ( waterdrain ) 
waterdraining = setTimer ( drainaway, 130000 ) 
end   
   end 
    
   function waterstop() 
if getWaterLevel(water) = 0 then 
killTimer ( waterdraining ) 
outputChatBox("Water is normal again",getRootElement(), 0,255,0) 
end   
   end 
  
addCommandHandler ( "water", flood ) 
  

btw, set water give's me thousand of error message spamming my server, Bad Argument....

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...