Here is a stock i made for creating fog ingame without restarting the server or changing the map
Code:
stock msg_create_fog( iRed, iGreen, iBlue, iDensity )
{
// Fog density offsets [Thnx to DA]
new const fog_density[ ] = { 0, 0, 0, 0, 111, 18, 3, 58, 111, 18, 125, 58, 66, 96, 27, 59, 90, 101, 60, 59, 90,
101, 68, 59, 10, 41, 95, 59, 111, 18, 125, 59, 111, 18, 3, 60, 68, 116, 19, 60 }
// Get the amount of density
new dens
dens = ( 4 * iDensity )
// The fog message
message_begin( MSG_BROADCAST, get_user_msgid( "Fog" ), { 0,0,0 }, 0 )
write_byte( iRed ) // Red
write_byte( iGreen ) // Green
write_byte( iBlue ) // Blue
write_byte( fog_density[ dens ] ) // SD
write_byte( fog_density[ dens + 1 ] ) // ED
write_byte( fog_density[ dens + 2 ] ) // D1
write_byte( fog_density[ dens + 3 ] ) // D2
message_end( )
}
Its usage is simple:
For eg if you want red fog then do this:
PHP Code:
msg_create_fog( 255, 0, 0, 1 )
1st argument is the red color content of the fog [Must be a num between 1-255]
2nd argument is the green color content of the fog [Must be a num between 1-255]
3rd argument is the blue color content of the fog [Must be a num between 1-255]
4th argument is the amount of density of the fog [Must be a num between 1-9]
To disable fog you can do this:
PHP Code:
msg_create_fog( 0, 0, 0, 0 )
- For creating black fog [Sounds wierd] you can set all colors to 0
- The fog only works if you have set your cs display settings to OpenGL and you should set this cvar gl_fog to 1 in order to see the fog
- You can change the fog color and density in-game [Using cvars] without restarting the map
__________________