Javier Posted March 21, 2013 Posted March 21, 2013 Hey guys, check this out function blackSky ( ) local weather = getWeather ( ) if ( ( weather ) == 9 ) then setSkyGradient ( 0, 0 ,0, 10, 10 ,10 ) else resetSkyGradient ( ) end end addEventHandler ( "onResourceStart", resourceRoot, blackSky ) The problem is that the sky is always black. Although the weather is not number 9...Any idea how I can fix it?
Moderators IIYAMA Posted March 21, 2013 Moderators Posted March 21, 2013 the numbers are from 0 t/m 255 10 = almost black. try: addEventHandler ( "onResourceStart", resourceRoot, function ( ) local weather = getWeather ( ) if weather == 9 then -- you don't have to use "()" when they aren't needed. setSkyGradient ( 0, 0 ,0, 200, 200 ,200 ) else resetSkyGradient ( ) end end) --You need to use " ()" at moments like this: 100*(100+1) = A -- 100+1 = 101 *100 = 10100 -- When you write it without "()" 100*100+1 = A --100*100 =10000 + 1 = 10001 () is always the first thing you do. 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
Blaawee Posted March 21, 2013 Posted March 21, 2013 setSkyGradient ( topRed, topGreen, topBlue, bottomRed, bottomGreen, bottomBlue ) #Optional Arguments : - topRed: The red value of the upper part of the sky, from 0 to 255. - topGreen: The green value of the upper part of the sky, from 0 to 255. - topBlue: The blue value of the upper part of the sky, from 0 to 255. - bottomRed: The red value of the lower part of the sky, from 0 to 255. - bottomGreen: The green value of the lower part of the sky, from 0 to 255. - bottomBlue: The blue value of the lower part of the sky, from 0 to 255.
Javier Posted March 21, 2013 Author Posted March 21, 2013 when I activate the resource, the sky is always black even though the weather is not the number 9
Moderators IIYAMA Posted March 21, 2013 Moderators Posted March 21, 2013 Even when you use this: setSkyGradient ( 255, 255 ,255, 255, 255 ,255 ) (/start runcode) /run setSkyGradient ( 255, 255 ,255, 255, 255 ,255 ) ? 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
Blaawee Posted March 21, 2013 Posted March 21, 2013 try this : change the color you want and remember setSkyGradient ( topRed, topGreen, topBlue, bottomRed, bottomGreen, bottomBlue ) #Optional Arguments : - topRed: The red value of the upper part of the sky, from 0 to 255. - topGreen: The green value of the upper part of the sky, from 0 to 255. - topBlue: The blue value of the upper part of the sky, from 0 to 255. - bottomRed: The red value of the lower part of the sky, from 0 to 255. - bottomGreen: The green value of the lower part of the sky, from 0 to 255. - bottomBlue: The blue value of the lower part of the sky, from 0 to 255. #Make sure it's Server side. addEventHandler ( 'onResourceStart', resourceRoot, function ( res ) local weatherID = getWeather( ); if ( weatherID == 9 ) then setSkyGradient( 255, 255 ,255, 255, 255 ,255 ); else resetSkyGradient( ); end end );
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