Advertisement
Arxero

Real Snow

Dec 5th, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <engine>
  3. #include <hamsandwich>
  4.  
  5. #define PLUGIN "Snow"
  6. #define VERSION "0.6"
  7. #define AUTHOR "Mistrick / edit LAWLIET / Nickron"
  8.  
  9. #define get_bit(%1,%2) (%1 & (1 << (%2 & MAXCLIENTS-1)))
  10. #define set_bit(%1,%2) (%1 |= (1 << (%2 & MAXCLIENTS-1)))
  11. #define reset_bit(%1,%2) (%1 &= ~(1 << (%2 & MAXCLIENTS-1)))
  12.  
  13. #define MAXCLIENTS 32
  14. #define SNOW_SPRITE "sprites/lawliet_snow/lawliet_snow.spr"
  15. #define CLASSNAME "SnowEntity"
  16.  
  17. new g_bAlive;
  18.  
  19. new g_iSpriteSnow;
  20. new g_iMaxPlayers;
  21.  
  22. public plugin_init()
  23. {
  24. register_plugin(PLUGIN, VERSION, AUTHOR);
  25.  
  26. register_event("HLTV", "Event_NewRound", "a", "1=0", "2=0");
  27. register_cvar("lawliet", "ny_RainingSnow", FCVAR_SERVER);
  28.  
  29. new ent = create_entity("info_target");
  30.  
  31. entity_set_string(ent, EV_SZ_classname, CLASSNAME);
  32. entity_set_float(ent, EV_FL_nextthink, get_gametime() + 2.0);
  33.  
  34. register_think(CLASSNAME, "ThinkSnow");
  35.  
  36. RegisterHam(Ham_Spawn, "player", "Ham_PlayerSpawn_Post", 1);
  37. RegisterHam(Ham_Killed, "player", "HamPlayerKilled_Post", 1);
  38.  
  39. g_iMaxPlayers = get_maxplayers();
  40. }
  41. public plugin_precache()
  42. {
  43. g_iSpriteSnow = precache_model(SNOW_SPRITE);
  44. }
  45. public Ham_PlayerSpawn_Post(id)
  46. {
  47. if(is_user_alive(id)) set_bit(g_bAlive, id);
  48. }
  49. public Event_NewRound(){
  50. set_fog(0, 255, 255);
  51. set_lights ("c");
  52. }
  53. public HamPlayerKilled_Post(id)
  54. {
  55. reset_bit(g_bAlive, id);
  56. }
  57. public ThinkSnow(ent)
  58. {
  59. entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.05);
  60.  
  61. static id;
  62. for(id = 1; id <= g_iMaxPlayers; id++)
  63. {
  64. if(!get_bit(g_bAlive, id)) continue;
  65.  
  66. new Float:fOrigin[3], iOrigin[3];
  67. entity_get_vector(id, EV_VEC_origin, fOrigin);
  68. FVecIVec(fOrigin, iOrigin);
  69. iOrigin[0] += random_num(-1000, 1000);
  70. iOrigin[1] += random_num(-1000, 1000);
  71. iOrigin[2] += random_num(100, 200);
  72. UTIL_CreateSnow(iOrigin, g_iSpriteSnow, 1, 1, 4);
  73. }
  74. }
  75. stock UTIL_CreateSnow(const iOrigin[3], const iSpriteID, const iCount, const iLife, const iScale)
  76. {
  77. message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  78. write_byte(TE_SPRITETRAIL);
  79. write_coord(iOrigin[0]); // start position (X)
  80. write_coord(iOrigin[1]); // start position (Y)
  81. write_coord(iOrigin[2]); // start position (Z)
  82. write_coord(iOrigin[0]); // end position (X)
  83. write_coord(iOrigin[1]); // end position (Y)
  84. write_coord(iOrigin[2]); // end position (Z)
  85. write_short(iSpriteID); // sprite index
  86. write_byte(iCount); // number of snow
  87. write_byte(iLife); // life in 0.1's
  88. write_byte(iScale); // scale in 0.1's
  89. write_byte(random_num(1, 5)); // velocity along vector in 10's
  90. write_byte(random_num(1, 3)); // randomness of velocity in 10's
  91. message_end();
  92. }
  93.  
  94. stock set_fog(red, green, blue){
  95. message_begin(MSG_ALL, get_user_msgid("Fog"));
  96. write_byte(red);
  97. write_byte(green);
  98. write_byte(blue);
  99. write_long(_:0.00050)
  100. message_end();
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement