Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define USE_RULES // DO NOT TOUCH
- // Includes
- #include < amxmodx >
- #include < cstrike >
- #include < hamsandwich >
- #include < fakemeta_util >
- #include < lastrequest_const >
- //#include < engine >
- new const szVersion[ ] = "1.0";
- // Defines
- //#define USE_DEBUG
- #define TASKID_COUNTDOWN 12348 // Pre battle taskid
- #define TASKID_MESSAGE 123471 // Battle message taskid
- #define MINIMUM_COUNTDOWN 3
- #define MAXIMUM_COUNTDOWN 5
- #define gIndex(%1,%2) g_mIndex[ %1 ][ %2 ]
- // Enums
- enum _:GAME_DATA
- {
- GAME_NAME[ 32 ],
- bool: GAME_VICTIM,
- bool: GAME_HAS_RULES,
- RULES_CALLBACK
- };
- enum _: g_mClientData
- {
- g_mCategory,
- g_mVictim,
- g_mBattle,
- g_mHealth,
- g_mCountdown,
- bool: bFreeze,
- bool: bInfoMsg
- };
- enum _:FWD_ID
- {
- FWD_GAME_START,
- FWD_GAME_END
- };
- new const szCategories[ LR_CATEGORIES_ID ][ ] =
- {
- "Custome Battles",
- "Shot for Shot",
- "Special Battles",
- "First Battles"
- };
- new Array: g_aCustomeGames;
- new Array: g_aShotGames;
- new Array: g_aSpecialGames;
- new Array: g_aFirstGames;
- new g_iForwards[ FWD_ID ];
- new szItem[ 128 ];
- new g_mIndex[ 33 ][ g_mClientData ];
- new g_iCountdown;
- new g_iGameId;
- new g_iCategoryId;
- new g_iPrisoner;
- new g_iGuard;
- new bool: bRules[ GAME_RULES ];
- new g_msgSetFOV;
- public plugin_init()
- {
- register_plugin( "Jailbreak: Last Request (API)", "1.0", "Rejack" );
- register_clcmd( "say /lr", "cmdMainMenu" );
- register_clcmd( "say /infomsg", "cmdInfoMsg" );
- register_concmd( "set_health", "cmdSetHealth" );
- g_msgSetFOV = get_user_msgid( "SetFOV" )
- register_event( "SetFOV","evSetFOV","b","1<90" );
- RegisterHam( Ham_TraceAttack, "player", "ForwardTraceAttack" );
- g_iForwards[ FWD_GAME_START ] = CreateMultiForward( "FwdLrStarted", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL );
- g_iForwards[ FWD_GAME_END ] = CreateMultiForward( "FwdLrEnded", ET_IGNORE, FP_CELL, FP_CELL );
- g_aCustomeGames = ArrayCreate( GAME_DATA );
- g_aShotGames = ArrayCreate( GAME_DATA );
- g_aSpecialGames = ArrayCreate( GAME_DATA );
- g_aFirstGames = ArrayCreate( GAME_DATA );
- if ( g_aCustomeGames == Invalid_Array || g_aShotGames == Invalid_Array || g_aSpecialGames == Invalid_Array || g_aFirstGames == Invalid_Array )
- set_fail_state( "Couldn't create array, plugin shutting down." );
- #if defined USE_DEBUG
- set_task( 3.5, "taskDebugLoadedPlugins" );
- #endif
- }
- /* Client Side */
- public cmdInfoMsg( const client )
- {
- g_mIndex[ client ][ bInfoMsg ] = !g_mIndex[ client ][ bInfoMsg ];
- ColorPrint( client, "You^4 %s^1 the last-request^3 info message^1.", g_mIndex[ client ][ bInfoMsg ] ? "Disabled" : "Enabled" );
- return 1;
- }
- public client_putinserver( client )
- {
- g_mIndex[ client ][ g_mCategory ] = -1;
- g_mIndex[ client ][ g_mVictim ] = 0;
- g_mIndex[ client ][ g_mBattle ] = -1;
- g_mIndex[ client ][ g_mHealth ] = 100;
- g_mIndex[ client ][ g_mCountdown ] = MINIMUM_COUNTDOWN;
- g_mIndex[ client ][ bFreeze ] = false;
- }
- public cmdSetHealth( const client )
- {
- new szArgs[ 32 ];
- read_args( szArgs, charsmax( szArgs ) );
- remove_quotes( szArgs );
- if ( !is_str_num( szArgs ) )
- {
- ColorPrint( client, "You need to use^4 numbers^1 only." );
- client_cmd( client, "messagemode set_health" );
- return 1;
- }
- static iCategory;
- iCategory = gIndex( client, g_mCategory );
- if ( iCategory == -1 )
- return 1;
- if ( iCategory != LR_CUSTOME_BATTLES && iCategory != LR_SHOT_FOR_SHOT )
- {
- ColorPrint( client, "You can't set the Health on this category^1." );
- return 1;
- }
- static Health;
- Health = str_to_num( szArgs );
- if ( iCategory == LR_CUSTOME_BATTLES && ( Health < CUSTOME_MIN_HP || Health > CUSTOME_MAX_HP ) ||
- iCategory == LR_SHOT_FOR_SHOT && ( Health < SHOT_MIN_HP || Health > SHOT_MAX_HP ) )
- {
- switch ( iCategory )
- {
- case LR_CUSTOME_BATTLES:
- {
- if ( Health < CUSTOME_MAX_HP )
- ColorPrint( client, "The maximum amount of health you can set is^4 %i Health^1.", CUSTOME_MAX_HP );
- else if ( Health > CUSTOME_MIN_HP )
- ColorPrint( client, "The minimum amount of health you can set is^4 %i Health^1.", CUSTOME_MIN_HP );
- }
- case LR_SHOT_FOR_SHOT:
- {
- if ( Health < SHOT_MAX_HP )
- ColorPrint( client, "The maximum amount of health you can set is^4 %i Health^1.", SHOT_MAX_HP );
- else if ( Health > SHOT_MIN_HP )
- ColorPrint( client, "The minimum amount of health you can set is^4 %i Health^1.", SHOT_MIN_HP );
- }
- }
- client_cmd( client, "messagemode set_health" );
- return 1;
- }
- g_mIndex[ client ][ g_mHealth ] = str_to_num( szArgs );
- return cmdSecondaryMenu( client );
- }
- /* Natives & API */
- public plugin_natives( )
- {
- register_native( "register_custome_lr", "RegisterCustomeGame" );
- register_native( "register_shot_lr", "RegisterShotGame" );
- register_native( "register_special_lr", "RegisterSpecialGame" );
- register_native( "register_first_lr", "RegisterFirstGame" );
- register_native( "set_rule", "NativeSetRule" );
- register_native( "get_rule", "NativeGetRule" );
- register_native( "userOpenMenu", "NativeOpenMenu" );
- register_native( "userExitRules", "NativeExitRules" );
- }
- public NativeOpenMenu( const iPlugin, const iParams )
- {
- if ( !is_user_connected( get_param( 1 ) ) )
- return 0;
- return cmdMainMenu( get_param( 1 ) );
- }
- public NativeExitRules( const iPlugin, const iParams )
- {
- static index;
- index = get_param( 1 );
- if ( !is_user_connected( index ) )
- return 0;
- return cmdSecondaryMenu( index );
- }
- public NativeSetRule( const iPlugin, const iParams )
- {
- bRules[ get_param( 1 ) ] = bool: get_param( 2 );
- return 1;
- }
- public NativeGetRule( const iPlugin, const iParams )
- {
- return bRules[ get_param( 1 ) ];
- }
- public RegisterCustomeGame( const iPlugin, const iParams )
- {
- return RegisterGame( LR_CUSTOME_BATTLES, iParams, iPlugin );
- }
- public RegisterShotGame( const iPlugin, const iParams )
- {
- return RegisterGame( LR_SHOT_FOR_SHOT, iParams, iPlugin );
- }
- public RegisterSpecialGame( const iPlugin, const iParams )
- {
- return RegisterGame( LR_SPECIAL_BATTLES, iParams, iPlugin );
- }
- public RegisterFirstGame( const iPlugin, const iParams )
- {
- return RegisterGame( LR_FIRST_BATTLES, iParams, iPlugin );
- }
- stock RegisterGame( const iCategory, const iParams, const iPlugin )
- {
- if ( iParams < 2 )
- {
- log_error( AMX_ERR_PARAMS, "Wrong paremeters." );
- return -1;
- }
- new aData[ GAME_DATA ];
- static iPosition;
- get_string( 1, aData[ GAME_NAME ], 31 );
- aData[ GAME_VICTIM ] = bool: get_param( 2 );
- aData[ GAME_HAS_RULES ] = bool: get_param( 3 );
- if ( aData[ GAME_HAS_RULES ] )
- {
- if ( iParams < 4 )
- {
- log_error( AMX_ERR_PARAMS, "Wrong paremeters." );
- return -1;
- }
- static iForward;
- static szCallback[ 32 ];
- get_string( 4, szCallback, charsmax( szCallback ) );
- iForward = CreateOneForward( iPlugin, szCallback, FP_CELL );
- if ( !szCallback[ 0 ] )
- {
- log_error( AMX_ERR_GENERAL, "Empty callback called in a new game (%s).", aData[ GAME_NAME ] );
- return -1;
- }
- aData[ RULES_CALLBACK ] = iForward;
- }
- switch ( iCategory )
- {
- case LR_CUSTOME_BATTLES:
- iPosition = ArraySize( g_aCustomeGames ),
- ArrayPushArray( g_aCustomeGames, aData );
- case LR_SHOT_FOR_SHOT:
- iPosition = ArraySize( g_aShotGames ),
- ArrayPushArray( g_aShotGames, aData );
- case LR_SPECIAL_BATTLES:
- iPosition = ArraySize( g_aSpecialGames ),
- ArrayPushArray( g_aSpecialGames, aData );
- case LR_FIRST_BATTLES:
- iPosition = ArraySize( g_aFirstGames ),
- ArrayPushArray( g_aFirstGames, aData );
- default:
- return -1;
- }
- #if defined USE_DEBUG
- log_amx( "[LR API - DEBUG] Successfuly created a last request game: '%s' (#%i). [%s]", aData[ GAME_NAME ], iPosition, aData[ GAME_HAS_RULES ] ? "Special" : "Regular" );
- #endif
- return iPosition;
- }
- /* Tasks */
- #if defined USE_DEBUG
- public taskDebugLoadedPlugins( ) // For debug purposes
- {
- log_amx( "[LR API - DEBUG] Successfuly created '#%i' custome games.", ArraySize( g_aCustomeGames ) );
- log_amx( "[LR API - DEBUG] Successfuly created '#%i' shot for shot games.", ArraySize( g_aShotGames ) );
- log_amx( "[LR API - DEBUG] Successfuly created '#%i' special games.", ArraySize( g_aSpecialGames ) );
- log_amx( "[LR API - DEBUG] Successfuly created '#%i' first games.", ArraySize( g_aFirstGames ) );
- }
- #endif
- public taskCountdownBeforeBattle( )
- {
- if ( g_iCountdown < 1 )
- {
- // Ended countdown start lr
- fm_set_user_freeze( g_iPrisoner, 0 );
- fm_set_user_freeze( g_iGuard, 0 );
- taskBattleMessage( ); // Start message
- if ( bRules[ bNoBunnyhop ] ) // No Bunnyhop rule
- {
- set_user_bunnyhop( g_iPrisoner, 0 );
- set_user_bunnyhop( g_iGuard, 0 );
- }
- return 1;
- }
- static Vox[ 32 ], aData[ GAME_DATA ];
- if ( g_iCategoryId != LR_FIRST_BATTLES )
- {
- num_to_word( g_iCountdown, Vox, charsmax( Vox ) );
- client_cmd( 0, "spk ^"vox/%s^"", Vox );
- }
- switch ( g_iCategoryId )
- {
- case LR_CUSTOME_BATTLES:
- ArrayGetArray( g_aCustomeGames, g_iGameId, aData );
- case LR_SHOT_FOR_SHOT:
- ArrayGetArray( g_aShotGames, g_iGameId, aData );
- case LR_SPECIAL_BATTLES:
- ArrayGetArray( g_aSpecialGames, g_iGameId, aData );
- case LR_FIRST_BATTLES:
- ArrayGetArray( g_aFirstGames, g_iGameId, aData );
- default:
- return 1;
- }
- set_hudmessage( 0, 255, 255, -1.0, 0.35, 0, 0.0, 1.0, 0.1, 0.1, 1 );
- show_hudmessage( 0, "%s vs. %s^n%s - %s^nWill start in %i SECOND%s", szName( g_iPrisoner ), szName( g_iGuard ), szCategories[ g_iCategoryId ], aData[ GAME_NAME ], g_iCountdown, ( g_iCountdown < 2 ) ? "" : "s" );
- g_iCountdown--;
- set_task( 1.0, "taskCountdownBeforeBattle", TASKID_COUNTDOWN );
- return 1;
- }
- public taskBattleMessage( )
- {
- if ( g_iCategoryId < 0 || g_iGameId < 0 ) // No game
- return 1;
- static aData[ GAME_DATA ];
- switch ( g_iCategoryId )
- {
- case LR_CUSTOME_BATTLES:
- ArrayGetArray( g_aCustomeGames, g_iGameId, aData );
- case LR_SHOT_FOR_SHOT:
- ArrayGetArray( g_aShotGames, g_iGameId, aData );
- case LR_SPECIAL_BATTLES:
- ArrayGetArray( g_aSpecialGames, g_iGameId, aData );
- case LR_FIRST_BATTLES:
- ArrayGetArray( g_aFirstGames, g_iGameId, aData );
- default:
- return 1;
- }
- static szMsg[ 512 ], szBuffer[ 128 ];
- formatex( szMsg, charsmax( szMsg ), "%s Jailbreak v%s", szPrefix, szVersion );
- add( szMsg, charsmax( szMsg ), "^n by Rejack" );
- formatex( szBuffer, charsmax( szBuffer ), "^nLast Request - %s", szCategories[ g_iCategoryId ] );
- add( szMsg, charsmax( szMsg ), szBuffer );
- formatex( szBuffer, charsmax( szBuffer ), "^n %s", aData[ GAME_NAME ] );
- add( szMsg, charsmax( szMsg ), szBuffer );
- add( szMsg, charsmax( szMsg ), "^n__________________________^n" );
- static indexPrisoner, indexGuard;
- indexPrisoner = find_player_index( );
- indexGuard = gIndex( indexPrisoner, g_mVictim );
- if ( !is_user_connected( indexPrisoner ) || !is_user_connected( indexGuard ) )
- return 1;
- add( szMsg, charsmax( szMsg ), "^n Participating Players:^n" );
- add( szMsg, charsmax( szMsg ), "^n - GUARDS" );
- formatex( szBuffer, charsmax( szBuffer ), "^n > %s (%i HP)", szName( indexGuard ), get_user_health( indexGuard ) );
- add( szMsg, charsmax( szMsg ), szBuffer );
- add( szMsg, charsmax( szMsg ), "^n^n - PRISONERS" );
- formatex( szBuffer, charsmax( szBuffer ), "^n > %s (%i HP)", szName( indexPrisoner ), get_user_health( indexPrisoner ) );
- add( szMsg, charsmax( szMsg ), szBuffer );
- static i, z, szSubBuffer[ 128 ];
- z = 0;
- szBuffer = "^n^n Game Rules:^n";
- for ( i = 0; i < GAME_RULES; i++ )
- {
- if ( bRules[ i ] )
- {
- formatex( szSubBuffer, charsmax( szSubBuffer ), "^n > %s", szRules[ i ] );
- add( szBuffer, charsmax( szBuffer ), szSubBuffer );
- z++;
- }
- }
- if ( z < 1 )
- szBuffer = "^n^nNo Rules";
- add( szMsg, charsmax( szMsg ), szBuffer );
- szBuffer = "^n^n^nIf you want to disable this message type '/infomsg'.";
- add( szMsg, charsmax( szMsg ), szBuffer );
- static Players[ 32 ], iNum;
- get_players( Players, iNum, "ch" );
- for ( i = 0; i < iNum; i++ )
- {
- if ( g_mIndex[ Players[ i ] ][ bInfoMsg ] )
- continue;
- set_hudmessage( 0, 255, 255, 0.03, 0.1, 0, 0.0, 0.3, 0.1, 0.1, 1 );
- show_hudmessage( Players[ i ], szMsg );
- }
- set_task( 0.3, "taskBattleMessage", TASKID_MESSAGE );
- return 0;
- }
- /* Events */
- public evSetFOV( client )
- {
- if ( bRules[ bNoZoom ] )
- {
- message_begin( MSG_ONE, g_msgSetFOV, { 0, 0, 0 }, client );
- write_byte( 90 );
- message_end();
- }
- return 0;
- }
- /* Forwards */
- public ForwardTraceAttack( victim, attacker, Float: fDamage, Float: fDir[ 3 ], ptr, bits )
- {
- if ( !bRules[ bHeadshot ] )
- return 1;
- if ( !is_user_alive( victim ) )
- return 1;
- if ( !is_user_alive( attacker ) )
- return 1;
- if ( victim == attacker )
- return 1;
- if ( get_tr2( ptr, TR_iHitgroup ) != HIT_HEAD )
- {
- new index;
- index = gIndex( victim, g_mVictim ); // if T get shot check
- if ( cs_get_user_team( attacker ) == CS_TEAM_CT || // if attacker is ct
- attacker != index ) // and the ct isnt the one participating the duel
- return 1;
- return 4;
- }
- return 1;
- }
- stock find_player_index( )
- {
- if ( g_iCategoryId < 0 || g_iGameId < 0 ) // No game
- return -1;
- static Players[ 32 ], iNum, index, i;
- get_players( Players, iNum, "aceh", "TERRORIST" );
- for ( i = 0; i < iNum; i++ )
- {
- if ( gIndex( Players[ i ], g_mVictim ) < 1 )
- continue;
- index = Players[ i ];
- break;
- }
- return index;
- }
- /* Main Menu */
- public cmdMainMenu( const client )
- {
- if ( // Nothing inside any array so no lrs
- ArraySize( g_aCustomeGames ) < 1 &&
- ArraySize( g_aShotGames ) < 1 &&
- ArraySize( g_aSpecialGames ) &&
- ArraySize( g_aFirstGames ) < 1
- )
- return 1;
- g_mIndex[ client ][ g_mCategory ] = -1;
- static Menu;
- formatex( szItem, charsmax( szItem ), "\r[%s]\w Last Request Menu^n^nSelect a category!", szPrefix );
- Menu = menu_create( szItem, "handlerMainMenu" );
- static i;
- for ( i = 0; i < sizeof ( szCategories ); i++ )
- {
- if (
- i == LR_CUSTOME_BATTLES && ArraySize( g_aCustomeGames ) < 1 ||
- i == LR_SHOT_FOR_SHOT && ArraySize( g_aShotGames ) < 1 ||
- i == LR_SPECIAL_BATTLES && ArraySize( g_aSpecialGames ) < 1 ||
- i == LR_FIRST_BATTLES && ArraySize( g_aFirstGames ) < 1
- )
- continue;
- menu_additem( Menu, szCategories[ i ] );
- }
- menu_display( client, Menu );
- return 1;
- }
- public handlerMainMenu( client, Menu, Item )
- {
- if ( Item == MENU_EXIT )
- {
- menu_destroy( Menu );
- return 1;
- }
- static mData[ 6 ], Trash;
- menu_item_getinfo( Menu, Item, Trash, mData, charsmax( mData ), _,_, Trash );
- g_mIndex[ client ][ g_mCategory ] = Item;
- g_mIndex[ client ][ g_mVictim ] = 0;
- g_mIndex[ client ][ g_mBattle ] = -1;
- g_mIndex[ client ][ g_mHealth ] = 100;
- g_mIndex[ client ][ g_mCountdown ] = MINIMUM_COUNTDOWN;
- g_mIndex[ client ][ bFreeze ] = false;
- return cmdSecondaryMenu( client );
- }
- /* Secondary Menu */
- public cmdSecondaryMenu( const client )
- {
- if ( gIndex( client, g_mCategory ) == -1 )
- return cmdMainMenu( client );
- static Menu, szBuffer[ 128 ];
- formatex( szItem, charsmax( szItem ), "\r[%s]\w Last Request Menu^n^nCustomize your battle!", szPrefix );
- Menu = menu_create( szItem, "handlerSecondaryMenu" );
- // 1. Selected victim
- if ( gIndex( client, g_mVictim ) == 0 )
- szBuffer = "\r NONE";
- else
- formatex( szBuffer, charsmax( szBuffer ), "\y %s", szName( gIndex( client, g_mVictim ) ) );
- formatex( szItem, charsmax( szItem ), "Selected victim: %s", szBuffer );
- menu_additem( Menu, szItem, "0" );
- // 2. Selected battle
- if ( gIndex( client, g_mBattle ) == -1 )
- szBuffer = "\r NONE";
- else
- {
- static aData[ GAME_DATA ];
- switch ( gIndex( client, g_mCategory ) )
- {
- case LR_CUSTOME_BATTLES:
- ArrayGetArray( g_aCustomeGames, gIndex( client, g_mBattle ), aData );
- case LR_SHOT_FOR_SHOT:
- ArrayGetArray( g_aShotGames, gIndex( client, g_mBattle ), aData );
- case LR_SPECIAL_BATTLES:
- ArrayGetArray( g_aSpecialGames, gIndex( client, g_mBattle ), aData );
- case LR_FIRST_BATTLES:
- ArrayGetArray( g_aFirstGames, gIndex( client, g_mBattle ), aData );
- }
- formatex( szBuffer, charsmax( szBuffer ), "\y %s", aData[ GAME_NAME ] );
- }
- formatex( szItem, charsmax( szItem ), "Selected battle: %s^n", szBuffer );
- menu_additem( Menu, szItem, "1" );
- if ( gIndex( client, g_mCategory ) != LR_SPECIAL_BATTLES && gIndex( client, g_mCategory ) != LR_FIRST_BATTLES )
- {
- // 3. Set Health
- formatex( szItem, charsmax( szItem ), "Set health:\y %i\d HEALTH", gIndex( client, g_mHealth ) );
- switch ( gIndex( client, g_mCategory ) )
- {
- case LR_CUSTOME_BATTLES:
- formatex( szBuffer, charsmax( szBuffer ), "^n \r*\w MAX:\y %i\d HEALTH^n \r*\w MIN:\y %i\d HEALTH", CUSTOME_MAX_HP, CUSTOME_MIN_HP );
- case LR_SHOT_FOR_SHOT:
- formatex( szBuffer, charsmax( szBuffer ), "^n \r*\w MAX:\y %i\d HEALTH^n \r*\w MIN:\y %i\d HEALTH", SHOT_MAX_HP, SHOT_MIN_HP );
- }
- add( szItem, charsmax( szItem ), szBuffer );
- menu_additem( Menu, szItem, "2" );
- }
- // 4. Countdown
- formatex( szItem, charsmax( szItem ), "Countdown:\y %i\d SECONDS", gIndex( client, g_mCountdown ) );
- menu_additem( Menu, szItem, "3" );
- if ( gIndex( client, g_mCategory ) != LR_FIRST_BATTLES )
- {
- // 5. Freeze
- formatex( szItem, charsmax( szItem ), "Freeze:%s^n", gIndex( client, bFreeze ) ? "\r Yes" : "\y No" );
- menu_additem( Menu, szItem, "4" );
- // 6. Select Rules
- menu_additem( Menu, "Select rules^n", "5" );
- }
- // 7. Start last-request
- menu_additem( Menu, "\rStart last request", "6" );
- menu_setprop( Menu, MPROP_EXITNAME, "Back" );
- menu_display( client, Menu );
- return 1;
- }
- public handlerSecondaryMenu( client, Menu, Item )
- {
- if ( gIndex( client, g_mCategory ) == -1 )
- return cmdMainMenu( client );
- if ( Item == MENU_EXIT )
- {
- menu_destroy( Menu );
- return cmdMainMenu( client );
- }
- static mData[ 6 ], Trash;
- menu_item_getinfo( Menu, Item, Trash, mData, charsmax( mData ), _,_, Trash );
- switch ( str_to_num( mData ) )
- {
- case 0: // Selected victim
- return cmdSelectVictim( client );
- case 1: // Selected battle
- return cmdSelectBattle( client );
- case 2: // Set health
- {
- client_cmd( client, "messagemode set_health" );
- return 1;
- }
- case 3: // Countdown
- {
- if ( gIndex( client, g_mCountdown ) >= MAXIMUM_COUNTDOWN )
- g_mIndex[ client ][ g_mCountdown ] = MINIMUM_COUNTDOWN - 1;
- g_mIndex[ client ][ g_mCountdown ]++;
- }
- case 4: // Freeze
- g_mIndex[ client ][ bFreeze ] = !g_mIndex[ client ][ bFreeze ];
- case 5: // Select rules
- {
- if ( gIndex( client, g_mVictim ) == 0 || gIndex( client, g_mBattle ) == -1 )
- {
- ColorPrint( client, "You need to select a^3 victim^1 and a^4 battle^1 in order to select^3 rules^1." );
- return cmdSecondaryMenu( client );
- }
- static aData[ GAME_DATA ];
- switch ( gIndex( client, g_mCategory ) )
- {
- case LR_CUSTOME_BATTLES:
- ArrayGetArray( g_aCustomeGames, gIndex( client, g_mBattle ), aData );
- case LR_SHOT_FOR_SHOT:
- ArrayGetArray( g_aShotGames, gIndex( client, g_mBattle ), aData );
- case LR_SPECIAL_BATTLES:
- ArrayGetArray( g_aSpecialGames, gIndex( client, g_mBattle ), aData );
- case LR_FIRST_BATTLES:
- ArrayGetArray( g_aFirstGames, gIndex( client, g_mBattle ), aData );
- }
- if ( aData[ GAME_HAS_RULES ] )
- {
- static ret;
- ExecuteForward( aData[ RULES_CALLBACK ], ret, client );
- return 1;
- }
- return cmdSelectRules( client );
- }
- case 6: // Start last-request
- {
- static g_iVictim;
- g_iVictim = gIndex( client, g_mVictim );
- set_user_bunnyhop( client, 1 );
- set_user_bunnyhop( g_iVictim , 1 );
- fm_set_user_godmode( client, 0 );
- fm_set_user_godmode( g_iVictim, 0 );
- fm_set_user_noclip( client, 0 );
- fm_set_user_noclip( g_iVictim, 0 );
- fm_set_user_gravity( client, 1.0 );
- fm_set_user_gravity( g_iVictim, 1.0 );
- fm_set_user_health( client, gIndex( client, g_mHealth ) );
- fm_set_user_health( g_iVictim, gIndex( client, g_mHealth ) );
- fm_set_user_armor( client, 0 );
- fm_set_user_armor( g_iVictim, 0 );
- fm_strip_user_weapons( client );
- fm_strip_user_weapons( g_iVictim );
- g_iCategoryId = gIndex( client, g_mCategory );
- g_iGameId = gIndex( client, g_mBattle );
- g_iCountdown = gIndex( client, g_mCountdown );
- ExecuteForward( g_iForwards[ FWD_GAME_START ], Item, client, g_iVictim, g_iCategoryId, g_iGameId, g_iCountdown );
- g_iPrisoner = client;
- g_iGuard = g_iVictim;
- if ( g_iCategoryId == LR_FIRST_BATTLES )
- g_iCountdown = 0;
- taskCountdownBeforeBattle( );
- if ( g_mIndex[ client ][ bFreeze ] )
- {
- fm_set_user_freeze( client, 1 );
- fm_set_user_freeze( g_iVictim, 1 );
- }
- return 1;
- }
- }
- menu_destroy( Menu );
- return cmdSecondaryMenu( client );
- }
- /* Select vicitm menu */
- public cmdSelectVictim( const client )
- {
- static Menu;
- formatex( szItem, charsmax( szItem ), "\r[%s]\w Last Request Menu^n^nSelect a victim!", szPrefix );
- Menu = menu_create( szItem, "handlerSelectVictim" );
- static Players[ 32 ], mData[ 6 ];
- static i, iNum, index;
- get_players( Players, iNum );
- for ( i = 0; i < iNum; i++ )
- {
- index = Players[ i ];
- num_to_str( index, mData, charsmax( mData ) );
- menu_additem( Menu, szName( index ), mData );
- }
- menu_setprop( Menu, MPROP_EXITNAME, "Back" );
- menu_display( client, Menu );
- return 1;
- }
- public handlerSelectVictim( client, Menu, Item )
- {
- if ( gIndex( client, g_mCategory ) == -1 )
- return cmdMainMenu( client );
- if ( Item != MENU_EXIT )
- {
- static mData[ 6 ], Trash;
- menu_item_getinfo( Menu, Item, Trash, mData, charsmax( mData ), _,_, Trash );
- g_mIndex[ client ][ g_mVictim ] = str_to_num( mData );
- }
- menu_destroy( Menu );
- return cmdSecondaryMenu( client );
- }
- /* Select battle menu */
- public cmdSelectBattle( const client )
- {
- static iSize;
- switch ( gIndex( client, g_mCategory ) )
- {
- case LR_CUSTOME_BATTLES:
- iSize = ArraySize( g_aCustomeGames );
- case LR_SHOT_FOR_SHOT:
- iSize = ArraySize( g_aShotGames );
- case LR_SPECIAL_BATTLES:
- iSize = ArraySize( g_aSpecialGames );
- case LR_FIRST_BATTLES:
- iSize = ArraySize( g_aFirstGames );
- }
- static Menu;
- formatex( szItem, charsmax( szItem ), "\r[%s]\w Last Request Menu^n^nSelect a battle!%s", szPrefix, ( iSize > 7 ) ? "^n^n\rPage:\d" : "" );
- Menu = menu_create( szItem, "handlerSelectBattle" );
- static aData[ GAME_DATA ], mData[ 6 ];
- static i;
- for ( i = 0; i < iSize; i++ )
- {
- switch ( gIndex( client, g_mCategory ) )
- {
- case LR_CUSTOME_BATTLES:
- ArrayGetArray( g_aCustomeGames, i, aData );
- case LR_SHOT_FOR_SHOT:
- ArrayGetArray( g_aShotGames, i, aData );
- case LR_SPECIAL_BATTLES:
- ArrayGetArray( g_aSpecialGames, i, aData );
- case LR_FIRST_BATTLES:
- ArrayGetArray( g_aFirstGames, i, aData );
- }
- num_to_str( i, mData, charsmax( mData ) );
- menu_additem( Menu, aData[ GAME_NAME ], mData );
- }
- menu_setprop( Menu, MPROP_EXITNAME, "Back" );
- menu_display( client, Menu );
- return 1;
- }
- public handlerSelectBattle( client, Menu, Item )
- {
- if ( gIndex( client, g_mCategory ) == -1 )
- return cmdMainMenu( client );
- if ( Item != MENU_EXIT )
- {
- static mData[ 6 ], Trash;
- menu_item_getinfo( Menu, Item, Trash, mData, charsmax( mData ), _,_, Trash );
- g_mIndex[ client ][ g_mBattle ] = str_to_num( mData );
- }
- menu_destroy( Menu );
- return cmdSecondaryMenu( client );
- }
- /* Select rules Menu */
- public cmdSelectRules( const client )
- {
- static Menu;
- formatex( szItem, charsmax( szItem ), "\r[%s]\w Last Request Menu^n^nSelect battle rules!", szPrefix );
- Menu = menu_create( szItem, "handlerSelectRules" );
- static i;
- for ( i = 0; i < sizeof ( szRules ); i++ )
- {
- formatex( szItem, charsmax( szItem ), "%s:%s", szRules[ i ], bRules[ i ] ? "\r ON" : "\y OFF" );
- menu_additem( Menu, szItem );
- }
- menu_setprop( Menu, MPROP_EXITNAME, "Back" );
- menu_display( client, Menu );
- return 1;
- }
- public handlerSelectRules( client, Menu, Item )
- {
- if ( Item != MENU_EXIT )
- {
- bRules[ Item ] = !bRules[ Item ];
- return cmdSelectRules( client );
- }
- menu_destroy( Menu );
- return cmdSecondaryMenu( client );
- }
- /* Stocks */
- stock ColorPrint( const index, const string[], any:... )
- {
- new szMsg[ 512 ], Players[ 32 ], PNum = 1;
- static iLen; iLen = formatex( szMsg, charsmax( szMsg ), "^4[%s]^1 ", szPrefix );
- vformat( szMsg[ iLen ], charsmax( szMsg ) - iLen, string, 3 );
- if ( index )
- Players[ 0 ] = index;
- else
- get_players( Players, PNum, "ch" );
- for ( new i; i < PNum; i++ )
- {
- if( is_user_connected( Players[ i ] ) )
- {
- message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, Players[ i ] );
- write_byte( Players[ i ] );
- write_string( szMsg );
- message_end( );
- }
- }
- return 1;
- }
- stock szName( const index )
- {
- static g_szName[ 32 ];
- get_user_name( index, g_szName, 31 );
- return g_szName;
- }
- stock fm_set_user_freeze( const index, freeze = 0 )
- {
- if ( !is_user_alive( index ) )
- return -1;
- static iFlags;
- iFlags = pev( index, pev_flags );
- switch ( freeze )
- {
- case 1:
- set_pev( index, pev_flags, iFlags | FL_FROZEN );
- default:
- set_pev( index, pev_flags, iFlags & ~FL_FROZEN );
- }
- return freeze;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement