Veteran Member
Join Date: Feb 2016
Location: brazil
|
10-16-2017
, 14:22
Re: Plugin to block awp and auto in 2x2 maps
|
#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[ETEAMS: TEAM_SPECTATOR], gCount, gCvar[ECVARS], gAwp[MAX_PLAYERS + 1], ETEAMS: gTeam[MAX_PLAYERS + 1];
#if defined PERCENT_PLAYERS
new gLimit;
#endif
public plugin_init(){
register_plugin("AWPoff", "1.0", "alliedmods");
new mapname[32];
get_mapname(mapname, charsmax(mapname));
new maps[][] = { "awp", "aim", "35hp", "$" };
for(new i; i < sizeof maps; i++){
if(containi(mapname, maps[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(gAwp, AWP_NONE, sizeof 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(players, gCount);
#else
get_players(players, gCount, "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 i = 0, id; i < gCount; i ++){
id = players[i];
#if defined ALLPLAYERS
if(!is_user_valid(id))
continue;
#endif
if(gAwp[id] == AWP_NONE)
continue;
fm_strip_user_gun(id, CSW_AWP);
#if defined RETURN_MONEY
if(gAwp[id] == AWP_BUY){
new gMoney = fm_get_user_money(id) + MONEY_AWP;
fm_set_user_money(id, gMoney);
}
#endif
client_print_color(id, false, "%s %s", MSG_PREFIX, MSG_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(id, wId){
if(fm_get_weaponid(wId) != CSW_AWP)
return HAM_IGNORED;
if(!check_awp(id, AWP_PICK_UP))
set_task(0.1, "delawp", id); //Костыли one love
return HAM_IGNORED;
}
public delawp(id)
fm_strip_user_gun(id, CSW_AWP);
public RemoveItem(id, iEnt){
if(fm_get_weaponid(iEnt) == CSW_AWP)
minus_awp(id);
}
public BuyRifle_Handle(id, key){
if(key != (gTeam[id] == TEAM_TERRORIST ? 4 : 5))
return PLUGIN_CONTINUE;
set_task(0.1, "mega_kostil", id);
if(!check_awp(id, AWP_BUY))
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
public MenuSelect(id){
if(get_menuid(id) != idRifleMenu)
return PLUGIN_CONTINUE;
new szSlot[3], Slot;
read_argv(true, szSlot, charsmax(szSlot));
Slot = str_to_num(szSlot);
if(Slot != (gTeam[id] == TEAM_TERRORIST ? 5 : 6))
return PLUGIN_CONTINUE;
set_task(0.1, "mega_kostil", id);
if(!check_awp(id, AWP_BUY))
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
public mega_kostil(id)
set_pdata_int(id, iMenu, idNoMenu);
public AwpBuy(id){
if(!check_awp(id, AWP_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(id, AWP_NONE);
//Native's
check_awp(id, type){
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(id, false, "%s %s", MSG_PREFIX, MSG_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(id, false, "%s %s", MSG_PREFIX, MSG_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(id, money){
set_pdata_int(id, iMoney, money);
message_begin(MSG_ONE_UNRELIABLE, g_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
|
|