Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.74 KB | None | 0 0
  1. /*
  2. Formatright © 2009, Jon
  3.  
  4. "Weed (CS)" is free software;
  5. you can redistribute it and/or modify it under the terms of the
  6. GNU General Public License as published by the Free Software Foundation.
  7.  
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12.  
  13. You should have received a copy of the GNU General Public License
  14. along with "Weed (CS)"; if not, write to the
  15. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  16. Boston, MA 02111-1307, USA.
  17. */
  18.  
  19. #include <amxmodx>
  20. #include <fakemeta>
  21. #include <engine>
  22.  
  23. #define PLUGIN "Weed"
  24. #define VERSION "1.0"
  25. #define AUTHOR "Jon"
  26.  
  27. #define write_coord_f(%1) engfunc(EngFunc_WriteCoord,%1)
  28.  
  29. #define FOV_AMOUNT 120
  30.  
  31. new const g_szHatModel[ ] = "models/hat/jamacahat2.mdl";
  32. new const g_szSmokeSprite[ ] = "sprites/steam1.spr";
  33. new const g_szSoundFile[ ] = "your_sound_file.mp3";
  34. new const g_szEntityClass[ ] = "class_weed";
  35.  
  36. new g_pDuration;
  37. new g_pCoolDown;
  38. new g_pAngles;
  39. new g_pDamage;
  40. new g_pColor;
  41. new g_pAdminOnly;
  42.  
  43. new g_iMaxPlayers;
  44. new g_iMsgSetFOV;
  45. new g_iMsgScreenFade;
  46. new g_iSmoke;
  47. new g_iTimer[ 33 ];
  48.  
  49. new bool:g_bColor;
  50. new bool:g_bAngles;
  51. new bool:g_bDamage;
  52. new bool:g_bSmoking[ 33 ];
  53.  
  54. new Float:g_fCoolDown[ 33 ];
  55.  
  56. public plugin_precache( )
  57. {
  58. precache_sound( g_szSoundFile );
  59. precache_model( g_szHatModel );
  60. precache_model( "models/rpgrocket.mdl" );
  61.  
  62. g_iSmoke = precache_model( g_szSmokeSprite );
  63. }
  64.  
  65. public plugin_init( )
  66. {
  67. register_plugin( PLUGIN, VERSION, AUTHOR );
  68.  
  69. g_pDuration = register_cvar( "weed_duration", "10" );
  70. g_pCoolDown = register_cvar( "weed_cooldown", "60.0" );
  71. g_pColor = register_cvar( "weed_color", "1" );
  72. g_pDamage = register_cvar( "weed_damage", "1" );
  73. g_pAngles = register_cvar( "weed_angles", "1" );
  74. g_pAdminOnly = register_cvar( "weed_adminonly", "0" );
  75.  
  76. g_iMaxPlayers = get_maxplayers( );
  77. g_iMsgSetFOV = get_user_msgid( "SetFOV" );
  78. g_iMsgScreenFade = get_user_msgid( "ScreenFade" );
  79.  
  80. register_event( "HLTV", "EventNewRound", "a", "1=0", "2=0" );
  81. register_logevent( "EventStartRound", 2, "1=Round_Start" );
  82.  
  83. register_think( g_szEntityClass, "FwdWeedThink" );
  84.  
  85. register_clcmd( "say /weed", "CmdWeed" );
  86. }
  87.  
  88. public EventNewRound( )
  89. {
  90. for( new i = 1; i <= g_iMaxPlayers; i++ )
  91. {
  92. g_bSmoking[ i ] = false;
  93. }
  94. }
  95.  
  96. public EventStartRound( )
  97. {
  98. g_bColor = bool:get_pcvar_num( g_pColor );
  99. g_bAngles = bool:get_pcvar_num( g_pAngles );
  100. g_bDamage = bool: get_pcvar_num( g_pDamage );
  101. }
  102.  
  103. public CmdWeed( iClient )
  104. {
  105. if( !is_user_alive( iClient ) )
  106. {
  107. client_print( iClient, print_chat, "[WEED] Dead men smoke no weed." );
  108. }
  109.  
  110. else if( g_fCoolDown[ iClient ] > get_gametime( ) )
  111. {
  112. client_print( iClient, print_chat, "[WEED] Try again in %.1f seconds.", g_fCoolDown[ iClient ] - get_gametime( ) );
  113. }
  114.  
  115. else if( g_bSmoking[ iClient ] )
  116. {
  117. client_print( iClient, print_chat, "[WEED] Dumbass! You're already smoking." );
  118. }
  119.  
  120. else if( get_pcvar_num( g_pAdminOnly ) && !( get_user_flags( iClient ) & ADMIN_BAN ) )
  121. {
  122. client_print( iClient, print_chat, "[WEED] Only admins smoke weed." );
  123. }
  124.  
  125. else
  126. {
  127. StartSmoking( iClient );
  128. }
  129. }
  130.  
  131. public FwdWeedThink( iEnt )
  132. {
  133. new iClient = entity_get_edict( iEnt, EV_ENT_aiment );
  134.  
  135. if( !is_user_alive( iClient ) || !g_bSmoking[ iClient ] )
  136. {
  137. StopSmoking( iClient, iEnt );
  138.  
  139. return PLUGIN_HANDLED;
  140. }
  141.  
  142. if( g_iTimer[ iClient ] > 0 )
  143. {
  144. UTIL_Smoke( iEnt );
  145.  
  146. if( g_bColor )
  147. {
  148. UTIL_ScreenFade( iClient );
  149. }
  150.  
  151. if( g_bAngles )
  152. {
  153. new Float:vPunchAngle[ 3 ];
  154. vPunchAngle[ 0 ] = random_float( 0.0, 180.0 );
  155. vPunchAngle[ 1 ] = random_float( 0.0, 180.0 );
  156. vPunchAngle[ 2 ] = random_float( 0.0, 180.0 );
  157.  
  158. entity_set_vector( iClient, EV_VEC_punchangle, vPunchAngle );
  159. }
  160.  
  161. if( g_bDamage )
  162. {
  163. fakedamage( iClient, "weed", 1.0, DMG_FREEZE );
  164. }
  165.  
  166. g_iTimer[ iClient ]--;
  167. entity_set_float( iEnt, EV_FL_nextthink, get_gametime( ) + 1.0 );
  168.  
  169. }
  170.  
  171. else
  172. {
  173. StopSmoking( iClient, iEnt );
  174. }
  175.  
  176. return PLUGIN_CONTINUE;
  177. }
  178.  
  179. StartSmoking( const iClient )
  180. {
  181. new iEnt = create_entity( "info_target" );
  182. entity_set_string( iEnt, EV_SZ_classname, g_szEntityClass );
  183. entity_set_int( iEnt, EV_INT_movetype, MOVETYPE_FOLLOW );
  184. entity_set_edict( iEnt, EV_ENT_aiment, iClient );
  185. entity_set_model( iEnt, g_szHatModel );
  186.  
  187. g_bSmoking[ iClient ] = true;
  188. g_iTimer[ iClient ] = get_pcvar_num( g_pDuration );
  189.  
  190. UTIL_Fov( iClient, 130 );
  191. entity_set_float( iEnt, EV_FL_nextthink, get_gametime( ) );
  192. client_cmd( iClient, "mp3 play sound/%s", g_szSoundFile );
  193.  
  194. new szName[ 33 ];
  195. get_user_name( iClient, szName, 32 );
  196.  
  197. set_hudmessage( random( 256 ), random( 256 ), random( 256 ), -1.0, -1.0, 1, 0.0, 4.0 );
  198. show_hudmessage( 0, "%s is smoking weeeeed!", szName );
  199. }
  200.  
  201. StopSmoking( const iClient, const iEnt )
  202. {
  203. g_bSmoking[ iClient ] = false;
  204. g_fCoolDown[ iClient ] = get_gametime( ) + get_pcvar_float( g_pCoolDown );
  205.  
  206. UTIL_Fov( iClient, 90 );
  207. client_cmd( iClient, "mp3 stop" );
  208.  
  209. if( g_bAngles )
  210. {
  211. entity_set_vector( iClient, EV_VEC_punchangle, Float:{ 0.0, 0.0, 0.0 } );
  212. }
  213.  
  214. remove_entity( iEnt );
  215. }
  216.  
  217. UTIL_ScreenFade( const iClient )
  218. {
  219. message_begin( MSG_ONE, g_iMsgScreenFade, _, iClient )
  220. write_short( 4096 );
  221. write_short( 4096 );
  222. write_short( 0x0000 );
  223. write_byte( random( 256 ) );
  224. write_byte( random( 256 ) );
  225. write_byte( random( 256 ) );
  226. write_byte( random( 256 ) );
  227. message_end( );
  228. }
  229.  
  230. UTIL_Fov( const iClient, const iAmount )
  231. {
  232. message_begin( MSG_ONE, g_iMsgSetFOV, _, iClient );
  233. write_byte( iAmount );
  234. message_end( );
  235. }
  236.  
  237. UTIL_Smoke( const iEnt )
  238. {
  239. new Float:vOrigin[ 3 ];
  240. entity_get_vector( iEnt, EV_VEC_origin, vOrigin );
  241.  
  242. message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
  243. write_byte( TE_SMOKE );
  244. write_coord_f( vOrigin[ 0 ] );
  245. write_coord_f( vOrigin[ 1 ] );
  246. write_coord_f( vOrigin[ 2 ] );
  247. write_short( g_iSmoke );
  248. write_byte( 10 );
  249. write_byte( 10 );
  250. message_end( );
  251. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement