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

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

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

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

> Правила форума

Этот раздел, как вы могли заметить по названию, предназначен для решения вопросов по поводу уже существующих модов и плагинов.
Пожалуйста, если у вас проблема с написанием плагина, не путайте этот раздел с разделом по скриптингу.
Для поиска плагинов и модов существует соответствующий раздел.

Название темы должно соответствовать содержанию. Темы с названием типа "Помогите", "Вопрос", "парни подскажите..." - будут удалены.
Все темы, не относящиеся к "Вопросам по модам и плагинам", будут удалены или перемещены в соответствующий раздел.

Правила оформления темы:
1. Помимо заголовка не забудьте верно сформулировать свой вопрос.
2. Выложите исходник (в тег кода + ) или ссылку на плагин который вызывает у вас вопросы.
3. Выложите лог с ошибками (если имеется) под спойлер

Voteban

Статус пользователя WOODYM4N
сообщение 22.4.2014, 15:24
Сообщение #1
Стаж: 12 лет

Сообщений: 40
Благодарностей: 6
Полезность: 54

Добрый день, подскажите пожалуйста как переделать под superban?
Voteban
Код
#include <amxmodx>
#include <amxmisc>
#include <colorchat>

#define MAX_players 32
#define MAX_menudata 1024

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","600")
  gf_Ratio=register_cvar("amxx_voteban_ratio","0.75")
  gf_MinVoters=register_cvar("amxx_voteban_minvoters","0.0")
  gf_BF_Ratio=register_cvar("amxx_voteban_bf_ratio","0.20")
  gi_BanTime=register_cvar("amxx_voteban_bantime","15")
  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, NORMAL, "^x01[^x04Life is GooD ©^x01] ^x03VoteBan выключен на сервере!")
    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, NORMAL, "^x01[^x04Life is GooD ©^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))
      {
        ColorChat(id, NORMAL, "^x01[^x04Life is GooD ©^x01] На сервере присутствует ^x04Админ ^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)
{
  new arrayloc = 0
  new keys = (1<<9)

  arrayloc = format(ga_MenuData,(MAX_menudata-1),"\d[\rLife is GooD ©\d] \dVoteban menu\w^n^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),"Забанить\y %s \wна\y %d \wминут?^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, NORMAL, "^x01[^x04Life is GooD ©^x01] Не хватает голосов для бана игрока - %s", ga_PlayerName[gi_Sellection])
    return 0
  }
  else
  {
    if( result < get_pcvar_float(gf_BF_Ratio) )
    {
      ColorChat(0, NORMAL, "^x01[^x04Life is GooD ©^x01] Голосование завершено! %s забанен на %d минут", 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, NORMAL, "^x01[^x04Life is GooD ©^x01] Голосование завершено! %s забанен на %d минут", 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, NORMAL, "^x01[^x04Life is GooD ©^x01] Голосование не состоялось")
      log_amx("[AMXX] The voteban dit not sucseed.")
    }
  }
  ColorChat(0, NORMAL, "^x01[^x04Life is GooD ©^x01] Всего проголосовало %d игроков: ^x03%d^x01 за бан, ^x03%d^x01 против ", gi_TotalPlayers, ga_Choice[0], (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^" ^"Voteban^"", 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
}
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   Цитировать сообщение
Статус пользователя Bloo
сообщение 22.4.2014, 15:25
Сообщение #2


Стаж: 12 лет

Сообщений: 15547
Благодарностей: 6971
Полезность: 1206

WOODYM4N, синтаксис бана у него какой?
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя WOODYM4N
сообщение 22.4.2014, 15:27
Сообщение #3
Стаж: 12 лет

Сообщений: 40
Благодарностей: 6
Полезность: 54

Цитата(Bloo @ 22.4.2014, 15:25) *
WOODYM4N, синтаксис бана у него какой?

amx_superban <name or #userid> <minutes> [reason]
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Bloo
сообщение 22.4.2014, 15:30
Сообщение #4


Стаж: 12 лет

Сообщений: 15547
Благодарностей: 6971
Полезность: 1206

WOODYM4N, вроде так. Тип бана в конфиге выбрать amxbans (он по умолчанию так стоит)
Код:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>

#define MAX_players 32
#define MAX_menudata 1024

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","600")
gf_Ratio=register_cvar("amxx_voteban_ratio","0.75")
gf_MinVoters=register_cvar("amxx_voteban_minvoters","0.0")
gf_BF_Ratio=register_cvar("amxx_voteban_bf_ratio","0.20")
gi_BanTime=register_cvar("amxx_voteban_bantime","15")
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, NORMAL, "^x01[^x04Life is GooD ©^x01] ^x03VoteBan выключен на сервере!")
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, NORMAL, "^x01[^x04Life is GooD ©^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))
{
ColorChat(id, NORMAL, "^x01[^x04Life is GooD ©^x01] На сервере присутствует ^x04Админ ^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)
{
new arrayloc = 0
new keys = (1<<9)

arrayloc = format(ga_MenuData,(MAX_menudata-1),"\d[\rLife is GooD ©\d] \dVoteban menu\w^n^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),"Забанить\y %s \wна\y %d \wминут?^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, NORMAL, "^x01[^x04Life is GooD ©^x01] Не хватает голосов для бана игрока - %s", ga_PlayerName[gi_Sellection])
return 0
}
else
{
if( result < get_pcvar_float(gf_BF_Ratio) )
{
ColorChat(0, NORMAL, "^x01[^x04Life is GooD ©^x01] Голосование завершено! %s забанен на %d минут", 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, NORMAL, "^x01[^x04Life is GooD ©^x01] Голосование завершено! %s забанен на %d минут", 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, NORMAL, "^x01[^x04Life is GooD ©^x01] Голосование не состоялось")
log_amx("[AMXX] The voteban dit not sucseed.")
}
}
ColorChat(0, NORMAL, "^x01[^x04Life is GooD ©^x01] Всего проголосовало %d игроков: ^x03%d^x01 за бан, ^x03%d^x01 против ", gi_TotalPlayers, ga_Choice[0], (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_superban ^"%s^" ^"%d^" ^"Voteban^"", ga_PlayerAuthID[Selected], get_pcvar_num(gi_BanTime))
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
}


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