goofie88 Posted November 17, 2012 Share Posted November 17, 2012 (edited) local level = 0 function floodSA(source,command,speed) if (isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("Admin"))) then if (speed) then if (isTimer(waterTimer)) then killTimer(waterTimer) destroyElement(floodWater) setWaterLevel(0) level = 0 outputDebugString ("Previous flooding has been stopped by the server.") end local speed = tonumber(speed) floodWater = createWater(-2998,-2998,0,2998,-2998,0,-2998,2998,0,2998,2998,0) outputChatBox("--------------------------------",getRootElement(),255,0,0) outputChatBox("ALERT: A FLOOD IS EMERGING! FIND HIGH GROUND!!!",getRootElement(),255,0,0) outputChatBox("--------------------------------",getRootElement(),255,0,0) waterTimer = setTimer(addSomeWater,100,0,speed) outputDebugString("Flooding started by "..getPlayerName (source).." at a speed of "..speed..".") else outputChatBox("You must specify a speed.",source,255,0,0) end else outputChatBox ("You must be an admin to use this command!",source,255,0,0) end end function floodCd () setTimer ( floodSA() outputChatBox ( "Flood will start in 5 sec" ) end, 5000, 1 ) addCommandHandler("flood",floodCd) [2012-11-17 18:58:32] WARNING: Loading script failed: flood\flood.lua:30: ')' expected (to close '(' at line 29) near 'outputChatBox' Why doesnt it work? Seems theres no error for me Edited November 17, 2012 by Guest Link to comment
Renkon Posted November 17, 2012 Share Posted November 17, 2012 (edited) setTimer ( function() floodSA() outputChatBox ( "Flood will start in 5 sec" ) end, 5000, 1 ) You missed function() Edited November 17, 2012 by Guest Link to comment
manve1 Posted November 17, 2012 Share Posted November 17, 2012 (edited) local level = 0 function floodSA(source,command,speed) if (isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("Admin"))) then if (speed) then if (isTimer(waterTimer)) then killTimer(waterTimer) destroyElement(floodWater) setWaterLevel(0) level = 0 outputDebugString ("Previous flooding has been stopped by the server.") end local speed = tonumber(speed) floodWater = createWater(-2998,-2998,0,2998,-2998,0,-2998,2998,0,2998,2998,0) outputChatBox("--------------------------------",root,255,0,0) outputChatBox("ALERT: A FLOOD IS EMERGING! FIND HIGH GROUND!!!",root,255,0,0) outputChatBox("--------------------------------",root,255,0,0) waterTimer = setTimer(addSomeWater,100,0,speed) outputDebugString("Flooding started by "..getPlayerName (source).." at a speed of "..speed..".") else outputChatBox("You must specify a speed.",source,255,0,0) end else outputChatBox ("You must be an admin to use this command!",source,255,0,0) end end function floodCd() setTimer ( function() outputChatBox ( "Flood will start in 5 sec", root, 255, 0, 0 ) end, 5000, 1 ) end addCommandHandler("flood",floodCd) Edited November 17, 2012 by Guest Link to comment
goofie88 Posted November 17, 2012 Author Share Posted November 17, 2012 Thank you Renkon there are no more errors but it doesnt call the flood Link to comment
Renkon Posted November 17, 2012 Share Posted November 17, 2012 floodSA(source,command,speed) <-- it requires 3 arguments in setTimer you are calling it with no arguments! Link to comment
Anderl Posted November 17, 2012 Share Posted November 17, 2012 (edited) --declare global variables local iLevel = 0; local pTimer = false; --declare main functions function FloodSA( player, _, iWrSpeed ) if (isObjectInACLGroup( "user." .. getAccountName( getPlayerAccount( player ) ), aclGetGroup( "Admin" ) )) then if (iWrSpeed) then if (isTimer( pTimer )) then --kill timer & destroys water killTimer( pTimer ); setWaterLevel( 0 ); iLevel = 0; outputDebugString( "Previous flood has been stopped by the server" ); end iWrSpeed = tonumber( iWrSpeed ); --starts new flood outputDebugString( "Floodin' started by " .. getPlayerName( player ) .. "at a speed of 1 meter per " .. iWrSpeed .. " seconds!" ); outputChatBox( "Water flood will start in 5 seconds!", root, 255, 0, 0, false ); pTimer = setTimer( AddWater, ( iWrSpeed * 1000 ), 0 ); outputChatBox( "--------------------------------", player, 255, 0, 0, false ); outputChatBox( "ALERT: A FLOOD IS EMERGING! FIND A HIGH GROUND!!!", player, 255, 0, 0, false ); outputChatBox( "--------------------------------", player, 255, 0, 0, false ); else --no speed arg passed; throwing error msg outputChatBox( "You must specify a speed!", player, 255, 0, 0, false ); end else --the element who called the command isn't an admin outputChatBox( "You aren't an admin!", player, 255, 0, 0, false ); end end addCommandHandler( "flood", FloodSA ); function AddWater() if (iLevel) then setWaterLevel( iLevel + 0.5 ); end end Not tested, though. To use this do: /flood [0-infinite] - speed is ( specifiedArg * 1000 ) which means 1 = 1000, 2 = 2000, 3 = 3000, ... P.S. Be sure to set the file as server-side. Edited November 17, 2012 by Guest Link to comment
goofie88 Posted November 17, 2012 Author Share Posted November 17, 2012 none of these scripts works Link to comment
Anderl Posted November 17, 2012 Share Posted November 17, 2012 Any errors in my script? How about using /debugscript 3? Link to comment
goofie88 Posted November 17, 2012 Author Share Posted November 17, 2012 nope no errors Link to comment
Anderl Posted November 17, 2012 Share Posted November 17, 2012 What appears in the chat box? Link to comment
goofie88 Posted November 17, 2012 Author Share Posted November 17, 2012 It writes "Water flood will start in 5 seconds!" and "ALERT: A FLOOD IS EMERGING! FIND A HIGH GROUND!!!" then it makes the water higher and stops Link to comment
goofie88 Posted November 17, 2012 Author Share Posted November 17, 2012 ah I fixed the Timer but I have a new problem, when i do /flood-stop the water goes instantly down not slowly /debugscript 3 - no errors local level = 0 local left = 5000 function floodSA(source,command,speed) if (isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("Admin"))) then if (speed) then outputChatBox ("Flood will start in 5 sec") if (isTimer(waterTimer)) then killTimer(waterTimer) destroyElement(floodWater) setWaterLevel(0) level = 0 outputDebugString ("Previous flooding has been stopped by the server.") end setTimer ( function () local speed = tonumber(speed) floodWater = createWater(-2998,-2998,0,2998,-2998,0,-2998,2998,0,2998,2998,0) outputChatBox("--------------------------------",getRootElement(),255,0,0) outputChatBox("ALERT: A FLOOD IS EMERGING! FIND HIGH GROUND!!!",getRootElement(),255,0,0) outputChatBox("--------------------------------",getRootElement(),255,0,0) waterTimer = setTimer(addSomeWater,100,0,speed) outputDebugString("Flooding started by "..getPlayerName (source).." at a speed of "..speed..".") end ,left, 1) else outputChatBox("You must specify a speed.",source,255,0,0) end else outputChatBox ("You must be an admin to use this command!",source,255,0,0) end end addCommandHandler("flood",floodSA) function addSomeWater(speed) level = level+speed/100 setWaterLevel(level) end function delSomeWater () height = getWaveHeight ( floodWater ) setWaterLevel ( height - 0.1) end function stopFlood(source,command) if (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("Admin"))) then if (isTimer(waterTimer)) then killTimer(waterTimer) -- destroyElement(floodWater) waterDown = setTimer(delSomeWater,100,0) outputDebugString("Flooding stopped by "..getPlayerName(source)..".") outputChatBox("THE FLOOD HAS PASSED, RETURN TO YOUR HOMES!",getRootElement(),255,0,0) else outputChatBox("There is no flood to stop.",source,255,0,0) end end end addCommandHandler("flood-stop",stopFlood) function resetWater() setWaterLevel(0) end addEventHandler("onResourceStop",getResourceRootElement(getThisResource()),resetWater) 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