BieHDC Posted June 5, 2013 Posted June 5, 2013 Hello, I want to make a script witch raises water to a defined high(example 20m) in a defined time(60secs until water reaches 20m) and the draining should start 15secs after map start I have found the following as example witch drains water: -- serverside local level = 0 function drainSomeWater() level = level - 0.01 setWaterLevel ( level ) end setTimer ( drainSomeWater, 100, 15000 ) if i dont use a negative number the water will raise (i think) but i want that the water needs 60sec unti have 20m and starts 15secs after map start, but i dont know how to do this. Please help me^^
Moderators IIYAMA Posted June 5, 2013 Moderators Posted June 5, 2013 The script is included with the map? or apart? raising/draining 20 meters 60 sec 20/60 = 0.33333333 per sec 0.33333333 / 10 = 0.033333 per 0.1 sec (100 millisecond) local level = 0 local waterState = "raising" local runningTimer function editSomeWater() if waterState == "raising" then level = level + 0.033333 setWaterLevel ( level ) if level >= 20 then waterState = "draining" setWaterLevel ( 20 ) end elseif waterState == "draining " then level = level - 0.033333 setWaterLevel ( level ) if level <= 0 then waterState = nil --"raising" for repeating setWaterLevel ( 0 ) end elseif isTimer(runningTimer) then killTimer(runningTimer) end end setTimer (function () runningTimer = setTimer ( editSomeWater, 100, 0 ) end,15000,1) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Moderators IIYAMA Posted June 5, 2013 Moderators Posted June 5, 2013 Must it stay at 20 m? local level = 0 local runningTimer function editSomeWater() level = level + 0.033333 setWaterLevel ( level ) if level >= 20 then setWaterLevel ( 20 ) if isTimer(runningTimer) then killTimer(runningTimer) end runningTimer = nil end end setTimer (function () runningTimer = setTimer ( editSomeWater, 100, 0 ) end,15000,1) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
BieHDC Posted June 5, 2013 Author Posted June 5, 2013 can you make this please with that i can set in directly the highest water level(20) the time to need until 20 (60sec) and the time to start raise and the script would calculate by itself? If i have to change the numbers, that would be easyer^^
Moderators IIYAMA Posted June 5, 2013 Moderators Posted June 5, 2013 aha lazy guy. Next time you make your own. local maxLevel = 20 -- max level local untilW = 60 -- sec local raising,level = (maxLevel/untilW)/10,0 untilW = nil local runningTimer function editSomeWater() level = level + raising -- level raising setWaterLevel ( level ) -- set the level if level >= maxLevel then -- compare values of level and max level setWaterLevel ( 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,15000,1) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
BieHDC Posted June 5, 2013 Author Posted June 5, 2013 thank you^^ are you paid scripter? then i have a big job for you
Moderators IIYAMA Posted June 5, 2013 Moderators Posted June 5, 2013 np. nope, I don't have time for paid scripting. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
MTA Team qaisjp Posted June 5, 2013 MTA Team Posted June 5, 2013 im a good scripter. but i cant test anymore. ask solidsnake14/Castillo
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