Преработка на JB LR

В този раздел можете да подавате всякакви заявки за намиране, изработка или преработка на плъгини/модове.
Аватар
DoPe ;]]
Извън линия
Потребител
Потребител
Мнения: 402
Регистриран на: 27 Фев 2017, 22:10
Обратна връзка:

Преработка на JB LR

Мнение от DoPe ;]] » 23 Фев 2018, 12:35

Код за потвърждение: Избери целия код

/*
*
*        Jailbreak Last Request
*            
*        H3avY Ra1n (AKA nikhilgupta345)
*
*        Description
*        -----------
*
*            This is a Last Request plugin for jailbreak mod, where 
*            the last terrorists can type /lr and is presented with a 
*            menu, which has numerous options to choose from that interact 
*            with the Counter-Terrorists.
*
*        Last Request Options
*        --------------------
*
*            Knife Battle     - Fight with knives 1v1
*            Shot for Shot    - Take turns shooting a deagle
*            Deagle Toss        - See who can throw the deagle the farthest
*            Shotgun Battle    - Fight with shotguns 1v1
*            Scout Battle    - Fight with scouts 1v1
*            Grenade Toss    - See who can throw the grenade the farthest
*            Race            - Race across a certain part of the map
*            Spray Contest    - See who can spray closest to the top or bottom border
*            of a wall. Prisoner decides.
*
*
*        Client Commands
*        ---------------
*    
*            say/say_team    /lr             - Opens Last Request Menu
*                            !lr
*                            /lastrequest
*                            !lastrequest
*
*
*        Installation
*        ------------
*
*            - Compile this plugin locally
*            - Place jb_lastrequest.amxx in addons/amxmodx/plugins/ folder
*            - Open addons/amxmodx/configs/plugins.ini
*            - Add the line 'jb_lastrequest.amxx' at the bottom
*            - Restart server or change map
*            
*
*        Changelog
*        ---------
*        
*            February 15, 2011     - v1.0 -     Initial Release
*            February 24, 2011    - v1.0.1 -     Removed teleporting back to cell
*            March 05, 2011        - v1.1 -    Changed way of allowing a Last Request
*            March 26, 2011        - v1.2 -     Added Multi-Lingual support.
*            August 10, 2011        - v2.0 -    Completely rewrote plugin
*
*        
*        Credits
*        -------
*        
*            Pastout        -    Used his thread as a layout for mine
*
*        
*        Plugin Thread: http://forums.alliedmods.net/showthread.php?p=1416279
*
*/

// Includes
////////////

#include < amxmodx >
#include < cstrike >
#include < fun >
#include < fakemeta >
#include < fakemeta_util >
#include < hamsandwich >

// Enums
/////////

enum
{
    LR_NONE=-1,
    LR_S4S,
    LR_SPRAY,
    LR_RACE,
    LR_GUNTOSS,
    LR_KNIFE,
    LR_NADETOSS,
    LR_SCOUT,
    LR_SHOTGUN,
    
    MAX_GAMES
};

enum
{
    GREY = 0,
    RED,
    BLUE,
    NORMAL
};

enum
{
    ALIVE, 
    DEAD, 
    ALL    
};

enum(+=1)// fix ur old enum into this 
{ 
    LR_PRISONER = 0, 
    LR_GUARD 
} 

enum ( += 100 )
{
    TASK_BEACON,
    TASK_ENDLR
};

// Consts
//////////

new const g_szPrefix[ ] = "!g[Jailbreak]!n";

new const g_szBeaconSound[ ] = "buttons/blip1.wav";
new const g_szBeaconSprite[ ] = "sprites/white.spr";

new const g_szGameNames[ MAX_GAMES ][ ] = 
{
    "Shot 4 Shot",
    "Spray Contest",
    "Race",
    "Gun Toss",
    "Knife Battle",
    "Grenade Toss",
    "Scout Battle",
    "Shotgun Battle"
};

new const g_szDescription[ MAX_GAMES ][ ] = 
{
    "Take turns shooting a deagle.",
    "Both players spray on a wall, highest or lowest.",
    "Both players race across a part of the map.",
    "See who can throw the deagle the farthest.",
    "Battle it out with knives.",
    "See who can throw the grenade the farthest from a point in the map.",
    "Battle it out with scouts.",
    "Battle it out with shotguns."
};

new const g_szTeamName[ ][ ] = 
{
    "",
    "TERRORIST",
    "CT",
    "SPECTATOR"
};

new const g_szPlugin[ ] = "Jailbreak Last Request";
new const g_szVersion[ ] = "2.0";
new const g_szAuthor[ ] = "H3avY Ra1n";

// Integers
////////////

new g_iCurrentGame = LR_NONE;
new g_iLastRequest[ 2 ];
new g_iCurrentPage[ 33 ];
new g_iChosenGame[ 33 ];

new g_iSprite;

new g_iMaxPlayers;

// Booleans
///////////

new bool:g_bAlive[ 33 ];
new bool:g_bConnected[ 33 ];

new bool:g_bLastRequestAllowed;

// Messages
////////////

new g_msgTeamInfo;
new g_msgSayText;

public plugin_precache()
{
    precache_sound( g_szBeaconSound );
    
    g_iSprite = precache_model( g_szBeaconSprite );
}

public plugin_init()
{
    register_plugin( g_szPlugin, g_szVersion, g_szAuthor );
    
    register_clcmd( "say /lr",                     "Cmd_LastRequest" );
    register_clcmd( "say !lr",                     "Cmd_LastRequest" );
    register_clcmd( "say /lastrequest",         "Cmd_LastRequest" );
    register_clcmd( "say !lastrequest",         "Cmd_LastRequest" );
    
    register_clcmd( "say_team /lr",             "Cmd_LastRequest" );
    register_clcmd( "say_team !lr",             "Cmd_LastRequest" );
    register_clcmd( "say_team /lastrequest",     "Cmd_LastRequest" );
    register_clcmd( "say_team !lastrequest",     "Cmd_LastRequest" );
    
    register_event( "HLTV",     "Event_RoundStart", "a", "1=0", "2=0" );
    
    register_logevent( "Logevent_RoundStart", 2, "1=Round_Start" );
    
    RegisterHam( Ham_Spawn,                 "player",             "Ham_PlayerSpawn_Post",     1 );
    RegisterHam( Ham_Weapon_PrimaryAttack,     "weapon_deagle",     "Ham_DeagleFire_Post",         1 );
    RegisterHam( Ham_Killed,                "player",            "Ham_PlayerKilled_Post",    1 );
    RegisterHam( Ham_TakeDamage,            "player",            "Ham_TakeDamage_Pre",        0 );
    
    register_forward( FM_Think, "Forward_EntityThink_Pre", 0 );
    
    register_message( get_user_msgid( "TextMsg" ), "Message_TextMsg" );
    
    g_msgTeamInfo     = get_user_msgid( "TeamInfo" );
    g_msgSayText     = get_user_msgid( "SayText" );
    
    g_iMaxPlayers     = get_maxplayers();
    
    set_task( 2.0, "StartBeacon", .flags="b" );
    
    set_task( 300.0, "Task_Advertise", .flags="b" );
}

public client_putinserver( id )
{
    g_iCurrentPage[ id ] = 0;
    
    g_bConnected[ id ] = true;
}

