Raised This Month: $ Target: $400
 0% 

Implament Immunity into this script :)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kitami
Senior Member
Join Date: Jun 2006
Location: Toronto
Old 08-16-2008 , 12:13   Implament Immunity into this script :)
Reply With Quote #1

I just wanted to add immunity to admins with the flag "j" from this plugin. So even though lets say the CTs and Ts both have 2 awps bought, an admin can still buy an awp, and also so that the admins with awps are not included into the count of how many awps our out there on the field.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>

#pragma semicolon                1      // force ; usage, just 'cause

#define INCLUDE_SCOUT            1      // Include scouts in sniper rifle

new g_szTitle[]   = "Sniper Rifle Control";
new 
g_szVersion[] = "1.2";
new 
g_szAuthor[]  = "WillyumYum";

new 
g_iSniperNum[3];                    // number of sniper rifles per team

new bool:g_bHasSniper[33];              // bool - true if player has a sniper rifle

new g_szWarn[]    = "Sniper rifle limit reached for your team!";

new const 
SNIPERMODELS[4][] =
{
    
#if ( INCLUDE_SCOUT )
    
"models/w_scout.mdl",               // CSW_SCOUT
    #else
    
"",
    
#endif
    
"models/w_sg550.mdl",               // CSW_SG550
    
"models/w_awp.mdl",                 // CSW_AWP
    
"models/w_g3sg1.mdl"                // CSW_G3SG1
};

// Map disabled - original code by Ryan

public bool:Map_Disabled() {

    new 
szDisabledFile[64];
    
get_configsdirszDisabledFile63 );
    
formatszDisabledFile63"%s/sc_disabled_maps.cfg"szDisabledFile );

    if ( 
file_existsszDisabledFile ) )
    {
        new 
iLineNumszData[64], iTextLen;

        while ( 
read_fileszDisabledFileiLineNumszData63iTextLen ) )
        {
            new 
szMapName[64], szDisabledName[64];

            
get_mapnameszMapName63 );
            new 
iLen copycszDisabledName63szData'*' );

            if ( 
equaliszMapNameszDisabledNameiLen ) )
                return 
true;

            
iLineNum++;
        }
    }

    return 
false;
}

public 
menuSniperidkey ) {

    if ( !
get_cvar_num"mp_sniper_control" ) )
        return 
PLUGIN_CONTINUE;

    new 
iTeam get_user_teamid );

    if ( 
iTeam == && ( g_iSniperNum[iTeam] < get_cvar_num"sc_max_snipers_t" ) || g_bHasSniper[id] ) )       // TERRORIST
        
return PLUGIN_CONTINUE;
    else
    if ( 
iTeam == && ( g_iSniperNum[iTeam] < get_cvar_num"sc_max_snipers_ct" ) || g_bHasSniper[id] ) )       // COUNTER-TERRORIST
        
return PLUGIN_CONTINUE;

    if( 
iTeam == && key == )  // Allows T's tp buy ak-47, but blocks CT's from buying scout
        
return PLUGIN_CONTINUE;
    else
    if( 
iTeam == && key == )  // Allows CT's to buy m4, but blocks T's from buying scout
        
return PLUGIN_CONTINUE;

    
engclient_cmdid"menuselect" ,"10");
    
client_printidprint_center g_szWarn );

    return 
PLUGIN_HANDLED;
}

public 
bool:check_primaryid ) {

    new 
iWeapons[32];
    new 
iTotalWeapons 0;
    
get_user_weaponsidiWeaponsiTotalWeapons );

    for ( new 
0iTotalWeaponsi++ )
    {
        switch ( 
iWeapons[i] )
        {
            case 
CSW_M3:      return true;
            case 
CSW_XM1014:  return true;
            case 
CSW_MP5NAVY: return true;
            case 
CSW_TMP:     return true;
            case 
CSW_P90:     return true;
            case 
CSW_MAC10:   return true;
            case 
CSW_UMP45:   return true;
            case 
CSW_AK47:    return true;
            case 
CSW_SG552:   return true;
            case 
CSW_GALI:    return true;
            case 
CSW_FAMAS:   return true;
            case 
CSW_M4A1:    return true;
            case 
CSW_AUG:     return true;
            case 
CSW_SCOUT:   return true;
            case 
CSW_AWP:     return true;
            case 
CSW_G3SG1:   return true;
            case 
CSW_SG550:   return true;
            case 
CSW_M249:    return true;
        }
    }
    return 
