BieHDC Posted July 11, 2013 Share Posted July 11, 2013 Hello, in past i have had a recource, which raises water all over map, but in my map this doesnt work. See Screenshots: http://postimg.org/image/bwimlcl4z/ http://postimg.org/image/6dkohvdhf/ http://postimg.org/image/v6tewux29/ http://postimg.org/image/s61g28hxz/ Here is my script: -- server side local maxLevel = 35 -- max level local untilW = 120 -- sec local raising,level = (maxLevel/untilW)/10,0 untilW = nil local runningTimer function editSomeWater() level = level + raising -- level raising setWaterLevel ( level, true, true ) -- set the level if level >= maxLevel then -- compare values of level and max level setWaterLevel ( maxLevel, true, true ) -- set it back to max level for perfection if isTimer(runningTimer) then -- check if the timer exist killTimer(runningTimer) -- stop the timer end runningTimer,level,maxLevel = nil,nil,nil -- delete data (ram) end end setTimer (function () -- set a timer for 15000 millisec (15 sec), runs one time "1" runningTimer = setTimer ( editSomeWater, 100, 0 ) -- set an invinity timer to set the water level, (0 = invinity) (only stops when you stop him with killTimer) end,30000,1) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) Link to comment
denny199 Posted July 11, 2013 Share Posted July 11, 2013 https://wiki.multitheftauto.com/wiki/CreateWater Link to comment
BieHDC Posted July 12, 2013 Author Share Posted July 12, 2013 Doesnt work -.- and no errors in debugscript 3 --server side -- Setting water properties. height = 0 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", resourceRoot, thaResourceStarting) local maxLevel = 35 -- max level local untilW = 120 -- sec local raising,level = (maxLevel/untilW)/10,0 untilW = nil local runningTimer function editSomeWater() level = level + raising -- level raising setWaterLevel ( level, true, true ) -- set the level if level >= maxLevel then -- compare values of level and max level setWaterLevel ( maxLevel, true, true ) -- set it back to max level for perfection if isTimer(runningTimer) then -- check if the timer exist killTimer(runningTimer) -- stop the timer end runningTimer,level,maxLevel = nil,nil,nil -- delete data (ram) end end setTimer (function () -- set a timer for 15000 millisec (15 sec), runs one time "1" runningTimer = setTimer ( editSomeWater, 100, 0 ) -- set an invinity timer to set the water level, (0 = invinity) (only stops when you stop him with killTimer) end,30000,1) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) Link to comment
myonlake Posted July 12, 2013 Share Posted July 12, 2013 (edited) You need to define the water element to the setWaterLevel. Try this. --server side -- Setting water properties. height = 0 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( ) setWaterLevel ( -500, false, false ) 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 ) end addEventHandler("onClientResourceStart", resourceRoot, thaResourceStarting) local maxLevel = 35 -- max level local untilW = 120 -- sec local raising,level = (maxLevel/untilW)/10,0 untilW = nil local runningTimer function editSomeWater() level = level + raising -- level raising setWaterLevel ( water, level ) -- set the level if level >= maxLevel then -- compare values of level and max level setWaterLevel ( water, maxLevel ) -- set it back to max level for perfection if isTimer(runningTimer) then -- check if the timer exist killTimer(runningTimer) -- stop the timer end runningTimer,level,maxLevel = nil,nil,nil -- delete data (ram) end end setTimer (function () -- set a timer for 15000 millisec (15 sec), runs one time "1" runningTimer = setTimer ( editSomeWater, 100, 0 ) -- set an invinity timer to set the water level, (0 = invinity) (only stops when you stop him with killTimer) end,30000,1) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) Edited July 12, 2013 by Guest Link to comment
BieHDC Posted July 12, 2013 Author Share Posted July 12, 2013 get this error: WARNING: MAP\waterrise.lua:33: Bad argument @ 'setWaterLevel' [Expected number at argument 1, got nil] setWaterLevel ( water, level, true, true ) -- set the level Link to comment
Alen141 Posted July 12, 2013 Share Posted July 12, 2013 get this error:WARNING: MAP\waterrise.lua:33: Bad argument @ 'setWaterLevel' [Expected number at argument 1, got nil] setWaterLevel ( water, level, true, true ) -- set the level It works for me --server side -- Setting water properties. height = 0 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( ) setWaterLevel ( -500, false, false ) 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 ) end addEventHandler("onClientResourceStart", resourceRoot, thaResourceStarting) local maxLevel = 35 -- max level local untilW = 120 -- sec local raising,level = (maxLevel/untilW)/10,0 untilW = nil local runningTimer function editSomeWater() level = level + raising -- level raising setWaterLevel ( water, level ) -- set the level if level >= maxLevel then -- compare values of level and max level setWaterLevel ( water, maxLevel ) -- set it back to max level for perfection if isTimer(runningTimer) then -- check if the timer exist killTimer(runningTimer) -- stop the timer end runningTimer,level,maxLevel = nil,nil,nil -- delete data (ram) end end setTimer (function () -- set a timer for 15000 millisec (15 sec), runs one time "1" runningTimer = setTimer ( editSomeWater, 100, 0 ) -- set an invinity timer to set the water level, (0 = invinity) (only stops when you stop him with killTimer) end,30000,1) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) Link to comment
BieHDC Posted July 12, 2013 Author Share Posted July 12, 2013 Ok will try and the godmode script doesnt work pls look again Link to comment
BieHDC Posted July 12, 2013 Author Share Posted July 12, 2013 I getting again the same mesage is i told The water should start to raise after 30sec and then always getting a bit higher until reach maxLevel This script worked without water creation, but it looked shitty see screenshots Link to comment
Alen141 Posted July 12, 2013 Share Posted July 12, 2013 I getting again the same mesage is i toldThe water should start to raise after 30sec and then always getting a bit higher until reach maxLevel This script worked without water creation, but it looked :~ see screenshots you have to change type of script in meta file,add this after your file name type="client" Link to comment
BieHDC Posted July 12, 2013 Author Share Posted July 12, 2013 Yes worked, but i change the eventhandler, because i want a good sync tryed with 2 lan pcs and got not small difference which eventhandler would you take? Link to comment
iMr.3a[Z]eF Posted July 12, 2013 Share Posted July 12, 2013 what function you are changing it event? Link to comment
BieHDC Posted July 12, 2013 Author Share Posted July 12, 2013 Ok with onResourceStart worked but timer doesnt wait 30sec anymore Here script again: --server side -- Setting water properties. height = 0 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( ) setWaterLevel ( -500, false, false ) 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 ) end addEventHandler("onResourceStart", resourceRoot, thaResourceStarting) local maxLevel = 35 -- max level local untilW = 120 -- sec local raising,level = (maxLevel/untilW)/10,0 untilW = nil local runningTimer function editSomeWater() level = level + raising -- level raising setWaterLevel ( water, level ) -- set the level if level >= maxLevel then -- compare values of level and max level setWaterLevel ( water, maxLevel ) -- set it back to max level for perfection if isTimer(runningTimer) then -- check if the timer exist killTimer(runningTimer) -- stop the timer end runningTimer,level,maxLevel = nil,nil,nil -- delete data (ram) end end setTimer (function () -- set a timer for 15000 millisec (15 sec), runs one time "1" runningTimer = setTimer ( editSomeWater, 100, 0 ) -- set an invinity timer to set the water level, (0 = invinity) (only stops when you stop him with killTimer) end,30000,1) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) Link to comment
iMr.3a[Z]eF Posted July 12, 2013 Share Posted July 12, 2013 --server side -- Setting water properties. height = 0 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( ) setWaterLevel ( -500, false, false ) 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 ) end addEventHandler("onResourceStart", resourceRoot, thaResourceStarting) local maxLevel = 35 -- max level local untilW = 120 -- sec local raising,level = (maxLevel/untilW)/10,0 untilW = nil local runningTimer function editSomeWater() level = level + raising -- level raising setWaterLevel ( water, level ) -- set the level if level >= maxLevel then -- compare values of level and max level setWaterLevel ( water, maxLevel ) -- set it back to max level for perfection if isTimer(runningTimer) then -- check if the timer exist killTimer(runningTimer) -- stop the timer end runningTimer,level,maxLevel = nil,nil,nil -- delete data (ram) end end setTimer ( editSomeWater, 30000, 1 ) -- set an invinity timer to set the water level, (0 = invinity) (only stops when you stop him with killTimer) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) outputChatBox ( "#FF0000Water starts to rise in 30sec! Be fast^^", getRootElement(), 255, 255, 255, true ) Link to comment
BieHDC Posted July 12, 2013 Author Share Posted July 12, 2013 water dont start to raise and debugscript 3 no output Link to comment
BieHDC Posted July 12, 2013 Author Share Posted July 12, 2013 and thats why not working? Link to comment
itoko Posted July 12, 2013 Share Posted July 12, 2013 yes, the level of water when it's raising is using untilW, but untilW never change, so the water level doesn't change. Link to comment
iMr.3a[Z]eF Posted July 12, 2013 Share Posted July 12, 2013 are you sure its ServerSide? Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now