AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   VoteBan + HD_Ban (https://forums.alliedmods.net/showthread.php?t=206814)

SivAnOl 01-26-2013 09:32

VoteBan + HD_Ban
 
Good day!
We have:
There is a source code plugin VoteBan (version and the rest not know for sure).
Plugin without colorchat and so on, in general almost standard.
The plugin is already set up as needed, you just need to rewrite something in the source.
What you need:
Make sure that:
amxx_voteban_type 0 - kick players involved with the reason.
amxx_voteban_type 1 - included a ban players using Hacks Detector with the reason (hd_ban% userid%% time%% reason%).
amxx_voteban_type 2 - included a ban players with the usual ban stating the reason (amx_ban).
amxx_voteban_type 3 - included a ban players with amx_bans indicating the reason.
Source:
Code:

#include <amxmodx>
#include <amxmisc>

#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


public plugin_init()
{
 register_plugin("VoteBan","1.5","RAF")
 register_clcmd("say /voteban","SayIt" )
 register_clcmd("say 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","180")
 gf_Ratio=register_cvar("amxx_voteban_ratio","0.55")
 gf_MinVoters=register_cvar("amxx_voteban_minvoters","0.1")
 gf_BF_Ratio=register_cvar("amxx_voteban_bf_ratio","0.25")
 gi_BanTime=register_cvar("amxx_voteban_bantime","30")
 gi_Disable=register_cvar("amxx_voteban_disable","0")
 gi_BanType=register_cvar("amxx_voteban_type","0")
}

public SayIt(id)
{
 if(get_pcvar_num(gi_Disable))
 {
 client_print(id,print_chat,"VoteBan off.")
 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
 client_print(id,print_chat,"Голосование возможно через %d секунд.",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,"Админ на сервере.VoteBan выключен.")
 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),"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("VoteBan запустил %s против %s %s.=D.",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)))
 {
 client_print(0,print_chat,"Недостаточно голосов за Бан %s!",ga_PlayerName[gi_Sellection])
 return 0
 }
 else
 {
 if(result < get_pcvar_float(gf_BF_Ratio))
 {
 client_print(0,print_chat,"%s забанен на %d минут voteban'ом.",ga_PlayerName[gi_VoteStarter],get_pcvar_num(gi_BanTime))
 ActualBan(gi_VoteStarter)
 log_amx("[AMXX] %s was Banned for %d minutes.",ga_PlayerName[gi_VoteStarter],get_pcvar_num(gi_BanTime))
 }

 if( result >= get_pcvar_float(gf_Ratio) )
 {
 client_print(0,print_chat,"%s забанен на %d минут voteban'ом.",ga_PlayerName[gi_Sellection],get_pcvar_num(gi_BanTime))
 log_amx("[AMXX] %s was Banned for %d minutes.",ga_PlayerAuthID[gi_Sellection],get_pcvar_num(gi_BanTime))
 ActualBan(gi_Sellection)
 }
 else
 {
 client_print(0,print_chat,"Голосование не состоялось.Недостаточно голосов.")
 log_amx("[AMXX] The VoteBan dit not sucseed.")
 }
 }
 client_print(0,print_chat,"Проголосовало %d игроков,%d За.",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])
 default:
 server_cmd("banid %d %s kick",get_pcvar_num(gi_BanTime),ga_PlayerAuthID[Selected])
 }
 return 0
}

Please help me. Thanks in advance.

fysiks 01-26-2013 22:12

Re: VoteBan + HD_Ban
 
What specifically do you need help with?

SivAnOl 01-27-2013 08:13

Re: VoteBan + HD_Ban
 
Quote:

Originally Posted by fysiks (Post 1881410)
What specifically do you need help with?

Need to change the variable "amxx_voteban_type".
0 - Kick player.
1 - Ban player by dialing hd_ban (Anti-Cheat).
2 - Normal ban commando amx_ban on IP.
3 - Ban via AMXBans.
Sorry for my english, i from Ukraine and use translate google.

fysiks 01-27-2013 15:05

Re: VoteBan + HD_Ban
 
You just need to change the code in the switch() on line 204 to match up with your needs. Then, you add the appropriate code to the case that will execute what you want done.

SivAnOl 01-27-2013 17:00

Re: VoteBan + HD_Ban
 
Quote:

Originally Posted by fysiks (Post 1881848)
You just need to change the code in the switch() on line 204 to match up with your needs. Then, you add the appropriate code to the case that will execute what you want done.

True, but there "case 1-2" and default.
On top of all this plugin does not understand how to ban Commando "hd_ban" (hd_ban% userid%% time%% reason%).
Namely, there is no variable "% reason%", "% time%" and "% userid%".
This means that the command will be given is not true.
And I tried to substitute:
Code:

  case 2:
  server_cmd ("amx_ban% d% %s Voteban", get_pcvar_num (gi_BanTime), ga_PlayerAuthID [Selected])

is:
Code:

  case 2:
  server_cmd ("hd_ban% s% %d Voteban", get_pcvar_num (gi_BanTime), ga_PlayerAuthID [Selected])

And did not help.

fysiks 01-27-2013 17:23

Re: VoteBan + HD_Ban
 
Why do you have a "%" after the command? It is not part of the command.

SivAnOl 01-28-2013 00:04

Re: VoteBan + HD_Ban
 
Quote:

Originally Posted by fysiks (Post 1881942)
Why do you have a "%" after the command? It is not part of the command.

Yeah, right. Corrected by removing "%" after "hd_ban".
Also does not work. Probably fail.

fysiks 01-28-2013 00:21

Re: VoteBan + HD_Ban
 
Well, first off, you did not copy the original code (the amx_ban part) correctly and you aren't ever going to get something correct that you base on incorrect code. Then, you seemed to have randomly moved things around when you shouldn't have. Because of this you are trying to format a number as a string and a string as a number.

What is HD Ban?

SivAnOl 01-28-2013 00:26

Re: VoteBan + HD_Ban
 
Quote:

Originally Posted by fysiks (Post 1882078)
What is HD Ban?

hd_ban is similarity amx_ban. HD is Hacks Detector (Anti-Cheat).
Your previous message interpreter translated unclear.
Maybe I wrote a misspelled command.
I ask you to specify what to write and where to operate banks as needed.

fysiks 01-28-2013 01:51

Re: VoteBan + HD_Ban
 
Well, I'm am not going to be helping you out anymore because I don't want to deal with translators. You will have to wait for someone else to help. My advice is to just modify working code one step at a time and test. Learn from that existing code on how things work.


All times are GMT -4. The time now is 20:41.

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