false;
}

public 
bool:check_sniperid ) {

    new 
iWeapons[32];
    new 
iTotalWeapons 0;
    
get_user_weaponsidiWeaponsiTotalWeapons );

    for ( new 
0iTotalWeaponsi++ )
    {
        switch ( 
iWeapons[i] )
        {
            
#if ( INCLUDE_SCOUT )
            
case CSW_SCOUT:   return true;
            
#else
            
case CSW_SCOUT:   return false;
            
#endif

            
case CSW_AWP:     return true;
            case 
CSW_G3SG1:   return true;
            case 
CSW_SG550:   return true;
        }
    }
    return 
false;
}

public 
vexd_pfntouch(pToucherpTouched) {

    if ( !
get_cvar_num"mp_sniper_control" ) )
        return 
PLUGIN_CONTINUE;

    new 
iTouchId   pToucher;
    new 
iPlayerId  pTouched;

    if ( 
iPlayerId || iPlayerId 32 || !is_user_aliveiPlayerId ) )
        return 
PLUGIN_CONTINUE;

    new 
szClassName[32];
    
entity_get_stringiTouchIdEV_SZ_classnameszClassName31 );

    if ( 
equalszClassName"weaponbox" ) )        // a dropped or already 'fired' weapon
    
{
        new 
szGunModel[32];
        
entity_get_stringiTouchIdEV_SZ_modelszGunModel31 );

        new 
bool:bHasPrimaryWeapon check_primaryiPlayerId );

        for ( new 
04i++ )
        {
            if ( 
get_entity_flagsiTouchId ) & FL_ONGROUND && !bHasPrimaryWeapon && equalszGunModelSNIPERMODELS[i] ) )
            {
                
set_entity_flagsiTouchIdFL_ONGROUND);

                new 
iTeam get_user_teamiPlayerId );

                if ( 
iTeam == )   // TERRORIST
                
{
                    if ( 
g_iSniperNum[iTeam] < get_cvar_num"sc_max_snipers_t" ) )
                    {
                        
set_entity_flagsiTouchIdFL_ONGROUND);
                    }
                    else
                    {
                        
client_printiPlayerIdprint_center g_szWarn );
                    }
                }
                else
                if ( 
iTeam == )   // COUNTER-TERRORIST
                
{
                    if ( 
g_iSniperNum[iTeam] < get_cvar_num"sc_max_snipers_ct" ) )
                    {
                        
set_entity_flagsiTouchIdFL_ONGROUND);
                    }
                    else
                    {
                        
client_printiPlayerIdprint_center g_szWarn );
                    }
                }
                break;
            }
        }
    }
    return 
PLUGIN_CONTINUE;
}

public 
cmdDropid ) {

    if ( !
get_cvar_num"mp_sniper_control" ) )
        return 
PLUGIN_CONTINUE;

    new 
iTeam get_user_teamid );

    new 
iAmmoiClip;
    new 
iWeap get_user_weaponidiAmmoiClip );

    if ( 
check_sniperid ) && ( iWeap == CSW_AWP || iWeap == CSW_G3SG1 || iWeap == CSW_SG550 ) )
    {
        
g_bHasSniper[id] = false;
        --
g_iSniperNum[iTeam];

    }
    
#if ( INCLUDE_SCOUT )

    
else
    if( 
check_sniperid ) && iWeap == CSW_SCOUT  )
    {
        
g_bHasSniper[id] = false;
        --
g_iSniperNum[iTeam];
    }

    
#endif

    
return PLUGIN_CONTINUE;
}

public 
evPickUpid ) {

    if ( !
get_cvar_num"mp_sniper_control" ) )
        return 
PLUGIN_CONTINUE;

    new 
iTeam get_user_teamid );

    if( 
check_sniperid ) && !g_bHasSniper[id] )
    {
        
g_bHasSniper[id] = true;
        ++
g_iSniperNum[iTeam];
    }

    if ( 
g_bHasSniper[id] && !check_sniperid ) )
    {
        
// Has a primary weapon and HAD sniper, but bought new non-sniper rifle weapon ( no drop event )

        
g_bHasSniper[id] = false;
        --
g_iSniperNum[iTeam];
    }

    return 
