Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <hamsandwich>
- #include <fakemeta>
- #include <cstrike>
- #include <engine>
- new players[ 32 ], pnum
- new Float: spawn[ 100 ][ 3 ], s_ent
- new x_spawn
- new p_position[ 33 ]
- new p_duel[ 33 ]
- new p_alone, bool:_p_alone
- new p_left_opponent, bool:_p_left_opponent
- new Float: fStarting, Float: p_fStarting[ 33 ]
- new bool: started, kills
- new bool:p_allowed[ 33 ]
- public plugin_init()
- {
- register_plugin( "arena 1v1" , "1.0" , "nebitno bitno da se ima" );
- register_event( "HLTV", "event_new_round", "a", "1=0", "2=0" )
- RegisterHam( Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1 )
- register_event( "DeathMsg", "death_msg", "a" )
- RegisterHam(Ham_TakeDamage, "player", "fwdPlayerHurt")
- server_cmd( "mp_friendlyfire 1" )
- }
- public pfn_keyvalue( ent )
- {
- if( !pev_valid( ent ) ) return
- new classname[32], key[32], value[32]
- copy_keyvalue(classname, 31, key, 31, value, 31)
- if( equal( key, "targetname" ) && containi( value, "arena_" ) != -1 )
- {
- entity_get_vector( ent, EV_VEC_origin, spawn[ ++s_ent ] )
- }
- }
- public event_new_round()
- {
- kills = 0
- started = false
- x_spawn = 0
- fStarting = get_gametime()
- set_task( 7.0, "duel_start" )
- }
- public client_disconnect( id )
- {
- if( is_user_alive( id ) )
- {
- if( _p_alone )
- {
- ExecuteHamB( Ham_CS_RoundRespawn, p_duel[ id ] )
- entity_set_origin( p_duel[ id ], spawn[ p_position[ p_duel[ id ] ] ] ) //da ozivi igraca na njegovom spawnu
- entity_set_origin( p_alone, spawn[ p_position[ id ] ] )
- _p_alone = false
- p_duel[ p_alone ] = p_duel[ id ] //updating duel players
- p_duel[ id ] = p_alone
- }
- else
- {
- p_left_opponent = true
- p_left_opponent = p_position[ id ]
- }
- }
- }
- public death_msg( id )
- {
- new id = read_data( 1 )
- new vid = read_data( 2 )
- if( !started ) return
- kills++
- p_allowed[ id ] = true
- ExecuteHamB( Ham_CS_RoundRespawn, id )
- if( kills > 1 )
- {
- if( _p_left_opponent )
- {
- entity_set_origin( id, spawn[ p_position[ p_left_opponent ] ] )
- _p_left_opponent = false
- p_duel[ id ] = p_duel[ p_left_opponent ]
- p_duel[ p_left_opponent ] = id
- }
- else
- {
- entity_set_origin( id, spawn[ p_position[ vid ] ] )
- entity_set_origin( p_duel[ vid ], spawn[ p_position[ p_duel[ vid ] ] ] )
- p_duel[ id ] = p_duel[ vid ]
- p_duel[ vid ] = id
- }
- }
- else
- {
- entity_set_origin( id, spawn[ p_position[ id ] ] )
- }
- }
- public fwHamPlayerSpawnPost( id )
- {
- if( !is_user_connected( id ) )
- return
- p_fStarting[ id ] = get_gametime()
- if( p_fStarting[ id ] < 7.0 + fStarting || p_allowed[ id ] )
- {
- if( p_allowed[ id ] )
- client_print( id, print_chat, "[Arena] Duel pocinje za %.01f sec", 7.0 - ( p_fStarting[ id ] - fStarting ) )
- p_allowed[ id ] = false
- }
- else
- {
- client_print( id, print_chat, "[Arena] Zakasnio si za duel, sacekaj da zavrse ovu rundu" )
- user_silentkill( id )
- }
- }
- public duel_start()
- {
- get_players( players, pnum, "a" )
- if( pnum <= 1 )
- {
- return
- }
- else if( pnum == 2 )
- {
- //celo je ovo moglo mozda da se skrati (kroz loop od 2, ali rezultat se isti dobija
- started = true
- x_spawn = 1
- entity_set_origin( players[ 0 ], spawn[ x_spawn ] )
- p_position[ players[ 0 ] ] = x_spawn
- p_duel[ players[ 0 ] ] = players[ 1 ]
- entity_set_origin( players[ 1 ], spawn[ ++x_spawn ] )
- p_position[ players[ 1 ] ] = x_spawn
- p_duel[ players[ 1 ] ] = players[ 0 ]
- }
- else if( pnum >= 3 )
- {
- started = true
- if( ( pnum & 1 ) == 0 )
- {
- new name[ 32 ]
- p_alone = pnum - 1
- _p_alone = true
- get_user_name( p_alone, name, charsmax( name ) )
- client_print( 0, print_console, "---Arena--- %s is alone in arena, waiting for first kill", name )
- }
- for( new i; i < pnum; i++ )
- {
- entity_set_origin( players[ i ], spawn[ ++x_spawn ] )
- p_position[ players[ i ] ] = x_spawn
- if( i == 0 )
- {
- p_duel[ i ] = i + 1
- p_duel[ i + 1 ] = i
- }
- else
- {
- if( i > 1 )
- {
- i = ( ( i & 1 ) == 1 ) ? i + 1: i
- }
- else
- continue
- if( i + 1 >= pnum ) break
- p_duel[ i ] = i + 1
- p_duel[ i + 1 ] = i
- }
- }
- client_print( 0, print_chat, "[Arena] Currently playing: %d players", pnum )
- }
- }
- public fwdPlayerHurt( iVictim, iInflictor, iAttacker, Float:flDamage, iDmgBits ) //from Variable-friendly
- {
- if( !is_user_connected( iAttacker ) )
- return HAM_IGNORED
- if( !started )
- return HAM_SUPERCEDE
- if( cs_get_user_team( iAttacker ) == cs_get_user_team( iVictim ) )
- SetHamParamFloat( 4, flDamage * 2.86 )
- return HAM_IGNORED
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement