AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Implementing Immunity (https://forums.alliedmods.net/showthread.php?t=99021)

Kitami 07-31-2009 21:47

Implementing Immunity
 
I was hoping to have admin immunity added to this sniper control script, I've looked on the forums for others that I could use. I don't like bothering you people all the time for help with this stuff.

http://forums.alliedmods.net/showthread.php?p=8002

I just need it so that it doesn't count admins with a certain flag to the awp limit / they can pickup an awp whenever they want.

Thanks alot guys!

Kitami 08-01-2009 21:05

Re: Implementing Immunity
 
Also I've checked around there is another plugin that works the only problem is it does not have admin immunity.

http://forums.alliedmods.net/showthread.php?p=887972

Exolent[jNr] 08-01-2009 22:12

Re: Implementing Immunity
 
PHP Code:

/* AMX Mod X script. 

* Drop AWP with Team Limit and Win limit v1.5 (CS & CS:CZ) 
* By SuicideDog & MattOG
*
* Modded orignal from JustinHoMi 
*
*Up-To Version 0.5: SuicideDog & JustinHoMi
*******************************************
*
*
* VERSION: 1.0: MattOG
**********************
*
* Combined all 3 plugins (g3sg1/sg550/awp limit) into one.
* Added seperate commands to control Auto's and Awps. (different limits/rounds)
* Fixed bug with old-style menu's still being able to buy guns. (Credit to bAnTAi, I used his Y.A.S.C. plugin to help with the code).
*
* I didn't make it stop bots:
* 1. All bots come with built in weapon restrictions.
* 2. Bots tend not to be AWP whores  ;)
*
*
* VERSION 1.1: MattOG
*********************
* Changed Maxawps/autos and winspreads to cvars to enable on-the-fly changing, and to allow changes to be set in server/amxx/map configs.
*
*
* VERSION: 1.2: MattOG
**********************
*
* Minor bug fix where old style menu's couldn't buy at all. (Thanks to Olie for pointing it out).
*
*
* VERSION: 1.3: SuicideDog/DaSoul
**********************
*
* Added DaSoul's code to allow it to work with PTB correctly
*
* VERSION: 1.4: KWo
**********************
*
* Little bug fixes causing Run Time Errors etc...
* Blocking pickup limited weapon
* Bots are affected by this plugin, too but it doesn't prevent them from buying (they drop limited weapons after buying)
* Optimized usage of cvars by using pcvar functions.
*
**********************
*
* VERSION: 1.5: KWo
*
* Added support for team balancing (if someone has an awp or auto sniper and get switched alive to the opposite team)
*
**********************
*
* VERSION: 1.52: KWo
*
* Added min_players setting (cvar) to allow awps/autos if at least min_players amount in each team is reached
*
**********************
* CVARS:
***********
*
* max_awps <xx> - Maximum Awps Allowed
* max_autos <xx> - Maximum Autos Allowed
* winspread_awp <xx> - When This Many Rounds Ahead, No Awps Allowed
* winspread_auto <xx> - When This Many Rounds Ahead, No Autos Allowed
* min_players <xx> - Below this amount of players in team, awp/auto are completly restricted (no matter of max_awps and max_autos)
* autolimit <1/0> - 1 = Restrict Auto, 0 = Don't
* awplimit <1/0> - 1 = Restrict Awp, 0 = Don't
* checkrebuy <1/0> - 1 = Prevent Rebuy Command, 0 = Don't
*
* TIPS:
*     To ALWAYS restrict to X number of awps/autos set winspread_awp/auto to 0 and max_awps/autos to however many awps/autos
*       To ONLY restrict after X number of rounds ahead, set max_awps/autos to 20 and winspread_awp/autos to however many rounds
*
* KNOWN BUG/ISSUES:
************
* Updating the CVARS in game will only take effect after the following round has finished.
* Bots can buy limitted weapon, but they drop it immediatelly after buying. They cannot pickup dropped limited weapons 
* (like human players), so it's not a big issue.
*
* TO DO:
********
* Dunno, you tell me  ;)  Possibly will look at that following round thing, though it isn't too much hassle so I may not bother. You Decide.
*
*/

#include <amxmodx> 
#include <fakemeta>

new plist[33] = { 0, ... }   // 0 = no awp; 1 = carrying awp 
new plist2[33] = {0, ... }   // 0 = no auto; 1 = carrying auto
new awp_count[3]         // 1 = T; 2 = CT 
new auto_count[3]        // 1 = T; 2 = CT
new ctscore 
new tscore 
new pl_team[33

/* PCvars */
new pv_awplimit
new pv_max_awps
new pv_winspread_awp
new pv_autolimit
new pv_max_autos
new pv_winspread_auto
new pv_checkrebuy
new pv_minplayers

/* handles restricting the menu */
public menu_awp(id,key)
{
    if (
get_pcvar_num(pv_awplimit) != || ( get_user_flagsid ) & ADMIN_IMMUNITY ) ) return PLUGIN_CONTINUE
    
    
new team get_user_team(id)
    new 
winspread_awp get_pcvar_num(pv_winspread_awp)
    new 
min_players get_pcvar_num(pv_minplayers)
    new 
team1_numteam2_num
    
new players[32]

    
get_players(players,team1_num,"e","TERRORIST")
    
get_players(players,team2_num,"e","CT")

    if ((
team1_num min_players) || (team2_num min_players))
    {
        
engclient_cmd(id,"menuselect","10")
        
client_print(id,print_center,"Not enough people in one team to allow AWP's.")
        return 
PLUGIN_HANDLED
    
}

    if (((
team == && ctscore-tscore >= winspread_awp) || (team == && tscore-ctscore >= winspread_awp))
        && 
winspread_awp)
    {
        
engclient_cmd(id,"menuselect","10")
        
client_print(id,print_center,"You are on the winning team and cannot use AWP's")
        return 
PLUGIN_HANDLED
    
}

    if (
awp_count[team] >= get_pcvar_num(pv_max_awps))
    {
        
engclient_cmd(id,"menuselect","10")
        
client_print(id,print_center,"Too many people on your team have AWP's")
        return 
PLUGIN_HANDLED
    
}

    return 
PLUGIN_CONTINUE
}

/* handles restricting the menu */
public menu_auto(id,key)
{
    if (
get_pcvar_num(pv_autolimit) != || ( get_user_flagsid ) & ADMIN_IMMUNITY ) ) return PLUGIN_CONTINUE

    
new team get_user_team(id)
    new 
winspread_auto get_pcvar_num(pv_winspread_auto)
    new 
min_players get_pcvar_num(pv_minplayers)
    new 
team1_numteam2_num
    
new players[32]

    
get_players(players,team1_num,"e","TERRORIST")
    
get_players(players,team2_num,"e","CT")

    if ((
team1_num min_players) || (team2_num min_players))
    {
        
engclient_cmd(id,"menuselect","10")
        
client_print(id,print_center,"Not enough people in one team to allow AUTO's.")
        return 
PLUGIN_HANDLED
    
}

    if (((
team == && ctscore-tscore >= winspread_auto) || (team == && tscore-ctscore >= winspread_auto))
        && 
winspread_auto)
    {
        
engclient_cmd(id,"menuselect","10")
        
client_print(id,print_center,"You are on the winning team and cannot use AUTO's")
        return 
PLUGIN_HANDLED
    
}

    if (
auto_count[team] >= get_pcvar_num(pv_max_autos))
    {
        
engclient_cmd(id,"menuselect","10")
        
client_print(id,print_center,"Too many people on your team have AUTO's")
        return 
PLUGIN_HANDLED
    
}

    return 
PLUGIN_CONTINUE
}

/* handles if they script the AWP buy*/
public cmdawp(id)
{
    if (
get_pcvar_num(pv_awplimit) != || ( get_user_flagsid ) & ADMIN_IMMUNITY ) ) return PLUGIN_CONTINUE

    
new team get_user_team(id)

    if ((
team 1) || (team 2)) return PLUGIN_CONTINUE

    
new winspread_awp get_pcvar_num(pv_winspread_awp)
    new 
name[32]
    
get_user_name(id,name,31)
    new 
min_players get_pcvar_num(pv_minplayers)
    new 
team1_numteam2_num
    
new players[32]

    
get_players(players,team1_num,"e","TERRORIST")
    
get_players(players,team2_num,"e","CT")

    if ((
team1_num min_players) || (team2_num min_players))
    {
        
engclient_cmd(id,"menuselect","10")
        
client_print(id,print_center,"Not enough people in one team to allow AWP's.")
        return 
PLUGIN_HANDLED
    
}

    if (((
team == && ctscore-tscore >= winspread_awp) || (team == && tscore-ctscore >= winspread_awp))
        && 
winspread_awp)
    {
        
client_print(id,print_center,"You are on the winning team and cannot use AWP's")
        return 
PLUGIN_HANDLED
   
}

    if (
awp_count[team] >= get_pcvar_num(pv_max_awps))
    {
        
client_print(id,print_center,"Too many people on your team have AWP's")
//        client_print(id,print_chat,"You are about to buy an awp. There was currently %d awps in Your team %d - too many to buy.", awp_count[team], team)
//        log_message("The player %s was about to buy an awp. There was %d awps in his team %d - too many to buy.", name, awp_count[team], team)
        
return PLUGIN_HANDLED
    
}
//    client_print(id,print_chat,"You are about to buy an awp. There was currently %d awps in Your team before You bought it.", awp_count[team])
//    log_message("The player %s is about to buy an awp. There was %d awps in his team %d before he bought it.", name, awp_count[team], team)
    
    
return PLUGIN_CONTINUE
}

