Код: Выбрать все
#include <amxmodx>
#include <fakemeta>
#define AWP_LIMIT 3 // Кол-во AWP на одну команду :)
#define ACCESS_IMMUNITY ADMIN_LEVEL_H // Иммунитет к функциям плагина. Для отключения Пропишите ADMIN_ALL
new bool:g_bUseAwp[33];
new awp_count[3];
public plugin_init()
{
#define VERSION "1.07"
register_plugin("Lite AwpLimit", VERSION, "neygomon")
register_cvar("lite_awplimit", VERSION, FCVAR_SERVER | FCVAR_SPONLY);
new sPref[][] = {"awp_", "aim_", "35hp", "fy_"};
new map[32]; get_mapname(map, charsmax(map));
for(new i; i < sizeof sPref; i++)
{
if(containi(map, sPref[i]) != -1)
{
pause("ad");
return;
}
}
register_menucmd(register_menuid("BuyRifle", true), (1<<4|1<<5), "OldMenusHook");
register_clcmd("menuselect", "ClCmdMenuSelect");
register_clcmd("drop", "ClCmdDrop");
register_clcmd("awp", "cmdawp");
register_clcmd("magnum", "cmdawp");
register_event("WeapPickup", "eWeapPickup", "b");
register_event("DeathMsg", "eDeathMsg", "a");
register_logevent("LeRoundStart", 2, "1=Round_Start");
}
public cmdawp(id, team)
{
#if ACCESS_IMMUNITY != ADMIN_ALL
if(get_user_flags(id) & ACCESS_IMMUNITY)
return PLUGIN_CONTINUE;
#endif
if(!team) team = get_user_team(id);
if(awp_count[team] >= AWP_LIMIT)
{
ChatColor(id, "^1[^4Россия(OnLine)^1] ^4Достигнуто максимальное количество AWP на команду ^1[^3%d ^4/ ^3%d^1]", awp_count[team], AWP_LIMIT);
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public OldMenusHook(id, iKey)
{
#if ACCESS_IMMUNITY != ADMIN_ALL
if(get_user_flags(id) & ACCESS_IMMUNITY)
return PLUGIN_CONTINUE;
#endif
return CheckKeys(id, iKey);
}
public ClCmdMenuSelect(id)
{
#if ACCESS_IMMUNITY != ADMIN_ALL
if(get_user_flags(id) & ACCESS_IMMUNITY)
return PLUGIN_CONTINUE;
#endif
if(!is_user_alive(id) || get_pdata_int(id, 205) != 6)
return PLUGIN_CONTINUE;
new sSlot[3];
if(read_argv(1, sSlot, charsmax(sSlot)))
return CheckKeys(id, str_to_num(sSlot));
return PLUGIN_CONTINUE;
}
CheckKeys(id, iKey)
{
new team = get_user_team(id);
if((team == 1 && iKey != 4) || (team == 2 && iKey != 5))
return PLUGIN_CONTINUE;
cmdawp(id, team);
return PLUGIN_HANDLED;
}
public ClCmdDrop(id)
{
if(~pev(id, pev_weapons) & (1 << CSW_AWP) || !g_bUseAwp[id]) return;
new team = get_user_team(id);
if(awp_count[team])
awp_count[team]--;
g_bUseAwp[id] = false;
}
Код: Выбрать все
public eWeapPickup(id)
{
new team = get_user_team(id);
new IsUseAwp = (pev(id, pev_weapons) & (1 << CSW_AWP)) ? 1 : 0;
switch(IsUseAwp)
{
case 0:
{
if(g_bUseAwp[id])
{
if(awp_count[team])
awp_count[team]--;
g_bUseAwp[id] = false;
}
}
case 1:
{
if(g_bUseAwp[id]) return;
#if ACCESS_IMMUNITY != ADMIN_ALL
if(~get_user_flags(id) & ACCESS_IMMUNITY && awp_count[team] >= AWP_LIMIT)
#else
if(awp_count[team] >= AWP_LIMIT)
#endif
{
ChatColor(id, "^1[^4Россия(OnLine)^1] ^4Достигнуто максимальное количество AWP на команду ^1[^3%d ^4/ ^3%d^1]", awp_count[team], AWP_LIMIT);
set_task(0.1, "drop_awp", id);
}
else
{
awp_count[team]++;
g_bUseAwp[id] = true;
}
}
}
}
public eDeathMsg()
FuncDiscDeath(read_data(2));
public client_disconnect(id)
FuncDiscDeath(id);
FuncDiscDeath(id)
{
if(!g_bUseAwp[id]) return;
new team = get_user_team(id);
if(awp_count[team])
awp_count[team]--;
g_bUseAwp[id] = false;
}
public drop_awp(id)
engclient_cmd(id, "drop", "weapon_awp");
public LeRoundStart()
{
new players[32], pnum, i;
arrayset(awp_count, 0, 3);
get_players(players, pnum, "ae", "TERRORIST");
for(i = 0; i < pnum; i++)
{
if(pev(players[i], pev_weapons) & (1 << CSW_AWP))
{
g_bUseAwp[players[i]] = true;
awp_count[1]++;
} else g_bUseAwp[players[i]] = false;
}
get_players(players, pnum, "ae", "CT");
for(i = 0; i < pnum; i++)
{
if(pev(players[i], pev_weapons) & (1 << CSW_AWP))
{
g_bUseAwp[players[i]] = true;
awp_count[2]++;
} else g_bUseAwp[players[i]] = false;
}
}
stock ChatColor(const id, const szMessage[], any:...)
{
static szMsg[190], IdMsg;
vformat(szMsg, charsmax(szMsg), szMessage, 3);
if(!IdMsg) IdMsg = get_user_msgid("SayText");
message_begin(MSG_ONE, IdMsg, .player = id);
write_byte(id);
write_string(szMsg);
message_end();
}