public client_disconnected( id )
{
    g_bConnected[ id ] = false;
    
    if( g_bAlive[ id ] )
        g_bAlive[ id ] = false;
        
    if( id == g_iLastRequest[ LR_PRISONER ] || id == g_iLastRequest[ LR_GUARD ] )
    {
        EndLastRequest( id == g_iLastRequest[ LR_PRISONER ] ? g_iLastRequest[ LR_GUARD ] : g_iLastRequest[ LR_PRISONER ], id );
    }
    
    remove_task( id + TASK_ENDLR );
}

public Ham_PlayerSpawn_Post( id )
{
    if( !is_user_alive( id ) )
        return HAM_IGNORED;
        
    g_bAlive[ id ] = true;
    
    return HAM_IGNORED;
}

public Ham_PlayerKilled_Post( iVictim, iKiller, iShouldGib )
{   
    log_amx("Ham_PlayerKilled_Post(%d, %d, %d) called", iVictim, iKiller, iShouldGib);
    log_amx("g_iLastRequest[LR_PRISONER]: %d", g_iLastRequest[LR_PRISONER]);
    log_amx("g_iLastRequest[LR_GUARD]: %d", g_iLastRequest[LR_GUARD]);
    log_amx("g_bLastRequestAllowed: %s", g_bLastRequestAllowed ? "true" : "false");
    log_amx("cs_get_user_team(iVictim): %s", cs_get_user_team(iVictim) == CS_TEAM_T ? "TERRORIST" : cs_get_user_team(iVictim) == CS_TEAM_CT ? "CT" : "OTHER");
    log_amx("get_playercount(CS_TEAM_T, ALIVE): %d", get_playercount(CS_TEAM_T, ALIVE));

    g_bAlive[ iVictim ] = false;
    
    if( iVictim == g_iLastRequest[ LR_PRISONER ] )
    {
        log_amx("EndLastRequest 1 - Pre");
        EndLastRequest( g_iLastRequest[ LR_GUARD ], iVictim );
        log_amx("EndLastRequest 1 - Post");
    }
    
    else if( iVictim == g_iLastRequest[ LR_GUARD ] )
    {
        log_amx("EndLastRequest 2 - Pre");
        EndLastRequest( g_iLastRequest[ LR_PRISONER ], iVictim );
        log_amx("EndLastRequest 2 - Post");
    }
    
    if( !g_bLastRequestAllowed && cs_get_user_team( iVictim ) == CS_TEAM_T )
    {
        if( get_playercount( CS_TEAM_T, ALIVE ) == 1 )
        {
            log_amx("ColorChat - Pre");
            ColorChat( 0, NORMAL, "%s !gLast Request!n sega e pozvolen. Napishete!g /lr!n za da otvorite menu-to.", g_szPrefix );
            log_amx("ColorChat - Post");
            g_bLastRequestAllowed = true;
        }
    }
    log_amx("Ham_PlayerKilled_Post() end");
}

public Ham_DeagleFire_Post( iEnt )
{
    if( g_iCurrentGame != LR_S4S )
    {
        return;
    }
    
    new id = pev( iEnt, pev_owner );
    new iOpponentEnt;
    
    if( cs_get_weapon_ammo( iEnt ) == 0 )
    {
        if( id == g_iLastRequest[ LR_PRISONER ] )
        {
            iOpponentEnt = fm_find_ent_by_owner( -1, "weapon_deagle", g_iLastRequest[ LR_GUARD ] );
            
            if( pev_valid( iOpponentEnt ) )
                cs_set_weapon_ammo( iOpponentEnt, 1 );
        }
        
        else if( id == g_iLastRequest[ LR_GUARD ] )
        {
            iOpponentEnt = fm_find_ent_by_owner( -1, "weapon_deagle", g_iLastRequest[ LR_PRISONER ] );
            
            if( pev_valid( iOpponentEnt ) )
                cs_set_weapon_ammo( iOpponentEnt, 1 );
        }
    }
}

public Ham_TakeDamage_Pre( iVictim, iInflictor, iAttacker, Float:flDamage, iBits )
{
    if( !( 1 <= iAttacker <= g_iMaxPlayers ) )
        return HAM_IGNORED;
    
    new bool:g_bVictimLR = iVictim == g_iLastRequest[ LR_PRISONER ] || iVictim == g_iLastRequest[ LR_GUARD ];
    new bool:g_bAttackerLR = iAttacker == g_iLastRequest[ LR_PRISONER ] || iAttacker == g_iLastRequest[ LR_GUARD ];
    
    if( g_bVictimLR && !g_bAttackerLR )
    {
        return HAM_SUPERCEDE;
    }
    
    else if( !g_bVictimLR && g_bAttackerLR )
    {
        return HAM_SUPERCEDE;
    }
    
    return HAM_IGNORED;
}

public Event_RoundStart()
{
    g_bLastRequestAllowed = false;
    g_iCurrentGame = LR_NONE;
}



public Logevent_RoundStart()
{
    if( !g_bLastRequestAllowed && get_playercount( CS_TEAM_T, ALIVE ) == 1 )
    {
        g_bLastRequestAllowed = true;
        ColorChat( 0, NORMAL, "%s !gLast Request!n sega e pozvolen. Napishete!g /lr", g_szPrefix );
    }
}

public Forward_EntityThink_Pre( iEnt )
{
    if( !pev_valid( iEnt ) || g_iCurrentGame != LR_NADETOSS )
        return FMRES_IGNORED;
    
    new id = pev( iEnt, pev_owner );
    
    if( id != g_iLastRequest[ LR_PRISONER ] && id != g_iLastRequest[ LR_GUARD ] )
        return FMRES_IGNORED;
        
    new szModel[ 32 ];
    
    pev( iEnt, pev_model, szModel, charsmax( szModel ) );
    
    if( equal( szModel, "models/w_smokegrenade.mdl" ) )
    {
        set_pev( iEnt, pev_renderfx, kRenderFxGlowShell );
        set_pev( iEnt, pev_renderamt, 125.0 );
        set_pev( iEnt, pev_rendermode, kRenderTransAlpha );
        
        set_pev( iEnt, pev_rendercolor, id == g_iLastRequest[ LR_GUARD ] ? { 0.0, 0.0, 255.0 } : { 255.0, 0.0, 0.0 } );
        
        return FMRES_SUPERCEDE;
    }    
    
    return FMRES_IGNORED;
}    



public Message_TextMsg()
{
    if( g_iCurrentGame == LR_NONE )
    {
        return PLUGIN_CONTINUE;
    }
    
    static szText[ 25 ];
    get_msg_arg_string( 2, szText, charsmax( szText ) );
    
    if( equal( szText, "#Round_Draw" ) || equal( szText, "#Game_will_restart_in" ) || equal( szText, "#Game_Commencing" ) )
    {
        g_iCurrentGame = LR_NONE;
        
        strip_user_weapons( g_iLastRequest[ LR_PRISONER ] );
        strip_user_weapons( g_iLastRequest[ LR_GUARD ] );
        
        GiveWeapons( g_iLastRequest[ LR_GUARD ] );
        
        g_iLastRequest[ LR_PRISONER ] = 0;
        g_iLastRequest[ LR_GUARD ] = 0;
    }
    
    return PLUGIN_CONTINUE;
}

public Cmd_LastRequest( id )
{
    if( !g_bAlive[ id ] )
    {
        ColorChat( id, NORMAL, "%s You must be !talive!n to have a !gLast Request!n.", g_szPrefix );
        return PLUGIN_HANDLED;
    }
    
    else if( cs_get_user_team( id ) != CS_TEAM_T )
    {
        ColorChat( id, NORMAL, "%s You must be a !tprisoner!n to have a !gLast Request!n.", g_szPrefix );
        return PLUGIN_HANDLED;
    }
    
    else if( !g_bLastRequestAllowed )
    {
        ColorChat( id, NORMAL, "%s There are too many !tprisoners!n remaining to have a !gLast Request!n.", g_szPrefix );
        return PLUGIN_HANDLED;
    }
    
    else if( g_iCurrentGame != LR_NONE )
    {
        ColorChat( id, NORMAL, "%s There's a !gLast Request!n already in progress!", g_szPrefix );
        return PLUGIN_HANDLED;
    }
    
    else LastRequestMenu( id );
    
    return PLUGIN_HANDLED;
}

public LastRequestMenu( id )
{
    new hMenu = menu_create( "\yChoose a Game:", "LastRequestMenu_Handler" );
    
    new szInfo[ 6 ];
    
    for( new i = 0; i < MAX_GAMES; i++ )
    {
        num_to_str( i, szInfo, charsmax( szInfo ) );
        
        menu_additem( hMenu, g_szGameNames[ i ], szInfo );
    }
    
    menu_setprop( hMenu, MPROP_NEXTNAME, "Next Page" );
    menu_setprop( hMenu, MPROP_BACKNAME, "Previous Page" );
    
    menu_display( id, hMenu, 0 );
}

public LastRequestMenu_Handler( id, hMenu, iItem )
{
    if( iItem == MENU_EXIT )
    {
        menu_destroy( hMenu );
        return PLUGIN_HANDLED;
    }
    
    new szData[ 6 ];
    new iAccess, hCallback;
    menu_item_getinfo( hMenu, iItem, iAccess, szData, charsmax( szData ), _, _, hCallback );
    
    g_iChosenGame[ id ] = str_to_num( szData );
    
    if( g_iCurrentGame != LR_NONE )
    {
        menu_destroy( hMenu );
        g_iChosenGame[ id ] = LR_NONE;
        ColorChat( id, NORMAL, "%s There's already a !gLast Request!n in progress.", g_szPrefix );
        return PLUGIN_HANDLED;
    }
    
    ShowPlayerMenu( id );
    
    menu_destroy( hMenu );
    return PLUGIN_HANDLED;
}
    
    
public ShowPlayerMenu( id )
{
    new hMenu = menu_create( "\yChoose an Opponent:", "PlayerMenu_Handler" );
    
    new szPlayerName[ 32 ], szInfo[ 6 ];
    
    for( new i = 1; i < g_iMaxPlayers; i++ )
    {
        if( !g_bAlive[ i ] || cs_get_user_team( i ) != CS_TEAM_CT )
            continue;
        
        get_user_name( i, szPlayerName, charsmax( szPlayerName ) );
        
        num_to_str( i, szInfo, charsmax( szInfo ) );
        
        menu_additem( hMenu, szPlayerName, szInfo );
    }
    
    menu_setprop( hMenu, MPROP_NEXTNAME, "Next Page" );
    menu_setprop( hMenu, MPROP_BACKNAME, "Previous Page" );
    
    menu_display( id, hMenu, 0 );
}

public PlayerMenu_Handler( id, hMenu, iItem )
{    
    if( iItem == MENU_EXIT || !g_bAlive[ id ] || !g_bLastRequestAllowed || g_iCurrentGame != LR_NONE )
    {
        g_iChosenGame[ id ] = LR_NONE;
        
        menu_destroy( hMenu );
        return PLUGIN_HANDLED;
    }
    
    new szData[ 6 ], szPlayerName[ 64 ];
    new iAccess, hCallback;
    
    menu_item_getinfo( hMenu, iItem, iAccess, szData, charsmax( szData ), szPlayerName, charsmax( szPlayerName ), hCallback );
    
    new iGuard = str_to_num( szData );
    
    if( !g_bAlive[ iGuard ] || cs_get_user_team( iGuard ) != CS_TEAM_CT )
    {
        ColorChat( id, NORMAL, "%s That player is no longer available for !gLast Request!n.", g_szPrefix );
        menu_destroy( hMenu );
        
        ShowPlayerMenu( id );
        return PLUGIN_HANDLED;
    }
    
    StartGame( g_iChosenGame[ id ], id, iGuard );
    
    menu_destroy( hMenu );
    return PLUGIN_HANDLED;
}

public StartGame( iGame, iPrisoner, iGuard )
{
    g_iCurrentGame = iGame;
    
    g_iLastRequest[ LR_PRISONER ] = iPrisoner;
    g_iLastRequest[ LR_GUARD ] = iGuard;
    
    new szPrisonerName[ 32 ], szGuardName[ 32 ];
    
    get_user_name( iPrisoner, szPrisonerName, charsmax( szPrisonerName ) );
    get_user_name( iGuard, szGuardName, charsmax( szGuardName ) );
    
    ColorChat( 0, NORMAL, "%s !t%s!n sreshtu !t%s!n vuv duela !g%s!n!", g_szPrefix, szPrisonerName, szGuardName, g_szGameNames[ iGame ] );
    
    strip_user_weapons( iPrisoner );
    strip_user_weapons( iGuard );
    
    set_user_health( iPrisoner, 100 );
    set_user_health( iGuard, 100 );
    
    set_user_armor( iPrisoner, 0 );
    set_user_armor( iGuard, 0 );
    
    StartBeacon();
    
    ColorChat( iPrisoner, NORMAL, "%s !tObjective: %s", g_szPrefix, g_szDescription[ iGame ] );
    ColorChat( iGuard, NORMAL, "%s !tObjective: %s", g_szPrefix, g_szDescription[ iGame ] );
    
    switch( iGame )
    {    
        case LR_S4S:
        {
            LR_Shot4Shot( iPrisoner );
            LR_Shot4Shot( iGuard );
        }
        
        case LR_RACE:
        {
            LR_Race( iPrisoner );
            LR_Race( iGuard );
        }
        
        case LR_KNIFE:
        {
            LR_Knife( iPrisoner );
            LR_Knife( iGuard );
        }
        
        case LR_SPRAY:
        {
            LR_Spray( iPrisoner );
            LR_Spray( iGuard );
        }
        
        case LR_GUNTOSS:
        {
            LR_GunToss( iPrisoner );
            LR_GunToss( iGuard );
        }
        
        case LR_NADETOSS:
        {
            LR_NadeToss( iPrisoner );
            LR_NadeToss( iGuard );
        }
        
        case LR_SCOUT:
        {
            LR_Scout( iPrisoner );
            LR_Scout( iGuard );
        }
        
        case LR_SHOTGUN:
        {
            LR_Shotgun( iPrisoner );
            LR_Shotgun( iGuard );
        }
    }
}

public StartBeacon()
{
    if( g_iCurrentGame == LR_NONE )
    {
        return;
    }
    
    new id;
    
    for( new i = 0; i < 2; i++ )
    {
        id = g_iLastRequest[ i ];
        
        static origin[3]
        emit_sound( id, CHAN_ITEM, g_szBeaconSound, 1.0, ATTN_NORM, 0, PITCH_NORM )
        
        get_user_origin( id, origin )
        message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
        write_byte( TE_BEAMCYLINDER )
        write_coord( origin[0] )    //position.x
        write_coord( origin[1] )    //position.y
        write_coord( origin[2]-20 )    //position.z
        write_coord( origin[0] )        //axis.x
        write_coord( origin[1] )        //axis.y
        write_coord( origin[2]+200 )    //axis.z
        write_short( g_iSprite )    //sprite index
        write_byte( 0 )           //starting frame
        write_byte( 1 )           //frame rate in 0.1's
        write_byte( 6 )            //life in 0.1's
        write_byte( 10 )            //line width in 0.1's
        write_byte( 1 )            //noise amplitude in 0.01's
        
        switch( cs_get_user_team( id ) )
        {
            case CS_TEAM_CT:
            {
                write_byte( 0 );
                write_byte( 0 );
                write_byte( 255 );
            }
            
            case CS_TEAM_T:
            {
                write_byte( 255 );
                write_byte( 0 );
                write_byte( 0 );
            }
        }
        
        write_byte( 255 );            // brightness
        write_byte( 0 );            // scroll speed in 0.1's
        message_end();
    }
}
    
