#include <amxmodx>
#include <reapi>
#define PLUGIN "[ReAPI] IDEAL VIP by Wikiname"
#define VERSION "1.4.8"
#define AUTHOR "Wikiname (Remake from Ba/lePa)"
//------------------------------------ Основные настройки плагина ------------------------------------------//
#define FLAG_ADMIN ADMIN_BAN // Флаг админа (только для уведомлений)
#define FLAG_VIP ADMIN_LEVEL_H // флаг доступа к функциям плагина (доступ к VIP-меню)
#define MUSIC // Если звук при входе админа не нужен, то поставьте // перед #define
//#define NO_THRUE_DAMAGE // Раскомментируйте, чтобы урон показывал только, если видно соперника
//#define EXP_SHOW // Раскомментировать, если используете Admin loader от Neugomon или F@ntom
#if defined EXP_SHOW
#define EXP_SHOW_TYPE 1 // 1 - Admin Loader by Neugomon (2.3), 2 - AdminLoad by Fant0M (3.8.2)
#endif
//------------------------------------------ Конец настроек -----------------------------------------------//
#define VIP_TAG (1<<2)
#define MAX_TEXT_LENGTH 200
#if AMXX_VERSION_NUM < 183
#include <dhudmessage>
#define MAX_NAME_LENGTH 32
#endif
#if defined NO_THRUE_DAMAGE
#include <engine>
#endif
#pragma semicolon 1
new bool:g_bBlockMap;
new g_Round, g_iWeapon[33], g_iVip ;
new cvar_connect, Float: cvar_x, Float: cvar_y;
new cvar_prefix;
new cvar_round, cvar_open, cvar_show, cvar_chat, cvar_pistols, cvar_funk, cvar_tab;
new Float: cvar_health, Float: cvar_health_head, Float: cvar_health_max;
new cvar_hud_hp;
new cvar_money, cvar_money_head;
new cvar_damage;
new cvar_awplimit;
#if defined EXP_SHOW
#if EXP_SHOW_TYPE == 1
native admin_expired(index);
#endif
#if EXP_SHOW_TYPE == 2
native adminload_get_expired(index);
#define admin_expired(%0) adminload_get_expired(%0);
#endif
#endif
new vip_opened[33];
new g_iSyncMsg;
new g_iMaxPlayers = 0;
new msgSayText;
new Float: g_iBuyTime, bool: g_iBuyTimeEnd;
new bool: g_Chosen[33] = false;
new g_PlayerPos[33];
new const Float:g_flCoords[][] = { {0.50, 0.42}, {0.56, 0.44}, {0.58, 0.50}, {0.56, 0.56}, {0.50, 0.58}, {0.44, 0.56}, {0.42, 0.50}, {0.44, 0.44} };
new string[32];
new szCvar[25];
public plugin_precache(){
if(IsBlockMap())
{
g_bBlockMap = true;
return;
}
#if defined MUSIC
precache_sound("IDEAL_VIP/ideal_sound.wav");
#endif
}
public plugin_init(){
register_plugin(PLUGIN, VERSION, AUTHOR);
register_cvar("reapi_ideal_vip_version", VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED);
register_dictionary("ideal_vip.txt");
g_iMaxPlayers = get_maxplayers();
register_message(get_user_msgid( "ScoreAttrib" ), "msgScoreAttrib");
register_event("HLTV", "EventRoundStart", "a", "1=0", "2=0");
register_event("TextMsg", "EventRoundRestart", "a", "2=#Game_will_restart_in","2=#Game_Commencing");
register_event ("Damage", "EventDamage", "b", "2!0");
RegisterHookChain(RG_CBasePlayer_Spawn, "CBasePlayer_Spawn", true);
RegisterHookChain(RG_CBasePlayer_Killed, "CBasePlayer_Killed", true);
register_concmd("nightvision", "MainMenu");
register_concmd("vipmenu", "MainMenu");
register_clcmd("say /vipmenu", "MainMenu");
register_clcmd("say_team /vipmenu", "MainMenu");
register_clcmd("say /vip_menu", "MainMenu");
register_clcmd("say_team /vip_menu", "MainMenu");
register_clcmd("say /vips", "vip_online");
register_clcmd("say_team /vips", "vip_online");
register_clcmd("say /adminka", "admin_motd");
register_clcmd("say_team /adminka", "admin_motd");
register_clcmd("say /vipka", "vip_motd");
register_clcmd("say_team /vipka", "vip_motd");
g_iSyncMsg = CreateHudSyncObj();
msgSayText = get_user_msgid("SayText");
}
public plugin_cfg(){
new szConfigDir[128];
cvar_round = get_pcvar_num(register_cvar("amx_vipround", "2"));
cvar_open = get_pcvar_num(register_cvar("amx_vipzaround", "2"));
cvar_show = get_pcvar_num(register_cvar("amx_vipshow","0"));
cvar_chat = get_pcvar_num(register_cvar("amx_chatshow", "0"));
cvar_pistols = get_pcvar_num(register_cvar("amx_vipautopistols", "1"));
cvar_funk = get_pcvar_num(register_cvar("amx_vipautoset", "1"));
cvar_health = get_pcvar_float(register_cvar("amx_viphealth", "5.0"));
cvar_health_head = get_pcvar_float(register_cvar("amx_viphealth_head", "10.0"));
cvar_health_max = get_pcvar_float(register_cvar("amx_viphealth_max", "100.0"));
cvar_hud_hp = get_pcvar_num(register_cvar("amx_hudhp", "1"));
cvar_money = get_pcvar_num(register_cvar("amx_vipmoney", "300"));
cvar_money_head = get_pcvar_num(register_cvar("amx_vipmoney_head", "500"));
cvar_tab = get_pcvar_num(register_cvar("amx_viptab", "1"));
cvar_x = get_pcvar_float(register_cvar("amx_vipXcoord", "-1.0"));
cvar_y = get_pcvar_float(register_cvar("amx_vipYcoord", "0.6"));
cvar_prefix = register_cvar("amx_vip_prefix", "!g[!tVIP SYSTEM!g]");
cvar_connect = register_cvar("amx_showconnect", "a");
cvar_awplimit = get_pcvar_num(register_cvar("amx_awproundlimit", "3"));
cvar_damage = get_pcvar_num(register_cvar("amx_vipdamager", "1"));
g_iBuyTime = get_cvar_float("mp_buytime");
get_pcvar_string(cvar_prefix, string, charsmax(string));
get_pcvar_string(cvar_connect, szCvar, charsmax(szCvar));
get_localinfo("amxx_configsdir", szConfigDir, charsmax(szConfigDir));
server_cmd("exec %s/ideal_vip.cfg", szConfigDir);
}
public admin_motd(id){
show_motd(id, "adminka.txt", "Как купить админку");
return PLUGIN_CONTINUE;
}
public vip_motd(id){
show_motd(id, "vipka.txt", "Как купить випку");
return PLUGIN_CONTINUE;
}
public client_putinserver(id){
g_iWeapon[id] = 0;
if(IsUserCool(id))
set_task(0.5, "vip_connect", id + 132);
}
public client_disconnected(id){
g_iWeapon[id] = 0;
g_Chosen[id] = false;
}
public vip_connect(TASKID){
new id = TASKID - 132;
#if defined MUSIC
client_cmd(0, "spk IDEAL_VIP/ideal_sound.wav");
#endif
new name[32]; get_user_name(id, name, charsmax(name));
new g_iRgb = random_num(1,255); //рандомные цвета для HUD и DHUD
const SHOW_CHAT = (1 << 0);
const SHOW_HUD = (1 << 1);
const SHOW_DHUD = (1 << 2);
new user_flags = get_user_flags(id) & FLAG_ADMIN;
new show_flags = read_flags(szCvar);
if(show_flags & SHOW_CHAT)
{
ChatColor(0, "%L", id, (user_flags) ? "ADMIN_CONNECT_CHAT" : "VIP_CONNECT_CHAT", string, name);
}
if(show_flags & SHOW_HUD)
{
set_hudmessage(g_iRgb, g_iRgb, g_iRgb, cvar_x, cvar_y, 0, 0.0, 6.0, 0.0, 0.0, -1);
show_hudmessage(0, "%L", id, (user_flags) ? "ADMIN_CONNECT_HUD" : "VIP_CONNECT_HUD", name);
}
if(show_flags & SHOW_DHUD)
{
set_dhudmessage(g_iRgb, g_iRgb, g_iRgb, cvar_x, cvar_y, 1, 0.0, 6.0, 0.0, 0.0);
show_dhudmessage(0, "%L", id, (user_flags) ? "ADMIN_CONNECT_HUD" : "VIP_CONNECT_HUD", name);
}
}
public EventRoundStart()
{
set_task(g_iBuyTime * 60.0, "offBuyTime");
g_iBuyTimeEnd = false;
g_Round++;
}
public offBuyTime() g_iBuyTimeEnd = true;
public EventRoundRestart() g_Round = 0;
public CBasePlayer_Spawn(const id)
{
vip_opened[id] = 0;
if(!g_bBlockMap)
{
if(IsUserCool(id))
{
if(g_Round == 0) FirstMenu(id);
if(is_user_alive(id))
{
if(cvar_funk == 1) task_funk(id);
if(cvar_show == 1 && !get_member(id, m_bHasPrimary) && g_Round >= cvar_round) MainMenu(id);
}
}
}
}
public CBasePlayer_Killed(iVictim, iKiller)
{
if(!g_bBlockMap)
{
if(IsUserCool(iVictim))
if(!g_Chosen[iVictim])
set_task(1.0, "FirstMenu", iVictim);
}
if(IsUserCool(iKiller))
{
if(is_user_alive(iKiller))
{
static Float:attackerHp, Float:addHp;
attackerHp = Float:get_entvar(iKiller, var_health);
addHp = get_member(iVictim, m_bHeadshotKilled) ? cvar_health_head : cvar_health;
attackerHp += addHp;
if (cvar_hud_hp == 1)
{
set_hudmessage(0, 255, 0, -1.0, 0.20, 0, 1.0, 1.0, 0.1, 0.1, -1);
ShowSyncHudMsg(iKiller, g_iSyncMsg, "+%d HP ( VIP )", floatround(addHp));
}
if ( get_member(iVictim, m_bHeadshotKilled) )
rg_add_account(iKiller, cvar_money_head, AS_ADD, true);
else
rg_add_account(iKiller, cvar_money, AS_ADD, true);
set_entvar(iKiller, var_health, attackerHp > cvar_health_max ? cvar_health_max : attackerHp);
if(attackerHp >= cvar_health_max) return HC_CONTINUE;
}
}
return HC_CONTINUE;
}
public EventDamage(iVictim)
{
if(cvar_damage == 0) return;
static iKiller;
iKiller = get_user_attacker(iVictim);
if (cvar_damage != 2)
if(!IsUserCool(iKiller)) return;
if(!iVictim || iVictim > g_iMaxPlayers) return;
if(!iKiller || iKiller > g_iMaxPlayers) return;
if(iVictim == iKiller) return;
#if defined NO_THRUE_DAMAGE
if(!ent_sees_ent(iKiller, iVictim)) return;
#endif
new iPos = ++g_PlayerPos[iKiller];
if(iPos == sizeof(g_flCoords))
{
iPos = g_PlayerPos[iKiller] = 0;
}
set_hudmessage(random(255), random(255), random(255), Float:g_flCoords[iPos][0], Float:g_flCoords[iPos][1], 0, 0.0, 1.0, 0.0, 0.0);
ShowSyncHudMsg(iKiller, g_iSyncMsg, "%i^n", read_data(2));
}
GiveDefaultItems( id, secondary_weapon, itask = 1 ) {
if( itask ) task_funk(id);
switch( secondary_weapon ) {
case 0: {
FirstMenu(id);
}
case 1: {
rg_give_item(id, "weapon_deagle", GT_REPLACE);
rg_set_user_bpammo(id, WEAPON_DEAGLE, 35);
}
case 2: {
rg_give_item(id, "weapon_glock18", GT_REPLACE);
rg_set_user_bpammo(id, WEAPON_GLOCK18, 120);
}
case 3: {
rg_give_item(id, "weapon_usp", GT_REPLACE);
rg_set_user_bpammo(id, WEAPON_USP, 100);
}
}
}
public task_funk(id){
rg_give_item(id, "weapon_knife", GT_REPLACE);
rg_give_item(id, "item_thighpack");
rg_give_item(id, "weapon_hegrenade");
rg_give_item(id, "weapon_flashbang");
rg_give_item(id, "weapon_flashbang");
rg_give_item(id, "weapon_smokegrenade");
rg_give_item(id, "item_assaultsuit", GT_REPLACE);
if(cvar_pistols)
{
GiveDefaultItems( id, g_iWeapon[id], .itask = 0);
}
}
public MainMenu(id){
new signals[2]; get_member(id, m_signals, signals);
if(g_bBlockMap)
{
ChatColor(id, "%L", id, "VIP_WARNING6", string);
}
else if(!IsUserCool(id))
{
ChatColor(id, "%L", id, "VIP_WARNING4", string);
}
else if(g_iBuyTimeEnd)
{
ChatColor(id, "%L", id, "VIP_WARNING8", string);
}
else if(!(signals[1] & (1 << 0)))
{
ChatColor(id, "%L", id, "VIP_WARNING9", string);
}
else
{
if(is_user_alive(id))
{
if(vip_opened[id] < cvar_open || cvar_open == 0)
{
if(g_Round >= cvar_round)
{
new szTitle[128], szName[32], szPistol[32], szMenuMulti[64];
get_user_name(id, szName, charsmax(szName));
switch(g_iWeapon[id])
{
case 0: szPistol = "NONE";
case 1: szPistol = "Deagle";
case 2: szPistol = "Glock";
case 3: szPistol = "Usp";
}
#if defined EXP_SHOW
new exp = admin_expired(id);
if(exp > 0)
{
new systime = get_systime();
if(exp - systime > 0)
{
if((exp - systime) / 86400 > 0)
formatex(szTitle, charsmax(szTitle), "\rVIP меню \w[\dby Wikiname\w]^n\wПривет, [\y%s\w]^n\wОсталось \y%d \wдней \w[\rVIP\w]\y-\wки ^n", szName, ((exp - systime) / 86400));
else formatex(szTitle, charsmax(szTitle), "\rVIP меню \w[\dby Wikiname\w]^n\wПривет, [\y%s\w]^n\rПоследний \wдень \w[\rVIP\w]\y-\wки ^n", szName);
}
}
else if(exp == 0)
formatex(szTitle, charsmax(szTitle), "\rVIP меню \w[\dby Wikiname\w]^n\wПривет, [\y%s\w]^n\w[\rVIP\w] \y- \wПрава \yбессрочны ^n", szName);
#else
formatex(szTitle, charsmax(szTitle), "\rVIP меню \w[\dby Wikiname\w]^n\wПривет, [\y%s\w]", szName);
#endif
new i_Menu = menu_create(szTitle, "MainMenu_Handler", 1);
formatex(szMenuMulti, charsmax(szMenuMulti), "%L", id, "ITEM_MENU1", szPistol);
menu_additem(i_Menu, szMenuMulti, "1", 0);
formatex(szMenuMulti, charsmax(szMenuMulti), "%L", id, "ITEM_MENU2", szPistol);
menu_additem(i_Menu, szMenuMulti, "2", 0);
formatex(szMenuMulti, charsmax(szMenuMulti), "%L", id, "ITEM_MENU3", szPistol);
menu_additem(i_Menu, szMenuMulti, "3", 0);
formatex(szMenuMulti, charsmax(szMenuMulti), "%L", id, "ITEM_MENU4", szPistol);
menu_additem(i_Menu, szMenuMulti, "4", 0);
formatex(szMenuMulti, charsmax(szMenuMulti), "%L", id, "ITEM_MENU5", szPistol);
menu_additem(i_Menu, szMenuMulti, "5", 0);
menu_addblank(i_Menu, 0);
formatex(szMenuMulti, charsmax(szMenuMulti), "%L", id, "ITEM_MENU6");
menu_additem(i_Menu, szMenuMulti, "6", 0);
menu_addblank(i_Menu, 1);
menu_setprop(i_Menu, MPROP_EXITNAME, "\rВыход");
menu_display(id, i_Menu, 0);
}
else
{
if(cvar_round == 2)
{
ChatColor(id, "%L", id, "VIP_WARNING5", string, cvar_round);
return PLUGIN_HANDLED;
}
else
{
ChatColor(id, "%L", id, "VIP_WARNING1", string, cvar_round);
return PLUGIN_HANDLED;
}
}
}
else
ChatColor(id, "%L", id, "VIP_WARNING2", string);
}
else
ChatColor(id, "%L", id, "VIP_WARNING3", string);
}
return PLUGIN_HANDLED;
}
public MainMenu_Handler(id, iMenu, item){
if(item == MENU_EXIT)
{
menu_destroy(iMenu);
return PLUGIN_HANDLED;
}
new szData[6], szName[60], iAccess, iCallback;
menu_item_getinfo(iMenu, item, iAccess, szData, charsmax(szData), szName, charsmax(szName), iCallback);
get_user_name(id, szName, charsmax(szName));
new iKey = str_to_num(szData);
if (iKey !=3)
{
vip_opened[id]++;
GiveDefaultItems( id, g_iWeapon[id] );
}
switch(iKey)
{
case 1:
{
rg_give_item(id, "weapon_m4a1", GT_REPLACE);
rg_set_user_bpammo(id, WEAPON_M4A1, 90);
if(cvar_chat == 1)
ChatColor(0, "%L", id, "VIP_M4A1", string, szName);
}
case 2:
{
rg_give_item(id, "weapon_ak47", GT_REPLACE);
rg_set_user_bpammo(id, WEAPON_AK47, 90);
if(cvar_chat == 1)
ChatColor(0, "%L", id, "VIP_AK47", string, szName);
}
case 3:
{
if(g_Round >= cvar_awplimit)
{
rg_give_item(id, "weapon_awp", GT_REPLACE);
rg_set_user_bpammo(id, WEAPON_AWP, 30);
vip_opened[id]++;
GiveDefaultItems( id, g_iWeapon[id] );
if(cvar_chat == 1)
ChatColor(0, "%L", id, "VIP_AWP", string, szName);
}
else
{
ChatColor(id, "%L", id, "VIP_WARNING7", string, cvar_awplimit);
}
}
case 4:
{
rg_give_item(id, "weapon_famas", GT_REPLACE);
rg_set_user_bpammo(id, WEAPON_FAMAS, 90);
if(cvar_chat == 1)
ChatColor(0, "%L", id, "VIP_FAMAS", string, szName);
}
case 5:
{
rg_give_item(id, "weapon_scout", GT_REPLACE);
rg_set_user_bpammo(id, WEAPON_SCOUT, 90);
if(cvar_chat == 1)
ChatColor(0, "%L", id, "VIP_SCOUT", string, szName);
}
case 6:
{
FirstMenu(id);
}
}
menu_destroy(iMenu);
return PLUGIN_HANDLED;
}
public FirstMenu(id){
if(!is_user_connected(id))
return;
new i_Menu = menu_create("\yЧто вы предпочитаете?", "FirstMenu_Handler");
menu_additem(i_Menu, "\wDeagle", "1", 0);
menu_additem(i_Menu, "\wGlock", "2", 0);
menu_additem(i_Menu, "\wUsp", "3", 0);
menu_setprop(i_Menu, MPROP_EXITNAME, "\rВыход");
menu_display(id, i_Menu, 0);
}
public FirstMenu_Handler(id, iMenu, item){
if(item == MENU_EXIT)
{
menu_destroy(iMenu);
return PLUGIN_HANDLED;
}
new szData[6], szName[60], iAccess, iCallback;
menu_item_getinfo(iMenu, item, iAccess, szData, charsmax(szData), szName, charsmax(szName), iCallback);
new iKey = str_to_num(szData);
g_Chosen[id] = true;
g_iWeapon[id] = iKey;
switch(iKey)
{
case 1:
{
rg_give_item(id, "weapon_deagle", GT_REPLACE);
rg_set_user_bpammo(id, WEAPON_DEAGLE, 35);
}
case 2:
{
rg_give_item(id, "weapon_glock18", GT_REPLACE);
rg_set_user_bpammo(id, WEAPON_GLOCK18, 120);
}
case 3:
{
rg_give_item(id, "weapon_usp", GT_REPLACE);
rg_set_user_bpammo(id, WEAPON_USP, 100);
}
}
menu_destroy(iMenu);
return PLUGIN_CONTINUE;
}
public msgScoreAttrib(const MsgId, const MsgType, const MsgDest){
if(cvar_tab)
{
if(IsUserCool(get_msg_arg_int(1)) && !get_msg_arg_int(2))
set_msg_arg_int(2, ARG_BYTE, VIP_TAG);
}
}
public vip_online(id){
g_iVip = 0;
new Len, message[512], name[32];
new iPlayer;
for(iPlayer = 1; iPlayer <= g_iMaxPlayers; iPlayer++)
{
if(IsUserCool(iPlayer))
{
g_iVip++;
get_user_name(iPlayer, name, charsmax(name));
if(g_iVip == 1)
Len += format(message[Len], 511 - Len, "%s", name);
else
Len += format(message[Len], 511 - Len, " , %s", name);
}
}
if(g_iVip < 1)
ChatColor(id, "%L", id, "VIP_ONLINE", string);
else
ChatColor(id, "%s !gОнлайн : !t%s", string, message);
}
stock ChatColor(const id, const input[], any:...){
new iCount = 1, iPlayers[32];
static szMsg[191];
vformat(szMsg, 190, input, 3);
replace_all(szMsg, 190, "!g", "^4"); // Green Color
replace_all(szMsg, 190, "!y", "^1"); // Default Color
replace_all(szMsg, 190, "!t", "^3"); // Team Color
if (id) iPlayers[0] = id; else get_players(iPlayers, iCount, "ch");
{
for(new iPlayer = 0; iPlayer < iCount; iPlayer++ )
{
if( is_user_connected(iPlayers[iPlayer]) )
{
message_begin(MSG_ONE_UNRELIABLE, msgSayText, _, iPlayers[iPlayer]);
write_byte(iPlayers[iPlayer]);
write_string(szMsg);
message_end();
}
}
}
}
stock IsBlockMap(){
new got_line, line_num, len;
new cfgdir[MAX_TEXT_LENGTH];
new cfgpath[MAX_TEXT_LENGTH];
new mapname[MAX_NAME_LENGTH];
new txt[MAX_TEXT_LENGTH];
get_localinfo("amxx_configsdir", cfgdir, charsmax(cfgdir));
get_mapname(mapname, MAX_NAME_LENGTH-1);
format(cfgpath, MAX_TEXT_LENGTH, "%s/ideal_block_maps.ini", cfgdir);
if (file_exists(cfgpath))
{
got_line = read_file(cfgpath, line_num, txt, MAX_TEXT_LENGTH-1, len);
while (got_line>0)
{
if (equali(txt, mapname)) return 1;
line_num++;
got_line = read_file(cfgpath, line_num, txt, MAX_TEXT_LENGTH-1, len);
}
}
return 0;
}
stock bool: IsUserCool(const id){
if(!is_user_connected(id))
return false;
if((get_user_flags(id) & FLAG_VIP))
return true;
return false;
}
stock bool:ent_sees_ent(iEnt, iEnt2)
{
static Float:fEntOrigin[3], Float:fEnt2Origin[3], Float:fResult[3];
entity_get_vector(iEnt, EV_VEC_origin, fEntOrigin);
entity_get_vector(iEnt2, EV_VEC_origin, fEnt2Origin);
return trace_line(iEnt, fEntOrigin, fEnt2Origin, fResult) == iEnt2;
}