/* handles if they script the AUTO buy*/ 
public cmdauto(id

    if (
get_pcvar_num(pv_autolimit) != || ( get_user_flagsid ) & ADMIN_IMMUNITY ) ) return PLUGIN_CONTINUE

    
new team get_user_team(id
    new 
winspread_auto get_pcvar_num(pv_winspread_auto)
    new 
min_players get_pcvar_num(pv_minplayers)
    new 
team1_numteam2_num
    
new players[32]

    
get_players(players,team1_num,"e","TERRORIST")
    
get_players(players,team2_num,"e","CT")

    if ((
team1_num min_players) || (team2_num min_players))
    {
        
engclient_cmd(id,"menuselect","10")
        
client_print(id,print_center,"Not enough people in one team to allow AUTO's.")
        return 
PLUGIN_HANDLED
    
}

    if (((
team == && ctscore-tscore >= winspread_auto) || (team == && tscore-ctscore >= winspread_auto))
        && 
winspread_auto)
    {
        
client_print(id,print_center,"You are on the winning team and cannot use AUTO's")
        return 
PLUGIN_HANDLED
    
}

    if (
auto_count[team] >= get_pcvar_num(pv_max_autos))
    {
        
client_print(id,print_center,"Too many people on your team have AUTO's")
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

/* handles when a player drops his weapon */ 
public handle_drop_weapon(id)
{
    new 
tmp1,tmp2 
    
new curweapon get_user_weapon(id,tmp1,tmp2)
    new 
team get_user_team(id)
    
/* handles when a player drops their awp */    
    
if (curweapon == CSW_AWP)
    {
        if (
get_pcvar_num(pv_awplimit) != 1)
            return 
PLUGIN_CONTINUE

        
if ((plist[id]==1) && (awp_count[team] > 0))
            
awp_count[team]--
        
plist[id] = 0            
        
return PLUGIN_CONTINUE
   
}
/* handles when a player drops his auto */ 
    
else if ((curweapon == CSW_SG550) || (curweapon == CSW_G3SG1))
    {
        if (
get_pcvar_num(pv_autolimit) != 1)
            return 
PLUGIN_CONTINUE

        
if ((plist2[id]==1) && (auto_count[team] > 0))
            
auto_count[team]--
        
plist2[id] = 0
        
return PLUGIN_CONTINUE
   
}
    return 
PLUGIN_CONTINUE



/* handles when a player picks up an awp */ 
public handle_pickup_awp(id)

    if (
get_pcvar_num(pv_awplimit) != 1) return PLUGIN_CONTINUE
    
    
if( get_user_flagsid ) & ADMIN_IMMUNITY )
    {
        
plistid ] = 1;
        
awp_countget_user_teamid ) ]++;
        return 
