HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include < amxmodx >
  2. #include < engine >
  3. #include < hamsandwich >
  4.  
  5. #define IsPlayer(%1) ( 1 <= %1 <= g_iMaxPlayers )
  6.  
  7. new const g_szClassname[ ] = "trigger_rules_watch";
  8.  
  9. enum _:RoomTypes {
  10. JAIL,
  11. GUNROOM,
  12. MARIOROOM
  13. };
  14.  
  15. enum _:CVARS {
  16. CV_JAIL_NOKILL,
  17. CV_JAIL_TIME,
  18.  
  19. CV_GUNROOM_NOKILL,
  20. CV_GUNROOM_TIME,
  21.  
  22. CV_MARIOROOM_NOKILL,
  23. CV_MARIOROOM_TIME
  24. };
  25.  
  26. new const g_szZones[ RoomTypes ][ ] = {
  27. "Jail",
  28. "Gun room",
  29. "Mario room"
  30. };
  31.  
  32. new const Float:g_flOrigins[ ][ 3 ] = {
  33. { -405.0, 2900.0, 720.0 },
  34. { -486.0, -1000.0, -275.0 },
  35. { -405.0, 2949.0, 2422.0 }
  36. };
  37.  
  38. new const Float:g_flAngles[ ][ 3 ] = {
  39. { 0.0, 270.0, 0.0 },
  40. { 0.0, 270.0, 0.0 },
  41. { 0.0, 270.0, 0.0 }
  42. };
  43.  
  44. new g_iMaxPlayers;
  45. new g_iCounter[ 33 ];
  46. new bool:g_bNoKill[ 33 ];
  47. new Float:g_flLastTouch[ 33 ];
  48. new g_pCvars[ CVARS ], g_iCvars[ CVARS ];
  49.  
  50. public plugin_init( ) {
  51. register_plugin( "surf_ski_2: Rules Watcher", "1.1", "xPaw" );
  52.  
  53. register_cvar( "ss2_rules_watcher", "1.1", FCVAR_SERVER | FCVAR_SPONLY );
  54.  
  55. g_iMaxPlayers = get_maxplayers( );
  56.  
  57. g_pCvars[ CV_JAIL_NOKILL ] = register_cvar( "rw_ss2_jail_nokill", "0" );
  58. g_pCvars[ CV_JAIL_TIME ] = register_cvar( "rw_ss2_jail_time", "999999" );
  59.  
  60. g_pCvars[ CV_GUNROOM_NOKILL ] = register_cvar( "rw_ss2_gunroom_nokill", "1" );
  61. g_pCvars[ CV_GUNROOM_TIME ] = register_cvar( "rw_ss2_gunroom_time", "999999" );
  62.  
  63. g_pCvars[ CV_MARIOROOM_NOKILL ] = register_cvar( "rw_ss2_marioroom_nokill", "1" );
  64. g_pCvars[ CV_MARIOROOM_TIME ] = register_cvar( "rw_ss2_marioroom_time", "999999" );
  65.  
  66. new szMap[ 12 ];
  67. get_mapname( szMap, 11 );
  68.  
  69. if( equali( szMap, "surf_ski_2" ) ) {
  70. CreateTrigger( JAIL, Float:{ -579.0, 2983.0, 586.0 }, Float:{ -309.0, 3288.0, 796.0 } );
  71. CreateTrigger( GUNROOM, Float:{ -713.0, -990.0, -157.0 }, Float:{ -295.0, -651.0, 26.0 } );
  72. CreateTrigger( MARIOROOM, Float:{ 2735.0, 193.0, -2361.0 }, Float:{ 3654.0, 1118.0, -2083.0 } );
  73.  
  74. register_touch( g_szClassname, "player", "FwdTriggerTouch" );
  75. RegisterHam( Ham_Spawn, "player", "FwdHamPlayerSpawn", 1 );
  76. RegisterHam( Ham_TakeDamage, "player", "FwdHamTakeDamage" );
  77. RegisterHam( Ham_TraceAttack, "player", "FwdHamTraceAttack" );
  78.  
  79. register_event( "HLTV", "EventNewRound", "a", "1=0", "2=0" );
  80.  
  81. CacheCvars( );
  82. }
  83. }
  84.  
  85. public EventNewRound( )
  86. CacheCvars( );
  87.  
  88. public FwdHamPlayerSpawn( const id ) {
  89. if( is_user_alive( id ) ) {
  90. g_bNoKill[ id ] = false;
  91. g_flLastTouch[ id ] = 0.0;
  92. g_iCounter[ id ] = 0;
  93. }
  94. }
  95.  
  96. public FwdHamTraceAttack( const id, const iAttacker ) {
  97. if( IsPlayer( iAttacker ) && g_bNoKill[ id ] && id != iAttacker ) {
  98. if( ( g_flLastTouch[ id ] + 0.1 ) >= get_gametime( ) )
  99. return HAM_SUPERCEDE;
  100. else
  101. g_bNoKill[ id ] = false;
  102. }
  103.  
  104. return HAM_IGNORED;
  105. }
  106.  
  107. public FwdHamTakeDamage( const id, const iInflictor, const iAttacker ) {
  108. if( IsPlayer( iAttacker ) && g_bNoKill[ id ] && id != iAttacker ) {
  109. if( ( g_flLastTouch[ id ] + 0.1 ) >= get_gametime( ) )
  110. return HAM_SUPERCEDE;
  111. else
  112. g_bNoKill[ id ] = false;
  113. }
  114.  
  115. return HAM_IGNORED;
  116. }
  117.  
  118. public FwdTriggerTouch( const iEntity, const id ) {
  119. static Float:flGametime;
  120. flGametime = get_gametime( );
  121.  
  122. if( flGametime > ( g_flLastTouch[ id ] + 1.2 ) ) {
  123. g_iCounter[ id ] = 0;
  124. g_flLastTouch[ id ] = flGametime;
  125. }
  126. else if( g_flLastTouch[ id ] < flGametime ) {
  127. g_iCounter[ id ]++;
  128.  
  129. static iType, bool:bNoKill, iTime;
  130. iType = entity_get_int( iEntity, EV_INT_iuser1 );
  131.  
  132. GetCvars( iType, bNoKill, iTime );
  133.  
  134. g_bNoKill[ id ] = bNoKill;
  135.  
  136. if( iTime > 0 ) {
  137. if( g_iCounter[ id ] >= iTime ) {
  138. if( iTime >= 5 ) {
  139. engclient_print( id, engprint_center, "^nTobb idot toltottel el mint %i masodperc %s%s-ban.^nKi lettel dobva.", iTime, iType == MARIOROOM ? "^n" : " ", g_szZones[ iType ] );
  140.  
  141. client_cmd( id, "spk buttons/blip1" );
  142. }
  143.  
  144. entity_set_vector( id, EV_VEC_angles, g_flAngles[ iType ] );
  145. entity_set_int( id, EV_INT_fixangle, 1 );
  146. entity_set_origin( id, g_flOrigins[ iType ] );
  147. }
  148.  
  149. if( g_iCounter[ id ] < 5 ) {
  150. if( iTime >= 5 )
  151. engclient_print( id, engprint_center, "%sTe %s-ban vagy.%s^n^nEnnyi idod van hogy kimenj: %i!", bNoKill ? "" : "^n", g_szZones[ iType ], bNoKill ? "^nYou can't kill anyone here." : "", iTime );
  152. else
  153. engclient_print( id, engprint_center, "%sTe %s.%s-ban vagy", bNoKill ? "" : "^n", g_szZones[ iType ], bNoKill ? "^nItt nem tudsz megolni senkit." : "" );
  154. }
  155. }
  156.  
  157. g_flLastTouch[ id ] = flGametime + 1.0;
  158. }
  159. }
  160.  
  161. GetCvars( const iType, &bool:bNoKill, &iTime ) {
  162. static CvarNoKill, CvarTime;
  163.  
  164. switch( iType ) {
  165. case JAIL: {
  166. CvarNoKill = CV_JAIL_NOKILL;
  167. CvarTime = CV_JAIL_TIME;
  168. }
  169. case GUNROOM: {
  170. CvarNoKill = CV_GUNROOM_NOKILL;
  171. CvarTime = CV_GUNROOM_TIME;
  172. }
  173. case MARIOROOM: {
  174. CvarNoKill = CV_MARIOROOM_NOKILL;
  175. CvarTime = CV_MARIOROOM_TIME;
  176. }
  177. }
  178.  
  179. bNoKill = bool:( g_iCvars[ CvarNoKill ] );
  180. iTime = g_iCvars[ CvarTime ];
  181. }
  182.  
  183. CacheCvars( ) {
  184. g_iCvars[ CV_JAIL_NOKILL ] = get_pcvar_num( g_pCvars[ CV_JAIL_NOKILL ] );
  185. g_iCvars[ CV_JAIL_TIME ] = get_pcvar_num( g_pCvars[ CV_JAIL_TIME ] );
  186.  
  187. g_iCvars[ CV_GUNROOM_NOKILL ] = get_pcvar_num( g_pCvars[ CV_GUNROOM_NOKILL ] );
  188. g_iCvars[ CV_GUNROOM_TIME ] = get_pcvar_num( g_pCvars[ CV_GUNROOM_TIME ] );
  189.  
  190. g_iCvars[ CV_MARIOROOM_NOKILL ] = get_pcvar_num( g_pCvars[ CV_MARIOROOM_NOKILL ] );
  191. g_iCvars[ CV_MARIOROOM_TIME ] = get_pcvar_num( g_pCvars[ CV_MARIOROOM_TIME ] );
  192. }
  193.  
  194. CreateTrigger( const iType, const Float:flMins[ 3 ], const Float:flMaxs[ 3 ] ) {
  195. new iEntity = create_entity( "info_target" );
  196.  
  197. if( !is_valid_ent( iEntity ) ) {
  198. log_amx( "Nem sikerult letrehozni ezt: ^"%s^"", g_szZones[ iType ] );
  199.  
  200. return 0;
  201. }
  202.  
  203. entity_set_string( iEntity, EV_SZ_classname, g_szClassname );
  204. entity_set_int( iEntity, EV_INT_iuser1, iType );
  205. entity_set_int( iEntity, EV_INT_movetype, MOVETYPE_NONE );
  206. entity_set_int( iEntity, EV_INT_solid, SOLID_TRIGGER );
  207. entity_set_size( iEntity, flMins, flMaxs );
  208.  
  209. return iEntity;
  210. }