ikjhn999
Пользователь
- Регистрация
- 8 Апр 2018
- Сообщения
- 38
- Симпатии
- 1
- Пол
- Мужской
Здравствуйте!
Помоги пожалуйста добавить команду,что бы VIPmenu открывалось не только через консоль команду (vipmenu) но и что бы он открывалось автоматически,каждый раунд.
p.s Там стоит команда,что бы VIPка работала с 2 раунда.
я не особо щарю,боюсь накосячить
Помоги пожалуйста добавить команду,что бы VIPmenu открывалось не только через консоль команду (vipmenu) но и что бы он открывалось автоматически,каждый раунд.
p.s Там стоит команда,что бы VIPка работала с 2 раунда.
C++:
#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 MinRoundToOpenMenu 2
#define AWP_LIMIT 10
#define AK47_LIMIT 7
#define M4A1_LIMIT 5
#define Damage_Awp 1.1
#define Damage_Ak4 1.2
#define Damage_M4A1 1.2
#define Damage_Deagle 2.0
#define DROP_TYPE 2 // 1 - обычный дроп. 2 - удаляется из рук вообще
new szGoldV[eGoldList][32] = {
"models/gold/v_knife.mdl",
"models/gold/v_deagle.mdl",
"models/gold/v_awp.mdl",
"models/gold/v_ak47.mdl",
"models/gold/v_m4a1.mdl"
};
new szGoldP[eGoldList][32] = {
"models/gold/p_knife.mdl",
"models/gold/p_deagle.mdl",
"models/gold/p_awp.mdl",
"models/gold/p_ak47.mdl",
"models/gold/p_m4a1.mdl"
};
new szGoldW[eGoldList][32] = {
"",
"models/gold/w_deagle.mdl",
"models/gold/w_awp.mdl",
"models/gold/w_ak47.mdl",
"models/gold/w_m4a1.mdl"
};
enum _:eKeyGold{
_Deagle = 36895,
_Awp,
_Ak47,
_M4A1
};
enum _:eGoldCost{
Cost_Awp = 300,
Cost_Ak4 = 200,
Cost_M4A1 = 100
};
new iVipFlag[33], bool:bDefuse, iRoundNum;
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, "weapon_ak47", "HamHook_Item_AttachToPlayer", false);
RegisterHam(Ham_Touch, "weapon_m4a1", "HamHook_Item_AttachToPlayer", false);
RegisterHam(Ham_Touch, "weapon_awp", "HamHook_Item_AttachToPlayer", false);
RegisterHam(Ham_Touch, "weapon_deagle","HamHook_Item_AttachToPlayer", 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[i][0]) precache_model(szGoldV[i]);
for(new i = 0; i < sizeof(szGoldP); i++) if (szGoldP[i][0]) precache_model(szGoldP[i]);
for(new i = 0; i < sizeof(szGoldW); i++) if (szGoldW[i][0]) precache_model(szGoldW[i]);
}
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++;
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;
}
public HamHook_Item_AttachToPlayer(const iItem, const iPlayer)
{
if (!pev_valid(iItem))
return HAM_IGNORED;
switch(pev(iItem, 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);
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[!yVIP!g] !yМеню не доступно. Жди ещё !team%i !yраунд", MinRoundToOpenMenu - iRoundNum);
return PLUGIN_HANDLED;
}
static szMenu[512], iLen;
iLen = formatex(szMenu, charsmax(szMenu), "\r[\yVIP\r] \wWeaponMenu^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 Gold \r[c %d раунда]^n", AK47_LIMIT);
else
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y4. \wВзять AK47 Gold \y(\r%i$\y)^n", Cost_Ak4);
if(iRoundNum < M4A1_LIMIT)
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y5. \dВзять M4A1 Gold \r[c %d раунда]^n", M4A1_LIMIT);
else
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y5. \wВзять M4A1 Gold \y(\r%i$\y)^n", Cost_M4A1);
if(iRoundNum < AWP_LIMIT)
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y6. \dВзять AWP Gold \r[c %d раунда]^n", AWP_LIMIT);
else
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y6. \wВзять AWP Gold \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;
static szWeaponName[][] = { "", "AK", "M4", "AWP", "Gold AK", "Gold M4", "Gold 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[!yViP!g] !yДоступно только с !g%i !yраунда", iRoundLimit[iNewKey - 3]);
return PLUGIN_HANDLED;
}
if (iMoney < iCost[iNewKey - 3] || iVipFlag[iPlayer] != ViPGold)
{
UtilChatColor(iPlayer, "!g[!yViP!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[i])) continue;
message_begin(MSG_ONE_UNRELIABLE, g_SayText, _, szPlayers[i]);
write_byte(szPlayers[i]);
write_string(szMessage);
message_end();
}
}
}