kieran Posted July 13, 2017 Share Posted July 13, 2017 (edited) I made a super simple weather script that changes weather and rain, but I am having some issues as I want to add a command to allow players to stop rain until they log off.... Server weather = {} weathers = 3 --1,2,3 weather[1] = 0 weather[2] = 3 weather[3] = 7 --rain rain = {} Therain = 3 --1,2,3 rain[1] = 0 rain[2] = 10 rain[3] = 5 setTimer( function (thePlayer) local Wacc = getPlayerAccount(thePlayer) if Wacc then local CheckWeather = getElementData( thePlayer, "tempdata.ChkWeath" ) if ( CheckWeather == false ) then randomWeather = math.random (1, weathers) randomRain = math.random (1, Therain) local cusweather = setWeather (weather[randomWeather]) local cusrain = setRainLevel (rain[randomRain]) elseif ( CheckWeather == true ) then return end end end, 300000, 1) function stopTheRain ( thePlayer, command ) local Wacc = getPlayerAccount(thePlayer) if Wacc then local setElementData ( thePlayer, "tempdata.ChkWeath", Wacc ) end end addCommandHandler("norain", stopTheRain) Basically it works on server if it's just cycling weather, but I wanted players to have choice for it to never rain as it can be a little FPS consuming. Error: [2017-07-13 03:02:19] SCRIPT ERROR: WeatherStuff\Weather.lua:63: ')' expected near ',' Why does it expect a bracket on line 63? Oh! And while I'm at it... Am I even setting element data correctly? Thanks in advance! P.S Reason it is server is because I tried it client (just changing weather and rain level (set for 10 secs) ) and it didn't work. Edited July 13, 2017 by kieran Link to comment
pro-mos Posted July 13, 2017 Share Posted July 13, 2017 Where's line 63 ?!? and line 42:setElementData ( thePlayer, "tempdata.ChkWeath", Wacc ) 1 Link to comment
kieran Posted July 13, 2017 Author Share Posted July 13, 2017 (edited) my bad @pro-mos, I meant line 42, I forgot I had stuff at start. (Is commented, so won't matter if it's there.) never mind, I put local where local shouldn't be... Fixed that problem.... But now I have another problem: Weather.lua:23: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] Spoiler weather = {} weathers = 3 --1,2,3 weather[1] = 0 weather[2] = 3 weather[3] = 7 --rain rain = {} Therain = 3 --1,2,3 rain[1] = 0 rain[2] = 10 rain[3] = 5 setTimer( function (thePlayer) local Wacc = getPlayerAccount(thePlayer) if Wacc then CheckWeather = getElementData( thePlayer, "tempdata.ChkWeath" ) if ( CheckWeather == false ) then randomWeather = math.random (1, weathers) randomRain = math.random (1, Therain) local cusweather = setWeather (weather[randomWeather]) local cusrain = setRainLevel (rain[randomRain]) elseif ( CheckWeather == true ) then return end end end, 300000, 1) function stopTheRain ( thePlayer, command ) local Wacc = getPlayerAccount(thePlayer) if Wacc then setElementData ( thePlayer, "tempdata.ChkWeath", Wacc ) outputDebugString ( "User changed weather settings." ) end end addCommandHandler("antirain", stopTheRain) Starting to think it would just be easier to set the data and timers client side..... Edited July 13, 2017 by kieran Link to comment
Sticmy Posted July 13, 2017 Share Posted July 13, 2017 (edited) local Wacc = getAccountName(getPlayerAccount(thePlayer)) Edited July 13, 2017 by Steven'Bc Link to comment
pa3ck Posted July 13, 2017 Share Posted July 13, 2017 If you turn off the rain server side, it will be turned off for everybody else as well. @ line 42 use setAccountData to save the "ChkWeath" state on the user account and also use setElementData which you can use on the client side. Use onPlayerLogin event to get the accountData and save it to setElementData again to be able to use it client side. You can also just implement the command client side and use xmlCreateFile / xmlLoadFile to create a settings XML where you can save things like this.. When you create a timer, there's no thePlayer parameter either, you can only pass values into it manually. 1 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