Правила форума Гаранты форума
Размещение рекламы AMX-X компилятор

Здравствуйте, гость Вход | Регистрация

Наши новости:

14-дек
24-апр
10-апр
11-апр

Voteban

, Переделать Voteban [РЕШЕНО]
Статус пользователя lemonzik
сообщение 20.4.2015, 18:17
Сообщение #1
Стаж: 11 лет

Сообщений: 126
Благодарностей: 5
Полезность: < 0

Народ, помогите пожалуйста сделать так, чтобы вотебаном мог пользоваться только тот, у кого есть флаг "t"

Думаю это не трудно будет сделать)
Прикрепленные файлы:
Прикрепленный файл  h_voteban.sma ( 6,88 килобайт ) Кол-во скачиваний: 38
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   Цитировать сообщение
Статус пользователя khanter
сообщение 21.4.2015, 15:49
Сообщение #2
Стаж: 11 лет

Сообщений: 10
Благодарностей: 1
Полезность: 0

Код:
Код
#include <amxmodx>
#include <amxmisc>
#include <colorchat>

#define MAX_players 32
#define MAX_menudata 1024
const _FlagAccess                 =        ADMIN_LEVEL_H;

new ga_PlayerName[MAX_players][32]
new ga_PlayerAuthID[MAX_players][35]
new ga_PlayerID[MAX_players]
new ga_PlayerIP[MAX_players][16]
new ga_MenuData[MAX_menudata]
new ga_Choice[2]
new gi_VoteStarter
new gi_MenuPosition
new gi_Sellection
new gi_TotalPlayers
new gi_SysTimeOffset = 0
new i
//pcvars
new gi_LastTime
new gi_DelayTime
new gf_Ratio
new gf_MinVoters
new gf_BF_Ratio
new gi_BanTime
new gi_Disable
new gi_BanType
new gi_BanReason
new banReasonCvar[32]


public plugin_init()
{
  register_plugin("voteban menu","1.2","hjvl")
  register_clcmd("say /voteban","SayIt" )
  register_clcmd("say voteban","SayIt" )
  register_clcmd("say_team /voteban","SayIt" )
  register_clcmd("say_tam voteban","SayIt" )
  register_menucmd(register_menuid("ChoosePlayer"), 1023, "ChooseMenu")
  register_menucmd(register_menuid("VoteMenu"), 1023, "CountVotes")

  gi_LastTime=register_cvar("amx_voteban_lasttime","0")
  gi_DelayTime=register_cvar("amxx_voteban_delaytime","60")
  gf_Ratio=register_cvar("amxx_voteban_ratio","0.50")
  gf_MinVoters=register_cvar("amxx_voteban_minvoters","0.0")
  gf_BF_Ratio=register_cvar("amxx_voteban_bf_ratio","0.0")
  gi_BanTime=register_cvar("amxx_voteban_bantime","5")
  gi_Disable=register_cvar("amxx_voteban_disable","0")
  gi_BanType=register_cvar("amxx_voteban_type","2")
  gi_BanReason=register_cvar("amxx_voteban_reason","Забанен через VoteBan")
}

public SayIt(id)
{
  if(get_pcvar_num(gi_Disable))
  {
    ColorChat(id, RED, "^x01[^x04Voteban|Бот^x01] ^x03 VoteBan выключен на сервере!")
    return 0
  }

  new Elapsed=get_systime(gi_SysTimeOffset) - get_pcvar_num(gi_LastTime)
  new Delay=get_pcvar_num(gi_DelayTime)

  if( (Delay > Elapsed) && !is_user_admin(id) )
  {
    new seconds = Delay - Elapsed
    ColorChat(id, RED, "^x01[^x04Voteban|Бот^x01] ^x01 Подождите ^x03 %d секунд ^x01 до следующего голосования за бан игрока!", seconds)
    return 0
  }

  get_players( ga_PlayerID, gi_TotalPlayers )
  for(i=0; i<gi_TotalPlayers; i++)
  {
    new TempID = ga_PlayerID[i]
    if( is_user_admin(TempID))
    {
      if(!is_user_admin(id))
      {
        client_print(id,print_chat,"^x01[^x04Voteban|Бот^x01] ^x01 На сервере присутствует ^x04 Администрация! ^x01 Voteban ^x03 [выключен]")
        return 0
      }
    }

    if(TempID == id)
      gi_VoteStarter=i

    get_user_name( TempID, ga_PlayerName[i], 31 )
    get_user_authid( TempID, ga_PlayerAuthID[i], 34 )
    get_user_ip( TempID, ga_PlayerIP[i], 15, 1 )
  }

  gi_MenuPosition = 0
  ShowPlayerMenu(id)
  return 0
}

public ShowPlayerMenu(id)
{
    if( ~get_user_flags( id ) & _FlagAccess )
    return PLUGIN_CONTINUE;
  new arrayloc = 0
  new keys = (1<<9)

  arrayloc = format(ga_MenuData,(MAX_menudata-1),"VoteBan Меню ^n")
  for(i=0; i<8; i++)
   if( gi_TotalPlayers>(gi_MenuPosition+i) )
   {
     arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"%d. %s^n", i+1, ga_PlayerName[gi_MenuPosition+i])
     keys |= (1<<i)
   }
  if( gi_TotalPlayers>(gi_MenuPosition+8) )
  {
    arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"^n9. Далее")
    keys |= (1<<8)
  }
  arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"^n0. Назад/Выход")

  show_menu(id, keys, ga_MenuData, 20, "ChoosePlayer")
  return PLUGIN_HANDLED
}

public ChooseMenu(id, key)
{
  switch(key)
  {
    case 8:
    {
      gi_MenuPosition=gi_MenuPosition+8
      ShowPlayerMenu(id)
    }
    case 9:
    {
      if(gi_MenuPosition>=8)
      {
        gi_MenuPosition=gi_MenuPosition-8
        ShowPlayerMenu(id)
      }
      else
        return 0
    }
    default:
    {
      gi_Sellection=gi_MenuPosition+key
      new Now=get_systime(gi_SysTimeOffset)
      set_pcvar_num(gi_LastTime, Now)

      run_vote()
      return 0
    }
  }
  return PLUGIN_HANDLED
}

public run_vote()
{
  log_amx("Vote ban started by %s for %s %s", ga_PlayerName[gi_VoteStarter], ga_PlayerName[gi_Sellection], ga_PlayerAuthID[gi_Sellection])
  format(ga_MenuData,(MAX_menudata-1),"Забанить %s на %d минут?^n1. Да^n2. Нет",ga_PlayerName[gi_Sellection], get_pcvar_num(gi_BanTime))
  ga_Choice[0] = 0
  ga_Choice[1] = 0
  show_menu( 0, (1<<0)|(1<<1), ga_MenuData, 15, "VoteMenu" )
  set_task(15.0,"outcom")
  return 0
}

public CountVotes(id, key)
{
  ++ga_Choice[key]
  return PLUGIN_HANDLED
}

public outcom()
{
  new TotalVotes = ga_Choice[0] + ga_Choice[1]
  new Float:result = (float(ga_Choice[0]) / float(TotalVotes))

  if( get_pcvar_float(gf_MinVoters) >= ( float(TotalVotes) / float(gi_TotalPlayers) ) )
  {
    ColorChat(0, RED, "^x01[^x04Voteban^x01] ^x01 Не хватает голосов для бана игрока ^x04 %s!", ga_PlayerName[gi_Sellection])
    return 0
  }
  else
  {
    if( result < get_pcvar_float(gf_BF_Ratio) )
    {
      ColorChat(0, RED, "^x01[^x04Voteban^x01] ^x01 Голосование завершено! ^x04 Игрок %s ^x01 забанен на ^x04 %d минут!^x01", ga_PlayerName[gi_VoteStarter], get_pcvar_num(gi_BanTime))
      ActualBan(gi_VoteStarter)
      log_amx("[AMXX] The vote back fired at %s, he is banned for %d minutes", ga_PlayerName[gi_VoteStarter], get_pcvar_num(gi_BanTime))
    }

    if( result >= get_pcvar_float(gf_Ratio) )
    {
      ColorChat(0, RED, "^x01[^x04Voteban^x01] ^x01 Голосование завершено! ^x04 Игрок %s ^x01 забанен на ^x04 %d минут!^x01", ga_PlayerName[gi_Sellection], get_pcvar_num(gi_BanTime))
      log_amx("[AMXX] The vote succeeded: %s is banned for %d minutes", ga_PlayerAuthID[gi_Sellection], get_pcvar_num(gi_BanTime))
      ActualBan(gi_Sellection)
    }
    else
    {
      ColorChat(0, RED, "^x01[^x04Voteban^x01] ^x03 Голосование не состоялось!")
      log_amx("[AMXX] The voteban dit not sucseed.")
    }
  }
  ColorChat(0, RED, "^x01[^x04Voteban^x01] ^x01 Всего проголосовало: ^x04 %d игроков, ^x04 %d ^x01 из них проголосовали ^x03 ЗА!", gi_TotalPlayers, ga_Choice[0])

  return 0
}

public ActualBan(Selected)
{
  new Type = get_pcvar_num(gi_BanType)
  switch(Type)
  {
    case 1:
      server_cmd("addip %d %s", get_pcvar_num(gi_BanTime), ga_PlayerIP[Selected])
    case 2:
      server_cmd("amx_ban %d %s", get_pcvar_num(gi_BanTime), ga_PlayerAuthID[Selected])
    case 3: {
      get_pcvar_string(gi_BanReason, banReasonCvar, charsmax(banReasonCvar))
      server_cmd("amx_bancs ^"%s^" %d ^"%s^"", ga_PlayerName[Selected], get_pcvar_num(gi_BanTime), banReasonCvar)
    }
    default:
      server_cmd("banid %d %s kick", get_pcvar_num(gi_BanTime), ga_PlayerAuthID[Selected])
  }
  return 0
}


Отредактировал: khanter, - 21.4.2015, 15:49
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя oxoTHuk.
сообщение 21.4.2015, 15:51
Сообщение #3


Иконка группы

Стаж: 17 лет

Сообщений: 879
Благодарностей: 515
Полезность: 867

Я себе поставил проверку на стим =)))
Только игрока со стимом могут вызывать голосование, флаг не удобно =)
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя lemonzik
сообщение 21.4.2015, 16:42
Сообщение #4
Стаж: 11 лет

Сообщений: 126
Благодарностей: 5
Полезность: < 0

khanter,

Отредактировал: Bloo, - 21.4.2015, 19:23
Причина: Выдано устное предупреждение!
Прикрепленные файлы:
Прикрепленное изображение
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя kokc
сообщение 21.4.2015, 16:55
Сообщение #5


Стаж: 12 лет

Сообщений: 50
Благодарностей: 8
Полезность: 13

Код:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>

#define MAX_players 32
#define MAX_menudata 1024
const _FlagAccess = ADMIN_LEVEL_H;

new ga_PlayerName[MAX_players][32]
new ga_PlayerAuthID[MAX_players][35]
new ga_PlayerID[MAX_players]
new ga_PlayerIP[MAX_players][16]
new ga_MenuData[MAX_menudata]
new ga_Choice[2]
new gi_VoteStarter
new gi_MenuPosition
new gi_Sellection
new gi_TotalPlayers
new gi_SysTimeOffset = 0
new i
//pcvars
new gi_LastTime
new gi_DelayTime
new gf_Ratio
new gf_MinVoters
new gf_BF_Ratio
new gi_BanTime
new gi_Disable
new gi_BanType
new gi_BanReason
new banReasonCvar[32]


public plugin_init()
{
register_plugin("voteban menu","1.2","hjvl")
register_clcmd("say /voteban","SayIt" )
register_clcmd("say voteban","SayIt" )
register_clcmd("say_team /voteban","SayIt" )
register_clcmd("say_tam voteban","SayIt" )
register_menucmd(register_menuid("ChoosePlayer"), 1023, "ChooseMenu")
register_menucmd(register_menuid("VoteMenu"), 1023, "CountVotes")

gi_LastTime=register_cvar("amx_voteban_lasttime","0")
gi_DelayTime=register_cvar("amxx_voteban_delaytime","60")
gf_Ratio=register_cvar("amxx_voteban_ratio","0.50")
gf_MinVoters=register_cvar("amxx_voteban_minvoters","0.0")
gf_BF_Ratio=register_cvar("amxx_voteban_bf_ratio","0.0")
gi_BanTime=register_cvar("amxx_voteban_bantime","5")
gi_Disable=register_cvar("amxx_voteban_disable","0")
gi_BanType=register_cvar("amxx_voteban_type","2")
gi_BanReason=register_cvar("amxx_voteban_reason","Забанен через VoteBan")
}

public SayIt(id)
{
if(get_pcvar_num(gi_Disable))
{
ColorChat(id, RED, "^x01[^x04Voteban|Бот^x01] ^x03 VoteBan выключен на сервере!")
return 0
}

new Elapsed=get_systime(gi_SysTimeOffset) - get_pcvar_num(gi_LastTime)
new Delay=get_pcvar_num(gi_DelayTime)

if( (Delay > Elapsed) && !is_user_admin(id) )
{
new seconds = Delay - Elapsed
ColorChat(id, RED, "^x01[^x04Voteban|Бот^x01] ^x01 Подождите ^x03 %d секунд ^x01 до следующего голосования за бан игрока!", seconds)
return 0
}

get_players( ga_PlayerID, gi_TotalPlayers )
for(i=0; i<gi_TotalPlayers; i++)
{
new TempID = ga_PlayerID[i]
if( is_user_admin(TempID))
{
if(!is_user_admin(id))
{
client_print(id,print_chat,"^x01[^x04Voteban|Бот^x01] ^x01 На сервере присутствует ^x04 Администрация! ^x01 Voteban ^x03 [выключен]")
return 0
}
}

if(TempID == id)
gi_VoteStarter=i

get_user_name( TempID, ga_PlayerName[i], 31 )
get_user_authid( TempID, ga_PlayerAuthID[i], 34 )
get_user_ip( TempID, ga_PlayerIP[i], 15, 1 )
}

gi_MenuPosition = 0
ShowPlayerMenu(id)
return 0
}

public ShowPlayerMenu(id)
{
if( ~get_user_flags( id ) & _FlagAccess )
return PLUGIN_CONTINUE;
new arrayloc = 0
new keys = (1<<9)

arrayloc = format(ga_MenuData,(MAX_menudata-1),"VoteBan Меню ^n")
for(i=0; i<8; i++)
if( gi_TotalPlayers>(gi_MenuPosition+i) )
{
arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"%d. %s^n", i+1, ga_PlayerName[gi_MenuPosition+i])
keys |= (1<<i)
}
if( gi_TotalPlayers>(gi_MenuPosition+8) )
{
arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"^n9. Далее")
keys |= (1<<8)
}
arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"^n0. Назад/Выход")

show_menu(id, keys, ga_MenuData, 20, "ChoosePlayer")
return PLUGIN_HANDLED
}

public ChooseMenu(id, key)
{
switch(key)
{
case 8:
{
gi_MenuPosition=gi_MenuPosition+8
ShowPlayerMenu(id)
}
case 9:
{
if(gi_MenuPosition>=8)
{
gi_MenuPosition=gi_MenuPosition-8
ShowPlayerMenu(id)
}
else
return 0
}
default:
{
gi_Sellection=gi_MenuPosition+key
new Now=get_systime(gi_SysTimeOffset)
set_pcvar_num(gi_LastTime, Now)

run_vote()
return 0
}
}
return PLUGIN_HANDLED
}

public run_vote()
{
log_amx("Vote ban started by %s for %s %s", ga_PlayerName[gi_VoteStarter], ga_PlayerName[gi_Sellection], ga_PlayerAuthID[gi_Sellection])
format(ga_MenuData,(MAX_menudata-1),"Забанить %s на %d минут?^n1. Да^n2. Нет",ga_PlayerName[gi_Sellection], get_pcvar_num(gi_BanTime))
ga_Choice[0] = 0
ga_Choice[1] = 0
show_menu( 0, (1<<0)|(1<<1), ga_MenuData, 15, "VoteMenu" )
set_task(15.0,"outcom")
return 0
}

public CountVotes(id, key)
{
++ga_Choice[key]
return PLUGIN_HANDLED
}

public outcom()
{
new TotalVotes = ga_Choice[0] + ga_Choice[1]
new Float:result = (float(ga_Choice[0]) / float(TotalVotes))

if( get_pcvar_float(gf_MinVoters) >= ( float(TotalVotes) / float(gi_TotalPlayers) ) )
{
ColorChat(0, RED, "^x01[^x04Voteban^x01] ^x01 Не хватает голосов для бана игрока ^x04 %s!", ga_PlayerName[gi_Sellection])
return 0
}
else
{
if( result < get_pcvar_float(gf_BF_Ratio) )
{
ColorChat(0, RED, "^x01[^x04Voteban^x01] ^x01 Голосование завершено! ^x04 Игрок %s ^x01 забанен на ^x04 %d минут!^x01", ga_PlayerName[gi_VoteStarter], get_pcvar_num(gi_BanTime))
ActualBan(gi_VoteStarter)
log_amx("[AMXX] The vote back fired at %s, he is banned for %d minutes", ga_PlayerName[gi_VoteStarter], get_pcvar_num(gi_BanTime))
}

if( result >= get_pcvar_float(gf_Ratio) )
{
ColorChat(0, RED, "^x01[^x04Voteban^x01] ^x01 Голосование завершено! ^x04 Игрок %s ^x01 забанен на ^x04 %d минут!^x01", ga_PlayerName[gi_Sellection], get_pcvar_num(gi_BanTime))
log_amx("[AMXX] The vote succeeded: %s is banned for %d minutes", ga_PlayerAuthID[gi_Sellection], get_pcvar_num(gi_BanTime))
ActualBan(gi_Sellection)
}
else
{
ColorChat(0, RED, "^x01[^x04Voteban^x01] ^x03 Голосование не состоялось!")
log_amx("[AMXX] The voteban dit not sucseed.")
}
}
ColorChat(0, RED, "^x01[^x04Voteban^x01] ^x01 Всего проголосовало: ^x04 %d игроков, ^x04 %d ^x01 из них проголосовали ^x03 ЗА!", gi_TotalPlayers, ga_Choice[0])

return 0
}

public ActualBan(Selected)
{
new Type = get_pcvar_num(gi_BanType)
switch(Type)
{
case 1:
server_cmd("addip %d %s", get_pcvar_num(gi_BanTime), ga_PlayerIP[Selected])
case 2:
server_cmd("amx_ban %d %s", get_pcvar_num(gi_BanTime), ga_PlayerAuthID[Selected])
case 3: {
get_pcvar_string(gi_BanReason, banReasonCvar, charsmax(banReasonCvar))
server_cmd("amx_bancs ^"%s^" %d ^"%s^"", ga_PlayerName[Selected], get_pcvar_num(gi_BanTime), banReasonCvar)
}
default:
server_cmd("banid %d %s kick", get_pcvar_num(gi_BanTime), ga_PlayerAuthID[Selected])
}
return 0
}
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя lemonzik
сообщение 21.4.2015, 16:57
Сообщение #6
Стаж: 11 лет

Сообщений: 126
Благодарностей: 5
Полезность: < 0

Спасибо, красавЧЕГ good.gif
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя khanter
сообщение 21.4.2015, 19:35
Сообщение #7
Стаж: 11 лет

Сообщений: 10
Благодарностей: 1
Полезность: 0

Цитата(lemonzik @ 21.4.2015, 16:57) *
Спасибо, красавЧЕГ good.gif


Так он же мою переделку скинул :D
просто я выделил текст павн и он лишние символы вставил :)
Нужно было убрать вначале лишнее и в конце каракули
Хотя не важно :)
Пожалуйста.

Отредактировал: khanter, - 21.4.2015, 19:37
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
  Тема закрытаНачать новую тему
 
0 пользователей и 1 гостей читают эту тему: