AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   [STOCK] Creating customizable fog (https://forums.alliedmods.net/showthread.php?t=132812)

abdul-rehman 07-19-2010 05:13

[STOCK] Creating customizable fog
 
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_fog25500

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_fog000

- 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

grimvh2 07-19-2010 06:02

Re: [STOCK] Creating customizable fog
 
You have fps drops when using this? (I get a drop from 101 to 40 when using smoke)

abdul-rehman 07-20-2010 04:05

Re: [STOCK] Creating customizable fog
 
Quote:

Originally Posted by grimvh2 (Post 1244239)
You have fps drops when using this? (I get a drop from 101 to 40 when using smoke)

No.....:up:

grimvh2 07-20-2010 08:08

Re: [STOCK] Creating customizable fog
 
Quote:

Originally Posted by abdul-rehman (Post 1245314)
No.....:up:

Then this is helpfull, thanks.

joropito 07-20-2010 14:22

Re: [STOCK] Creating customizable fog
 
Change MSG_ALL to MSG_BROADCAST

mottzi 07-20-2010 19:14

Re: [STOCK] Creating customizable fog
 
can you add a Screenshot, please?

abdul-rehman 07-21-2010 03:45

Re: [STOCK] Creating customizable fog
 
Quote:

Originally Posted by joropito (Post 1245765)
Change MSG_ALL to MSG_BROADCAST

Can u tell me whats the difference between them ? :oops:

joropito 07-21-2010 08:41

Re: [STOCK] Creating customizable fog
 
Quote:

Originally Posted by abdul-rehman (Post 1246475)
Can u tell me whats the difference between them ? :oops:

MSG_ALL: tries to send a reliable msg to all players and wait for that

MSG_BROADCAST: send a msg and trust that it will be read by each player


Using MSG_ALL you can get some crash with a lagged server or a high cpu usage.

abdul-rehman 07-21-2010 11:23

Re: [STOCK] Creating customizable fog
 
Quote:

Originally Posted by joropito (Post 1246619)
MSG_ALL: tries to send a reliable msg to all players and wait for that

MSG_BROADCAST: send a msg and trust that it will be read by each player


Using MSG_ALL you can get some crash with a lagged server or a high cpu usage.

OK thanx for the information

DruGzOG 07-23-2010 21:41

Re: [STOCK] Creating customizable fog
 
How does this not drop fps?


All times are GMT -4. The time now is 13:31.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.