Raised This Month: $ Target: $400
 0% 

help edit vip plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
vase070
Senior Member
Join Date: Jun 2011
Old 10-14-2017 , 15:38   help edit vip plugin
Reply With Quote #1

so the plugin does not react to sv_restart or sv_restartround and after 2 restarts the vip menu will show anyways, can that be fixed ?

what i mean is every time sv_restart or sv_restartround is used the plugin should count as 0 rounds played

also in the menu where it says "You have % seconds" even if you press 0 the "You have % seconds" part of the menu still stays open until 5 seconds passed

here is the code

Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <cstrike>
#include <fun>
#include <fakemeta_util>
  
#pragma tabsize 0
  
#define PLUGIN "VIP"
#define VERSION "3.8"
#define AUTHOR "Extreem and vinipux"
  
#define VIP_FLAG ADMIN_LEVEL_A
  
static const COLOR[] = "^x04" //green
static const CONTACT[] = ""
new maxplayers
new gmsgSayText
new vipsOnline
new g_awp_active
//Menu Items
new p_Menu_Enable, p_Give_AK47, p_Give_M4A1, p_Give_AWP
  
  
new bool:HasC4[33]
new pistols[6] = {CSW_P228, CSW_ELITE, CSW_FIVESEVEN, CSW_GALIL, CSW_USP, CSW_GLOCK18};
new automaton[18] = 
{CSW_P90,CSW_AK47,CSW_SG552,CSW_G3SG1,CSW_TMP,CSW_M4A1,CSW_M3,CSW_M249,CSW_MP5NAVY,CSW_AWP,CSW_FAMAS,
CSW_SG550,CSW_UMP45,CSW_AUG,CSW_MAC10,CSW_XM1014,CSW_SCOUT,CSW_P228};
 
 
 
new INT_rounds = 0
new timer[33], cvar_menuoff
  
//Start Items
new p_Start_Deagle, p_Start_He, p_Start_Flash, p_Start_Smoke, round_number, g_maxplayers, p_Plugin_Exist, p_Plugin_Exist_Time
public plugin_init() {
   register_plugin(PLUGIN, VERSION, AUTHOR)
   register_clcmd("say /vip", "vipinfo")
   register_clcmd("say /vipka", "vipinfo")
   register_clcmd("say /wantvip", "vipinfo")
   register_clcmd("say /adminka", "vipinfo")
   register_dictionary("viplang.txt")
   new configsDir[64]
   get_configsdir(configsDir, 63)
   register_event("CurWeapon", "event_CurWeapon", "be", "1=1")
   register_clcmd("awp","HandleCmd")
   register_event("HLTV", "EVENT__round_start", "a", "1=0", "2=0")
   p_Menu_Enable = register_cvar("menu_enable", "1")
   p_Give_AK47 = register_cvar("menu_ak47", "1")
   p_Give_M4A1 = register_cvar("menu_m4a1", "1")
   p_Give_AWP = register_cvar("menu_awp", "1")
   p_Start_Deagle = register_cvar("start_deagle", "1")
   p_Start_He = register_cvar("start_hegrenade", "1")
   p_Start_Flash = register_cvar("start_flash", "2")
   p_Start_Smoke = register_cvar("start_smokegrenade","1")
   p_Plugin_Exist = register_cvar("plugin_exist", "1")
   p_Plugin_Exist_Time = register_cvar("plugin_exist_time", "180.0")
   vipsOnline = register_cvar("show_vips", "1")
   RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1);
   register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
   //register_event("TextMsg", "event_game_restart", "a", "2=#Game_Commencing", "2=#Game_will_restart_in")
   g_maxplayers=get_maxplayers()
   maxplayers = get_maxplayers()
   register_clcmd("say", "handle_say")
   register_cvar("amx_contactinfo", CONTACT, FCVAR_SERVER)
   gmsgSayText = get_user_msgid("SayText")
   cvar_menuoff = register_cvar("menuoff", "3")
   g_awp_active = register_cvar("awp_active", "1")
}
stock ChatColor(const id,const input[],any:...)
{
   new count = 1,players[32]
   static msg[191]
   vformat(msg,190,input,3)
     
   replace_all(msg,190,"!g","^4")
   replace_all(msg,190,"!y","^1")
   replace_all(msg,190,"!team","^3")
   replace_all(msg, 190,"!team2","^0")
     
   if(id)players[0] = id;else get_players(players,count,"ch")
   {
      for (new i = 0;i < count;i++)
      {
         if(is_user_connected(players[i]))
         {
            message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("SayText"),_,players[i])
            write_byte(players[i])
            write_string(msg)
            message_end()
         }
      }
   }
}
public EVENT__round_start()
{
   INT_rounds++
}
public HandleCmd(id){
   if (get_pcvar_num(g_awp_active) == 1)
      return PLUGIN_CONTINUE
   if(!(get_user_flags(id) & VIP_FLAG))
      return PLUGIN_CONTINUE
   client_print(id, print_center, "%L", LANG_SERVER, "AWP_ONLY_FOR_VIP")
   return PLUGIN_HANDLED
}
  
