Требуется помощь, может кто нибудь добавить ограничения по байтайму? После того как пройдёт байтайм, сверху будет писать "Меню можно открыть только во время закупки!"
Вложения
-
4,5 KB Просмотры: 14
#include <amxmodx>
#include <reapi>
#if AMXX_VERSION_NUM < 183
#include <colorchat>
#endif
#define ADMIN_LOADER // Выводить срок до конца админки с Admin Loader by Neugomon
enum _:MENU_DATA { NAME[128], WPN_M[32], FLAG_M[32], AMMO_M, ROUND_M, USE_M, MSG_M[128] };
new g_arrMenuData[64][MENU_DATA], g_iMenuSize;
enum _:SPAWN_DATA { WPN_S[32], FLAG_S[32], AMMO_S, ROUND_S };
new g_arrSpawnData[64][SPAWN_DATA], g_iSpawnSize;
enum _:MAPS_DATA { MAPNAME[32], BLOCKTYPE[32] };
new g_arrMapsData[64][MAPS_DATA], g_iMapsSize;
enum _:BLOCK_DATA { bMenu, bSpawn };
new bool:g_arrBlockData[BLOCK_DATA];
new g_iUseNum[33][64];
new g_iMenuPage[33];
new Float: g_BuyTime, bool: g_BuyTimeEnd;
#if defined ADMIN_LOADER
native admin_expired(index);
#endif
public plugin_init()
{
register_plugin("Advanced Vip", "1.1", "Hypa_[KZ]");
#if AMXX_VERSION_NUM < 183
register_dictionary_colored("advanced_vip.txt");
#else
register_dictionary("advanced_vip.txt");
#endif
register_event("HLTV", "EventRoundStart", "a", "1=0", "2=0");
register_clcmd("vipmenu", "ClCmdVipMenu", ADMIN_LEVEL_H);
register_clcmd("say /vipmenu", "ClCmdVipMenu", ADMIN_LEVEL_H);
register_clcmd("say_team /vipmenu", "ClCmdVipMenu", ADMIN_LEVEL_H);
register_menucmd(register_menuid("Vip Menu"), 1023, "MenuHandler");
RegisterHookChain(RG_CBasePlayer_Spawn, "CBasePlayer_Spawn", 1);
}
public plugin_cfg()
{
new szConfigsDir[64], szConfig[64];
get_localinfo("amxx_configsdir", szConfigsDir, charsmax(szConfigsDir));
formatex(szConfig, charsmax(szConfig), "%s/advanced_vip.ini", szConfigsDir);
g_BuyTime = get_cvar_float("mp_buytime");
new iFile = fopen(szConfig, "rt");
if(iFile)
{
new szBuffer[1024];
new iState;
new sFlags_M[32], iAmmo_M[8], iRound_M[8], iUse_M[8];
new sFlags_S[32], iAmmo_S[8], iRound_S[8];
new szMapName[64]; rh_get_mapname(szMapName, charsmax(szMapName));
while(!feof(iFile))
{
fgets(iFile, szBuffer, charsmax(szBuffer));
trim(szBuffer);
if(!szBuffer[0])
continue;
switch(szBuffer[0])
{
case '/': continue;
case ';': continue;
case '[':
{
if(!strcmp(szBuffer, "[MENU]"))
iState = 1;
else if(!strcmp(szBuffer, "[SPAWN]"))
iState = 2;
else if(!strcmp(szBuffer, "[BLOCK_MAPS]"))
iState = 3;
continue;
}
}
switch(iState)
{
case 1:
{
parse(szBuffer,
g_arrMenuData[g_iMenuSize][NAME], charsmax(g_arrMenuData[][NAME]),
g_arrMenuData[g_iMenuSize][WPN_M], charsmax(g_arrMenuData[][WPN_M]),
sFlags_M, charsmax(sFlags_M),
iAmmo_M, charsmax(iAmmo_M),
iRound_M, charsmax(iRound_M),
iUse_M, charsmax(iUse_M),
g_arrMenuData[g_iMenuSize][MSG_M], charsmax(g_arrMenuData[][MSG_M]));
g_arrMenuData[g_iMenuSize][FLAG_M] = read_flags(sFlags_M);
g_arrMenuData[g_iMenuSize][AMMO_M] = str_to_num(iAmmo_M);
g_arrMenuData[g_iMenuSize][ROUND_M] = str_to_num(iRound_M);
g_arrMenuData[g_iMenuSize][USE_M] = str_to_num(iUse_M);
for(new id; id < MAX_CLIENTS + 1; id++)
g_iUseNum[id][g_iMenuSize] = str_to_num(g_arrMenuData[g_iMenuSize][USE_M]);
g_iMenuSize++;
}
case 2:
{
parse(szBuffer,
g_arrSpawnData[g_iSpawnSize][WPN_S], charsmax(g_arrSpawnData[][WPN_S]),
sFlags_S, charsmax(sFlags_S),
iAmmo_S, charsmax(iAmmo_S),
iRound_S, charsmax(iRound_S));
g_arrSpawnData[g_iSpawnSize][FLAG_S] = read_flags(sFlags_S);
g_arrSpawnData[g_iSpawnSize][AMMO_S] = str_to_num(iAmmo_S);
g_arrSpawnData[g_iSpawnSize][ROUND_S] = str_to_num(iRound_S);
g_iSpawnSize++;
}
case 3:
{
parse(szBuffer,
g_arrMapsData[g_iMapsSize][MAPNAME], charsmax(g_arrMapsData[][MAPNAME]),
g_arrMapsData[g_iMapsSize][BLOCKTYPE], charsmax(g_arrMapsData[][BLOCKTYPE]));
if(containi(szMapName, g_arrMapsData[g_iMapsSize][MAPNAME]) != -1)
{
if(containi(g_arrMapsData[g_iMapsSize][BLOCKTYPE], "menu") != -1)
g_arrBlockData[bMenu] = true;
if(containi(g_arrMapsData[g_iMapsSize][BLOCKTYPE], "spawn") != -1)
g_arrBlockData[bSpawn] = true;
}
g_iMapsSize++;
}
}
}
}
fclose(iFile);
}
public EventRoundStart()
{
set_task(g_BuyTime * 60.0, "offBuyTime");
g_BuyTimeEnd = false;
g_Round++;
}
public offBuyTime() g_BuyTimeEnd = true;
public CBasePlayer_Spawn(const id)
{
if(!g_arrBlockData[bSpawn] && is_user_alive(id))
{
for(new i; i < g_iSpawnSize; i++)
{
if(get_user_flags(id) & g_arrSpawnData[i][FLAG_S] && get_member_game(m_iTotalRoundsPlayed) >= (g_arrSpawnData[i][ROUND_S] - 1))
{
switch(g_arrSpawnData[i][WPN_S][0])
{
case 'w':
{
rg_give_item(id, g_arrSpawnData[i][WPN_S], g_arrSpawnData[i][AMMO_S] < 3 ? GT_APPEND : GT_REPLACE);
rg_set_user_bpammo(id, rg_get_weapon_info(g_arrSpawnData[i][WPN_S], WI_ID), g_arrSpawnData[i][AMMO_S]);
}
case 'a':
{
switch(g_arrSpawnData[i][WPN_S][3])
{
case 'm': rg_add_account(id, g_arrSpawnData[i][AMMO_S], AS_ADD);
case 'h': set_entvar(id, var_health, Float:get_entvar(id, var_health) + float(g_arrSpawnData[i][AMMO_S]));
case 'a': set_entvar(id, var_armorvalue, Float:get_entvar(id, var_armorvalue) + float(g_arrSpawnData[i][AMMO_S]));
}
}
case 's':
{
switch(g_arrSpawnData[i][WPN_S][3])
{
case 'm': rg_add_account(id, g_arrSpawnData[i][AMMO_S], AS_SET);
case 'h': set_entvar(id, var_health, float(g_arrSpawnData[i][AMMO_S]));
case 'a': set_entvar(id, var_armorvalue, float(g_arrSpawnData[i][AMMO_S]));
}
}
case 'd':
{
if(get_member(id, m_iTeam) == TEAM_CT)
rg_give_defusekit(id);
}
}
}
}
}
for(new x; x < g_iMenuSize; x++)
g_iUseNum[id][x] = g_arrMenuData[x][USE_M];
}
public ClCmdVipMenu(const id, flags)
{
if(g_BuyTimeEnd)
{
client_print(id, print_center, "Меню доступно во время закупки!");
return 1;
}
if(~get_user_flags(id) & flags)
return client_print_color(id, print_team_default, "%L %L", id, "VIP_CHAT", id, "VIP_ACCESS");
if(g_arrBlockData[bMenu])
return client_print_color(id, print_team_default, "%L %L", id, "VIP_CHAT", id, "VIP_BLOCKMAP");
g_iMenuPage[id] = 0;
ShowMenu(id, g_iMenuPage[id]);
return PLUGIN_HANDLED;
}
ShowMenu(id, iPos)
{
new start, end;
new iLen, sMenu[512];
new iKeys = MENU_KEY_0|MENU_KEY_8;
start = iPos * 8;
end = start + 8;
iLen = formatex(sMenu, charsmax(sMenu), "%L\R%d/%d^n^n", id, "VIP_MENU_TITLE", iPos + 1, (g_iMenuSize / 8 + ((g_iMenuSize % 8) ? 1 : 0)));
#if defined ADMIN_LOADER
new exp = admin_expired(id);
if(exp > 0)
{
new systime = get_systime();
if(exp - systime > 0)
{
if((exp - systime) / 86400 > 0)
iLen = formatex(sMenu, charsmax(sMenu), "%L\R%d/%d^n%L^n^n", id, "VIP_MENU_TITLE", iPos + 1, (g_iMenuSize / 8 + ((g_iMenuSize % 8) ? 1 : 0)), id, "VIP_MENU_EXP", ((exp - systime) / 86400));
else iLen = formatex(sMenu, charsmax(sMenu), "%L\R%d/%d^n%L^n^n", id, "VIP_MENU_TITLE", iPos + 1, (g_iMenuSize / 8 + ((g_iMenuSize % 8) ? 1 : 0)), id, "VIP_MENU_LASTDAY");
}
}
else if(exp == 0) iLen = formatex(sMenu, charsmax(sMenu), "%L\R%d/%d^n%L^n^n", id, "VIP_MENU_TITLE", iPos + 1, (g_iMenuSize / 8 + ((g_iMenuSize % 8) ? 1 : 0)), id, "VIP_MENU_NOTLIMIT");
#else
iLen = formatex(sMenu, charsmax(sMenu), "%L\R%d/%d^n%L^n^n", id, "VIP_MENU_TITLE", iPos + 1, (g_iMenuSize / 8 + ((g_iMenuSize % 8) ? 1 : 0)), id, "VIP_MENU_SELECT");
#endif
if(start >= g_iMenuSize)
start = iPos = g_iMenuPage[id] = 0;
if(end > g_iMenuSize)
end = g_iMenuSize;
for(new i = start, a; i < end; ++i)
{
iKeys |= (1 << a++);
replace_all(g_arrMenuData[i][NAME], charsmax(g_arrMenuData[][NAME]), "\n", "^n");
iLen += formatex(sMenu[iLen], charsmax(sMenu) - iLen, "\r%d. \w%s^n", a, g_arrMenuData[i][NAME]);
}
if(end != g_iMenuSize)
{
formatex(sMenu[iLen], charsmax(sMenu) - iLen, "^n\r9. \yДалее^n\r0. \r%s", iPos ? "Назад" : "Выход");
iKeys |= MENU_KEY_9;
}
else formatex(sMenu[iLen], charsmax(sMenu) - iLen, "^n\r0. %s", iPos ? "Назад" : "Выход");
return show_menu(id, iKeys, sMenu, -1, "Vip Menu");
}
public MenuHandler(id, iKey)
{
switch(iKey)
{
case 8: ShowMenu(id, ++g_iMenuPage[id]);
case 9:
{
if(g_iMenuPage[id])
ShowMenu(id, --g_iMenuPage[id]);
}
default:
{
if(~get_user_flags(id) & g_arrMenuData[iKey][FLAG_M])
return client_print_color(id, print_team_default, "%L %L", id, "VIP_CHAT", id, "VIP_ACCESS");
if(!is_user_alive(id))
return client_print_color(id, print_team_default, "%L %L", id, "VIP_CHAT", id, "VIP_ALIVE");
if(get_member_game(m_iTotalRoundsPlayed) < (g_arrMenuData[iKey][ROUND_M] - 1))
return client_print_color(id, print_team_default, "%L %L", id, "VIP_CHAT", id, "VIP_ROUND", g_arrMenuData[iKey][ROUND_M]);
if(!g_iUseNum[id][iKey] && g_arrMenuData[iKey][USE_M])
return client_print_color(id, print_team_default, "%L %L", id, "VIP_CHAT", id, "VIP_USE", g_arrMenuData[iKey][USE_M]);
switch(g_arrMenuData[iKey][WPN_M][0])
{
case 'w':
{
if(user_has_weapon(id, rg_get_weapon_info(g_arrMenuData[iKey][WPN_M], WI_ID)))
return client_print_color(id, print_team_default, "%L %L", id, "VIP_CHAT", id, "VIP_WEAPON");
rg_give_item(id, g_arrMenuData[iKey][WPN_M], g_arrMenuData[iKey][AMMO_M] < 3 ? GT_APPEND : GT_REPLACE);
rg_set_user_bpammo(id, rg_get_weapon_info(g_arrMenuData[iKey][WPN_M], WI_ID), g_arrMenuData[iKey][AMMO_M]);
}
case 'a':
{
switch(g_arrMenuData[iKey][WPN_M][3])
{
case 'm': rg_add_account(id, g_arrMenuData[iKey][AMMO_M], AS_ADD);
case 'h': set_entvar(id, var_health, Float:get_entvar(id, var_health) + float(g_arrMenuData[iKey][AMMO_M]));
case 'a': set_entvar(id, var_armorvalue, Float:get_entvar(id, var_armorvalue) + float(g_arrMenuData[iKey][AMMO_M]));
}
}
case 's':
{
switch(g_arrMenuData[iKey][WPN_M][3])
{
case 'm': rg_add_account(id, g_arrMenuData[iKey][AMMO_M], AS_SET);
case 'h': set_entvar(id, var_health, float(g_arrMenuData[iKey][AMMO_M]));
case 'a': set_entvar(id, var_armorvalue, float(g_arrMenuData[iKey][AMMO_M]));
}
}
case 'd':
{
if(get_member(id, m_iTeam) == TEAM_CT)
rg_give_defusekit(id);
}
}
g_iUseNum[id][iKey]--;
replace_all(g_arrMenuData[iKey][MSG_M], charsmax(g_arrMenuData[][MSG_M]), "!n", "^1");
replace_all(g_arrMenuData[iKey][MSG_M], charsmax(g_arrMenuData[][MSG_M]), "!t", "^3");
replace_all(g_arrMenuData[iKey][MSG_M], charsmax(g_arrMenuData[][MSG_M]), "!g", "^4");
client_print_color(id, print_team_default, "%L %s", id, "VIP_CHAT", g_arrMenuData[iKey][MSG_M]);
}
}
return PLUGIN_HANDLED;
}