public EndLastRequest( iWinner, iLoser )
{
    new szWinnerName[ 32 ], szLoserName[ 32 ];
    
    get_user_name( iWinner, szWinnerName, 31 );
    get_user_name( iLoser, szLoserName, 31 );
    
    ColorChat( 0, NORMAL, "%s !t%s!n beat !t%s!n in the !gLast Request!n.", g_szPrefix, szWinnerName, szLoserName );
    
    //strip_user_weapons( iLoser );

    g_iCurrentGame = LR_NONE;
    
    g_iLastRequest[ LR_PRISONER ] = 0;
    g_iLastRequest[ LR_GUARD ] = 0;
    
    set_task( 0.1, "Task_EndLR", TASK_ENDLR + iWinner );
}

public Task_EndLR( iTaskID )
{
    new id = iTaskID - TASK_ENDLR;

    strip_user_weapons( id );
    set_user_health( id, 100 );
    
    if( cs_get_user_team( id ) == CS_TEAM_CT )
        GiveWeapons( id );
}

//////////////////////////////
//            LR Games        //
//////////////////////////////

LR_Knife( id )
{
    new szMapName[ 32 ], iCTOrigin[ 3 ], iTOrigin[ 3 ];
    
    give_item( id, "weapon_knife" );
    
    get_mapname( szMapName, charsmax( szMapName ) );
    
    if( equali( szMapName, "some1s_jailbreak" ) )
    {
        iCTOrigin = { -759, 1047, 100 };
        iTOrigin = { -585, 867, 100 };
        
        if( id == g_iLastRequest[ LR_PRISONER ] )
            set_user_origin( id, iTOrigin );
        
        else
            set_user_origin( id, iCTOrigin );
    }
}

LR_Shotgun( id )
{
    give_item( id, "weapon_m3" );
    cs_set_user_bpammo( id, CSW_M3, 28 );
}

LR_Scout( id )
{
    new szMapName[ 32 ], iCTOrigin[ 3 ], iTOrigin[ 3 ];

    give_item( id, "weapon_scout" );
    cs_set_user_bpammo( id, CSW_SCOUT, 90 );
    
    get_mapname( szMapName, charsmax( szMapName ) );
    
    if( equali( szMapName, "some1s_jailbreak" ) )
    {
        iCTOrigin = { -2898, -2040, 37 };
        iTOrigin = { -2908, 905, 37 };
        
        if( id == g_iLastRequest[ LR_PRISONER ] )
            set_user_origin( id, iTOrigin );
        
        else
            set_user_origin( id, iCTOrigin );
    }
}

LR_Shot4Shot( id )
{
    new szMapName[ 32 ], iCTOrigin[ 3 ], iTOrigin[ 3 ];
    
    if( id == g_iLastRequest[ LR_PRISONER ] )
    {
        cs_set_weapon_ammo( give_item( id, "weapon_deagle" ), 1 );
    }
    
    else cs_set_weapon_ammo( give_item( id, "weapon_deagle" ), 0 );
    
    get_mapname( szMapName, charsmax( szMapName ) );
    
    if( equali( szMapName, "some1s_jailbreak" ) )
    {
        iCTOrigin = { -1352, 271, 38 };
        iTOrigin = { -1338, -782, 38 };
        
        if( id == g_iLastRequest[ LR_PRISONER ] )
            set_user_origin( id, iTOrigin );
        
        else
            set_user_origin( id, iCTOrigin );
    }
}

LR_Race( id )
{
    give_item( id, "weapon_knife" );
}

LR_Spray( id )
{
    give_item( id, "weapon_knife" );
}

LR_GunToss( id )
{
    give_item( id, "weapon_knife" );
    cs_set_weapon_ammo( give_item( id, "weapon_deagle" ), 0 );
}

LR_NadeToss( id )
{
    give_item( id, "weapon_knife" );
    give_item( id, "weapon_smokegrenade" );
    ColorChat( id, NORMAL, "%s Do not throw the nade until you are doing the toss!", g_szPrefix );
}

public Task_Advertise()
{
    //ColorChat( 0, NORMAL, "%s This server is running !tLast Request v%s !nby !tH3avY Ra1n!n.", g_szPrefix, g_szVersion );
}

GiveWeapons( id )
{
    give_item( id, "weapon_m4a1" );
    give_item( id, "weapon_deagle" );
    give_item( id, "weapon_smokegrenade" );
    
    cs_set_user_bpammo( id, CSW_M4A1, 90 );
    cs_set_user_bpammo( id, CSW_DEAGLE, 120 );
}

ColorChat( id, colour, const text[], any:... )
{
    if( !get_playersnum() )
    {
        return;
    }
    
    static message[192];
    
    message[0] = 0x01;
    vformat(message[1], sizeof(message) - 1, text, 4);
    
    replace_all(message, sizeof(message) - 1, "!g", "^x04");
    replace_all(message, sizeof(message) - 1, "!n", "^x01");
    replace_all(message, sizeof(message) - 1, "!t", "^x03");
    
    static index, MSG_Type;
    
    if( !id )
    {
        static i;
        for(i = 1; i <= g_iMaxPlayers; i++)
        {
            if( g_bConnected[i] )
            {
                index = i;
                break;
            }
        }
        
        MSG_Type = MSG_ALL;
    }
    else
    {
        MSG_Type = MSG_ONE;
        index = id;
    }
    
    static bool:bChanged;
    if( colour == GREY || colour == RED || colour == BLUE )
    {
        message_begin(MSG_Type, g_msgTeamInfo, _, index);
        write_byte(index);
        write_string(g_szTeamName[colour]);
        message_end();
        
        bChanged = true;
    }
    
    message_begin(MSG_Type, g_msgSayText, _, index);
    write_byte(index);
    write_string(message);
    message_end();
    
    if( bChanged )
    {
        message_begin(MSG_Type, g_msgTeamInfo, _, index);
        write_byte(index);
        write_string(g_szTeamName[_:cs_get_user_team(index)]);
        message_end();
    }
}

get_playercount( CsTeams:iTeam, iStatus )
{
    new iPlayerCount;
    
    for( new i = 1; i <= g_iMaxPlayers; i++ )
    {
        if( !g_bConnected[ i ] || cs_get_user_team( i ) != iTeam ) continue;
        
        switch( iStatus )
        {
            case DEAD: if( g_bAlive[ i ] ) continue;
            case ALIVE: if( !g_bAlive[ i ] ) continue;
        }
        
        iPlayerCount++;
    }
    
    return iPlayerCount;
}  
Ако може го направете така, че като е останал само 1 Т не всеки път да пише /lr за да му се отваря менюто, ами като свърши дадения дуел веднага пак да му се отвори автоматично, благодаря. :)
The Best Deathrun Server: 79.124.49.91:27019
The Best Respawn Server: 79.124.49.88:27021

Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

Преработка на JB LR

Мнение от OciXCrom » 23 Фев 2018, 15:56

Код за потвърждение: Избери целия код

/*
*
*        Jailbreak Last Request
*            
*        H3avY Ra1n (AKA nikhilgupta345)
*
*        Description
*        -----------
*
*            This is a Last Request plugin for jailbreak mod, where 
*            the last terrorists can type /lr and is presented with a 
*            menu, which has numerous options to choose from that interact 
*            with the Counter-Terrorists.
*
*        Last Request Options
*        --------------------
*
*            Knife Battle     - Fight with knives 1v1
*            Shot for Shot    - Take turns shooting a deagle
*            Deagle Toss        - See who can throw the deagle the farthest
*            Shotgun Battle    - Fight with shotguns 1v1
*            Scout Battle    - Fight with scouts 1v1
*            Grenade Toss    - See who can throw the grenade the farthest
*            Race            - Race across a certain part of the map
*            Spray Contest    - See who can spray closest to the top or bottom border
*            of a wall. Prisoner decides.
*
*
*        Client Commands
*        ---------------
*    
*            say/say_team    /lr             - Opens Last Request Menu
*                            !lr
*                            /lastrequest
*                            !lastrequest
*
*
*        Installation
*        ------------
*
*            - Compile this plugin locally
*            - Place jb_lastrequest.amxx in addons/amxmodx/plugins/ folder
*            - Open addons/amxmodx/configs/plugins.ini
*            - Add the line 'jb_lastrequest.amxx' at the bottom
*            - Restart server or change map
*            
*
*        Changelog
*        ---------
*        
*            February 15, 2011     - v1.0 -     Initial Release
*            February 24, 2011    - v1.0.1 -     Removed teleporting back to cell
*            March 05, 2011        - v1.1 -    Changed way of allowing a Last Request
*            March 26, 2011        - v1.2 -     Added Multi-Lingual support.
*            August 10, 2011        - v2.0 -    Completely rewrote plugin
*
*        
*        Credits
*        -------
*        
*            Pastout        -    Used his thread as a layout for mine
*
*        
*        Plugin Thread: http://forums.alliedmods.net/showthread.php?p=1416279
*
*/

// Includes
////////////

#include < amxmodx >
#include < cstrike >
#include < fun >
#include < fakemeta >
#include < fakemeta_util >
#include < hamsandwich >

// Enums
/////////

enum
{
	LR_NONE=-1,
	LR_S4S,
	LR_SPRAY,
	LR_RACE,
	LR_GUNTOSS,
	LR_KNIFE,
	LR_NADETOSS,
	LR_SCOUT,
	LR_SHOTGUN,
	
	MAX_GAMES
};

enum
{
	GREY = 0,
	RED,
	BLUE,
	NORMAL
};

enum
{
	ALIVE, 
	DEAD, 
	ALL    
};

enum(+=1)// fix ur old enum into this 
{ 
	LR_PRISONER = 0, 
	LR_GUARD 
} 

enum ( += 100 )
{
	TASK_BEACON,
	TASK_ENDLR
};

// Consts
//////////

new const g_szPrefix[ ] = "!g[Jailbreak]!n";

new const g_szBeaconSound[ ] = "buttons/blip1.wav";
new const g_szBeaconSprite[ ] = "sprites/white.spr";

new const g_szGameNames[ MAX_GAMES ][ ] = 
{
	"Shot 4 Shot",
	"Spray Contest",
	"Race",
	"Gun Toss",
	"Knife Battle",
	"Grenade Toss",
	"Scout Battle",
	"Shotgun Battle"
};

new const g_szDescription[ MAX_GAMES ][ ] = 
{
	"Take turns shooting a deagle.",
	"Both players spray on a wall, highest or lowest.",
	"Both players race across a part of the map.",
	"See who can throw the deagle the farthest.",
	"Battle it out with knives.",
	"See who can throw the grenade the farthest from a point in the map.",
	"Battle it out with scouts.",
	"Battle it out with shotguns."
};

new const g_szTeamName[ ][ ] = 
{
	"",
	"TERRORIST",
	"CT",
	"SPECTATOR"
};

new const g_szPlugin[ ] = "Jailbreak Last Request";
new const g_szVersion[ ] = "2.0";
new const g_szAuthor[ ] = "H3avY Ra1n";

// Integers
////////////

new g_iCurrentGame = LR_NONE;
new g_iLastRequest[ 2 ];
new g_iCurrentPage[ 33 ];
new g_iChosenGame[ 33 ];

new g_iSprite;

new g_iMaxPlayers;

// Booleans
///////////

new bool:g_bAlive[ 33 ];
new bool:g_bConnected[ 33 ];

new bool:g_bLastRequestAllowed;

// Messages
////////////

new g_msgTeamInfo;
new g_msgSayText;

public plugin_precache()
{
	precache_sound( g_szBeaconSound );
	
	g_iSprite = precache_model( g_szBeaconSprite );
}

public plugin_init()
{
	register_plugin( g_szPlugin, g_szVersion, g_szAuthor );
	
	register_clcmd( "say /lr",                     "Cmd_LastRequest" );
	register_clcmd( "say !lr",                     "Cmd_LastRequest" );
	register_clcmd( "say /lastrequest",         "Cmd_LastRequest" );
	register_clcmd( "say !lastrequest",         "Cmd_LastRequest" );
	
	register_clcmd( "say_team /lr",             "Cmd_LastRequest" );
	register_clcmd( "say_team !lr",             "Cmd_LastRequest" );
	register_clcmd( "say_team /lastrequest",     "Cmd_LastRequest" );
	register_clcmd( "say_team !lastrequest",     "Cmd_LastRequest" );
	
	register_event( "HLTV",     "Event_RoundStart", "a", "1=0", "2=0" );
	
	register_logevent( "Logevent_RoundStart", 2, "1=Round_Start" );
	
	RegisterHam( Ham_Spawn,                 "player",             "Ham_PlayerSpawn_Post",     1 );
	RegisterHam( Ham_Weapon_PrimaryAttack,     "weapon_deagle",     "Ham_DeagleFire_Post",         1 );
	RegisterHam( Ham_Killed,                "player",            "Ham_PlayerKilled_Post",    1 );
	RegisterHam( Ham_TakeDamage,            "player",            "Ham_TakeDamage_Pre",        0 );
	
	register_forward( FM_Think, "Forward_EntityThink_Pre", 0 );
	
	register_message( get_user_msgid( "TextMsg" ), "Message_TextMsg" );
	
	g_msgTeamInfo     = get_user_msgid( "TeamInfo" );
	g_msgSayText     = get_user_msgid( "SayText" );
	
	g_iMaxPlayers     = get_maxplayers();
	
	set_task( 2.0, "StartBeacon", .flags="b" );
	
	set_task( 300.0, "Task_Advertise", .flags="b" );
}

public client_putinserver( id )
{
	g_iCurrentPage[ id ] = 0;
	
	g_bConnected[ id ] = true;
}

public client_disconnected( id )
{
	g_bConnected[ id ] = false;
	
	if( g_bAlive[ id ] )
		g_bAlive[ id ] = false;
		
	if( id == g_iLastRequest[ LR_PRISONER ] || id == g_iLastRequest[ LR_GUARD ] )
	{
		EndLastRequest( id == g_iLastRequest[ LR_PRISONER ] ? g_iLastRequest[ LR_GUARD ] : g_iLastRequest[ LR_PRISONER ], id );
	}
	
	remove_task( id + TASK_ENDLR );
}

public Ham_PlayerSpawn_Post( id )
{
	if( !is_user_alive( id ) )
		return HAM_IGNORED;
		
	g_bAlive[ id ] = true;
	
	return HAM_IGNORED;
}

public Ham_PlayerKilled_Post( iVictim, iKiller, iShouldGib )
{   
	log_amx("Ham_PlayerKilled_Post(%d, %d, %d) called", iVictim, iKiller, iShouldGib);
	log_amx("g_iLastRequest[LR_PRISONER]: %d", g_iLastRequest[LR_PRISONER]);
	log_amx("g_iLastRequest[LR_GUARD]: %d", g_iLastRequest[LR_GUARD]);
	log_amx("g_bLastRequestAllowed: %s", g_bLastRequestAllowed ? "true" : "false");
	log_amx("cs_get_user_team(iVictim): %s", cs_get_user_team(iVictim) == CS_TEAM_T ? "TERRORIST" : cs_get_user_team(iVictim) == CS_TEAM_CT ? "CT" : "OTHER");
	log_amx("get_playercount(CS_TEAM_T, ALIVE): %d", get_playercount(CS_TEAM_T, ALIVE));

	g_bAlive[ iVictim ] = false;
	
	if( iVictim == g_iLastRequest[ LR_PRISONER ] )
	{
		log_amx("EndLastRequest 1 - Pre");
		EndLastRequest( g_iLastRequest[ LR_GUARD ], iVictim );
		log_amx("EndLastRequest 1 - Post");
	}
	
	else if( iVictim == g_iLastRequest[ LR_GUARD ] )
	{
		log_amx("EndLastRequest 2 - Pre");
		EndLastRequest( g_iLastRequest[ LR_PRISONER ], iVictim );
		log_amx("EndLastRequest 2 - Post");
	}
	
	if( !g_bLastRequestAllowed && cs_get_user_team( iVictim ) == CS_TEAM_T )
	{
		if( get_playercount( CS_TEAM_T, ALIVE ) == 1 )
		{
			log_amx("ColorChat - Pre");
			ColorChat( 0, NORMAL, "%s !gLast Request!n sega e pozvolen. Napishete!g /lr!n za da otvorite menu-to.", g_szPrefix );
			log_amx("ColorChat - Post");
			g_bLastRequestAllowed = true;
		}
	}
	log_amx("Ham_PlayerKilled_Post() end");
}

public Ham_DeagleFire_Post( iEnt )
{
	if( g_iCurrentGame != LR_S4S )
	{
		return;
	}
	
	new id = pev( iEnt, pev_owner );
	new iOpponentEnt;
	
	if( cs_get_weapon_ammo( iEnt ) == 0 )
	{
		if( id == g_iLastRequest[ LR_PRISONER ] )
		{
			iOpponentEnt = fm_find_ent_by_owner( -1, "weapon_deagle", g_iLastRequest[ LR_GUARD ] );
			
			if( pev_valid( iOpponentEnt ) )
				cs_set_weapon_ammo( iOpponentEnt, 1 );
		}
		
		else if( id == g_iLastRequest[ LR_GUARD ] )
		{
			iOpponentEnt = fm_find_ent_by_owner( -1, "weapon_deagle", g_iLastRequest[ LR_PRISONER ] );
			
			if( pev_valid( iOpponentEnt ) )
				cs_set_weapon_ammo( iOpponentEnt, 1 );
		}
	}
}

public Ham_TakeDamage_Pre( iVictim, iInflictor, iAttacker, Float:flDamage, iBits )
{
	if( !( 1 <= iAttacker <= g_iMaxPlayers ) )
		return HAM_IGNORED;
	
	new bool:g_bVictimLR = iVictim == g_iLastRequest[ LR_PRISONER ] || iVictim == g_iLastRequest[ LR_GUARD ];
	new bool:g_bAttackerLR = iAttacker == g_iLastRequest[ LR_PRISONER ] || iAttacker == g_iLastRequest[ LR_GUARD ];
	
	if( g_bVictimLR && !g_bAttackerLR )
	{
		return HAM_SUPERCEDE;
	}
	
	else if( !g_bVictimLR && g_bAttackerLR )
	{
		return HAM_SUPERCEDE;
	}
	
	return HAM_IGNORED;
}

public Event_RoundStart()
{
	g_bLastRequestAllowed = false;
	g_iCurrentGame = LR_NONE;
}



public Logevent_RoundStart()
{
	if( !g_bLastRequestAllowed && get_playercount( CS_TEAM_T, ALIVE ) == 1 )
	{
		g_bLastRequestAllowed = true;
		ColorChat( 0, NORMAL, "%s !gLast Request!n sega e pozvolen. Napishete!g /lr", g_szPrefix );
	}
}

public Forward_EntityThink_Pre( iEnt )
{
	if( !pev_valid( iEnt ) || g_iCurrentGame != LR_NADETOSS )
		return FMRES_IGNORED;
	
	new id = pev( iEnt, pev_owner );
	
	if( id != g_iLastRequest[ LR_PRISONER ] && id != g_iLastRequest[ LR_GUARD ] )
		return FMRES_IGNORED;
		
	new szModel[ 32 ];
	
	pev( iEnt, pev_model, szModel, charsmax( szModel ) );
	
	if( equal( szModel, "models/w_smokegrenade.mdl" ) )
	{
		set_pev( iEnt, pev_renderfx, kRenderFxGlowShell );
		set_pev( iEnt, pev_renderamt, 125.0 );
		set_pev( iEnt, pev_rendermode, kRenderTransAlpha );
		
		set_pev( iEnt, pev_rendercolor, id == g_iLastRequest[ LR_GUARD ] ? { 0.0, 0.0, 255.0 } : { 255.0, 0.0, 0.0 } );
		
		return FMRES_SUPERCEDE;
	}    
	
	return FMRES_IGNORED;
}    



public Message_TextMsg()
{
	if( g_iCurrentGame == LR_NONE )
	{
		return PLUGIN_CONTINUE;
	}
	
	static szText[ 25 ];
	get_msg_arg_string( 2, szText, charsmax( szText ) );
	
	if( equal( szText, "#Round_Draw" ) || equal( szText, "#Game_will_restart_in" ) || equal( szText, "#Game_Commencing" ) )
	{
		g_iCurrentGame = LR_NONE;
		
		strip_user_weapons( g_iLastRequest[ LR_PRISONER ] );
		strip_user_weapons( g_iLastRequest[ LR_GUARD ] );
		
		GiveWeapons( g_iLastRequest[ LR_GUARD ] );
		
		g_iLastRequest[ LR_PRISONER ] = 0;
		g_iLastRequest[ LR_GUARD ] = 0;
	}
	
	return PLUGIN_CONTINUE;
}

public Cmd_LastRequest( id )
{
	if( !g_bAlive[ id ] )
	{
		ColorChat( id, NORMAL, "%s You must be !talive!n to have a !gLast Request!n.", g_szPrefix );
		return PLUGIN_HANDLED;
	}
	
	else if( cs_get_user_team( id ) != CS_TEAM_T )
	{
		ColorChat( id, NORMAL, "%s You must be a !tprisoner!n to have a !gLast Request!n.", g_szPrefix );
		return PLUGIN_HANDLED;
	}
	
	else if( !g_bLastRequestAllowed )
	{
		ColorChat( id, NORMAL, "%s There are too many !tprisoners!n remaining to have a !gLast Request!n.", g_szPrefix );
		return PLUGIN_HANDLED;
	}
	
	else if( g_iCurrentGame != LR_NONE )
	{
		ColorChat( id, NORMAL, "%s There's a !gLast Request!n already in progress!", g_szPrefix );
		return PLUGIN_HANDLED;
	}
	
	else LastRequestMenu( id );
	
	return PLUGIN_HANDLED;
}

public LastRequestMenu( id )
{
	new hMenu = menu_create( "\yChoose a Game:", "LastRequestMenu_Handler" );
	
	new szInfo[ 6 ];
	
	for( new i = 0; i < MAX_GAMES; i++ )
	{
		num_to_str( i, szInfo, charsmax( szInfo ) );
		
		menu_additem( hMenu, g_szGameNames[ i ], szInfo );
	}
	
	menu_setprop( hMenu, MPROP_NEXTNAME, "Next Page" );
	menu_setprop( hMenu, MPROP_BACKNAME, "Previous Page" );
	
	menu_display( id, hMenu, 0 );
}

public LastRequestMenu_Handler( id, hMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		menu_destroy( hMenu );
		return PLUGIN_HANDLED;
	}
	
	new szData[ 6 ];
	new iAccess, hCallback;
	menu_item_getinfo( hMenu, iItem, iAccess, szData, charsmax( szData ), _, _, hCallback );
	
	g_iChosenGame[ id ] = str_to_num( szData );
	
	if( g_iCurrentGame != LR_NONE )
	{
		menu_destroy( hMenu );
		g_iChosenGame[ id ] = LR_NONE;
		ColorChat( id, NORMAL, "%s There's already a !gLast Request!n in progress.", g_szPrefix );
		return PLUGIN_HANDLED;
	}
	
	ShowPlayerMenu( id );
	
	menu_destroy( hMenu );
	return PLUGIN_HANDLED;
}
	
	
public ShowPlayerMenu( id )
{
	new hMenu = menu_create( "\yChoose an Opponent:", "PlayerMenu_Handler" );
	
	new szPlayerName[ 32 ], szInfo[ 6 ];
	
	for( new i = 1; i < g_iMaxPlayers; i++ )
	{
		if( !g_bAlive[ i ] || cs_get_user_team( i ) != CS_TEAM_CT )
			continue;
		
		get_user_name( i, szPlayerName, charsmax( szPlayerName ) );
		
		num_to_str( i, szInfo, charsmax( szInfo ) );
		
		menu_additem( hMenu, szPlayerName, szInfo );
	}
	
	menu_setprop( hMenu, MPROP_NEXTNAME, "Next Page" );
	menu_setprop( hMenu, MPROP_BACKNAME, "Previous Page" );
	
	menu_display( id, hMenu, 0 );
}

public PlayerMenu_Handler( id, hMenu, iItem )
{    
	if( iItem == MENU_EXIT || !g_bAlive[ id ] || !g_bLastRequestAllowed || g_iCurrentGame != LR_NONE )
	{
		g_iChosenGame[ id ] = LR_NONE;
		
		menu_destroy( hMenu );
		return PLUGIN_HANDLED;
	}
	
	new szData[ 6 ], szPlayerName[ 64 ];
	new iAccess, hCallback;
	
	menu_item_getinfo( hMenu, iItem, iAccess, szData, charsmax( szData ), szPlayerName, charsmax( szPlayerName ), hCallback );
	
	new iGuard = str_to_num( szData );
	
	if( !g_bAlive[ iGuard ] || cs_get_user_team( iGuard ) != CS_TEAM_CT )
	{
		ColorChat( id, NORMAL, "%s That player is no longer available for !gLast Request!n.", g_szPrefix );
		menu_destroy( hMenu );
		
		ShowPlayerMenu( id );
		return PLUGIN_HANDLED;
	}
	
	StartGame( g_iChosenGame[ id ], id, iGuard );
	
	menu_destroy( hMenu );
	return PLUGIN_HANDLED;
}

public StartGame( iGame, iPrisoner, iGuard )
{
	g_iCurrentGame = iGame;
	
	g_iLastRequest[ LR_PRISONER ] = iPrisoner;
	g_iLastRequest[ LR_GUARD ] = iGuard;
	
	new szPrisonerName[ 32 ], szGuardName[ 32 ];
	
	get_user_name( iPrisoner, szPrisonerName, charsmax( szPrisonerName ) );
	get_user_name( iGuard, szGuardName, charsmax( szGuardName ) );
	
	ColorChat( 0, NORMAL, "%s !t%s!n sreshtu !t%s!n vuv duela !g%s!n!", g_szPrefix, szPrisonerName, szGuardName, g_szGameNames[ iGame ] );
	
	strip_user_weapons( iPrisoner );
	strip_user_weapons( iGuard );
	
	set_user_health( iPrisoner, 100 );
	set_user_health( iGuard, 100 );
	
	set_user_armor( iPrisoner, 0 );
	set_user_armor( iGuard, 0 );
	
	StartBeacon();
	
	ColorChat( iPrisoner, NORMAL, "%s !tObjective: %s", g_szPrefix, g_szDescription[ iGame ] );
	ColorChat( iGuard, NORMAL, "%s !tObjective: %s", g_szPrefix, g_szDescription[ iGame ] );
	
	switch( iGame )
	{    
		case LR_S4S:
		{
			LR_Shot4Shot( iPrisoner );
			LR_Shot4Shot( iGuard );
		}
		
		case LR_RACE:
		{
			LR_Race( iPrisoner );
			LR_Race( iGuard );
		}
		
		case LR_KNIFE:
		{
			LR_Knife( iPrisoner );
			LR_Knife( iGuard );
		}
		
		case LR_SPRAY:
		{
			LR_Spray( iPrisoner );
			LR_Spray( iGuard );
		}
		
		case LR_GUNTOSS:
		{
			LR_GunToss( iPrisoner );
			LR_GunToss( iGuard );
		}
		
		case LR_NADETOSS:
		{
			LR_NadeToss( iPrisoner );
			LR_NadeToss( iGuard );
		}
		
		case LR_SCOUT:
		{
			LR_Scout( iPrisoner );
			LR_Scout( iGuard );
		}
		
		case LR_SHOTGUN:
		{
			LR_Shotgun( iPrisoner );
			LR_Shotgun( iGuard );
		}
	}
}

public StartBeacon()
{
	if( g_iCurrentGame == LR_NONE )
	{
		return;
	}
	
	new id;
	
	for( new i = 0; i < 2; i++ )
	{
		id = g_iLastRequest[ i ];
		
		static origin[3]
		emit_sound( id, CHAN_ITEM, g_szBeaconSound, 1.0, ATTN_NORM, 0, PITCH_NORM )
		
		get_user_origin( id, origin )
		message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
		write_byte( TE_BEAMCYLINDER )
		write_coord( origin[0] )    //position.x
		write_coord( origin[1] )    //position.y
		write_coord( origin[2]-20 )    //position.z
		write_coord( origin[0] )        //axis.x
		write_coord( origin[1] )        //axis.y
		write_coord( origin[2]+200 )    //axis.z
		write_short( g_iSprite )    //sprite index
		write_byte( 0 )           //starting frame
		write_byte( 1 )           //frame rate in 0.1's
		write_byte( 6 )            //life in 0.1's
		write_byte( 10 )            //line width in 0.1's
		write_byte( 1 )            //noise amplitude in 0.01's
		
		switch( cs_get_user_team( id ) )
		{
			case CS_TEAM_CT:
			{
				write_byte( 0 );
				write_byte( 0 );
				write_byte( 255 );
			}
			
			case CS_TEAM_T:
			{
				write_byte( 255 );
				write_byte( 0 );
				write_byte( 0 );
			}
		}
		
		write_byte( 255 );            // brightness
		write_byte( 0 );            // scroll speed in 0.1's
		message_end();
	}
}
	
public EndLastRequest( iWinner, iLoser )
{
	new szWinnerName[ 32 ], szLoserName[ 32 ];
	
	get_user_name( iWinner, szWinnerName, 31 );
	get_user_name( iLoser, szLoserName, 31 );
	
	ColorChat( 0, NORMAL, "%s !t%s!n beat !t%s!n in the !gLast Request!n.", g_szPrefix, szWinnerName, szLoserName );
	
	//strip_user_weapons( iLoser );

	g_iCurrentGame = LR_NONE;
	
	g_iLastRequest[ LR_PRISONER ] = 0;
	g_iLastRequest[ LR_GUARD ] = 0;
	
	set_task( 0.1, "Task_EndLR", TASK_ENDLR + iWinner );
}

public Task_EndLR( iTaskID )
{
	new id = iTaskID - TASK_ENDLR;

	strip_user_weapons( id );
	set_user_health( id, 100 );
	
	if( cs_get_user_team( id ) == CS_TEAM_CT )
		GiveWeapons( id );
	
	if( is_user_alive( id ) )
	{
		new iPlayers[ 32 ], iPnum;
		get_players( iPlayers, iPnum, "ae", "CT" );
	
		if(iPnum)
			LastRequestMenu( id );
	}
}

//////////////////////////////
//            LR Games        //
//////////////////////////////

LR_Knife( id )
{
	new szMapName[ 32 ], iCTOrigin[ 3 ], iTOrigin[ 3 ];
	
	give_item( id, "weapon_knife" );
	
	get_mapname( szMapName, charsmax( szMapName ) );
	
	if( equali( szMapName, "some1s_jailbreak" ) )
	{
		iCTOrigin = { -759, 1047, 100 };
		iTOrigin = { -585, 867, 100 };
		
		if( id == g_iLastRequest[ LR_PRISONER ] )
			set_user_origin( id, iTOrigin );
		
		else
			set_user_origin( id, iCTOrigin );
	}
}

LR_Shotgun( id )
{
	give_item( id, "weapon_m3" );
	cs_set_user_bpammo( id, CSW_M3, 28 );
}

LR_Scout( id )
{
	new szMapName[ 32 ], iCTOrigin[ 3 ], iTOrigin[ 3 ];

	give_item( id, "weapon_scout" );
	cs_set_user_bpammo( id, CSW_SCOUT, 90 );
	
	get_mapname( szMapName, charsmax( szMapName ) );
	
	if( equali( szMapName, "some1s_jailbreak" ) )
	{
		iCTOrigin = { -2898, -2040, 37 };
		iTOrigin = { -2908, 905, 37 };
		
		if( id == g_iLastRequest[ LR_PRISONER ] )
			set_user_origin( id, iTOrigin );
		
		else
			set_user_origin( id, iCTOrigin );
	}
}

LR_Shot4Shot( id )
{
	new szMapName[ 32 ], iCTOrigin[ 3 ], iTOrigin[ 3 ];
	
	if( id == g_iLastRequest[ LR_PRISONER ] )
	{
		cs_set_weapon_ammo( give_item( id, "weapon_deagle" ), 1 );
	}
	
	else cs_set_weapon_ammo( give_item( id, "weapon_deagle" ), 0 );
	
	get_mapname( szMapName, charsmax( szMapName ) );
	
	if( equali( szMapName, "some1s_jailbreak" ) )
	{
		iCTOrigin = { -1352, 271, 38 };
		iTOrigin = { -1338, -782, 38 };
		
		if( id == g_iLastRequest[ LR_PRISONER ] )
			set_user_origin( id, iTOrigin );
		
		else
			set_user_origin( id, iCTOrigin );
	}
}

LR_Race( id )
{
	give_item( id, "weapon_knife" );
}

LR_Spray( id )
{
	give_item( id, "weapon_knife" );
}

LR_GunToss( id )
{
	give_item( id, "weapon_knife" );
	cs_set_weapon_ammo( give_item( id, "weapon_deagle" ), 0 );
}

LR_NadeToss( id )
{
	give_item( id, "weapon_knife" );
	give_item( id, "weapon_smokegrenade" );
	ColorChat( id, NORMAL, "%s Do not throw the nade until you are doing the toss!", g_szPrefix );
}

public Task_Advertise()
{
	//ColorChat( 0, NORMAL, "%s This server is running !tLast Request v%s !nby !tH3avY Ra1n!n.", g_szPrefix, g_szVersion );
}

GiveWeapons( id )
{
	give_item( id, "weapon_m4a1" );
	give_item( id, "weapon_deagle" );
	give_item( id, "weapon_smokegrenade" );
	
	cs_set_user_bpammo( id, CSW_M4A1, 90 );
	cs_set_user_bpammo( id, CSW_DEAGLE, 120 );
}

ColorChat( id, colour, const text[], any:... )
{
	if( !get_playersnum() )
	{
		return;
	}
	
	static message[192];
	
	message[0] = 0x01;
	vformat(message[1], sizeof(message) - 1, text, 4);
	
	replace_all(message, sizeof(message) - 1, "!g", "^x04");
	replace_all(message, sizeof(message) - 1, "!n", "^x01");
	replace_all(message, sizeof(message) - 1, "!t", "^x03");
	
	static index, MSG_Type;
	
	if( !id )
	{
		static i;
		for(i = 1; i <= g_iMaxPlayers; i++)
		{
			if( g_bConnected[i] )
			{
				index = i;
				break;
			}
		}
		
		MSG_Type = MSG_ALL;
	}
	else
	{
		MSG_Type = MSG_ONE;
		index = id;
	}
	
	static bool:bChanged;
	if( colour == GREY || colour == RED || colour == BLUE )
	{
		message_begin(MSG_Type, g_msgTeamInfo, _, index);
		write_byte(index);
		write_string(g_szTeamName[colour]);
		message_end();
		
		bChanged = true;
	}
	
	message_begin(MSG_Type, g_msgSayText, _, index);
	write_byte(index);
	write_string(message);
	message_end();
	
	if( bChanged )
	{
		message_begin(MSG_Type, g_msgTeamInfo, _, index);
		write_byte(index);
		write_string(g_szTeamName[_:cs_get_user_team(index)]);
		message_end();
	}
}

get_playercount( CsTeams:iTeam, iStatus )
{
	new iPlayerCount;
	
	for( new i = 1; i <= g_iMaxPlayers; i++ )
	{
		if( !g_bConnected[ i ] || cs_get_user_team( i ) != iTeam ) continue;
		
		switch( iStatus )
		{
			case DEAD: if( g_bAlive[ i ] ) continue;
			case ALIVE: if( !g_bAlive[ i ] ) continue;
		}
		
		iPlayerCount++;
	}
	
	return iPlayerCount;
}  

Аватар
DoPe ;]]
Извън линия
Потребител
Потребител
Мнения: 402
Регистриран на: 27 Фев 2017, 22:10
Обратна връзка:

Преработка на JB LR

Мнение от DoPe ;]] » 23 Фев 2018, 16:06

Lock.
The Best Deathrun Server: 79.124.49.91:27019
The Best Respawn Server: 79.124.49.88:27021

Заключено
  • Подобни теми
    Отговори
    Преглеждания
     Последно мнение

Обратно към “Заявки за плъгини”

Кой е на линия

Потребители разглеждащи този форум: Google [Bot] и 23 госта