Raised This Month: $51 Target: $400
 12% 

Plugin to block awp and auto in 2x2 maps


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FreezerPT
Senior Member
Join Date: Mar 2017
Location: 127.0.0.1
Old 10-13-2017 , 11:22   Plugin to block awp and auto in 2x2 maps
Reply With Quote #1

Hello i want a plugin to block awp and auto in 2x2 maps
__________________
FreezerPT is offline
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 10-13-2017 , 13:33   Re: Plugin to block awp and auto in 2x2 maps
Reply With Quote #2

search
__________________
retired chump
DjSoftero is offline
tarsisd2
Veteran Member
Join Date: Feb 2016
Location: brazil
Old 10-16-2017 , 14:22   Re: Plugin to block awp and auto in 2x2 maps
Reply With Quote #3

there you go

cvars

PHP Code:
awp_players_low "8"        //Block only when there are less people defined by cvar. to disable it, set it to 0. [Default: 8]
awp_limit "1"                //Enable | Turn off the limit of awp [Default: Enabled]
awp_limit_max "2"            //How many AWPs are permitted at the limit [Default: 2 per team] | If PERCENT_PLAYERS is unconmented, then enter here the necessary percentage
awp_limit_immun "1"        //Enable | Disable immunity from the limit (People with the flag does not take into account at all) [Default: Enabled] 
plugin

PHP Code:
#include < amxmodx >
#include < hamsandwich >
#include < fakemeta_util >

#if AMXX_VERSION_NUM < 183
    #include < colorchat >
    #define MAX_PLAYERS 32
#endif

//■■■■■■■■■■■■■■■■■■■■■■■ CONFIG START ■■■■■■■■■■■■■■■■■■■■■■■//
#define ALLPLAYERS


// ^4 - green | ^3 - team color (CТ - blue | Т - red | SPEC - gray) | ^1 - yellow
#define MSG_PREFIX             "^3[^4AWP^3]"
#define MSG_LOWONLINE         "Уou^4 cannot buy^3 AWP. Reason:^4 low online."
#define MSG_LIMIT             "Уou^4 cannot buy^3 AWP. Reason:^4 too much snipers."

#define FLAG                  ADMIN_BAN                //flag for immunity

#define RETURN_MONEY                                //Refund money when selecting awp at the end of the round due to low online? (Comment if you do not want to return money))
#if defined RETURN_MONEY
    #define MONEY_AWP        4750                    //How much to refund?
    
    
new g_MoneyMsgID;
#endif

//#define PERCENT_PLAYERS    
/*
Uncomment if you want the limit to depend on the percentage of players

For example: Online = 10, Percent (awp_limit_max) = 20
10/100 * 20 = 2 sniper on the team (2 at terror and 2 at ct)
*/
//■■■■■■■■■■■■■■■■■■■■■■■■ CONFIG END ■■■■■■■■■■■■■■■■■■■■■■■■//

const iMoney 115;
const 
iMenu 205;
const 
iTeam 114;
const 
idRifleMenu 6;
const 
idNoMenu 0;
const 
OFFSET_LINUX_WEAPONS 4;
const 
OFFSET_WEAPONID  43;

#define get_menuid(%0)            get_pdata_int(%0, iMenu)
#define fm_get_user_team(%0)     ETEAMS:get_pdata_int(%0, iTeam)
#define fm_get_weaponid(%0)        get_pdata_int(%0, OFFSET_WEAPONID, OFFSET_LINUX_WEAPONS)
#define fm_get_user_money(%0)    get_pdata_int(%0 , iMoney)
#define IsPlayer(%0)            (0 < %0 < 33)

enum ETEAMS {
    
TEAM_TERRORIST 1,
    
TEAM_CT,
    
    
TEAM_SPECTATOR
};

enum ECVARS {
    
CVAR_ONLINE 0,
    
CVAR_LIMIT_AWP_STATUS,
    
CVAR_LIMIT_MAX_AWP,
    
CVAR_LIMIT_IMMUN,
    
CVAR_BUYTIME
};

enum {
    
AWP_NONE 0,
    
AWP_BUY,
    
AWP_PICK_UP
};

new 
gBuy true;
new 
sAwp[ETEAMSTEAM_SPECTATOR], gCountgCvar[ECVARS], gAwp[MAX_PLAYERS 1], ETEAMSgTeam[MAX_PLAYERS 1];
#if defined PERCENT_PLAYERS
new gLimit;
#endif

