Vip Gold Menu

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
1
Реакции
0
Всем привет!
Есть вип меню думаю всем знакомо ,чуток переделанное,ну не хватает мозгов как добавить кнопку автопоказа меню!
Кто шарит подскажите пожалуйста! Буду очень благодарен)
#include <amxmodx>
#include <cstrike>
#include <hamsandwich>
#include <fakemeta_util>

enum _:eVipType { Null = 0, ViP, ViPGold };
enum _:eGoldList{ Knife = 0, Deagle, Awp, Ak47, M4A1 };

#define VipFlag "b"
#define VipFlagGold "t"

#define RoundLimitUse 2 /add/ // меняет сколько раз за раунд можно открыть меню
#define MinRoundToOpenMenu 4
#define AWP_LIMIT 4
#define AK47_LIMIT 3
#define M4A1_LIMIT 3

#define Damage_Awp 1.1
#define Damage_Ak4 1.2
#define Damage_M4A1 1.2
#define Damage_Deagle 1.5

#define DROP_TYPE 2 //1 - обычный дроп. 2 - удаляется из рук вообще

new szGoldV[eGoldList][32] = {
"models/tsp/v_knife.mdl",
"models/tsp/v_deagle.mdl",
"models/tsp/v_awp.mdl",
"models/tsp/v_ak47.mdl",
"models/tsp/v_m4a1.mdl"
};

new szGoldP[eGoldList][32] = {
"models/gold/p_knife1.mdl",
"models/tsp/p_deagle.mdl",
"models/tsp/p_awp.mdl",
"models/tsp/p_ak47.mdl",
"models/tsp/p_m4a1.mdl"
};

new szGoldW[eGoldList][32] = {
"",
"models/tsp/w_deagle.mdl",
"models/tsp/w_awp.mdl",
"models/tsp/w_ak47.mdl",
"models/tsp/w_m4a1.mdl"
};

enum _:eKeyGold{
_Deagle = 36895,
_Awp,
_Ak47,
_M4A1
};

enum _:eGoldCost{
Cost_Awp = 300,
Cost_Ak4 = 100,
Cost_M4A1 = 100
};

new iVipFlag[33], RoundLimit[33], bool:bDefuse, iRoundNum; /add/

public plugin_init()
{
register_plugin("[AMXX] ViP Gold", "1.0", "Flymic24");

register_event("TextMsg", "Event_RoundRestart", "a", "2&#Game_C", "2&#Game_w");
register_event("HLTV", "Event_RoundStart", "a", "1=0", "2=0");

register_message(get_user_msgid("ScoreAttrib"), "MessageScoreAttrib");

if(engfunc(EngFunc_FindEntityByString, FM_NULLENT, "classname", "func_bomb_target"))
bDefuse = true;

RegisterHam(Ham_Spawn, "player", "HamHook_Player_Spawn", true);

RegisterHam(Ham_Item_Deploy, "weapon_knife", "HamHook_Knife_Deploy", true);
RegisterHam(Ham_Item_Deploy, "weapon_ak47", "HamHook_Item_Deploy", true);
RegisterHam(Ham_Item_Deploy, "weapon_awp", "HamHook_Item_Deploy", true);
RegisterHam(Ham_Item_Deploy, "weapon_m4a1", "HamHook_Item_Deploy", true);
RegisterHam(Ham_Item_Deploy, "weapon_deagle","HamHook_Item_Deploy", true);

RegisterHam(Ham_Touch, "weaponbox", "HamHook_WeaponboxTouch", false);

RegisterHam(Ham_TraceAttack, "func_breakable", "HamHook_Entity_TraceAttack", false);
RegisterHam(Ham_TraceAttack, "hostage_entity", "HamHook_Entity_TraceAttack", false);
RegisterHam(Ham_TraceAttack, "info_target", "HamHook_Entity_TraceAttack", false);
RegisterHam(Ham_TraceAttack, "player", "HamHook_Entity_TraceAttack", false);

register_forward(FM_SetModel, "Fakemeta_SetModel")

register_clcmd("say /vipmenu", "WeaponMenu");
register_clcmd("vipmenu", "WeaponMenu");

register_menucmd(register_menuid("Vip Menu"), 1023, "VipHandler");
}

public plugin_precache()
{
for(new i = 0; i < sizeof(szGoldV); i++) if (szGoldV[0]) precache_model(szGoldV);
for(new i = 0; i < sizeof(szGoldP); i++) if (szGoldP[0]) precache_model(szGoldP);
for(new i = 0; i < sizeof(szGoldW); i++) if (szGoldW[0]) precache_model(szGoldW);
}

public client_putinserver(iPlayer)
{
if (GetUserFlags(iPlayer) == Null)
return;

new szName[32]; get_user_name(iPlayer, szName, charsmax(szName));
UtilChatColor(0, "На сервер зашёл !gVIP !yклиент !team%s", szName);
}

public Event_RoundRestart() iRoundNum = 0;

public Event_RoundStart()
{
iRoundNum++;
for(new id = 1; id <= get_maxplayers(); id++) RoundLimit[id] = 0
}

public MessageScoreAttrib(iMsgId, iDest, iReceiver)
{
new iPlayer = get_msg_arg_int(1);

if(iVipFlag[iPlayer] > Null && !get_msg_arg_int(2))
set_msg_arg_int(2, ARG_BYTE, (1<<2));
}

public HamHook_Knife_Deploy(const iItem)
{
if (pev_valid(iItem) != 2)
return HAM_IGNORED;

new iPlayer = get_pdata_cbase(iItem, 41, 4);

if(iVipFlag[iPlayer] != ViPGold)
return HAM_IGNORED;

set_pev(iPlayer, pev_viewmodel2, szGoldV[ Knife ]);
set_pev(iPlayer, pev_weaponmodel2, szGoldP[ Knife ]);

return HAM_IGNORED;
}

public HamHook_Item_Deploy(const iItem)
{
if (pev_valid(iItem) != 2)
return HAM_IGNORED;

new iIndex = 0;

switch(pev(iItem, pev_impulse))
{
case _Ak47: iIndex = Ak47;
case _Awp: iIndex = Awp;
case _M4A1: iIndex = M4A1;
case _Deagle: iIndex = Deagle;
default: return HAM_IGNORED;
}

if (iIndex)
{
new iPlayer = get_pdata_cbase(iItem, 41, 4);
set_pev(iPlayer, pev_viewmodel2, szGoldV[ iIndex ]);
set_pev(iPlayer, pev_weaponmodel2, szGoldP[ iIndex ]);
}

return HAM_IGNORED;
}

const MAX_ITEM_TYPES = 6;
stock const m_rgpPlayerItems_CWeaponBox[ 6 ] = { 34 , 35 , ... };

public HamHook_WeaponboxTouch(const iWeapon, const iPlayer)
{
if (!pev_valid(iWeapon) || !is_user_alive(iPlayer))
return HAM_IGNORED;

static pItem, i;

for(i = 0; i < MAX_ITEM_TYPES; i++)
{
pItem = get_pdata_cbase(iWeapon, m_rgpPlayerItems_CWeaponBox[ i ], 4);

if(pev_valid( pItem ) != 2) continue;

switch(pev(pItem, pev_impulse))
{
case _Deagle.._M4A1: if (iVipFlag[iPlayer] != ViPGold) return HAM_SUPERCEDE;
default: return HAM_IGNORED;
}
}

return HAM_IGNORED;
}

public HamHook_Entity_TraceAttack(const iEntity, const iAttacker, Float:flDamage)
{
if (!is_user_alive(iAttacker) || !pev_valid(iEntity))
return HAM_IGNORED;

new iItem = get_pdata_cbase(iAttacker, 373, 5);

if (!pev_valid(iItem)) return HAM_IGNORED;

new Float:iIndex;

switch(pev(iItem, pev_impulse))
{
case _Ak47: iIndex = Damage_Ak4;
case _Awp: iIndex = Damage_Awp;
case _M4A1: iIndex = Damage_M4A1;
case _Deagle: iIndex = Damage_Deagle;
default: return HAM_IGNORED;
}

if (iIndex) SetHamParamFloat(3, flDamage * iIndex);

return HAM_IGNORED;
}

public HamHook_Player_Spawn(const iPlayer)
{
if (!is_user_alive(iPlayer) || is_user_bot(iPlayer))
return HAM_IGNORED;

if (iVipFlag[iPlayer] <= Null)
return HAM_IGNORED;

give_item_ex2(iPlayer, "weapon_hegrenade", 1);
give_item_ex2(iPlayer, "weapon_flashbang", 2);
give_item_ex2(iPlayer, "weapon_smokegrenade", 1);

if (!user_has_weapon(iPlayer, CSW_DEAGLE))
{
give_item_ex2(iPlayer, "weapon_deagle", 35, true, (iVipFlag[iPlayer] == ViPGold) ? _Deagle : Null);
}

cs_set_user_armor(iPlayer, 100, CS_ARMOR_VESTHELM);

if(bDefuse && cs_get_user_team(iPlayer) == CS_TEAM_CT)
cs_set_user_defuse(iPlayer, 1);
WeaponMenu(iPlayer);
return HAM_IGNORED;
}

public Fakemeta_SetModel(const iEntity, szModel[])
{
if(!pev_valid(iEntity))
return FMRES_IGNORED;

new szClassName[32];
pev(iEntity, pev_classname, szClassName, charsmax(szClassName));

if (!equali(szClassName, "weaponbox"))
return FMRES_IGNORED;

for(new iSlot, iWeapon, iIndex; iSlot < 6; iSlot++)
{
iWeapon = get_pdata_cbase(iEntity, 34 + iSlot, 4);

if (pev_valid(iWeapon))
{
switch(pev(iWeapon, pev_impulse))
{
case _Ak47: iIndex = Ak47;
case _Awp: iIndex = Awp;
case _M4A1: iIndex = M4A1;
case _Deagle: iIndex = Deagle;
}

if (iIndex)
{
engfunc(EngFunc_SetModel, iEntity, szGoldW[iIndex]);
return FMRES_SUPERCEDE;
}
}
}

return FMRES_IGNORED;
}

public WeaponMenu(iPlayer)
{
if (!is_user_alive(iPlayer) || iVipFlag[iPlayer] <= Null)
return PLUGIN_HANDLED;

if (iRoundNum < MinRoundToOpenMenu)
{
UtilChatColor(iPlayer, "!g[!yТебе сюда пацан 25+] !yМеню не доступно. Жди ещё !team%i !yраунд", MinRoundToOpenMenu - iRoundNum);
return PLUGIN_HANDLED;
}
if(RoundLimit[iPlayer] >= RoundLimitUse){ /add/
UtilChatColor(iPlayer, "!g[!yТебе сюда пацан 25+] !yМеню будет доступно в следующем раунде");
return PLUGIN_HANDLED;
}

static szMenu[512], iLen;

iLen = formatex(szMenu, charsmax(szMenu), "\r[\yТебе сюда пацан 25+\r] \wVIPMenu^n^n");

iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y1. \wВзять AK47^n");
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y2. \wВзять M4A1^n");
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y3. \wВзять AWP^n");

if (iVipFlag[iPlayer] == ViPGold)
{
if(iRoundNum < AK47_LIMIT)
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y4. \dВзять AK47 Азимов \r[c %d раунда]^n", AK47_LIMIT);
else
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y4. \wВзять AK47 Азимов \y(\r%i$\y)^n", Cost_Ak4);

if(iRoundNum < M4A1_LIMIT)
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y5. \dВзять M4A1 Азимов \r[c %d раунда]^n", M4A1_LIMIT);
else
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y5. \wВзять M4A1 Азимов \y(\r%i$\y)^n", Cost_M4A1);

if(iRoundNum < AWP_LIMIT)
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y6. \dВзять AWP Азимов \r[c %d раунда]^n", AWP_LIMIT);
else
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y6. \wВзять AWP Азимов \y(\r%i$\y)^n", Cost_Awp);
}

iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\y0. \wВыход");

set_pdata_int(iPlayer, 205, 0);

show_menu(iPlayer, 1023, szMenu, -1, "Vip Menu");

return PLUGIN_HANDLED;
}

public VipHandler(iPlayer, iKey)
{
if (!is_user_alive(iPlayer))
return PLUGIN_HANDLED;

new iNewKey = iKey + 1;
if(iKey != 9) RoundLimit[iPlayer]++

static szWeaponName[][] = { "", "AK", "M4", "AWP", "Азимов AK", "Азимов M4", "Азимов AWP" };
static szChoosedWP[][] = { "", "weapon_ak47", "weapon_m4a1", "weapon_awp" };
static szChoosedBP[] = { 0, 90, 90, 90, 30 };
static iGoldKey[] = { 0, _Ak47, _M4A1, _Awp };
static iCost[] = { 0, Cost_Ak4, Cost_M4A1, Cost_Awp };
static iRoundLimit[] = { 0, AK47_LIMIT, M4A1_LIMIT, AWP_LIMIT };

switch (iNewKey)
{
case 1..3: give_item_ex2(iPlayer, szChoosedWP[iNewKey], szChoosedBP[iNewKey], true);
case 4..6:
{
new iMoney = cs_get_user_money(iPlayer);

if (iRoundNum < iRoundLimit[iNewKey - 3])
{
UtilChatColor(iPlayer, "!g[!yТебе сюда пацан 25+!g] !yДоступно только с !g%i !yраунда", iRoundLimit[iNewKey - 3]);
return PLUGIN_HANDLED;
}
if (iMoney < iCost[iNewKey - 3] || iVipFlag[iPlayer] != ViPGold)
{
UtilChatColor(iPlayer, "!g[!yТебе сюда пацан 25+!g] !yНе достаточно денег: !team%i!g$", iCost[iNewKey - 3]);
return PLUGIN_HANDLED;
}
else
{
give_item_ex2(iPlayer, szChoosedWP[iNewKey - 3], szChoosedBP[iNewKey - 3], true, iGoldKey[iNewKey - 3]);
cs_set_user_money(iPlayer, iMoney - iCost[iNewKey - 3]);
}
}
default: return PLUGIN_HANDLED;
}

UtilChatColor(iPlayer, "!g[!yViP!g] !yВы получили: !g[!team%s!g]", szWeaponName[iNewKey]);

return PLUGIN_HANDLED;
}

stock give_item_ex2(iPlayer, const szWeaponName[], iAmmo = 0, bool:bDrop = false, iKey = 0)
{
if (!equal(szWeaponName, "weapon_", 7))
return false;

new iWeapon = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, szWeaponName));

if (!pev_valid(iWeapon))
return false;

if (bDrop)
{
new szWeapon[ 32 ],
iSlot = ExecuteHamB(Ham_Item_ItemSlot, iWeapon),
iItem = get_pdata_cbase(iPlayer, 367 + iSlot, 5);

while ((pev_valid(iItem) == 2))
{
pev(iItem, pev_classname, szWeapon, charsmax(szWeapon));

switch(DROP_TYPE)
{
case 1: engclient_cmd(iPlayer, "drop", szWeapon);
case 2: ham_strip_weapon(iPlayer, szWeapon);
}

iItem = get_pdata_cbase(iItem, 42, 4);
}
}

set_pev(iWeapon, pev_spawnflags, pev(iWeapon, pev_spawnflags) | SF_NORESPAWN);

if (iKey > 0) set_pev(iWeapon, pev_impulse, iKey);
if (iAmmo > 0) cs_set_user_bpammo(iPlayer, get_weaponid(szWeaponName), iAmmo);

dllfunc(DLLFunc_Spawn, iWeapon);
dllfunc(DLLFunc_Touch, iWeapon, iPlayer);

return true;
}

stock ham_strip_weapon(id, weapon[])
{
if(!equal(weapon,"weapon_",7)) return 0

new wId = get_weaponid(weapon)
if(!wId) return 0

new wEnt
while((wEnt = engfunc(EngFunc_FindEntityByString, wEnt, "classname", weapon)) && pev(wEnt, pev_owner) != id) {}
if(!wEnt) return 0

new iTmp
if(get_user_weapon(id, iTmp, iTmp) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon, wEnt)

if(!ExecuteHamB(Ham_RemovePlayerItem, id, any:wEnt)) return 0

ExecuteHamB(Ham_Item_Kill, wEnt)
set_pev(id, pev_weapons, pev(id, pev_weapons) & ~(1<<wId))

return 1
}

stock GetUserFlags(const iPlayer)
{
if (!is_user_connected(iPlayer))
return -1;

new iFlags = get_user_flags(iPlayer);
new iReturnBit;

if (iFlags & read_flags(VipFlagGold))
{
iVipFlag[iPlayer] = ViPGold;
iReturnBit = ViPGold;
}
else if (iFlags & read_flags(VipFlag))
{
iVipFlag[iPlayer] = ViP;
iReturnBit = ViP;
}
else
{
iVipFlag[iPlayer] = Null;
iReturnBit = Null;
}

return iReturnBit;
}

stock UtilChatColor(const iPlayer, const szInput[], any:...)
{
new iCount = 1, szPlayers[32];
static szMessage[191];

vformat(szMessage, charsmax(szMessage), szInput, 3);

replace_all(szMessage, charsmax(szMessage), "!g", "^4"); // Green Color
replace_all(szMessage, charsmax(szMessage), "!y", "^1"); // Default Color
replace_all(szMessage, charsmax(szMessage), "!team", "^3"); // Team Color

static g_SayText;
if (!g_SayText) g_SayText = get_user_msgid("SayText");

if(iPlayer) szPlayers[0] = iPlayer; else get_players(szPlayers, iCount, "ch");
{
for(new i = 0; i < iCount; i++)
{
if(!is_user_connected(szPlayers)) continue;

message_begin(MSG_ONE_UNRELIABLE, g_SayText, _, szPlayers);
write_byte(szPlayers);
write_string(szMessage);
message_end();
}
}
}
 
Сообщения
3,010
Реакции
1,730
Помог
79 раз(а)
Mihail45,
В данном разделе размещаются темы, в которых требуется помощь с доработкой или объяснением материала.
В теме должны быть опубликованы попытки (diff кода или последовательность действий) самостоятельного поиска решения.
Если у вас нет наработок и попыток самому вникнуть в проблему, тогда вам в раздел "Покупка"
 
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу