Участник
Пользователь
- Сообщения
- 94
- Реакции
- 16
- Помог
- 2 раз(а)
стоит вип система, в вип меню оружие берется только 1 раз за раунд, хотелось бы добавить функцию чтоб брать можно было несколько раз
Код:
#include <amxmodx>
#include <amxmisc>
#include <reapi>
#include <vip_system>
#pragma semicolon 1
enum _:cvars { FLAG_DEF, FLAG, VIPMENU, BLOCKBONUS };
new pCvar[cvars], g_Flags[cvars], g_iMenuRnd, g_iBonusRnd;
enum _:fwd { FWD_SPAWN, FWD_RESTART };
new g_fwdFunction[fwd];
new g_iRound;
new HookChain:HookSpawn;
public plugin_natives() {
register_library(VIP_SYSTEM_VERSION);
register_native("get_flag_access_def", "native_flag_access_def", 1);
register_native("get_flag_access", "native_flag_access", 1);
register_native("get_round_num", "native_round_num", 1);
register_native("get_block_maps", "native_block_maps", 1);
register_native("core_is_bonus_spawn", "native_bonus_spawn", 1);
register_native("core_is_allow_use", "native_allow_use", 1);
}
public native_flag_access_def(id){
if(is_user_connected(id) && get_user_flags(id) & g_Flags[FLAG_DEF]) return true;
return false;
}
public native_flag_access(id){
if(is_user_connected(id) && get_user_flags(id) & g_Flags[FLAG]) return true;
return false;
}
public native_round_num()
return g_iRound;
public native_block_maps() {
new szDisabledFile[64];
get_configsdir(szDisabledFile, charsmax(szDisabledFile));
formatex(szDisabledFile, charsmax(szDisabledFile), "%s/vip_disabled_maps.cfg", szDisabledFile);
if(file_exists(szDisabledFile)) {
new iLineNum, szData[64], iTextLen;
new szMapName[64]; rh_get_mapname(szMapName, charsmax(szMapName));
while(read_file(szDisabledFile, iLineNum, szData, charsmax(szData), iTextLen)) {
if(containi(szMapName, szData) != -1) return true;
iLineNum++;
}
}
return false;
}
public native_bonus_spawn(id) {
if(!is_user_alive(id)) return false;
if(get_block_maps()) return false;
if(!get_flag_access_def(id)) return false;
return true;
}
public native_allow_use(id) {
if(!is_user_alive(id)) {
client_print_color(id, -2, "%L %L", LANG_SERVER, "CHAT_TAG", LANG_SERVER, "VIP_ALIVE");
return false;
}
if(get_block_maps()) {
client_print_color(id, -2, "%L %L", LANG_SERVER, "CHAT_TAG", LANG_SERVER, "BLOCK_MAPS");
return false;
}
if(!get_flag_access_def(id)) {
client_print_color(id, -2, "%L %L", LANG_SERVER, "CHAT_TAG", LANG_SERVER, "ONLY_VIP");
return false;
}
if(g_iMenuRnd > g_iRound) {
client_print_color(id, -2, "%L %L", LANG_SERVER, "CHAT_TAG", LANG_SERVER, "WARMUP_ROUND");
return false;
}
return true;
}
public plugin_init() {
register_plugin("[ReVIP] System Core", VIP_SYSTEM_VERSION, "pUzzlik");
register_dictionary("vip_system.txt");
// flag access def. t
pCvar[FLAG_DEF] = register_cvar("access_flag_vip", "t");
// flag access (def. g)
pCvar[FLAG] = register_cvar("other_access_flag", "m");
// with round displayed vip menu
pCvar[VIPMENU] = register_cvar("display_menu_rnd", "2");
// with round enable forward spawn player
pCvar[BLOCKBONUS] = register_cvar("spawn_player_block", "2");
g_fwdFunction[FWD_RESTART] = CreateMultiForward("vip_core_restart_round", ET_IGNORE, FP_CELL);
g_fwdFunction[FWD_SPAWN] = CreateMultiForward("vip_core_player_spawn", ET_IGNORE, FP_CELL);
RegisterHookChain(RG_RoundEnd, "RoundEnd", true);
RegisterHookChain(RG_CSGameRules_RestartRound, "CSGameRules_RestartRound_Pre");
DisableHookChain(HookSpawn = RegisterHookChain(RG_CBasePlayer_Spawn, "CBasePlayer_Spawn", true));
new szFileCfg[64];
get_configsdir(szFileCfg, charsmax(szFileCfg));
formatex(szFileCfg, charsmax(szFileCfg), "%s/vip_system.cfg", szFileCfg);
if(file_exists(szFileCfg)) server_cmd("exec %s", szFileCfg);
}
public plugin_cfg() {
new sFlagDef[10]; get_pcvar_string(pCvar[FLAG_DEF], sFlagDef, charsmax(sFlagDef));
new sFlag[10]; get_pcvar_string(pCvar[FLAG], sFlag, charsmax(sFlag));
g_Flags[FLAG_DEF] = read_flags(sFlagDef);
g_Flags[FLAG] = read_flags(sFlag);
g_iMenuRnd = get_pcvar_num(pCvar[VIPMENU]);
g_iBonusRnd = get_pcvar_num(pCvar[BLOCKBONUS]);
}
public RoundEnd(WinStatus:status, ScenarioEventEndRound:event) {
if(event == ROUND_GAME_COMMENCE || event == ROUND_GAME_RESTART) {
g_iRound = 0;
DisableHookChain(HookSpawn);
}
}
public CSGameRules_RestartRound_Pre() {
g_iRound++;
new Result;
ExecuteForward(g_fwdFunction[FWD_RESTART], Result, g_iRound);
if(g_iRound == g_iBonusRnd) EnableHookChain(HookSpawn);
}
public CBasePlayer_Spawn(const id) {
new Result;
ExecuteForward(g_fwdFunction[FWD_SPAWN], Result, id);
}
Код:
#include <amxmodx>
#include <reapi>
#include <vip_system>
//#define ADMIN_LOADER // Compatible with Admin Loader from neugomon (https://www.neugomon.ru/threads/486/)
#pragma semicolon 1
new const MenuKey = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<9);
enum _:cvars {
AUTO_MENU,
GIVE_ITEMS,
WEAPONSRND,
AWPM249RND,
SHOP,
SHOP_RND
};
new iPistol[MAX_CLIENTS+1], bool:g_bUsePistol, bool:g_bUseWeapon[MAX_CLIENTS+1];
static sItems[10];
new pCvar[cvars], pCvarCfg[cvars];
new g_iRound;
public plugin_init() {
register_plugin("[ReVIP] Menu", VIP_SYSTEM_VERSION, "pUzzlik");
register_dictionary("vip_system.txt");
// auto open vip menu 1 - on, 0 - off
pCvar[AUTO_MENU] = register_cvar("open_menu_spawn", "0");
/*
flags items
a - armor
d - defuse
f - flashbang
h - hegranade
p - pistol
s - smoke
*/
pCvar[GIVE_ITEMS] = register_cvar("give_items", "adfhps");
// which is available with a round primary weapons
pCvar[WEAPONSRND] = register_cvar("primary_weapons_rnd", "2");
// which is available with a round primary weapons
pCvar[AWPM249RND] = register_cvar("heavy_weapons_rnd", "4");
// if you want to use a custom shop, (1 - enable)
pCvar[SHOP] = register_cvar("use_custom_shop", "1");
// with round displayed shop menu
pCvar[SHOP_RND] = register_cvar("custom_shop_block_rnd", "2");
register_clcmd("vipmenu", "ShowMenu");
register_clcmd("say /vipmenu", "ShowMenu");
register_clcmd("say_team /vipmenu", "ShowMenu");
register_clcmd("say", "hook_say");
register_clcmd("say_team", "hook_say");
register_menucmd(register_menuid("Vip Menu"), MenuKey, "MenuHandler");
}
public plugin_cfg() {
get_pcvar_string(pCvar[GIVE_ITEMS],sItems,charsmax(sItems)); trim(sItems);
pCvarCfg[WEAPONSRND] = get_pcvar_num(pCvar[WEAPONSRND]);
pCvarCfg[AWPM249RND] = get_pcvar_num(pCvar[AWPM249RND]);
pCvarCfg[AUTO_MENU] = get_pcvar_num(pCvar[AUTO_MENU]);
pCvarCfg[SHOP] = get_pcvar_num(pCvar[SHOP]);
pCvarCfg[SHOP_RND] = get_pcvar_num(pCvar[SHOP_RND]);
}
public vip_core_restart_round(round) {
arrayset(g_bUseWeapon, false, sizeof(g_bUseWeapon));
g_iRound = round;
}
public vip_core_player_spawn(const id) {
if(core_is_bonus_spawn(id)) {
for(new i, str_len = strlen(sItems); i < str_len ; i++) {
switch(sItems[i]){
case 'a': rg_set_user_armor(id, 100, ARMOR_VESTHELM);
case 'd': {
new TeamName:team = get_member(id, m_iTeam);
if(team == TEAM_CT) rg_give_defusekit (id, true);
}
case 'f': {
rg_give_item(id, "weapon_flashbang", GT_APPEND);
rg_give_item(id, "weapon_flashbang", GT_APPEND);
}
case 'h': rg_give_item(id, "weapon_hegrenade", GT_APPEND);
case 'p': {
switch(iPistol[id]) {
case 0: { rg_give_item(id, "weapon_deagle", GT_REPLACE); rg_set_user_bpammo(id, WEAPON_DEAGLE, 35); }
case 1: { rg_give_item(id, "weapon_usp", GT_REPLACE); rg_set_user_bpammo(id, WEAPON_USP, 100); }
case 2: { rg_give_item(id, "weapon_glock18", GT_REPLACE); rg_set_user_bpammo(id, WEAPON_GLOCK18, 120); }
}
g_bUsePistol = true;
}
case 's': rg_give_item(id, "weapon_smokegrenade", GT_APPEND);
}
}
if(pCvarCfg[AUTO_MENU] && g_iRound >= pCvarCfg[WEAPONSRND]) ShowMenu(id);
}
}
public hook_say(id) {
static szMsg[32]; read_args(szMsg, charsmax(szMsg)); remove_quotes(szMsg);
static const szChoosedWP[][] = { "/ak47", "/m4a1", "/famas", "/awp", "/b51" };
for(new a; a < sizeof szChoosedWP; a++) {
if(!strcmp(szMsg, szChoosedWP[a])) {
if(!core_is_allow_use(id)) break;
return MenuHandler(id, a);
}
}
return PLUGIN_CONTINUE;
}
public ShowMenu(id) {
if(!core_is_allow_use(id)) return PLUGIN_HANDLED;
new szMenu[512], key; key = MENU_KEY_0;
new iLen, szName[16]; get_entvar(id, var_netname, szName, charsmax(szName));
iLen = formatex(szMenu, charsmax(szMenu), "\r%L \w[\d%L\w]^n\w%L^n", LANG_SERVER, "MENU_NAME", LANG_SERVER, "NAME_SERVER", LANG_SERVER, "WELCOME", szName);
#if defined ADMIN_LOADER
new exp = admin_expired(id);
if(exp > 0) {
new sys = get_systime();
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%L^n^n", LANG_SERVER, "VIP_EXPIRED", LANG_SERVER, ((exp - sys) / 86400 > 0) ? "VIP_DAYS" : "VIP_DAY", (exp - sys) / 86400);
} else if(exp == 0) iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%L^n^n", LANG_SERVER, "VIP_EXPIRED_PRMANENT");
#else
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n");
#endif
new szUseWpn[2]; formatex(szUseWpn, charsmax(szUseWpn), "%s", g_bUseWeapon[id] ? "d" : "w");
if(g_iRound < pCvarCfg[WEAPONSRND])
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r1. \d%L \r%L^n\r2. \d%L \r%L^n\r3. \d%L \r%L^n", LANG_SERVER, "AK47", LANG_SERVER, "ROUND", pCvarCfg[WEAPONSRND], LANG_SERVER, "M4A1", LANG_SERVER, "ROUND", pCvarCfg[WEAPONSRND], LANG_SERVER, "FAMAS", LANG_SERVER, "ROUND", pCvarCfg[WEAPONSRND]);
else {
key |= MENU_KEY_1|MENU_KEY_2|MENU_KEY_3;
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r1. \%s%L^n\r2. \%s%L^n\r3. \%s%L^n", szUseWpn, LANG_SERVER, "AK47", szUseWpn, LANG_SERVER, "M4A1", szUseWpn, LANG_SERVER, "FAMAS");
}
if(g_iRound < pCvarCfg[AWPM249RND])
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r4. \d%L \r%L^n\r5. \d%L \r%L^n^n", LANG_SERVER, "AWP", LANG_SERVER, "ROUND", pCvarCfg[AWPM249RND], LANG_SERVER, "M249", LANG_SERVER, "ROUND", pCvarCfg[AWPM249RND]);
else {
key |= MENU_KEY_4|MENU_KEY_5;
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r4. \%s%L^n\r5. \%s%L^n^n", szUseWpn, LANG_SERVER, "AWP", szUseWpn, LANG_SERVER, "M249");
}
if(g_bUsePistol) {
key |= MENU_KEY_6;
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r6. %L \r[\w%s\r]^n", LANG_SERVER, "PISTOL", iPistol[id] == 0 ? "Deagle" : iPistol[id] == 1 ? "USP" : "Glock");
}
formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r0. %L", LANG_SERVER, "EXIT");
set_member(id, m_iMenu, Menu_OFF);
return show_menu(id, key, szMenu, -1, "Vip Menu");
}
public MenuHandler(id, key) {
if(key <= 4) {
/*** Защита от дурака ***/
if(g_iRound < pCvarCfg[WEAPONSRND]) return client_print_color(id, 0, "%L %L", LANG_SERVER, "CHAT_TAG", LANG_SERVER, "PISTOLS_ROUND");
/*** End ***/
if(g_bUseWeapon[id]) return client_print_color(id, 0, "%L %L", LANG_SERVER, "CHAT_TAG", LANG_SERVER, "ALREDY_WEAPON_RND");
g_bUseWeapon[id] = true;
static const szChoosedBP[] = { 90, 90, 90, 30, 250 };
static const szChoosedWP[][] = { "weapon_ak47", "weapon_m4a1", "weapon_famas", "weapon_awp", "weapon_m249" };
return rg_give_items(id, szChoosedWP[key], szChoosedBP[key]);
}
else if (key == 5) GivePistol(id);
return PLUGIN_HANDLED;
}
public GivePistol(id) {
iPistol[id] >= 2 ? (iPistol[id] = 0) : iPistol[id]++;
ShowMenu(id);
return PLUGIN_HANDLED;
}
stock rg_give_items(id, currWeaponName[], ammoAmount) {
rg_drop_items_by_slot(id, PRIMARY_WEAPON_SLOT);
rg_give_item(id, currWeaponName, GT_APPEND);
rg_set_user_bpammo(id, rg_get_weapon_info(currWeaponName, WI_ID), ammoAmount);
engclient_cmd(id, currWeaponName);
return PLUGIN_HANDLED;
}
Download all Attachments
-
4.4 KB Просмотры: 3
-
7.1 KB Просмотры: 4