public plugin_init(){
    
register_plugin("AWPoff""1.0""alliedmods");
    
    new 
mapname[32]; 
    
get_mapname(mapnamecharsmax(mapname));    
    
    new 
maps[][] = { "awp""aim""35hp""$" };
    for(new 
isizeof mapsi++){
        if(
containi(mapnamemaps[i]) != -1){
            
pause("ad");
            return;
        }
    }
    
    
register_logevent("EventRoundStart"2"1=Round_Start");
    
register_logevent("EventRoundEnd"2"1=Round_End");
    
register_logevent("EventRestartRound"2"1&Restart_Round_");
    
    
register_menucmd(register_menuid("BuyRifle"true), (1<<4|1<<5), "BuyRifle_Handle");
    
register_clcmd("menuselect""MenuSelect");
    
register_clcmd("awp""AwpBuy");
    
register_clcmd("magnum""AwpBuy");
    
    
RegisterHam(Ham_AddPlayerItem"player""AddItem");
    
RegisterHam(Ham_RemovePlayerItem"player""RemoveItem");
    
RegisterHam(Ham_Spawn"player""SpawnPlayer"true);
    
    
#if defined RETURN_MONEY
    
g_MoneyMsgID get_user_msgid("Money");
    
#endif
    
    
gCvar[CVAR_ONLINE] =             register_cvar("awp_players_low""8");        // Block only when there are less people defined by cvar. to disable it, set it to 0. default 8
    
gCvar[CVAR_LIMIT_AWP_STATUS] =     register_cvar("awp_limit""1");            //Enable | Turn off the limit of awp [Default: Enabled]
    
gCvar[CVAR_LIMIT_MAX_AWP] =        register_cvar("awp_limit_max""2");        //How many AWPs are permitted at the limit [Standard by 2 per team] | If PERCENT_PLAYERS is unconmented, then enter here the necessary percentage
    
gCvar[CVAR_LIMIT_IMMUN] =         register_cvar("awp_limit_immun""1");        //Enable | Disable immunity from the limit (People with the flag does not take into account at all) [Default: Enabled]
    
    
gCvar[CVAR_BUYTIME] =             get_cvar_pointer("mp_buytime");
}

public 
client_disconnect(id)    if(IsPlayer(id))    minus_awp(id);

public 
EventRestartRound(){
    
sAwp[TEAM_CT] = 0;
    
sAwp[TEAM_TERRORIST] = 0;
    
arrayset(gAwpAWP_NONEsizeof gAwp);
}

public 
EventRoundStart(){
    
gBuy true;
    
set_task(get_pcvar_float(gCvar[CVAR_BUYTIME]) * 60.0"off_buy"333);
}
    
public 
off_buy()
    
gBuy false;
    
public 
EventRoundEnd(){
    new 
players[32];
    
#if defined ALLPLAYERS
    
get_players(playersgCount);
    
#else
    
get_players(playersgCount"ch");
    
#endif
    
    #if defined PERCENT_PLAYERS
    
const MAX_PERCENT 100;
    
gLimit gCount get_pcvar_num(gCvar[CVAR_LIMIT_MAX_AWP]) / MAX_PERCENT;
    
#endif
    
    
if(gCount >= get_pcvar_num(gCvar[CVAR_ONLINE]))
        return 
PLUGIN_CONTINUE;
    
    for(new 
0idgCount++){
        
id players[i];
            
        
#if defined ALLPLAYERS
        
if(!is_user_valid(id))    
            continue;
        
#endif
        
        
if(gAwp[id] == AWP_NONE)
            continue;
        
        
fm_strip_user_gun(idCSW_AWP);
        
#if defined RETURN_MONEY
        
if(gAwp[id] == AWP_BUY){
            new 
gMoney fm_get_user_money(id) + MONEY_AWP;
            
fm_set_user_money(idgMoney);
        }
        
#endif
        
client_print_color(idfalse"%s %s"MSG_PREFIXMSG_LOWONLINE);
    }
    
EventRestartRound();
    return 
PLUGIN_CONTINUE;
}

public 
SpawnPlayer(id){
    if(!
is_user_alive(id))
        return 
HAM_IGNORED;
    
    
gTeam[id] = fm_get_user_team(id);
    return 
HAM_IGNORED;
}

public 
AddItem(idwId){
    if(
fm_get_weaponid(wId) != CSW_AWP)
        return 
HAM_IGNORED;
    
    if(!
check_awp(idAWP_PICK_UP))
        
set_task(0.1"delawp"id);    //Костыли one love
    
    
return HAM_IGNORED;
}

public 
delawp(id)
    
fm_strip_user_gun(idCSW_AWP);
    
public 
RemoveItem(idiEnt){
    if(
fm_get_weaponid(iEnt) == CSW_AWP)
        
minus_awp(id);
}

public 
BuyRifle_Handle(idkey){    
    if(
key != (gTeam[id] == TEAM_TERRORIST 5))
        return 
PLUGIN_CONTINUE;
        
    
set_task(0.1"mega_kostil"id);
    
    if(!
check_awp(idAWP_BUY))
        return 
PLUGIN_HANDLED;
    
    return 
PLUGIN_CONTINUE;
}

public 
MenuSelect(id){
    if(
get_menuid(id) != idRifleMenu)
        return 
PLUGIN_CONTINUE;
    
    new 
szSlot[3], Slot;
    
read_argv(trueszSlotcharsmax(szSlot));
    
Slot str_to_num(szSlot);
    
    if(
Slot != (gTeam[id] == TEAM_TERRORIST 6))
        return 
PLUGIN_CONTINUE;
    
    
set_task(0.1"mega_kostil"id);

    if(!
check_awp(idAWP_BUY))
        return 
PLUGIN_HANDLED;
        
    return 
PLUGIN_CONTINUE;
}

public 
mega_kostil(id)
    
set_pdata_int(idiMenuidNoMenu);

public 
AwpBuy(id){    
    if(!
check_awp(idAWP_BUY))
        return 
PLUGIN_HANDLED;
    
    return 
PLUGIN_CONTINUE;
}

//Native's
public plugin_natives()
    
register_native("awpoff_check""check_native"true);

public 
check_native(id)
    return 
check_awp(idAWP_NONE);
//Native's
    
check_awp(idtype){
    if(
gAwp[id] != AWP_NONE || !is_user_valid(id) || !is_user_alive(id))
        return 
true;
    
    if(!
gBuy && type == AWP_BUY)                            
        return 
false;
    
    new 
gMoney fm_get_user_money(id), AWP_COST 4750;    
    if(
gMoney AWP_COST && type == AWP_BUY)
        return 
false;
    
    
gAwp[id] = type;
    
    if(
gCount get_pcvar_num(gCvar[CVAR_ONLINE]))
        
client_print_color(idfalse"%s %s"MSG_PREFIXMSG_LOWONLINE);
    else if(
get_pcvar_num(gCvar[CVAR_LIMIT_AWP_STATUS])){
        
        if(
get_pcvar_num(gCvar[CVAR_LIMIT_IMMUN]) && get_user_flags(id) & FLAG)
            return 
true;
            
        
#if defined PERCENT_PLAYERS        
        
if(sAwp[gTeam[id]] < gLimit)
        
#else
        
if(sAwp[gTeam[id]] < get_pcvar_num(gCvar[CVAR_LIMIT_MAX_AWP]))
        
#endif
        
{
            if(
type != AWP_NONE)
                
sAwp[gTeam[id]] ++;
            return 
true;
        }else
            
client_print_color(idfalse"%s %s"MSG_PREFIXMSG_LIMIT);
    }else
        return 
true;
    
    
gAwp[id] = AWP_NONE;
    return 
false;
}

minus_awp(id){
    if(!
is_user_valid(id) || gAwp[id] == AWP_NONE)
        return;
        
    
gAwp[id] = AWP_NONE;
    
    if(!
get_pcvar_num(gCvar[CVAR_LIMIT_AWP_STATUS]))
        return;
    
    if(
get_pcvar_num(gCvar[CVAR_LIMIT_IMMUN]) && get_user_flags(id) & FLAG)
        return;
    
    
sAwp[gTeam[id]] --;    
}

#if defined RETURN_MONEY
fm_set_user_money(idmoney){
    
set_pdata_int(idiMoneymoney);
    
    
message_begin(MSG_ONE_UNRELIABLEg_MoneyMsgID_id);
    
write_long(money);
    
write_byte(true);
    
message_end();
}
#endif

is_user_valid(id){
    if(
is_user_bot(id))        return false;    
    if(
is_user_hltv(id))    return false;    
    return 
true;

You will need colorchat include to compile

Good Luck
tarsisd2 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 20:01.


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