public event_CurWeapon(id){
   if (get_pcvar_num(g_awp_active) == 1){
      if(read_data(2) == CSW_AWP){
         if(!(get_user_flags(id) & VIP_FLAG)){
            client_print(id, print_center, "%L", LANG_SERVER, "AWP_ONLY_FOR_VIP")
            client_cmd(id, "drop")
         }
           
         }
      }
   return PLUGIN_HANDLED
}
public mymenu(id){
   if(is_user_alive(id))
{
   timer[id] = get_pcvar_num(cvar_menuoff)
   set_task(1.0, "destroy_menu", id, _, _, "b")
   new MyMenu=menu_create("VIP Menu ^n ^n","vipMenu");
   new MyMenuFun=menu_makecallback("mcbMyMenu");
   new m4a1[150]
   formatex(m4a1, sizeof m4a1 - 1, "%L", id, "MENU_M4A1")
   menu_additem(MyMenu,m4a1,"1",0,MyMenuFun);
   new ak47[150]
   formatex(ak47, sizeof ak47 - 1, "%L", id, "MENU_AK47")
   menu_additem(MyMenu,ak47 ,"2",0,MyMenuFun);
   new awp[150]
   formatex(awp, sizeof awp - 1, "%L", id, "MENU_AWP")
   menu_additem(MyMenu,awp,"3",0,MyMenuFun);
   if(get_user_flags(id) & VIP_FLAG){
      menu_display(id, MyMenu,0);
}
   }
   else{
      ChatColor(id,"%L",LANG_SERVER,"NOT_VIP")
   }
   return PLUGIN_HANDLED;
}
public destroy_menu(id)
{
        if (timer[id])
        {
                new text_timer[64]
                formatex(text_timer, charsmax(text_timer), "You have %d seconds", timer[id]);
                if (timer[id] > 10)
                        set_hudmessage(255, 255, 255, 0.02, 0.42, 0, 0.0, 1.0, 1.0, 1.0)
                else if (timer[id] > 5)
                        set_hudmessage(255, 255, 0, 0.02, 0.42, 0, 0.0, 1.0, 1.0, 1.0)
                else
                        set_hudmessage(255, 0, 0, 0.02, 0.42, 1, 0.0, 1.0, 1.0, 1.0)
                show_hudmessage(id, text_timer)
                --timer[id]
        }
   else
        {
                remove_task(id)
                show_menu(id, 0, "^n", 1) // Убераем меню
        }
}
public vipMenu(id, menu, item)
{
    new data[7], iName[64];
    new access, callback;
      
    menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
      
    new key = str_to_num(data);
      
   switch(key)
{
      case 1:{
// Проверяем на все пистолеты
         for (new i = 0; i < 6; i++)
      {
         // Если у игрока есть пистолет с заданным индексом
         // забираем пистолет и выходим из цикла
         if (fm_strip_user_gun(id, pistols[i]))
         {
            break;
         }
      }
// Проверяем на все автоматы
         for (new i = 0; i < 18; i++)
      {
         // Если у игрока есть пистолет с заданным индексом
         // забираем пистолет и выходим из цикла
         if (fm_strip_user_gun(id, automaton[i]))
         {
            break;
         }
      }
  
         if (user_has_weapon(id, CSW_C4)){
            HasC4[id] = true;
         }
         else{
            HasC4[id] = false;
         }
  
         give_item(id, "weapon_m4a1")
         cs_set_user_bpammo(id, CSW_M4A1, 90)
         give_item(id,"weapon_knife")
         if(get_pcvar_num(p_Start_He) == 1){
            give_item(id,"weapon_hegrenade")
         }        
         if(get_pcvar_num(p_Start_Flash) == 1){
            give_item(id, "weapon_flashbang");
         }
         else if(get_pcvar_num(p_Start_Flash) == 2){
            give_item(id, "weapon_flashbang");
            give_item(id, "weapon_flashbang");
         }
         if(get_pcvar_num(p_Start_Smoke) == 1){
            give_item(id, "weapon_smokegrenade");
         }
         if(get_pcvar_num(p_Start_Deagle) == 1){
            give_item(id,"weapon_deagle")
            cs_set_user_bpammo(id, CSW_DEAGLE, 35)
         }
         else if(cs_get_user_team(id) == CS_TEAM_CT){
            give_item(id, "weapon_usp")
            cs_set_user_bpammo(id, CSW_USP, 24)
         }
         else if (cs_get_user_team(id) == CS_TEAM_T){
            give_item(id, "weapon_glock18")
            cs_set_user_bpammo(id, CSW_GLOCK18, 40)
         }
         give_item(id, "weapon_smokegrenade");
         give_item(id, "item_assaultsuit");
         give_item(id, "item_thighpack");
         if (HasC4[id]){
            give_item(id, "weapon_c4");
            cs_set_user_plant( id );
         }
         ChatColor(id,"%L",LANG_SERVER,"GET_WEAPON_M4A1")
         remove_task(id)
         show_menu(id, 0, "^n", 1) // Убераем меню
   }
      case 2:
{
         for (new i = 0; i < 6; i++)
      {
         // Если у игрока есть пистолет с заданным индексом
         // забираем пистолет и выходим из цикла
         if (fm_strip_user_gun(id, pistols[i]))
         {
            break;
         }
      }
// Проверяем на все автоматы
         for (new i = 0; i < 18; i++)
      {
         // Если у игрока есть пистолет с заданным индексом
         // забираем пистолет и выходим из цикла
         if (fm_strip_user_gun(id, automaton[i]))
         {
            break;
         }
      }
  
         if (user_has_weapon(id, CSW_C4)){
            HasC4[id] = true;
         }
         else{
            HasC4[id] = false;
         }
         give_item(id, "weapon_ak47")
         cs_set_user_bpammo(id, CSW_AK47, 90)
         give_item(id,"weapon_knife")
         if(get_pcvar_num(p_Start_He) == 1){
            give_item(id,"weapon_hegrenade")
         }        
         if(get_pcvar_num(p_Start_Flash) == 1){
            give_item(id, "weapon_flashbang");
         }
         else if(get_pcvar_num(p_Start_Flash) == 2){
            give_item(id, "weapon_flashbang");
            give_item(id, "weapon_flashbang");
         }
         if(get_pcvar_num(p_Start_Smoke) == 1){
            give_item(id, "weapon_smokegrenade");
         }
         if(get_pcvar_num(p_Start_Deagle) == 1){
            give_item(id,"weapon_deagle")
            cs_set_user_bpammo(id, CSW_DEAGLE, 35)
         }
         else if(cs_get_user_team(id) == CS_TEAM_CT){
            give_item(id, "weapon_usp")
            cs_set_user_bpammo(id, CSW_USP, 24)
         }
         else if (cs_get_user_team(id) == CS_TEAM_T){
            give_item(id, "weapon_glock18")
            cs_set_user_bpammo(id, CSW_GLOCK18, 40)
         }
         give_item(id, "weapon_smokegrenade");
         give_item(id, "item_assaultsuit");
         give_item(id, "item_thighpack");
         if (HasC4[id]){
            give_item(id, "weapon_c4");
            cs_set_user_plant( id );
         }
         ChatColor(id,"%L",LANG_SERVER,"GET_WEAPON_AK47")
         remove_task(id)
         show_menu(id, 0, "^n", 1) // Убераем меню
     
}
      case 3:{
            
    if(round_number >= 2)
    {
         for (new i = 0; i < 6; i++)
      {
         // Если у игрока есть пистолет с заданным индексом
         // забираем пистолет и выходим из цикла
         if (fm_strip_user_gun(id, pistols[i]))
         {
            break;
         }
      }
// Проверяем на все автоматы
         for (new i = 0; i < 18; i++)
      {
         // Если у игрока есть пистолет с заданным индексом
         // забираем пистолет и выходим из цикла
         if (fm_strip_user_gun(id, automaton[i]))
         {
            break;
         }
      }
  
         if (user_has_weapon(id, CSW_C4)){
            HasC4[id] = true;
         }
         else{
            HasC4[id] = false;
         }
         give_item(id, "weapon_awp")
         cs_set_user_bpammo(id, CSW_AWP, 30)
         give_item(id,"weapon_knife")
         if(get_pcvar_num(p_Start_He) == 1){
            give_item(id,"weapon_hegrenade")
         }        
         if(get_pcvar_num(p_Start_Flash) == 1){
            give_item(id, "weapon_flashbang");
         }
         else if(get_pcvar_num(p_Start_Flash) == 2){
            give_item(id, "weapon_flashbang");
            give_item(id, "weapon_flashbang");
         }
         if(get_pcvar_num(p_Start_Smoke) == 1){
            give_item(id, "weapon_smokegrenade");
         }
         if(get_pcvar_num(p_Start_Deagle) == 1){
            give_item(id,"weapon_deagle")
            cs_set_user_bpammo(id, CSW_DEAGLE, 35)
         }
         else if(cs_get_user_team(id) == CS_TEAM_CT){
            give_item(id, "weapon_usp")
            cs_set_user_bpammo(id, CSW_USP, 24)
         }
         else if (cs_get_user_team(id) == CS_TEAM_T){
            give_item(id, "weapon_glock18")
            cs_set_user_bpammo(id, CSW_GLOCK18, 40)
         }
         give_item(id, "weapon_smokegrenade");
         give_item(id, "item_assaultsuit");
         give_item(id, "item_thighpack")
         if (HasC4[id]){
            give_item(id, "weapon_c4");
            cs_set_user_plant( id );
         }
         ChatColor(id,"%L",LANG_SERVER,"GET_WEAPON_AWP")
         remove_task(id)
         show_menu(id, 0, "^n", 1) // Убераем меню
    }
               }
                  }
           
}
  
  
public mcbMyMenu(id, menu, item){
   if(item==0){
   if(get_pcvar_num(p_Give_M4A1) != 1){
      return ITEM_DISABLED;
   }
}
   if(item==1){
      if(get_pcvar_num(p_Give_AK47) != 1){
         return ITEM_DISABLED;
      }
   }
   if(item==2){
      if(get_pcvar_num(p_Give_AWP) != 1){
         return ITEM_DISABLED;
      }
   }
   return ITEM_ENABLED;
}
public event_round_start()
{
   if(get_pcvar_num(p_Menu_Enable) == 1){
    round_number++
     
    if (round_number>1)
    {
        for (new id=1;id<=g_maxplayers;id++)
        {
            if (!is_user_connected(id)||is_user_bot(id))
                continue
            if(get_user_flags(id) & VIP_FLAG){
          if(cs_get_user_team(id) == CS_TEAM_CT || CS_TEAM_T){
                   set_task(0.1, "mymenu", id, _, _, "a", 1)
  
      }
      }
        }
    }
   }
}
public event_game_restart()
{
    round_number=0
}
public fwHamPlayerSpawnPost(id)
      if(get_user_flags(id) & VIP_FLAG)
{
{
      for (new i = 0; i < 6; i++)
      {
         // Если у игрока есть пистолет с заданным индексом
         // забираем пистолет и выходим из цикла
      if (fm_strip_user_gun(id, pistols[i]))
         {
            break;
         }
      }
}
      if(is_user_connected(id) && get_user_flags(id) & VIP_FLAG)
{
      give_item(id,"weapon_knife")
      if(get_pcvar_num(p_Start_Deagle) == 1){
            give_item(id,"weapon_deagle")
            cs_set_user_bpammo(id, CSW_DEAGLE, 35)
      }
      else if(cs_get_user_team(id) == CS_TEAM_CT){
         give_item(id, "weapon_usp")
         cs_set_user_bpammo(id, CSW_USP, 24)
      }
      else if (cs_get_user_team(id) == CS_TEAM_T){
         give_item(id, "weapon_glock18")
         cs_set_user_bpammo(id, CSW_GLOCK18, 40)
      }
      if(get_pcvar_num(p_Start_He) == 1){
         give_item(id, "weapon_hegrenade")
      }
      if(get_pcvar_num(p_Start_Flash) == 1){
         give_item(id, "weapon_flashbang")
      }
      else if(get_pcvar_num(p_Start_Flash) == 2){
         give_item(id, "weapon_flashbang")
         give_item(id, "weapon_flashbang")
      }
      if(get_pcvar_num(p_Start_Smoke) == 1){
         give_item(id, "weapon_smokegrenade")
      }
   }
}
public vipinfo(id){
   show_motd(id, "admin.html")
}
public client_authorized(id)
{
   if(get_pcvar_num(p_Plugin_Exist) == 1){
         set_task(get_pcvar_float(p_Plugin_Exist_Time), "vipInfoMessage", id, _, _, "b")
   }
}
public vipInfoMessage(id)
{
   if(!is_user_admin(id))
   ChatColor(id,"%L",LANG_SERVER,"INFO_VIP_PLUGIN_EXIST")
     
}
public handle_say(id) {
   new said[192]
   read_args(said,192)
   if( ( containi(said, "who") != -1 && containi(said, "admin") != -1 ) || contain(said, "/admin") != -1 )
      set_task(0.1,"print_adminlist",id)
   return PLUGIN_CONTINUE
}
  
