Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Sublime AMXX Editor v2.2 */
- #include <amxmodx>
- #include <engine>
- #include <fakemeta>
- #include <colorchat>
- #define PLUGIN "LJ CUP 240 (kz_lj2)"
- #define VERSION "1.5"
- #define AUTHOR "JocA"
- #define MODEL "models/player.mdl"
- #define TASK_ALMOST_STARTED 1222
- #define TASK_FINISH_CUP 1555
- new g_szMapName[ 32 ]
- new g_iVerticalInvis
- new g_iHorizontalJumped
- new Float: float_origin[ 3 ] = { 848.0, 953.0, -845.0 }
- new Float: float_full_tp[ 3 ] = { 2300.0, 953.0, -895.0 }
- new Float: float_jumped_block[ 3 ] = { 990.0, 762.0, -873.0 }
- new Float: float_jumped_tp[ 3 ] = { 990.0, 1355.0, -825.0 }
- new g_iPlayerBlock[ 33 ]
- new bool: g_bTouching[ 33 ]
- new bool: g_bPlaying[ 33 ]
- new bool: g_bCup
- new bool: g_bPrepareStart
- new Float: g_fCupTime
- new g_entCountDown, Float: g_flFreq, Float: g_flTimeLeft //connor
- public plugin_init()
- {
- register_plugin(PLUGIN, VERSION, AUTHOR)
- register_touch( "kz_lj2_horizontal_jumped", "player", "jumped_it" )
- register_touch( "kz_lj2_full_tp", "player", "failed_it" )
- register_clcmd( "say /startlj", "lj_starting" )
- register_clcmd( "say /endlj", "quit_lj" )
- register_clcmd( "say /quitlj", "quit_lj" )
- register_clcmd( "say /joinlj", "joining" )
- register_forward(FM_PlayerPreThink, "FM_PlayerPreThink_Pre", 0) //NumB thanks!
- get_mapname( g_szMapName, charsmax( g_szMapName ) )
- if( !equal( g_szMapName, "kz_longjumps2" ) )
- set_fail_state( "LJ-Cup plugin paused, not kz_longjumps2 map" )
- }
- public client_putinserver( id )
- {
- g_iPlayerBlock[ id ] = 0
- g_bTouching[ id ] = false
- }
- public client_disconnected( id )
- {
- g_iPlayerBlock[ id ] = 0
- g_bTouching[ id ] = false
- if( g_bPlaying[ id ] )
- quit_lj( id )
- }
- public FM_PlayerPreThink_Pre(iPlrId)
- {
- if( !g_bCup )
- return FMRES_IGNORED;
- if( !g_bPlaying[ iPlrId ] )
- return FMRES_IGNORED;
- if( pev(iPlrId, pev_oldbuttons)&IN_DUCK && !(pev(iPlrId, pev_button)&IN_DUCK) ) // if user unpressed duck key
- {
- static s_iFlags;
- s_iFlags = pev(iPlrId, pev_flags);
- if( !(s_iFlags&FL_DUCKING) && pev(iPlrId, pev_bInDuck) ) // if user wasn't fully ducked and is in ducking process
- {
- set_pev(iPlrId, pev_bInDuck, false); // set user not in ducking process
- set_pev(iPlrId, pev_flags, (s_iFlags|FL_DUCKING)); // set user fully fucked
- engfunc(EngFunc_SetSize, iPlrId, Float:{-16.0, -16.0, -25.0}, Float:{16.0, 16.0, 25.0}); // set user size as fully ducked (won't take one frame delay)
- message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, iPlrId)
- write_short((1<<8))
- write_short((1<<8))
- write_short(0x0000)
- write_byte(255)
- write_byte(0)
- write_byte(0)
- write_byte(130)
- message_end()
- set_dhudmessage( 100, 5, 5, -1.0, 0.6, 0, 3.0 )
- show_dhudmessage( iPlrId, "Blocking Mouse Duck!^nJump just with the LJ!" )
- }
- }
- return FMRES_IGNORED;
- }
- public joining( id )
- {
- if( g_bPlaying[ id ] )
- {
- ColorChat( id, BLUE, "^4[LJ-Cup]^1 You are already in the LJ Cup!" )
- return PLUGIN_HANDLED
- }
- if( g_bCup )
- {
- ColorChat( id, BLUE, "^4[LJ-Cup]^1 You must wait new LJ Cup to start." )
- return PLUGIN_HANDLED
- }
- if( g_bPrepareStart )
- {
- g_bPlaying[ id ] = true
- ColorChat( 0, BLUE, "^4[LJ-Cup]^3 %n^1 joined the^3 LJ Cup^1. Hurry up!", id )
- return PLUGIN_HANDLED
- }
- return PLUGIN_HANDLED
- }
- public quit_lj( id )
- {
- if( !g_bPlaying[ id ] )
- {
- ColorChat( 0, RED, "^4[LJ-Cup]^1 You can't leave if you didn't join..." )
- return PLUGIN_HANDLED
- }
- if( g_bPrepareStart || g_bCup )
- {
- ColorChat( 0, RED, "^4[LJ-Cup]^3 %n^1 left the^3 LJ Cup^1. Ask him why...", id )
- g_bPlaying[ id ] = false
- g_iPlayerBlock[ id ] = 0
- }
- new num_of_players
- for( new i = 1; i <= get_maxplayers(); i++ )
- {
- if( !is_user_connected( i ) || is_user_bot( i ) )
- continue
- if( g_bPlaying[ i ] )
- num_of_players++
- }
- if( !num_of_players )
- {
- finish_cup( 0 )
- ColorChat( 0, RED, "^4[LJ-Cup]^1 Cup has Ended, there are no players left." )
- }
- return PLUGIN_HANDLED
- }
- public lj_starting( id )
- {
- if( g_bPrepareStart || g_bCup )
- {
- ColorChat( id, BLUE, "^4[LJ-Cup]^1 Cup is already in progress. Join or wait to start the new one!" )
- return PLUGIN_HANDLED
- }
- ColorChat( 0, BLUE, "^4[LJ-Cup]^3 %n^1 started the race, type^3 /joinlj^1 to join!^4 [Starting in 10 seconds]", id )
- g_bPrepareStart = true
- g_bPlaying[ id ] = true
- set_task( 10.0, "almost_start_cup", TASK_ALMOST_STARTED )
- return PLUGIN_HANDLED
- }
- public almost_start_cup()
- {
- for( new i = 1; i <= get_maxplayers(); i++ )
- {
- if( !is_user_connected( i ) )
- continue
- if( !g_bPlaying[ i ] )
- continue
- entity_set_origin( i, float_jumped_tp )
- drop_to_floor( i )
- set_task( 5.0, "start_cup", i )
- fm_set_user_frozen( i, 1 )
- message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, i)
- write_short((1<<10)*5)
- write_short((1<<10)*20)
- write_short(0x0000)
- write_byte(0)
- write_byte(0)
- write_byte(0)
- write_byte(230)
- message_end()
- set_dhudmessage( 255, 255, 255, -1.0, 0.35, 0, 4.0, 7.0 )
- show_dhudmessage( i, "Long Jump Cup is starting!^nHave fun and good luck !" )
- set_hudmessage( 15, 255, 55, -1.0, 0.43, 0, 4.0, 7.0, 0.0, 0.0, -1 )
- show_hudmessage( i, "Important rules: don't cheat !" )
- g_iPlayerBlock[ i ] = 0
- }
- set_task( 5.0, "set_start_cup" )
- }
- public set_start_cup()
- {
- create_function_all( 1 )
- create_small()
- create_tp()
- g_bCup = true
- g_fCupTime = get_gametime()
- MakeCountDown( 60.0, 0.15 )
- set_task( 60.0, "finish_cup", TASK_FINISH_CUP )
- }
- public start_cup( id )
- {
- fm_set_user_frozen( id, 0 )
- set_pev( id, pev_basevelocity, NULL_VECTOR) /* thanks to: */
- set_pev( id, pev_fuser2, 0.0 ) /* juice */
- }
- public finish_cup( type )
- {
- remove_task( TASK_FINISH_CUP )
- remove_task( TASK_ALMOST_STARTED )
- g_bCup = false
- g_bPrepareStart = false
- g_fCupTime = 0.0
- if( type )
- {
- client_print( 0, print_console, "--------- KZ LongJump Cup ---------^n^nResults of LJ Category with 1 minute set time:^n" )
- for( new id = 1; id <= get_maxplayers(); id++ )
- {
- if( !is_user_connected( id ) )
- continue
- if( g_bPlaying[ id ] )
- {
- if( g_iPlayerBlock[ id ] < 8 )
- client_print( 0, print_console, "%n - Jumped Block: %d", id, 240 + g_iPlayerBlock[ id ] )
- else
- client_print( 0, print_console, "%n - Jumped Block: 249", id )
- g_iPlayerBlock[ id ] = 0
- g_bPlaying[ id ] = false
- }
- }
- client_print( 0, print_console, "^n--------- END of KZ LJ Table ---------^n" )
- ColorChat( 0, BLUE, "^4[LJ-Cup]^1 Cup Finished!^3 Check results in your console!" )
- }
- //reset blocks for next cup
- remove_entity_name( "kz_lj2_full_tp" )
- remove_entity_name( "kz_lj2_horizontal_jumped" )
- remove_entity_name( "kz_lj2_vertical_invis" )
- remove_entity_name( "CountDown" )
- g_iVerticalInvis = 0
- g_iHorizontalJumped = 0
- float_origin[ 0 ] = 848.0
- float_jumped_block[ 0 ] = 990.0
- }
- public failed_it( ent, id )
- {
- if( 1 <= id <= 32 && !g_bTouching[ id ] && g_bCup && g_bPlaying[ id ] )
- {
- g_bTouching[ id ] = true
- create_jumped( id )
- set_task( 0.3, "uncheck_it", id )
- }
- }
- public jumped_it( ent, id )
- {
- if( 1 <= id <= 32 && !g_bTouching[ id ] && g_bCup && g_bPlaying[ id ] )
- {
- g_bTouching[ id ] = true
- g_iPlayerBlock[ id ]++
- create_jumped( id )
- set_task( 0.3, "uncheck_it", id )
- }
- }
- public uncheck_it( id )
- g_bTouching[ id ] = false
- public create_jumped( id )
- {
- if( g_iPlayerBlock[ id ] >= 10 )
- {
- ColorChat( 0, BLUE, "^4[LJ-Cup]^3 %n^1 won the LJ Cup! With time:^3 %s^1 !", id, StringTimer( get_gametime() - g_fCupTime ) )
- finish_cup( 1 )
- return PLUGIN_HANDLED
- }
- float_jumped_tp[ 0 ] = float_jumped_tp[ 0 ] + ( g_iPlayerBlock[ id ] * 288.2 )
- entity_set_origin( id, float_jumped_tp )
- float_jumped_tp[ 0 ] = 990.0
- drop_to_floor( id )
- return PLUGIN_HANDLED
- }
- public create_small( )
- {
- if( g_iHorizontalJumped >= 10 )
- return PLUGIN_HANDLED
- if( g_iHorizontalJumped )
- float_jumped_block[ 0 ] += 288.2
- g_iHorizontalJumped++
- new ent = create_entity("info_target")
- entity_set_string(ent,EV_SZ_classname,"kz_lj2_horizontal_jumped")
- entity_set_model(ent,MODEL)
- entity_set_int(ent,EV_INT_solid,SOLID_BBOX)
- entity_set_size(ent,Float:{-90.0,-50.0,-5.0},Float:{90.0,50.0,5.0})
- entity_set_origin(ent,float_jumped_block)
- set_pev(ent, pev_rendermode, kRenderTransAlpha)
- set_pev(ent, pev_renderamt, 0)
- create_small()
- return PLUGIN_HANDLED
- }
- public create_tp()
- {
- new ent = create_entity("info_target")
- entity_set_string(ent,EV_SZ_classname,"kz_lj2_full_tp")
- entity_set_model(ent,MODEL)
- entity_set_int(ent,EV_INT_solid,SOLID_BBOX)
- entity_set_size(ent,Float:{-1600.0,-400.0,-5.0},Float:{1600.0,400.0,5.0})
- entity_set_origin(ent,float_full_tp)
- set_pev(ent, pev_rendermode, kRenderTransAlpha)
- set_pev(ent, pev_renderamt, 0)
- }
- public create_function_all( type )
- {
- if( type )
- {
- g_iVerticalInvis++
- }
- if( type == 2 )
- float_origin[ 0 ] += 288.0
- new ent = create_entity("info_target")
- entity_set_string(ent,EV_SZ_classname,"kz_lj2_vertical_invis")
- entity_set_model(ent,MODEL)
- entity_set_int(ent,EV_INT_solid,SOLID_BBOX)
- if( type )
- entity_set_size(ent,Float:{-2.0,-550.0,-50.0},Float:{2.0,550.0,150.0})
- else
- entity_set_size(ent,Float:{-550.0,-2.0,-50.0},Float:{550.0,2.0,150.0})
- entity_set_origin(ent,float_origin)
- set_pev( ent, pev_rendermode, kRenderTransAlpha )
- set_pev( ent, pev_renderamt, 0 )
- if( g_iVerticalInvis >= 11 )
- return PLUGIN_HANDLED
- else
- {
- create_function_all( 2 )
- }
- return PLUGIN_HANDLED
- }
- MakeCountDown(Float:flTimeleft, Float:flFrequency = 0.15) //connor
- {
- if( !g_entCountDown )
- {
- g_entCountDown = create_entity( "info_target" );
- new const szClass[] = "countdown";
- register_think(szClass, "CountDown" );
- entity_set_string(g_entCountDown, EV_SZ_classname, szClass);
- }
- g_flTimeLeft = flTimeleft;
- g_flFreq = flFrequency;
- entity_set_float(g_entCountDown, EV_FL_nextthink, get_gametime() + flFrequency);
- call_think(g_entCountDown);
- }
- public CountDown( iEntity )
- {
- if( iEntity != g_entCountDown || !g_bCup )
- return;
- if (g_flTimeLeft > 0.0 )
- {
- set_dhudmessage( 255, 255, 255, -1.0, 0.05, 0, 0.0, 0.15, 0.01, 0.01 )
- show_dhudmessage( 0, "Cuptime:^n%s", StringTimer( g_flTimeLeft ) )
- entity_set_float(g_entCountDown, EV_FL_nextthink, get_gametime() + g_flFreq)
- g_flTimeLeft -= g_flFreq
- }
- }
- stock fm_set_user_frozen(client, frozen)
- {
- if( !is_user_alive(client) ) return 0;
- new flags = pev(client, pev_flags);
- if( frozen && !(flags & FL_FROZEN) )
- {
- set_pev(client, pev_flags, (flags | FL_FROZEN))
- }
- else if( !frozen && (flags & FL_FROZEN) )
- {
- set_pev(client, pev_flags, (flags & ~FL_FROZEN));
- }
- return 1;
- }
- stock StringTimer(const Float:flRealTime )
- {
- new szOutPut[ 25 ]
- static iMinutes, iSeconds, iMiliSeconds
- iMinutes = floatround(flRealTime / 60, floatround_floor);
- iSeconds = floatround(flRealTime - (iMinutes * 60), floatround_floor);
- iMiliSeconds = floatround((flRealTime - (iMinutes * 60 + iSeconds)) * 100, floatround_floor);
- formatex(szOutPut, charsmax( szOutPut ), "%02d:%02d.%02d", iMinutes, iSeconds, iMiliSeconds);
- return szOutPut
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement