Vinspire Posted June 13, 2014 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 If nothing goes right, go left.
Moderators IIYAMA Posted June 13, 2014 Moderators 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 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
Vinspire Posted June 13, 2014 Author 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 If nothing goes right, go left.
Moderators IIYAMA Posted June 13, 2014 Moderators Posted June 13, 2014 Copy my code again. 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
Et-win Posted June 13, 2014 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) ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
Karuzo Posted June 13, 2014 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.
Et-win Posted June 13, 2014 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 ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
Vinspire Posted June 13, 2014 Author 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! If nothing goes right, go left.
Et-win Posted June 13, 2014 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'. ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
Vinspire Posted June 14, 2014 Author 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) If nothing goes right, go left.
Et-win Posted June 14, 2014 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. ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
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