public print_adminlist(user)
{
   if(get_pcvar_num(vipsOnline) == 1){
   new adminnames[33][32]
   new message[256]
   new contactinfo[256], contact[112]
   new id, count, x, len
     
   for(id = 1; id <= maxplayers; id++)
      if(is_user_connected(id))
         if(get_user_flags(id) & VIP_FLAG)
            get_user_name(id, adminnames[count++], 31)
  
   len = format(message, 255, "%s Админы онлайн: ",COLOR)
   if(count > 0) {
      for(x = 0; x < count; x++) {
         len += format(message[len], 255-len, "%s%s ", adminnames[x], x < (count-1) ? ", ":"")
         if(len > 96 ) {
            print_message(user, message)
            len = format(message, 255, "%s ",COLOR)
         }
      }
      print_message(user, message)
   }
   else {
      len += format(message[len], 255-len, "%L", LANG_SERVER,"NO_VIPS_ONLLINE")
      print_message(user, message)
   }
     
   get_cvar_string("amx_contactinfo", contact, 63)
   if(contact[0])  {
      format(contactinfo, 111, "%s Связь с главным админом -- %s", COLOR, contact)
      print_message(user, contactinfo)
   }
}
}
print_message(id, msg[]) {
   message_begin(MSG_ONE, gmsgSayText, {0,0,0}, id)
   write_byte(id)
   write_string(msg)
   message_end()
}
vase070 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:50.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode