Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.57 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <hamsandwich>
  3. #include <fakemeta>
  4. #include <cstrike>
  5. #include <engine>
  6.  
  7. new players[ 32 ], pnum
  8.  
  9. new Float: spawn[ 100 ][ 3 ], s_ent
  10. new x_spawn
  11.  
  12. new p_position[ 33 ]
  13. new p_duel[ 33 ]
  14. new p_alone, bool:_p_alone
  15. new p_left_opponent, bool:_p_left_opponent
  16.  
  17. new Float: fStarting, Float: p_fStarting[ 33 ]
  18.  
  19. new bool: started, kills
  20.  
  21. new bool:p_allowed[ 33 ]
  22.  
  23. public plugin_init()
  24. {
  25.     register_plugin( "arena 1v1" , "1.0" , "nebitno bitno da se ima" );
  26.    
  27.     register_event( "HLTV", "event_new_round", "a", "1=0", "2=0" )  
  28.     RegisterHam( Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1 )
  29.     register_event( "DeathMsg", "death_msg", "a" )
  30.     RegisterHam(Ham_TakeDamage, "player", "fwdPlayerHurt")
  31.    
  32.     server_cmd( "mp_friendlyfire 1" )
  33. }
  34. public pfn_keyvalue( ent )  
  35. {
  36.     if( !pev_valid( ent ) ) return
  37.    
  38.     new classname[32], key[32], value[32]
  39.     copy_keyvalue(classname, 31, key, 31, value, 31)
  40.  
  41.     if( equal( key, "targetname" ) && containi( value, "arena_" ) != -1 )
  42.     {
  43.         entity_get_vector( ent, EV_VEC_origin, spawn[ ++s_ent ] )
  44.     }
  45. }
  46. public event_new_round()
  47. {
  48.     kills = 0
  49.     started = false
  50.     x_spawn = 0
  51.     fStarting = get_gametime()
  52.     set_task( 7.0, "duel_start" )
  53. }
  54. public client_disconnect( id )
  55. {
  56.     if( is_user_alive( id ) )
  57.     {
  58.         if( _p_alone )
  59.         {
  60.             ExecuteHamB( Ham_CS_RoundRespawn, p_duel[ id ] )
  61.             entity_set_origin( p_duel[ id ], spawn[ p_position[ p_duel[ id ] ] ] ) //da ozivi igraca na njegovom spawnu
  62.            
  63.             entity_set_origin( p_alone, spawn[ p_position[ id ] ] )
  64.             _p_alone = false
  65.            
  66.             p_duel[ p_alone ] = p_duel[ id ] //updating duel players
  67.             p_duel[ id ] = p_alone
  68.         }
  69.         else
  70.         {
  71.             p_left_opponent = true
  72.             p_left_opponent = p_position[ id ]
  73.         }
  74.     }
  75. }
  76. public death_msg( id )
  77. {
  78.     new id = read_data( 1 )
  79.     new vid = read_data( 2 )
  80.    
  81.     if( !started ) return
  82.    
  83.     kills++
  84.     p_allowed[ id ] = true
  85.     ExecuteHamB( Ham_CS_RoundRespawn, id )
  86.    
  87.     if( kills > 1 )
  88.     {
  89.         if( _p_left_opponent )
  90.         {
  91.             entity_set_origin( id, spawn[ p_position[ p_left_opponent ] ] )
  92.             _p_left_opponent = false
  93.             p_duel[ id ] = p_duel[ p_left_opponent ]
  94.             p_duel[ p_left_opponent ] = id
  95.         }
  96.         else
  97.         {
  98.             entity_set_origin( id, spawn[ p_position[ vid ] ] )
  99.             entity_set_origin( p_duel[ vid ], spawn[ p_position[ p_duel[ vid ] ] ] )
  100.             p_duel[ id ] = p_duel[ vid ]
  101.             p_duel[ vid ] = id
  102.         }
  103.     }
  104.     else
  105.     {
  106.         entity_set_origin( id, spawn[ p_position[ id ] ] )
  107.     }
  108.        
  109. }
  110. public fwHamPlayerSpawnPost( id )
  111. {
  112.     if( !is_user_connected( id ) )
  113.         return
  114.    
  115.     p_fStarting[ id ] = get_gametime()
  116.     if( p_fStarting[ id ] < 7.0 + fStarting || p_allowed[ id ] )
  117.     {
  118.         if( p_allowed[ id ] )
  119.             client_print( id, print_chat, "[Arena] Duel pocinje za %.01f sec", 7.0 - ( p_fStarting[ id ] - fStarting ) )
  120.            
  121.         p_allowed[ id ] = false
  122.     }
  123.     else
  124.     {
  125.         client_print( id, print_chat, "[Arena] Zakasnio si za duel, sacekaj da zavrse ovu rundu" )
  126.         user_silentkill( id )
  127.     }
  128. }
  129. public duel_start()
  130. {
  131.     get_players( players, pnum, "a" )
  132.    
  133.     if( pnum <= 1 )
  134.     {
  135.         return
  136.     }
  137.     else if( pnum == 2 )
  138.     {  
  139.         //celo je ovo moglo mozda da se skrati (kroz loop od 2, ali rezultat se isti dobija
  140.         started = true
  141.         x_spawn = 1
  142.         entity_set_origin( players[ 0 ], spawn[ x_spawn ] )
  143.         p_position[ players[ 0 ] ] = x_spawn
  144.         p_duel[ players[ 0 ] ] = players[ 1 ]
  145.        
  146.         entity_set_origin( players[ 1 ], spawn[ ++x_spawn ] )
  147.         p_position[ players[ 1 ] ] = x_spawn
  148.         p_duel[ players[ 1 ] ] = players[ 0 ]
  149.     }
  150.     else if( pnum >= 3 )
  151.     {
  152.         started = true
  153.         if( ( pnum & 1 ) == 0 )
  154.         {
  155.             new name[ 32 ]
  156.             p_alone = pnum - 1
  157.             _p_alone = true
  158.             get_user_name( p_alone, name, charsmax( name ) )
  159.             client_print( 0, print_console, "---Arena--- %s is alone in arena, waiting for first kill", name )
  160.         }
  161.         for( new i; i < pnum; i++ )
  162.         {
  163.             entity_set_origin( players[ i ], spawn[ ++x_spawn ] )
  164.             p_position[ players[ i ] ] = x_spawn
  165.  
  166.             if( i == 0 )
  167.             {
  168.                 p_duel[ i ] = i + 1
  169.                 p_duel[ i + 1 ] = i
  170.             }
  171.             else
  172.             {
  173.                 if( i > 1 )
  174.                 {
  175.                     i = ( ( i & 1 ) == 1 ) ? i + 1: i
  176.                 }
  177.                 else
  178.                     continue
  179.        
  180.                 if( i + 1 >= pnum ) break
  181.                
  182.                 p_duel[ i ] = i + 1
  183.                 p_duel[ i + 1 ] = i
  184.             }
  185.         }
  186.         client_print( 0, print_chat, "[Arena] Currently playing: %d players", pnum )
  187.     }
  188. }
  189.  
  190. public fwdPlayerHurt( iVictim, iInflictor, iAttacker, Float:flDamage, iDmgBits ) //from Variable-friendly
  191. {
  192.     if( !is_user_connected( iAttacker ) )
  193.         return HAM_IGNORED
  194.  
  195.     if( !started )
  196.         return HAM_SUPERCEDE
  197.        
  198.     if( cs_get_user_team( iAttacker ) == cs_get_user_team( iVictim ) )
  199.         SetHamParamFloat( 4, flDamage * 2.86 )
  200.    
  201.     return HAM_IGNORED
  202. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement