Skocz do zawartości

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie

Vote Ban - Banconfig ?


  • Zamknięty Temat jest zamknięty
2 odpowiedzi w tym temacie

#1 luk

    Początkujący

  • Użytkownik

Reputacja: 2
Nowy

  • Postów:14
  • Lokalizacja:Sosnowiec
Offline

Napisano 30.08.2009 20:36

Czy jest możliwości przerobić plugin, aby dawał bany na amx_banconfig a nie na IP, bo co do ban na steam to może zostać ?

#include <amxmodx>

#define PLUGIN "Ban Vote"
#define VERSION "1.0"
#define AUTHOR "Alka"

#define BAN_VOTE_DELAY 60.0

new g_iMaxPlayers;

new g_iVotesNum;
new g_szVoterName[32];
new g_szVotedName[32];
new g_szReason[64];
new bool:g_bValidUid;
new Float:g_fLastVote;

new bool:g_bHasVoted[33];

new const g_szSyntax[] = "/vote";
new const g_szBanTime[] = "1440";

public plugin_init() {
	
	register_plugin(PLUGIN, VERSION, AUTHOR);
	
	register_clcmd("say", "clcmdHandleSay", -1, "");
	register_clcmd("enter_ban_reason", "clcmdBanReason", -1, "");
	
	g_iMaxPlayers = get_maxplayers();
}

public clcmdHandleSay(id)
{	
	new szArgs[128];
	read_args(szArgs, sizeof szArgs - 1);
	
	remove_quotes(szArgs);
	
	if(equali(szArgs, g_szSyntax))
	{
		Util_DisplayList(id);
		return 0;
	}
	
	new szTemp[32];
	parse(szArgs, szArgs, sizeof szArgs - 1, szTemp, sizeof szTemp - 1);
	
	if(equali(szArgs, g_szSyntax) && szTemp[0] == '#')
	{
		new iPlayers[32], iPlayersNum;
		get_players(iPlayers, iPlayersNum, "ch");
		
		if(iPlayersNum < 3)
		{
			Util_PrintGreen(id, "> Sorry, not enough players(3) to start a Ban Vote!");
			return 1;
		}
		
		if((get_gametime() - g_fLastVote) < BAN_VOTE_DELAY)
		{
			Util_PrintGreen(id, "> Sorry, you must wait %.1f sec. before start another vote!", BAN_VOTE_DELAY);
			return 1;
		}
		
		for(new i = 0 ; i < sizeof szTemp ; i++)
		{
			if(!isdigit(szTemp[i]) && szTemp[i] != '#' && szTemp[i])
			{
				Util_PrintGreen(id, "> Syntax Error: Invalid userid! Type ^"/vote^" for more info.");
				return 1;
			}
		}
		for(new j = 1 ; j <= g_iMaxPlayers ; j++)
		{
			if(!is_user_connected(j))
				continue;
			
			if(get_user_userid(j) == str_to_num(szTemp[1]))
			{
				g_bValidUid = true;
				
				get_user_name(id, g_szVoterName, sizeof g_szVoterName - 1);
				get_user_name(j, g_szVotedName, sizeof g_szVotedName - 1);
				
				Util_PrintGreen(0, "> Player '%s' voted '%s' to be banned!", g_szVoterName, g_szVotedName);
				Util_PrintGreen(id, "> Enter the ban reason!");
				
				g_bHasVoted[id] = true;
				
				client_cmd(id, "messagemode enter_ban_reason");
			}
		}
		if(!g_bValidUid)
		{
			Util_PrintGreen(id, "> Syntax Error: Invalid userid! Type ^"/vote^" for more info.");
			return 1;
		}
	}
	g_fLastVote = get_gametime();
	
	return 0;
}

public clcmdBanReason(id)
{
	if(!g_bHasVoted[id])
		return 1;
	
	read_argv(1, g_szReason, sizeof g_szReason - 1);
	
	if(!g_szReason[0])
	{
		client_cmd(id, "messagemode enter_ban_reason");
		return 1;
	}
	g_bValidUid = false;
	g_bHasVoted[id] = false;
	
	new szTemp[128];
	formatex(szTemp, sizeof szTemp - 1, "wBan r%s wfor: y%s", g_szVotedName, g_szReason);
	
	new iMenu = menu_create(szTemp, "menuHandle", 0);
	menu_additem(iMenu, "wYes", "1", 0, -1);
	menu_additem(iMenu, "wNo", "2", 0, -1);
	menu_addblank(iMenu, 0);
	
	menu_setprop(iMenu, MPROP_EXIT, MEXIT_NEVER);
	
	for(new i = 1 ; i <= g_iMaxPlayers ; i++)
	{
		if(!is_user_connected(i) || (i == get_user_index(g_szVotedName)))
			continue;
		
		menu_display(i, iMenu, 0);
	}
	set_task(15.0, "taskCheckVotes", 0);
	
	return 1;
}

public menuHandle(id, menu, item)
{
	new szData[6], iAccess, iCallBack;
	menu_item_getinfo(menu, item, iAccess, szData, sizeof szData - 1, _, _, iCallBack);
	
	new iKey = str_to_num(szData);
	
	switch(iKey)
	{
		case 1 : { g_iVotesNum++; }
	}
	return 1;
}

public taskCheckVotes()
{
	new iPlayers[32], iPlayersNum;
	get_players(iPlayers, iPlayersNum, "ch");
	
	if(g_iVotesNum >= (iPlayersNum - 1))
	{
		new id = get_user_index(g_szVotedName);
		
		if(!is_user_connected(id))
		{
			Util_PrintGreen(0, "> Ban vote has failed, since player is not on server anymore!");
		}
		else
		{
			if(!is_steam_user(id))
			{
				new szIp[32];
				get_user_ip(id, szIp, sizeof szIp - 1, 1);
				
				server_cmd("kick #%d ^"Ban Vote^";wait;addip ^"%s^" ^"%s^";wait;writeip", get_user_userid(id), g_szBanTime, szIp);
			}
			else
			{
				new szSteamId[32];
				get_user_authid(id, szSteamId, sizeof szSteamId - 1);
				
				server_cmd("kick #%d ^"Ban Vote^";wait;banid ^"%s^" ^"%s^";wait;writeid", get_user_userid(id), g_szBanTime, szSteamId);
			}
			Util_PrintGreen(0, "> Player '%s' has been successfully banned due Ban Vote!", g_szVotedName);
			Util_Log("Player '%s' has been banned due Ban Vote started by '%s'!Reason: '%s'", g_szVotedName, g_szVoterName, g_szReason);
		}
	}
	g_iVotesNum = 0;
	g_szVotedName[0] = '^0';
	g_szVoterName[0] = '^0';
	g_szReason[0] = '^0';
}

public client_disconnect(id)
{
	static iVoted;
	iVoted = get_user_index(g_szVotedName);
	
	if(id == iVoted)
	{
		if(!is_steam_user(id))
		{
			new szIp[32];
			get_user_ip(id, szIp, sizeof szIp - 1, 1);
			
			server_cmd("kick #%d ^"Ban Vote^";wait;addip ^"1440^" ^"%s^";wait;writeip", get_user_userid(id), szIp);
		}
		else
		{
			new szSteamId[32];
			get_user_authid(id, szSteamId, sizeof szSteamId - 1);
			
			server_cmd("kick #%d ^"Ban Vote^";wait;banid ^"1440^" ^"%s^";wait;writeid", get_user_userid(id), szSteamId);
		}
		Util_PrintGreen(0, "> Player '%s' has been successfully banned due leaving the server in middle of a Ban Vote!", g_szVotedName);
		Util_Log("Player '%s' has been successfully banned due leaving the server in middle of a Ban Vote!", g_szVotedName);
	}
}

stock Util_DisplayList(id)
{
	new szBuffer[512], iLen;
	new szName[32], iIndex;
	
	iLen = formatex(szBuffer, sizeof szBuffer - 1, "<body bgcolor=#000000><font color=#ff0000><pre>");
	iLen += formatex(szBuffer[iLen], (sizeof szBuffer - 1) - iLen, "<font size=^"4^">%s   %s   %s</font>^n", "#", "Name", "Steam User");
	
	for(new i = 1 ; i <= g_iMaxPlayers ; i++)
	{
		if(!is_user_connected(i))
			continue;
		
		get_user_name(i, szName, sizeof szName - 1);
		iIndex = get_user_userid(i);
		
		iLen += formatex(szBuffer[iLen], (sizeof szBuffer - 1) - iLen, "%d   %s   %s^n", iIndex, szName, is_steam_user(i) ? "Yes" : "No");
	}
	show_motd(id, szBuffer, "");
}

stock bool:is_steam_user(id)
{
	new szSteamid[32];
	get_user_authid(id, szSteamid, sizeof szSteamid - 1);
	
	if(szSteamid[7] == ':')
		return true;
	
	return false;
}

stock Util_PrintGreen(id, const message[], {Float, Sql, Resul,_}:...) {
	
	static msg[192];
	msg[0] = 0x04;
	
	vformat(msg[1], 190, message, 3);
	
	if( id > 0 && id <= g_iMaxPlayers)
	{
		message_begin(MSG_ONE, get_user_msgid("SayText"),_, id);
		write_byte(id);
		write_string(msg);
		message_end();
	}
	else if(id == 0)
	{
		for( new i = 1; i <= g_iMaxPlayers; i++ )
		{
			if(!is_user_connected(i))
				continue;
			
			message_begin(MSG_ONE, get_user_msgid("SayText"),_, i);
			write_byte(i);
			write_string(msg);
			message_end();
		}
	}
}

stock Util_Log(const string[], {Float, Sql, Resul,_}:...) {
	
	static const szFile[] = "vote_ban.log";
	
	static szMessage[256];
	vformat(szMessage, sizeof szMessage - 1, string, 3);
	
	log_to_file(szFile, szMessage);
}

  • +
  • -
  • 0

#2 R3X

    Godlike

  • Przyjaciel

Reputacja: 2 987
Godlike

  • Postów:4 248
  • Lokalizacja:Nie
Offline

Napisano 31.08.2009 20:30

No i musisz mieć plugin z komendą amx_bancfg

Załączone pliki


  • +
  • -
  • 0

#3 luk

    Początkujący

  • Autor tematu
  • Użytkownik

Reputacja: 2
Nowy

  • Postów:14
  • Lokalizacja:Sosnowiec
Offline

Napisano 01.09.2009 10:38

Tutaj daje lepszy plugin:

http://forums.allied...ead.php?t=43568

#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 menu","1.2","hjvl")

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","600")

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","0")

}

public SayIt(id)

{

if(get_pcvar_num(gi_Disable))

{

client_print(id,print_chat,"[AMXX]amx_votaban disabled")

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,"[AMXX] You have to wait %d seconds before a new voteban can be started", 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,"There is an admin on the server, voting is disabled!")

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 menu ^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. More")

keys |= (1<<8)

}

arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"^n0. Back/exit")

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),"Ban %s for %d minutes?^n1. Yes^n2. No",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,"[AMXX] Not enough voters to ban %s!", ga_PlayerName[gi_Sellection])

return 0

}

else

{

if( result < get_pcvar_float(gf_BF_Ratio) )

{

client_print(0,print_chat,"[AMXX] The vote back fired at %s, he is banned for %d minutes", 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) )

{

client_print(0,print_chat,"[AMXX] The vote succeeded, %s is banned for %d minutes", 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

{

client_print(0,print_chat,"[AMXX] The vote did not succeeded!")

log_amx("[AMXX] The voteban dit not sucseed.")

}

}

client_print(0,print_chat,"A total of %d players, %d voted yes.", 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 

}


Problemy:

1. Nie ma logów w osobnym pliku, typu: kto wpisał /voteban, kto dostał bana, IP, data.

2. Gdy ustawine jest
gf_Ratio=register_cvar("amxx_voteban_ratio","0.50")
przy glosowaniu 18 osób 6 było za i głosownie zakończone sukcesem.

3. Przerobiłem linijke

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

na

server_cmd("amx_banconfig %d %s Voteban", get_pcvar_num(gi_BanTime), ga_PlayerAuthID[Selected])

Gdy ktos dostaje bana nadal gra :/
  • +
  • -
  • 0




Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych