HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. // Include File
  2.  
  3. #include < amxmodx >
  4. #include < amxmisc >
  5. #include < fun >
  6. #include < fakemeta >
  7. #include < fakemeta_util >
  8.  
  9. // Info Plugin
  10.  
  11. #define PLUGIN "Plant Timer"
  12. #define VERSION "1.6"
  13. #define AUTHOR "swapped"
  14.  
  15. // Variables
  16.  
  17. new bool:planted;
  18. new plant_count[33];
  19. new g_iPlant_cvar;
  20. new g_iSanction_cvar;
  21. new bool:task;
  22.  
  23. // Pragma
  24.  
  25. #pragma semicolon 1
  26.  
  27. public plugin_init( )
  28. {
  29. /* Plugin Info */
  30.  
  31. register_plugin(PLUGIN, VERSION, AUTHOR);
  32.  
  33. /* Register Cvar`s */
  34.  
  35. g_iPlant_cvar = register_cvar( "plant_count", "60" );
  36. g_iSanction_cvar = register_cvar( "plant_sanction", "3" );
  37.  
  38. /* Register Some CMD`s to block it */
  39.  
  40. register_clcmd( "drop", "CmdBlockDrop" );
  41. register_clcmd( "chooseteam", "CmdBlock" );
  42. register_clcmd( "jointeam", "CmdBlock" );
  43. register_clcmd( "jointeam 1", "CmdBlock");
  44. register_clcmd( "jointeam 2", "CmdBlock");
  45. register_clcmd( "jointeam 3", "CmdBlock");
  46. register_clcmd( "jointeam 4", "CmdBlock");
  47. register_clcmd( "jointeam 5", "CmdBlock");
  48. register_clcmd( "jointeam 6", "CmdBlock");
  49.  
  50. /* Bomb Events */
  51.  
  52. register_logevent( "logevent_function_s", 3, "2=Spawned_With_The_Bomb" );
  53. register_logevent( "hk_die_msg", 3, "2=Dropped_The_Bomb" );
  54. register_logevent( "logevent_function_p", 3, "2=Planted_The_Bomb" );
  55. register_logevent( "logevent_function_e", 3, "2=Got_The_Bomb" );
  56. register_logevent( "logevent_round_start", 2, "1=Round_Start" ) ;
  57. register_logevent( "logevent_round_end", 2, "1=Round_End" ) ;
  58.  
  59. /* Block Suicide */
  60.  
  61. register_forward( FM_ClientKill, "Forward_ClientKill" );
  62.  
  63. /* Multi Language */
  64.  
  65. register_dictionary( "plant_timer.txt" );
  66.  
  67. }
  68.  
  69. public logevent_round_start()
  70. {
  71. if( !task )
  72. set_task( 1.75, "scan" );
  73. }
  74.  
  75. public client_putinserver( id )
  76. plant_count[id] = get_pcvar_num( g_iPlant_cvar );
  77.  
  78.  
  79. public logevent_round_end( )
  80. {
  81. new Players[ 32 ];
  82. new playerCount, i;
  83. get_players( Players, playerCount, "a" );
  84.  
  85. for( i = 0; i < playerCount; i++ )
  86. {
  87. if( is_user_alive( Players[ i ] ) )
  88. {
  89. remove_task( Players[i] );
  90. plant_count[ Players[ i ] ] = get_pcvar_num( g_iPlant_cvar );
  91. }
  92. }
  93. }
  94.  
  95. public logevent_function_s( )
  96. {
  97. if( !task )
  98. set_task( 1.75, "scan" );
  99. }
  100.  
  101.  
  102. public logevent_function_e()
  103. {
  104. if( !task )
  105. set_task( 1.75, "scan" );
  106. }
  107.  
  108.  
  109.  
  110. public scan()
  111. {
  112. new Players[ 32 ];
  113. new playerCount, i;
  114. get_players( Players, playerCount, "a" );
  115.  
  116. for( i=0; i<playerCount; i++ )
  117. {
  118. if( user_has_weapon( Players[ i ], CSW_C4 ) )
  119. {
  120. if( is_user_alive( Players[ i ] ) )
  121. {
  122. set_task( 1.0, "check_if_plant", Players[ i ] );
  123. planted = false;
  124. task = true;
  125. plant_count[ Players[ i ] ] = get_pcvar_num( g_iPlant_cvar );
  126. }
  127. }
  128. }
  129. }
  130. public check_if_plant( id )
  131. {
  132. new szName[ 33 ];
  133. get_user_name( id, szName, charsmax( szName ) - 1 );
  134.  
  135. if( planted || get_user_team( id ) == 2 || !user_has_weapon( id, CSW_C4 ) )
  136. {
  137. remove_task( id );
  138. return PLUGIN_HANDLED;
  139. }
  140.  
  141. if( !plant_count[ id ] )
  142. {
  143. remove_task( id );
  144. plant_count[ id ] = get_pcvar_num(g_iPlant_cvar);
  145.  
  146. switch( get_pcvar_num( g_iSanction_cvar ) )
  147. {
  148. case 1:
  149. {
  150. set_task( 1.0, "OtherPlayer" );
  151. user_kill( id );
  152. client_print( 0, print_chat, " %L",id,"KILLED ",szName );
  153. return PLUGIN_HANDLED;
  154. }
  155. case 2:
  156. {
  157. set_task( 1.0, "OtherPlayer" );
  158. server_cmd( "kick #%d Kilettel rugva mert nem plantoltal idoben!",get_user_userid( id ) );
  159. return PLUGIN_HANDLED;
  160. }
  161.  
  162. case 3:
  163. {
  164. new iPlayers[ 32 ], iNum;
  165. get_players( iPlayers, iNum, "c", "TERRORIST" );
  166.  
  167. new iRandomPlayer = iPlayers[ random_num( 0, iNum -1 ) ];
  168.  
  169. if( is_user_alive( iRandomPlayer ) && get_user_team( iRandomPlayer ) == 1 )
  170. {
  171. fm_transfer_user_gun( id, iRandomPlayer, CSW_C4 );
  172. return PLUGIN_CONTINUE;
  173. }
  174.  
  175. }
  176.  
  177. default: return PLUGIN_HANDLED;
  178. }
  179.  
  180. return PLUGIN_HANDLED;
  181. }
  182.  
  183. else
  184. {
  185. set_hudmessage( 85, 255, 42, 0.03, 0.38, 0, 6.0, 1.0 );
  186. show_hudmessage( id, "%L",id,"PLANT",plant_count[id] );
  187. set_task( 1.0, "check_if_plant", id );
  188. plant_count[id]--;
  189. return PLUGIN_CONTINUE;
  190. }
  191. return PLUGIN_CONTINUE;
  192. }
  193.  
  194. public logevent_function_p( )
  195. {
  196. planted = true;
  197. task = false;
  198. }
  199.  
  200. public OtherPlayer( )
  201. {
  202.  
  203. if(planted)
  204. {
  205. return PLUGIN_HANDLED;
  206. }
  207.  
  208. new iPlayers[ 32 ], iNum;
  209. get_players( iPlayers, iNum, "c", "TERRORIST" );
  210.  
  211. new iRandomPlayer = iPlayers[ random_num( 0, iNum -1 ) ];
  212.  
  213. if( is_user_alive( iRandomPlayer ) && get_user_team(iRandomPlayer) == 1 )
  214. {
  215. give_item( iRandomPlayer, "weapon_c4" );
  216. set_task( 1.0, "check_if_plant", iRandomPlayer );
  217. return PLUGIN_CONTINUE;
  218. }
  219. return PLUGIN_CONTINUE;
  220. }
  221.  
  222. public Forward_ClientKill( id )
  223. {
  224. if(is_user_alive(id))
  225. return FMRES_SUPERCEDE;
  226. return FMRES_IGNORED;
  227.  
  228. }
  229.  
  230.  
  231. public CmdBlock( const id )
  232. {
  233. if( user_has_weapon( id, CSW_C4 ) )
  234. {
  235. client_print( id, print_center, "%L",id,"NO_CHANGE_TEAM" );
  236. return PLUGIN_HANDLED;
  237. }
  238. return PLUGIN_CONTINUE;
  239. }
  240.  
  241. public CmdBlockDrop( const id )
  242. {
  243. new weapon = get_user_weapon( id );
  244.  
  245. if( weapon == CSW_C4 )
  246. {
  247. client_print( id, print_center, "%L",id,"NO_DROP" );
  248. return PLUGIN_HANDLED;
  249. }
  250. return PLUGIN_CONTINUE;
  251. }
  252.  
  253. public hk_die_msg( )
  254. {
  255. if( planted )
  256. return PLUGIN_HANDLED;
  257.  
  258. new id = get_loguser_index( );
  259.  
  260. if( is_user_alive( id ) )
  261. {
  262. remove_task( id );
  263. plant_count[ id ] = get_pcvar_num(g_iPlant_cvar);
  264. task = false;
  265. return PLUGIN_HANDLED;
  266. }
  267. return PLUGIN_CONTINUE;
  268. }
  269.  
  270. stock get_loguser_index()
  271. {
  272. new loguser[ 80 ];
  273. new name[32];
  274.  
  275. read_logargv( 0, loguser, 79 );
  276. parse_loguser( loguser, name, 31 );
  277.  
  278. return get_user_index( name );
  279. }