Vinspire Posted June 13, 2014 Share Posted June 13, 2014 (edited) Hello guys, the code below is an attempt of trying to set your own weather on your screen with the command csw. What I thought of here is that if you do => E.g: "/csw 0" then you get the normal weather, /csw 1 = sun, /csw 2 = foggy, and so on to 250 or so, (idk the max weather list) Could you help me a bit with this? doesn't work perfectly now. It's because it sets randomly weathers when you do /csw. I don't want it to set randomly, I want the thing above. Do you think you could help? if so Thanks alot. addCommandHandler('csw', function ( ) setWeather(math.random (0, 9 ) ) local Weather = getWeather () outputChatBox("The weather is currently: "..Weather, source) end ) Edited June 14, 2014 by Guest Link to comment
Moderators IIYAMA Posted June 13, 2014 Moderators Share Posted June 13, 2014 (edited) addCommandHandler('csw', function (player,CMD,Weather) Weather = tonumber(Weather) if Weather then setWeather(Weather) --local Weather = getWeather () outputChatBox("The weather is currently: "..Weather, player) end end) Edited June 13, 2014 by Guest Link to comment
Vinspire Posted June 13, 2014 Author Share Posted June 13, 2014 addCommandHandler('csw', function (Weather) Weather = tonumber(Weather) if Weather then setWeather(Weather) --local Weather = getWeather () outputChatBox("The weather is currently: "..Weather, source) end end) That doesn't work ;s Link to comment
Moderators IIYAMA Posted June 13, 2014 Moderators Share Posted June 13, 2014 Copy my code again. Link to comment
Et-win Posted June 13, 2014 Share Posted June 13, 2014 For client-side: addCommandHandler('csw', function (Weather) Weather = tonumber(Weather) local sWeather = setWeather(Weather) if (sWeather == false) then outputChatBox("This is not a valid weather ID! You entered: "..Weather) end end end) For server-side: addCommandHandler('csw', function (Weather) Weather = tonumber(Weather) local sWeather = setWeather(Weather) if (sWeather == false) then outputChatBox("This is not a valid weather ID! You entered: "..Weather, source) end end end) Link to comment
Karuzo Posted June 13, 2014 Share Posted June 13, 2014 For server-side: addCommandHandler('csw', function (Weather) Weather = tonumber(Weather) local sWeather = setWeather(Weather) if (sWeather == false) then outputChatBox("This is not a valid weather ID! You entered: "..Weather, source) end end end) addCommandHandler server-side has a playerSource parameter. your forgot that. Link to comment
Et-win Posted June 13, 2014 Share Posted June 13, 2014 *Coughs* For server-side: function cWeather(thePlayer, theCommand, weatherID) local weatherID = tonumber(weatherID) local sWeather = setWeather(weatherID) if (sWeather ~= false) then outputChatBox("Successfully changed the weather!", thePlayer) else outputChatBox("This is not a valid weather ID. You entered: "..tostring(weatherID), thePlayer) end end addCommandHandler("cws", cWeather) For client-side: function cWeather(theCommand, weatherID) local weatherID = tonumber(weatherID) local sWeather = setWeather(weatherID) if (sWeather ~= false) then outputChatBox("Successfully changed the weather!") else outputChatBox("This is not a valid weather ID. You entered: "..tostring(weatherID)) end end addCommandHandler("cws", cWeather) Typed in my own 'rules' this time. I guess it shouldn't give any errors by 'setWeather' if I'm correct Link to comment
Vinspire Posted June 13, 2014 Author Share Posted June 13, 2014 Thanks guys, . If you could help me setting the time too that would be best doesn't work too, doesn't say much on this on the wiki so =/ What I want with this code is that players can set their own time on their screen for better graphic or other reasons. addEventHandler( 'onClientRender', getRootElement( ), function (csettime) local hour, minutes = getTime() setTime( 1, 0 ) end ) addCommandHandler('cst', csettime) Thanks! Link to comment
Et-win Posted June 13, 2014 Share Posted June 13, 2014 Take my client-side code. Add one more variable into the function. Add one more local variable to make the variable you just added to the function a number (tonumber()). Change the 'setWeather' code to the 'setTime' code and it's needed 'settings'. Link to comment
Vinspire Posted June 14, 2014 Author Share Posted June 14, 2014 Something like this? .. (sorry I didn't really get what you mean (shit scripter <-) function cTime(theCommand, timeID) local timeID= tonumber(timeID) local sTime = setTime(timeID) if (sTime ~= false) then end end addCommandHandler("cst", cTime) addCommandHandler("csettime", cTime) Link to comment
Et-win Posted June 14, 2014 Share Posted June 14, 2014 Something like this? ..(sorry I didn't really get what you mean (:~ scripter <-) Code Should do the hours and minutes separated, because 'setTime' needs that. function cTime(theCommand, timeID1, timeID2) local timeID1 = tonumber(timeID1) --Hours local timeID2 = tonumber(timeID2) --Minutes local sTime = setTime(timeID1, timeID2) if (sTime ~= false) then --Success else --Failed end end addCommandHandler("cst", cTime) addCommandHandler("csettime", cTime) Note: This is client-side. 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