Добрый вечер господа, делал тут для себя менюшку, все работает отлично, без нареканий, единственное баг что иногда может просто никак не реагировать будто не работает менюшка, вообще не появляться и не вызываться по данной команде, хотя в консоли показывает что сам плагин запущен, проблема бывает не всегда но все же хотелось бы исправить, подскажите кто знает по коду, благодарю!
Код:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#if AMXX_VERSION_NUM < 183
#include <colorchat>
#define MAX_PLAYERS 32
#endif
const OFFSET_AWM_AMMO = 377
const OFFSET_SCOUT_AMMO = 378
const OFFSET_PARA_AMMO = 379
const OFFSET_FAMAS_AMMO = 380
const OFFSET_M3_AMMO = 381
const OFFSET_USP_AMMO = 382
const OFFSET_FIVESEVEN_AMMO = 383
const OFFSET_DEAGLE_AMMO = 384
const OFFSET_P228_AMMO = 385
const OFFSET_GLOCK_AMMO = 386
const OFFSET_FLASH_AMMO = 387
const OFFSET_HE_AMMO = 388
const OFFSET_SMOKE_AMMO = 389
const OFFSET_C4_AMMO = 390
const OFFSET_LINUX = 5
new const szAdminPrefix[] = "^1[^4PVM^1]";
#define ACCESS_VIPS ADMIN_CHAT
#define MAXJUMPS 2
#define OpenNumRound 3
enum _:jData
{
bool:ACTIVE,
bool:DOJUMP,
JUMPCOUNT
}
new PlayerJump[MAX_PLAYERS + 1][jData];
new bool:g_Silent[MAX_PLAYERS + 1];
new T_Money[MAX_PLAYERS + 1], T_Health[MAX_PLAYERS + 1], T_Grenade[MAX_PLAYERS + 1], T_TwoJump[MAX_PLAYERS + 1], T_Spawn[MAX_PLAYERS + 1];
new CT_USP[MAX_PLAYERS + 1], CT_Money[MAX_PLAYERS + 1], CT_Health[MAX_PLAYERS + 1], CT_Grenade[MAX_PLAYERS + 1], CT_Footsteps[MAX_PLAYERS + 1], CT_Spawn[MAX_PLAYERS + 1];
new RespawnRoundControl[MAX_PLAYERS + 1];
new Curret_Round;
public plugin_init()
{
register_plugin("Premium Vipmenu", "0.1", "YahOoo!))");
register_clcmd("pvm_menu", "Show__VipsMenu");
register_clcmd("say /pvm", "Show__VipsMenu");
register_clcmd("say_team /pvm", "Show__VipsMenu");
register_menucmd(register_menuid("Show_VipsMenu"), (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9), "Handle_VipsMenu");
register_event("HLTV", "EventRoundStart", "a", "1=0", "2=0");
register_event("TextMsg", "EventGameRestart", "a", "2=#Game_will_restart_in");
register_event("TextMsg", "EventGameRestart", "a", "2=#Game_Commencing");
RegisterHam(Ham_Spawn, "player", "fwdPlayerSpawn_Pre", false);
RegisterHam(Ham_Player_Jump, "player", "fwdHamPlayerJump");
register_forward(FM_PlayerPreThink, "forward_player_prethink");
}
public client_connect(id)
{
PlayerJump[id][ACTIVE] = false;
}
public client_disconnect(id)
{
arrayset(PlayerJump[id], 0, jData);
g_Silent[id] = false;
}
public EventRoundStart()
{
Curret_Round++
for(new id = 1; id <= get_maxplayers(); id++)
{
T_Money[id]++;
T_Health[id] = 1;
T_Grenade[id] = 1;
T_TwoJump[id] = 1;
T_Spawn[id] = 1;
CT_USP[id] = 1;
CT_Money[id]++;
CT_Health[id] = 1;
CT_Grenade[id] = 1;
CT_Footsteps[id] = 1;
CT_Spawn[id] = 1;
--RespawnRoundControl[id];
}
}
public EventGameRestart()
{
Curret_Round = 0
}
public fwdPlayerSpawn_Pre(id)
{
if(is_user_connected(id))
{
PlayerJump[id][ACTIVE] = false;
FM_SetUserFootsteps(id, 0);
}
}
/**=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=
ViPs Меню.
-=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-*/
public Show__VipsMenu(id)
{
if(get_user_flags(id) & ACCESS_VIPS)
{
if(Curret_Round < OpenNumRound)
{
client_print_color(id, print_team_default, "%s ^1Доступно только с^3 3 ^1Раунда!", szAdminPrefix);
return PLUGIN_HANDLED;
}
if(get_user_team(id) == 1)
{
new szMenu[1024], iKeys = (1<<9),
iLen = formatex(szMenu, charsmax(szMenu), "\w[\rPublic\w] \rПремиум-VIP-Меню^n^n");
if(T_Money[id] >= 3)
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[1]\r ~ \wПолучить \r(\y16000 \d$\r) \r[\y1\r]^n");
iKeys |= (1<<0);
} else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[1]\r ~ \dПолучить \r(\y16000 \d$\r) \r[\wЧерез\r: \y%d\r]^n", 3 - T_Money[id]);
if(T_Health[id] > 0)
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[2]\r ~ \wПолучить \r(\y50 \dHP\r) \r[\y1\r]^n");
iKeys |= (1<<1);
} else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[2]\r ~ \dПолучить \r(\y50 \dHP\r) \r[\y0\r]^n");
if(T_Grenade[id] > 0)
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[3]\r ~ \wПолучить Набор Гранат \r[\y1\r]^n");
iKeys |= (1<<2);
} else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[3]\r ~ \dПолучить Набор Гранат \r[\y0\r]^n");
if(RespawnRoundControl[id] <= 0)
{
if(!is_user_alive(id))
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[4]\r ~ \wВозродиться \r[\y1\r]^n^n");
iKeys |= (1<<3);
} else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[4]\r ~ \dВозродиться \r(\yЖивой\r)^n^n");
} else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[4]\r ~ \dВозродиться \r(\wЧерез\d: \y%d\r)^n^n", RespawnRoundControl[id])
if(get_user_flags(id) & ACCESS_VIPS)
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[5]\r ~ \wКикнуть/Предупреждение^n");
iKeys |= (1<<4);
}else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[5]\r ~ \dКикнуть/Предупреждение^n");
if(get_user_flags(id) & ACCESS_VIPS)
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[6]\r ~ \wСоздать голосование за карту^n");
iKeys |= (1<<5);
}else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[6]\r ~ \dСоздать голосование за карту^n");
if(get_user_flags(id) & ACCESS_VIPS)
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[7]\r ~ \wСменить карту^n");
iKeys |= (1<<6);
}else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[7]\r ~ \dСменить карту^n");
if(get_user_flags(id) & ACCESS_VIPS)
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[8]\r ~ \wОружейка^n^n^n");
iKeys |= (1<<7);
}else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[8]\r ~ \dОружейка^n^n^n");
formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[0]\r ~ \wВыход");
return show_menu(id, iKeys, szMenu, -1, "Show_VipsMenu");
}
} else client_print_color(id, print_team_default, "%s ^1Нет ^3Доступа^1! Купить Премиум-VIP ^4vk.com/nskpub18^1", szAdminPrefix);
return PLUGIN_HANDLED;
}
public Handle_VipsMenu(id, iKey)
{
new szName[32]; get_user_name(id, szName, charsmax(szName));
new GetNumCt = SetNumCt(1);
new GetNumTt = SetNumTt(1);
if(get_user_team(id) == 1)
{
switch(iKey)
{
case 0:
{
FM_SetMoney(id, FM_GetMoney(id) + 16000);
client_print_color(0, print_team_default, "%s ^1Премиум-VIP ^4%s ^1взял ^4 16000 ^3$^1!", szAdminPrefix, szName);
T_Money[id] = 0;
}
case 1:
{
FM_SetUserHealth(id, FM_GetUserHealth(id) + 50);
client_print_color(0, print_team_default, "%s ^1Премиум-VIP ^4%s ^1взял^4 50 ^3HP^1!", szAdminPrefix, szName);
T_Health[id]--;
}
case 2:
{
FM_GiveItem(id, "weapon_smokegrenade");
FM_GiveItem(id, "weapon_flashbang");
FM_GiveItem(id, "weapon_hegrenade");
client_print_color(0, print_team_default, "%s ^1Премиум-VIP ^4%s ^1взял ^3Набор Гранат^1!", szAdminPrefix, szName);
T_Grenade[id]--;
}
case 3:
{
if(GetNumCt < 1)
{
client_print_color(id, print_team_default, "%s ^1Должно быть^4 1 ^1и более живых, в команде ^3противников^1. Сейчас^3: ^4%d^1!", szAdminPrefix, GetNumCt);
return PLUGIN_HANDLED;
}
if(RespawnRoundControl[id] <= 0)
{
ExecuteHam(Ham_CS_RoundRespawn, id)
RespawnRoundControl[id] = 3
client_print_color(0, print_team_default, "%s ^1Премиум-VIP ^4%s ^3Возродился^1!", szAdminPrefix, szName);
}
}
case 4: client_cmd(id, "amx_kickmenu");
case 5: client_cmd(id, "amx_votemapmenu");
case 6: client_cmd(id, "amx_mapmenu");
case 7: client_cmd(id, "weaponmenu");
case 9: return PLUGIN_HANDLED;
}
}
return PLUGIN_HANDLED;
}
stock FM_GetMoney(id)
{
return get_pdata_int(id, 115);
}
stock FM_SetMoney(id, szMoney, szFlash = 1)
{
set_pdata_int(id, 115, szMoney);
message_begin(MSG_ONE, get_user_msgid("Money"), _, id);
write_long(szMoney);
write_byte(szFlash ? 1 : 0);
message_end();
}
stock FM_GetUserHealth(id)
{
return pev(id, pev_health);
}
stock FM_SetUserHealth(id, Health)
{
Health > 0 ? set_pev(id, pev_health, float(Health)) : dllfunc(DLLFunc_ClientKill, id);
return 1;
}
stock FM_GiveItem(id, const item[])
{
static iEnt
iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
if(!pev_valid(iEnt)) return;
static Float:iOriginF[3]
pev(id, pev_origin, iOriginF)
set_pev(iEnt, pev_origin, iOriginF)
set_pev(iEnt, pev_spawnflags, pev(iEnt, pev_spawnflags) | SF_NORESPAWN)
dllfunc(DLLFunc_Spawn, iEnt)
static iSave
iSave = pev(iEnt, pev_solid)
dllfunc(DLLFunc_Touch, iEnt, id)
if(pev(iEnt, pev_solid) != iSave)
return;
engfunc(EngFunc_RemoveEntity, iEnt)
}
stock FM_SetUserBPAmmo(id, iWeapon, iAmount)
{
static iOffset
switch(iWeapon)
{
case CSW_AWP: iOffset = OFFSET_AWM_AMMO;
case CSW_SCOUT, CSW_AK47, CSW_G3SG1: iOffset = OFFSET_SCOUT_AMMO;
case CSW_M249: iOffset = OFFSET_PARA_AMMO;
case CSW_M4A1, CSW_FAMAS, CSW_AUG, CSW_SG550, CSW_GALI, CSW_SG552: iOffset = OFFSET_FAMAS_AMMO;
case CSW_M3, CSW_XM1014: iOffset = OFFSET_M3_AMMO;
case CSW_USP, CSW_UMP45, CSW_MAC10: iOffset = OFFSET_USP_AMMO;
case CSW_FIVESEVEN, CSW_P90: iOffset = OFFSET_FIVESEVEN_AMMO;
case CSW_DEAGLE: iOffset = OFFSET_DEAGLE_AMMO;
case CSW_P228: iOffset = OFFSET_P228_AMMO;
case CSW_GLOCK18, CSW_MP5NAVY, CSW_TMP, CSW_ELITE: iOffset = OFFSET_GLOCK_AMMO;
case CSW_FLASHBANG: iOffset = OFFSET_FLASH_AMMO;
case CSW_HEGRENADE: iOffset = OFFSET_HE_AMMO;
case CSW_SMOKEGRENADE: iOffset = OFFSET_SMOKE_AMMO;
case CSW_C4: iOffset = OFFSET_C4_AMMO;
default: return;
}
set_pdata_int(id, iOffset, iAmount, OFFSET_LINUX);
}
public fwdHamPlayerJump(id)
{
if(!PlayerJump[id][ACTIVE])
return;
static oldButtons;
oldButtons = pev(id, pev_oldbuttons);
if( !(pev(id,pev_flags) & FL_ONGROUND) && !(oldButtons & IN_JUMP) )
{
if(PlayerJump[id][JUMPCOUNT] < MAXJUMPS - 1)
{
PlayerJump[id][DOJUMP] = true;
PlayerJump[id][JUMPCOUNT] ++;
}
}else if(pev(id, pev_flags) & FL_ONGROUND)
{
PlayerJump[id][JUMPCOUNT] = 0;
}
if(PlayerJump[id][DOJUMP])
{
static Float:velocity[3];
pev(id, pev_velocity, velocity);
velocity[2] = random_float(265.0, 285.0);
set_pev(id, pev_velocity, velocity);
PlayerJump[id][DOJUMP] = false;
}
}
FM_SetUserFootsteps(id, iSet = 1)
{
if(iSet)
{
set_pev(id, pev_flTimeStepSound, 999);
g_Silent[id] = true;
}
else
{
set_pev(id, pev_flTimeStepSound, 400);
g_Silent[id] = false;
}
return 1;
}
/*FM_GetUserFootsteps(id)
{
return g_Silent[id];
}*/
public forward_player_prethink(id)
{
if(g_Silent[id])
set_pev(id, pev_flTimeStepSound, 999);
}
stock GetAliveCtTt()
{
new CountCt, CountTt, i;
for(i = 1; i <= get_maxplayers(); i++)
{
if(is_user_alive(i) && is_user_connected(i) && get_user_team(i) == 2)
{
CountCt++;
return CountCt;
}
else if(is_user_alive(i) && is_user_connected(i) && get_user_team(i) == 1)
{
CountTt++;
return CountTt;
}
}
return PLUGIN_CONTINUE;
}
stock SetNumCt(alive)
{
new GetNumCt, index
for(index = 1; index <= get_maxplayers(); index++)
{
if(!is_user_connected(index))
{
continue
}
if(alive)
{
if(get_user_team(index) == 2 && is_user_alive(index))
{
GetNumCt++
}
}
}
return GetNumCt;
}
stock SetNumTt(alive)
{
new GetNumTt, index
for(index = 1; index <= get_maxplayers(); index++)
{
if(!is_user_connected(index))
{
continue
}
if(alive)
{
if(get_user_team(index) == 1 && is_user_alive(index))
{
GetNumTt++
}
}
}
return GetNumTt;
}