PLUGIN_CONTINUE;
    }

    new 
team get_user_team(id)
    new 
winspread_awp get_pcvar_num(pv_winspread_awp)
    new 
name[32]
    
get_user_name(id,name,31)
    new 
min_players get_pcvar_num(pv_minplayers)
    new 
team1_numteam2_num
    
new players[32]

    
get_players(players,team1_num,"e","TERRORIST")
    
get_players(players,team2_num,"e","CT")

    if ((
team1_num min_players) || (team2_num min_players))
    {
        
set_task(0.5"drop_awp"id)
        
client_print(id,print_center,"Not enough people in one team to allow AWP's.")
        return 
PLUGIN_CONTINUE
    
}

    if (((
team == && ctscore-tscore >= winspread_awp) || (team == && tscore-ctscore >= winspread_awp))
        && 
winspread_awp)
    {
        
client_print(id,print_center,"You are on the winning team and cannot use AWP's")
        
set_task(0.5"drop_awp"id)
        return 
PLUGIN_CONTINUE
   


    if (
awp_count[team] >= get_pcvar_num(pv_max_awps)) 
   { 
        
client_print(id,print_center,"Too many people on your team have AWP's")
//        log_message("The player %s bought or picked-up an awp. There is %d awps in his %d team. He should drop it.", name, awp_count[team], team)
        
set_task(0.5"drop_awp"id)
//        engclient_cmd(id, "drop", "weapon_awp")
//        client_cmd(id,"weapon_awp;wait;wait;wait;drop")
        
return PLUGIN_CONTINUE
    

    else
    {
        
plist[id] = 1
        awp_count
[team]++
//        client_print(id,print_chat,"You have bought or picked-up an awp. There is %d awps in Your team.", awp_count[team])
//        log_message("The player %s bought or picked-up an awp. There is %d awps in his team %d.", name, awp_count[team], team)
    
}
    return 
PLUGIN_CONTINUE 
}

public 
drop_awp(id)
{
    new 
team

    
if (!is_user_connected(id)) return

    
engclient_cmd(id"drop""weapon_awp")

    if (
is_user_bot(id)) // we cannot hook when the bot drops his weapon
    
{
        
team get_user_team(id)
        
plist[id] = 0
        
if (awp_count[team] > 0)
            
awp_count[team]--
    }
}

/* handles when a player picks up a g3sg1 */ 
public handle_pickup_g3sg1(id)
{
    if (
get_pcvar_num(pv_autolimit) != 1) return PLUGIN_CONTINUE
    
    
if( get_user_flagsid ) & ADMIN_IMMUNITY )
    {
        
plist2id ] = 1;
        
auto_countget_user_teamid ) ]++;
        return 
PLUGIN_CONTINUE;
    }

    new 
team get_user_team(id)
    new 
winspread_auto get_pcvar_num(pv_winspread_auto)
    new 
min_players get_pcvar_num(pv_minplayers)
    new 
team1_numteam2_num
    
new players[32]

    
get_players(players,team1_num,"e","TERRORIST")
    
get_players(players,team2_num,"e","CT")

    if ((
team1_num min_players) || (team2_num min_players))
    {
        
client_print(id,print_center,"Not enough people in one team to allow AUTO's.")
        
set_task(0.5"drop_g3sg1"id)
        return 
PLUGIN_CONTINUE
    
}

    if (((
team == && ctscore-tscore >= winspread_auto) || (team == && tscore-ctscore >= winspread_auto))
        && 
winspread_auto)
    {  
        
client_print(id,print_center,"You are on the winning team and cannot use AUTO's")
        
set_task(0.5"drop_g3sg1"id)
        return 
PLUGIN_CONTINUE
    
}

    if (
auto_count[team] >= get_pcvar_num(pv_max_autos))
    {
        
client_print(id,print_center,"Too many people on your team have AUTO's")
        
set_task(0.5"drop_g3sg1"id)
        return 
PLUGIN_CONTINUE
    
}
    else
    {
        
plist2[id] = 1
        auto_count
[team]++
    }
    return 
PLUGIN_CONTINUE 
}

public 
drop_g3sg1(id)
{
    new 
team

    
if (!is_user_connected(id)) return

    
engclient_cmd(id"drop""weapon_g3sg1")

    if (
is_user_bot(id)) // we cannot hook when the bot drops his weapon
    
{
        
team get_user_team(id)
        
plist2[id] = 0
        
if (auto_count[team] > 0)
            
auto_count[team]--
    }
}

/* handles when a player picks up a sg550 */ 
public handle_pickup_sg550(id)
{
    if (
get_pcvar_num(pv_autolimit) != 1) return PLUGIN_CONTINUE
    
    
if( get_user_flagsid ) & ADMIN_IMMUNITY )
    {
        
plist2id ] = 1;
        
auto_countget_user_teamid ) ]++;
        return 
PLUGIN_CONTINUE;
    }

    new 
team get_user_team(id)
    new 
winspread_auto get_pcvar_num(pv_winspread_auto)
    new 
min_players get_pcvar_num(pv_minplayers)
    new 
team1_numteam2_num
    
new players[32]

    
get_players(players,team1_num,"e","TERRORIST")
    
get_players(players,team2_num,"e","CT")

    if ((
team1_num min_players) || (team2_num min_players))
    {
        
client_print(id,print_center,"Not enough people in one team to allow AUTO's.")
        
set_task(0.5"drop_sg550"id)
        return 
PLUGIN_CONTINUE
    
}

    if (((
team == && ctscore-tscore >= winspread_auto) || (team == && tscore-ctscore >= winspread_auto))
        && 
winspread_auto)
    {  
        
client_print(id,print_center,"You are on the winning team and cannot use AUTO's")
        
set_task(0.5"drop_sg550"id)
        return 
PLUGIN_CONTINUE
    
}

    if (
auto_count[team] >= get_pcvar_num(pv_max_autos))
    {
        
client_print(id,print_center,"Too many people on your team have AUTO's")
        
set_task(0.5"drop_sg550"id)
        return 
PLUGIN_CONTINUE
    
}
    else
    {
        
plist2[id] = 1
        auto_count
[team]++
    }
    return 
PLUGIN_CONTINUE 
}

public 
drop_sg550(id)
{
    new 
team

    
if (!is_user_connected(id)) return

    
engclient_cmd(id"drop""weapon_sg550")

    if (
is_user_bot(id)) // we cannot hook when the bot drops his weapon
    
{
        
team get_user_team(id)
        
plist2[id] = 0
        
if (auto_count[team] > 0)
            
auto_count[team]--
    }
}

/* removes awp and auto when player dies */ 
public handle_death() 
{
    if ((
get_pcvar_num(pv_awplimit) != 1) && (get_pcvar_num(pv_autolimit) != 1))
        return 
PLUGIN_CONTINUE 
  
    
new idx read_data(2)
    
    if (
plist[idx] == 1)
    {
        new 
team get_user_team(idx)
        if (
awp_count[team] > 0)
            
awp_count[team]--
        
plist[idx] = 0
    
}
    if (
plist2[idx] == 1)
    {
        new 
team get_user_team(idx)
        if (
auto_count[team] > 0)
            
auto_count[team]--
        
plist2[idx] = 0
    
}
    return 
PLUGIN_CONTINUE
}

/* clear vars when player connects */ 
public client_connect(id)
{
    
plist[id] = 0
    plist2
[id] = 0
    
return PLUGIN_CONTINUE
}

/* clear vars when player disconnects */ 
public client_disconnect(id)
{
    if (
plist[id] == 1)
    {
        new 
team get_user_team(id)
        if (
awp_count[team] > 0)
            
awp_count[team]--
    } 
    if (
plist2[id] == 1)
    {
        new 
team get_user_team(id)
        if (
auto_count[team] > 0)
            
auto_count[team]--
    }
    
plist[id] = 0
    plist2
[id] = 0

    
return PLUGIN_CONTINUE
}

public 
team_score()

    if ((
get_pcvar_num(pv_awplimit) != 1) && (get_pcvar_num(pv_autolimit) != 1))
        return 
PLUGIN_CONTINUE

    
new team[32]
    
read_data(1,team,32)

    if (
equal(team,"CT"))
    { 
        
ctscore read_data(2)
    }
    else if (
equal(team,"TERRORIST"))
    {
        
tscore read_data(2)
    }
    return 
PLUGIN_CONTINUE


public 
check_winning_team(id

    if ((
get_pcvar_num(pv_awplimit) != 1) && (get_pcvar_num(pv_autolimit) != 1)) return PLUGIN_CONTINUE
    
if (!id || id get_maxplayers()) return PLUGIN_CONTINUE
    
if( get_user_flagsid ) & ADMIN_IMMUNITY ) return PLUGIN_CONTINUE;
    
    new 
team get_user_team(id
    if (
plist[id] == 1
    {
        new 
winspread_awp get_pcvar_num(pv_winspread_awp)
        if (((
team == && ctscore-tscore >= winspread_awp) || (team == && tscore-ctscore >= winspread_awp))
            && 
winspread_awp)
        {
            
client_print(id,print_center,"You are on the winning team and cannot use AWP's")
            
engclient_cmd(id"drop""weapon_awp")
            return 
PLUGIN_CONTINUE
        
}
        return 
PLUGIN_CONTINUE
    
}
    if (
plist2[id] == 1
    {
        new 
winspread_auto get_pcvar_num(pv_winspread_auto)
        if (((
team == && ctscore-tscore >= winspread_auto) || (team == && tscore-ctscore >= winspread_auto))
            && 
winspread_auto)
        {
            
client_print(id,print_center,"You are on the winning team and cannot use AUTO's")
            new 
iwpniwpns[32], nwpn[32]
            
get_user_weapons(idiwpnsiwpn)
            for (new 
0iwpn; ++a)
            {
                
get_weaponname(iwpns[a], nwpn31)
                if (
equali(nwpn,"weapon_g3sg1") || equali(nwpn,"weapon_sg550"))
                    
engclient_cmd(id"drop"nwpn)
            }
            return 
PLUGIN_CONTINUE
        
}
        return 
PLUGIN_CONTINUE
    
}
    return 
PLUGIN_CONTINUE
}


/*
* 1 = T's: AWP Key 4, AUTOSNIPER Key 5
* 2 = CT's: AWP Key 5, AUTOSNIPER Key 4
*/
public via_me(id,key)
{
    new 
team get_user_team(id)

    if ((
team==&& key==5) || (team==&& key==4))
        
menu_auto(idkey)
    if ((
team==&& key==4) || (team==&& key==5))
        
menu_awp(idkey)

    return 
PLUGIN_CONTINUE
}

public 
check_rebuy(id)
{
    if (
get_pcvar_num(pv_checkrebuy) != 1) return PLUGIN_CONTINUE
    client_print
(id,print_center,"Sorry Rebuy command is blocked on this server")

    return 
PLUGIN_HANDLED
}

public 
total_snipers()
{
    new 
players[32], numPlayerCountidxPlayer
    
    
// 1 = T; 2 = CT 
    
awp_count[1] = 0
    auto_count
[1] = 0

    get_players
(playersnumPlayerCount,"he","TERRORIST")
    for(
idxPlayer 0idxPlayer numPlayerCountidxPlayer++)
    {
        new 
Weapons[32]
        new 
numWeaponsi
        get_user_weapons
(players[idxPlayer], WeaponsnumWeapons)
        
plist[players[idxPlayer]] = 0
        plist2
[players[idxPlayer]] = 0
        
for (i=0i<numWeaponsi++)
        {
            if (
Weapons[i] == CSW_AWP)
            {
                
plist[players[idxPlayer]] = 1
                awp_count
[1]++
            }
            if ((
Weapons[i] == CSW_G3SG1) || (Weapons[i] == CSW_SG550))
            {
                
plist2[players[idxPlayer]] = 1
                auto_count
[1]++
            }
        } 
    } 

    
awp_count[2] = 0
    auto_count
[2] = 0
    
    get_players
(playersnumPlayerCount,"he","CT")
    for(
idxPlayer 0idxPlayer numPlayerCountidxPlayer++)
    {
        new 
Weapons[32]
        new 
numWeaponsi
        get_user_weapons
(players[idxPlayer], WeaponsnumWeapons)
        
plist[players[idxPlayer]] = 0
        plist2
[players[idxPlayer]] = 0        
        
for (i=0i<numWeaponsi++)
        {
            if (
Weapons[i] == CSW_AWP)
            {
                
plist[players[idxPlayer]] = 1
                awp_count
[2]++
            }
            if ((
Weapons[i] == CSW_G3SG1) || (Weapons[i] == CSW_SG550))
            {
                
plist2[players[idxPlayer]] = 1
                auto_count
[2]++
            }
        } 
    } 
}

public 
round_start()
{
    
total_snipers()
    return 
PLUGIN_CONTINUE  
}

public 
hook_touch(ptrptd)
{
    static 
ptrClass[32]
    static 
ptdClass[32]
    static 
ptrModel[128]
    static 
team
    
static min_players
    
static team1_numteam2_num
    
static players[32]
    static 
winspread_auto

    
if ((get_pcvar_num(pv_awplimit) != 1) && (get_pcvar_num(pv_autolimit) != 1))
        return 
PLUGIN_CONTINUE

    
if (ptd get_maxplayers() || ptd || ptr )
        return 
PLUGIN_CONTINUE
        
    
if ( (!pev_valid(ptr)) || (!pev_valid(ptd)) )
        return 
PLUGIN_CONTINUE

    
if (!is_user_connected(ptd))
        return 
PLUGIN_CONTINUE

    pev
(ptrpev_classnameptrClass31)
    
pev(ptrpev_modelptrModel127)
    
pev(ptdpev_classnameptdClass31)
    
    if (!
equal(ptrClass"weaponbox"))
        return 
PLUGIN_CONTINUE
    
    
if (equal(ptdClass"player"))
    {
        if( 
get_user_flagsptd ) & ADMIN_IMMUNITY )
        {
            return 
FMRES_IGNORED;
        }
        
        
team get_user_team(ptd)
        
min_players get_pcvar_num(pv_minplayers)
        
get_players(players,team1_num,"e","TERRORIST")
        
get_players(players,team2_num,"e","CT")
        
        if (
equal(ptrModel"models/w_awp.mdl"))
        {
            if ((
team1_num min_players) || (team2_num min_players))
            {
                
client_print(ptd,print_center,"Not enough people in one team to allow AWP's.")
                return 
FMRES_SUPERCEDE
            
}

            if (
awp_count[team] >= get_pcvar_num(pv_max_awps))
            {
                
client_print(ptd,print_center,"Too many people on your team have AWP's")
                return 
FMRES_SUPERCEDE
            
}

            new 
winspread_awp get_pcvar_num(pv_winspread_awp)
            if (((
team == && ctscore-tscore >= winspread_awp) || (team == && tscore-ctscore >= winspread_awp))
                && 
winspread_awp)
            {
                
client_print(ptd,print_center,"You are on the winning team and cannot use AWP's")
                return 
FMRES_SUPERCEDE
            
}

            return 
PLUGIN_CONTINUE
        
}
        if ((
equal(ptrModel"models/w_g3sg1.mdl")) || (equal(ptrModel"models/w_sg550.mdl")))
        {
            if ((
team1_num min_players) || (team2_num min_players))
            {
                
client_print(ptd,print_center,"Not enough people in one team to allow AUTO's.")
                return 
FMRES_SUPERCEDE
            
}

            if (
auto_count[team] >= get_pcvar_num(pv_max_autos))
            {
                
client_print(ptd,print_center,"Too many people on your team have AUTO's")
                return 
FMRES_SUPERCEDE
            
}

            
winspread_auto get_pcvar_num(pv_winspread_auto)
            if (((
team == && ctscore-tscore >= winspread_auto) || (team == && tscore-ctscore >= winspread_auto))
                && 
winspread_auto)
            {
                
client_print(ptd,print_center,"You are on the winning team and cannot use AUTO's")
                return 
FMRES_SUPERCEDE
            
}
            return 
PLUGIN_CONTINUE
        
}
    }    
    return 
PLUGIN_CONTINUE
}

public 
team_assign() 
{
    new 
arg[2], team
    
new id read_data(1)
    
read_data(2,arg,1)
    if ( 
arg[0] == 'C'  )
        
team 2
    
else if ( arg[0] == 'T' )
        
team 1
    
else
        
team 0

    
if (!is_user_connected(id) || !is_user_alive(id) || (!plist[id] && !plist2[id]) 
        || (
pl_team[id] == team))
    {
        
pl_team[id] = team
        
return PLUGIN_CONTINUE
    
}
    
pl_team[id] = team
    total_snipers
()
    new 
name[32]
    
get_user_name(id,name,31)
/*
    if (plist[id]) 
   { 
        client_print(id,print_center,"You had an awp and got transferred alive to the new team.")
        log_message("The player %s with an awp changed the team alive. There is now %d awps for team 1 and %d for team 2.", 
            name, awp_count[1], awp_count[2])
    }
*/
    
return PLUGIN_CONTINUE
}


public 
plugin_init()
{
    
register_plugin("AWP/AUTO Limit (Team/Win)","1.52","SuicideDog/MattOG/DaSoul")
    
register_menucmd(-31,(1<<4),"via_me" )                                    //  T: AWP, CT: Sig SG-550 Sniper       - VGUI
    
register_menucmd(-31,(1<<5),"via_me" )                                    // CT: AWP, T:  H&K G3SG-1 Sniper Rifle - VGUI
    
register_menucmd(register_menuid("BuyRifle",1),(1<<4),"via_me" )          //  T: AWP, CT: Sig SG-550 Sniper       - STANDARD
    
register_menucmd(register_menuid("BuyRifle",1),(1<<5),"via_me" )          // CT: AWP, T:  H&K G3SG-1 Sniper Rifle - STANDARD
    
register_clcmd("drop","handle_drop_weapon")

    
register_clcmd("awp","cmdawp"
    
register_clcmd("magnum","cmdawp")
    
register_clcmd("g3sg1","cmdauto")
    
register_clcmd("d3au1","cmdauto")
    
register_clcmd("sg550","cmdauto")
    
register_clcmd("krieg550","cmdauto")
    
register_clcmd("rebuy","check_rebuy")

    
pv_awplimit register_cvar("awplimit","1")
    
pv_autolimit register_cvar("autolimit","1")
    
pv_checkrebuy register_cvar("checkrebuy","1")
    
pv_max_awps register_cvar("max_awps","2")
    
pv_max_autos register_cvar("max_autos","1")
    
pv_minplayers register_cvar("min_players","5")
    
pv_winspread_awp register_cvar("winspread_awp","3")
    
pv_winspread_auto register_cvar("winspread_auto","2")

    
register_event("TeamScore""team_score""a")
    
register_event("TeamInfo","team_assign","a")
    
register_event("WeapPickup","handle_pickup_awp","b","1=18"
    
register_event("WeapPickup","handle_pickup_sg550","b","1=13"
    
register_event("WeapPickup","handle_pickup_g3sg1","b","1=24"
    
register_event("DeathMsg","handle_death","a"

    
register_event("ResetHUD","check_winning_team","b"

    
register_logevent("round_start"2"1=Round_Start")
    
register_forward(FM_Touch"hook_touch")


From this plugin:
http://forums.alliedmods.net/showthread.php?t=51732

Kitami 08-04-2009 17:50

Re: Implementing Immunity
 
THANKS SO MUCH!!

So now do I just change ADMIN_IMMUNITY to ADMIN_VOTE as I wanted it to be ADMIN VOTE flag only that has immunity if that's not possible that's fine.

Exolent[jNr] 08-04-2009 18:57

Re: Implementing Immunity
 
Yes, that's all you do.


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

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