PLUGIN_CONTINUE;
}

public 
evRestartRound() {

    if ( !
get_cvar_num"mp_sniper_control" ) )
        return 
PLUGIN_CONTINUE;

    
g_iSniperNum[0] = g_iSniperNum[1] = g_iSniperNum[2]    = 0;

    for(new 
133; ++a)
        
g_bHasSniper[a] = false;

    return 
PLUGIN_CONTINUE;
}

public 
sc_remove_dataid ) {

    new 
iTeam get_user_teamid );

    if ( 
g_bHasSniper[id] )
    {
        
g_bHasSniper[id] = false;
        --
g_iSniperNum[iTeam];
    }

    return 
PLUGIN_CONTINUE;
}

public 
client_disconnectid ) {

    if ( !
get_cvar_num"mp_sniper_control" ) )
        return 
PLUGIN_CONTINUE;

    
sc_remove_dataid );

    return 
PLUGIN_CONTINUE;
}

public 
evDeath() {

    new 
id read_data(2);
    
sc_remove_dataid );

    return 
PLUGIN_CONTINUE;
}

public 
plugin_init() {

    
register_pluging_szTitleg_szVersiong_szAuthor );

    
// set defaults ( for non 'sniper_control.cfg' users )

    
register_cvar"mp_sniper_control""1" );
    
register_cvar"sc_max_snipers_t",  "2" );
    
register_cvar"sc_max_snipers_ct""2" );

    
// Standard Menus

    
register_menucmdregister_menuid("BuyRifle" ), (1<<4), "menuSniper" );        //  T: AWP, CT: Sig SG-550 Sniper
    
register_menucmdregister_menuid("BuyRifle" ), (1<<5), "menuSniper" );        // CT: AWP,  T: H&K G3/SG-1 Sniper Rifle


    // Block Aliases and Vgui menus - because steam sucks and uses aliases to buy rifles ?!?!?

    
register_clcmd("awp",      "menuSniper");
    
register_clcmd("magnum",   "menuSniper");
    
register_clcmd("g3sg1",    "menuSniper");
    
register_clcmd("d3au1",    "menuSniper");
    
register_clcmd("sg550",    "menuSniper");
    
register_clcmd("krieg550""menuSniper");

    
register_menucmd( -31 ,(1<<4), "menuSniper" );                                     //  T: AWP, CT: Sig SG-550 Sniper        - VGUI
    
register_menucmd( -31 ,(1<<5), "menuSniper" );                                     // CT: AWP,  T: H&K G3/SG-1 Sniper Rifle - VGUI

    #if ( INCLUDE_SCOUT )

    
register_menucmdregister_menuid("BuyRifle" ), (1<<1), "menuSniper" );        // CT: Scout - Standard
    
register_menucmdregister_menuid("BuyRifle" ), (1<<2), "menuSniper" );        //  T: Scout - Standard

    
register_clcmd("scout",    "menuSniper");

    
register_menucmd( -31 ,(1<<1), "menuSniper" );                                     // CT: Scout - VGUI
    
register_menucmd( -31 ,(1<<2), "menuSniper" );                                     //  T: Scout - VGUI

    #endif

    
register_event"WeapPickup""evPickUp",       "b"                         );        // 3 = Scout, 13 = SG-550, 18 = AWP, G3/SG-1
    
register_clcmd"drop",       "cmdDrop"                                     );
    
register_event"DeathMsg",   "evDeath",        "a"                         );
    
register_event"TextMsg",    "evRestartRound""a""2&Game_C""2&Game_w" );

    if ( !
Map_Disabled() )
    {
        new 
szConfigFile[64];
        
get_configsdirszConfigFile63 );
        
formatszConfigFile63"%s/sniper_control.cfg"szConfigFile );
        
server_cmd"exec %s"szConfigFile );                                                // load configuration settings
    
}
    else
    {
        
set_cvar_num"mp_sniper_control");
    }

    return 
PLUGIN_CONTINUE;

Also one more thing about this, and restricting items is that if you have the awp on auto buy even though only 2 people can have an awp, with auto buy you can buy as many awps as you want, so the CTs can have 10 awps or 16 if everyone auto bought there awp.
__________________
You know what I'd like to be? I mean if I had my goddamn choice, I'd just be the catcher in the rye and all.
Kitami is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:18.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode