Заявка за промяна на Плъгин GagSystem "K0st0v"

В този раздел можете да подавате всякакви заявки за намиране, изработка или преработка на плъгини/модове.

Модератор: Extreme

Аватар
Action/A/
Извън линия
Баннат
Баннат
Мнения: 19
Регистриран на: 11 Дек 2018, 00:26

Заявка за промяна на Плъгин GagSystem "K0st0v"

Мнение от Action/A/ » 12 Дек 2018, 02:16

Момчета бихте ли ми направили този плъгин да може да се използва от флаг "e" и като напиша /gag /gagmenu да не пише [K0st0v] [GagSystem] Нещо подобно искам да пише [Cs-Dust2] Мерси предварително заповядайте кода от .sma и ако може като си гагнат да може да се чете първото съобщение то има 2 първото е цветно второто не ако може 2-рото да се премахне :) -

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <unixtime>
#include <sqlx>

#pragma semicolon 1

#define PLUGIN	"Gag System [Sqlx]"
#define AUTHOR	"kostov"
#define VERSION	"1.0"

new Handle:g_iSqlX, Handle:g_iSqlConn;
new iError[512], MsgHudSync, SayText, iTime;
new iCacheUserName[34], bool:iUserGaGed[33];
new iCacheAdmName[34], iCacheUserIp[18];
new iMaxGagTime, iFlagGagTime;

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	
	register_cvar("gag_system", VERSION, FCVAR_SERVER|FCVAR_SPONLY);
	
	iMaxGagTime = register_cvar("amx_maxgag_time", "20");
	iFlagGagTime = register_cvar("amx_maxgag_flag", "d");
	
	register_concmd("amx_gag", "cmdGag", ADMIN_LEVEL_B, "<name> <time> [reason]");
	register_concmd("amx_ungag", "cmdUnGag", ADMIN_LEVEL_B, "<ip>");
	register_concmd("amx_gagmenu", "cmdGagMenu", ADMIN_LEVEL_B);
	register_concmd("amx_gagreason", "cmdGagReason", ADMIN_LEVEL_B);
	register_concmd("amx_gag_clean", "cmdCleanTable", ADMIN_RCON);
	
	register_concmd("say", "cmdSayChat", -1);
	register_concmd("say_team", "cmdSayChat", -1);
	
	MsgHudSync	= CreateHudSyncObj();
	SayText 	= get_user_msgid("SayText");
	
	set_task(1.0, "plugin_mysql_init");
	set_task(30.0, "plugin_remove_past_gag");
}

public plugin_end()
{
	if(g_iSqlConn)
	{
		SQL_FreeHandle(g_iSqlConn);
		SQL_FreeHandle(g_iSqlX);
	}
}

public plugin_mysql_init()
{
	new iHost[64], iUser[64], iPass[64], iDb[64], iErrorCode;
	get_cvar_string("amx_sql_host", iHost, sizeof iHost - 1);
	get_cvar_string("amx_sql_user", iUser, sizeof iUser - 1);
	get_cvar_string("amx_sql_pass", iPass, sizeof iPass - 1);
	get_cvar_string("amx_sql_db", iDb, sizeof iDb - 1);
	
	g_iSqlX    = SQL_MakeDbTuple(iHost, iUser, iPass, iDb);
	g_iSqlConn = SQL_Connect(g_iSqlX, iErrorCode, iError, sizeof iError - 1);
	
	if(!g_iSqlConn)
	{
		server_cmd("Could not connect to SQL database!");
		SQL_FreeHandle(g_iSqlConn);
		SQL_FreeHandle(g_iSqlX);
	}
	
	server_cmd("%s Connected!", PLUGIN);
}

public plugin_remove_past_gag()
{
	new Handle:get;
	get = SQL_PrepareQuery(g_iSqlConn, "DELETE FROM `amx_gag` WHERE time <= UNIX_TIMESTAMP(now());");
	SQL_Execute(get);
	SQL_FreeHandle(get);
}

public cmdGag(id, level, cid)
{
	if(!cmd_access(id, level, cid, 3))
	{
		return PLUGIN_HANDLED;
	}
	
	new iArg[32], iTime[5], iReason[129];
	read_argv(1, iArg, sizeof iArg - 1);
	read_argv(2, iTime, sizeof iTime - 1);
	read_argv(3, iReason, sizeof iReason - 1);
	
	new AdminName[33]; 
	get_user_name(id, AdminName, sizeof AdminName - 1);
	
	new iPlayer = cmd_target(id, iArg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF);
	new iGetTime = str_to_num(iTime);
	
	new PlayerIp[18];
	get_user_ip(iPlayer, PlayerIp, sizeof PlayerIp - 1, 1);
	
	if(!iPlayer)
	{
		client_print(id, print_console, "Cannot find player %s", iArg);
	} else {
		new iGetCvar[16];
		get_pcvar_string(iFlagGagTime, iGetCvar, sizeof iGetCvar - 1);
		if(iGetTime > get_pcvar_num(iMaxGagTime))
		{
			if(!(get_user_flags(id) & read_flags(iGetCvar)))
			{
				client_print(id, print_console, "You have no right to gag more than %d minutes", get_pcvar_num(iMaxGagTime));
				return PLUGIN_HANDLED;
			}
		}
		GagPlayer(id, iArg, PlayerIp, iGetTime, iReason, AdminName);
	}
	
	return PLUGIN_HANDLED;
}

public cmdUnGag(id, level, cid)
{
	if(!cmd_access(id, level, cid, 1))
	{
		return PLUGIN_HANDLED;
	}
	
	new PlayerIp[33];
	read_argv(1, PlayerIp, sizeof PlayerIp - 1);
	UnGagPlayer(id, PlayerIp);
	
	return PLUGIN_HANDLED;
}

public cmdCleanTable(id, level, cid)
{
	if(!cmd_access(id, level, cid, 1))
	{
		return PLUGIN_HANDLED;
	}
	
	TruncateTableMenu(id);
	return PLUGIN_HANDLED;
}

public TruncateTableMenu(id)
{
	new iMenu = menu_create("\wAre you sure you want to empty database?", "TruncateTableMenuFunc");
	menu_additem(iMenu, "\rYes", "1", 0);
	menu_additem(iMenu, "\rNo", "2", 0);
	menu_setprop(iMenu, MPROP_EXIT, MEXIT_ALL);
	menu_display(id, iMenu, 0);
}

public TruncateTableMenuFunc(id, iMenu, Item)
{
	if(Item == MENU_EXIT)
	{
		menu_destroy(iMenu);
		return PLUGIN_HANDLED;
	}
	
	new iData[6], iName[64];
	new access, callback;
    
	menu_item_getinfo(iMenu, Item, access, iData, charsmax(iData), iName, sizeof iName - 1, callback);

	new iKey = str_to_num(iData);
	
	switch(iKey)
	{
		case 1:
		{
			new Handle:iTruncate;
			iTruncate = SQL_PrepareQuery(g_iSqlConn, "TRUNCATE TABLE `amx_gag`");
			if(SQL_Execute(iTruncate))
			{
				Gaged(id, "^4The table was cleared ^3successfully^1!");
			} else {
				Gaged(id, "^4There was a problem, the table is not cleared^4!");
			}
			SQL_FreeHandle(iTruncate);
		}
		case 2:
		{
			return PLUGIN_CONTINUE;
		}
	}
	
	menu_destroy(iMenu);
	return PLUGIN_HANDLED;
}

public cmdSayChat(id)
{
	new iGetUserIp[18];
	get_user_ip(id, iGetUserIp, sizeof iGetUserIp - 1, 1);
	CheckGagedPlayer(id, iGetUserIp);
	
	if(iUserGaGed[id])
	{
		return PLUGIN_HANDLED;
	}
	
	return PLUGIN_CONTINUE;
}

public client_PreThink(id)
{
	if(is_user_connected(id))
	{
		if(iUserGaGed[id])
		{
			set_speak(id, SPEAK_MUTED);
		} else {
			set_speak(id, SPEAK_NORMAL);
		}
	}
}

public client_connect(id)
{
	iUserGaGed[id] = false;
}

public client_disconnect(id)
{
	iUserGaGed[id] = false;
}

public cmdGagMenu(id, level, cid)
{
	if(!cmd_access(id, level, cid, 1))
		return PLUGIN_HANDLED;
	
	new iMenu = menu_create("\rGag Menu:", "cmdGagMenuFunc");
	new iPlayers[32], iNum, iTarget;
	new UserName[34], szTempID[10];
	get_players(iPlayers, iNum);
	for(new i; i < iNum; i++)
	{
		iTarget = iPlayers[i];
		get_user_name(iTarget, UserName, sizeof UserName - 1);
		num_to_str(iTarget, szTempID, charsmax(szTempID));
		menu_additem(iMenu, UserName, szTempID, _, menu_makecallback("GagMenuPlayers"));
	}

	menu_display(id, iMenu, 0);
	return PLUGIN_HANDLED;
}

public GagMenuPlayers(iClient, iMenu, Item)
{
	new iAccess, Info[3], iCallback;
	menu_item_getinfo(iMenu, Item, iAccess, Info, sizeof Info - 1, _, _, iCallback);
    
	new iGetID = str_to_num(Info);
	
	if(access(iGetID, ADMIN_IMMUNITY))
	{
		return ITEM_DISABLED;
	} 
	
	if(iUserGaGed[iGetID])
	{
		return ITEM_DISABLED;
	}
	
	return ITEM_ENABLED;
}

public cmdGagMenuFunc(id, iMenu, Item)
{
	if(Item == MENU_EXIT)
	{
		menu_destroy(iMenu);
		return PLUGIN_HANDLED;
	}

	new iData[6], iName[64];
	new access, callback;
	menu_item_getinfo(iMenu, Item, access, iData, charsmax(iData), iName, charsmax(iName), callback);

	new iTarget = str_to_num(iData);
	get_user_name(iTarget, iCacheUserName, sizeof iCacheUserName - 1);
	get_user_name(id, iCacheAdmName, sizeof iCacheAdmName - 1);
	get_user_ip(iTarget, iCacheUserIp, sizeof iCacheUserIp - 1, 1);
	cmdGagMenuTime(id);
	menu_destroy(iMenu);
	return PLUGIN_HANDLED;
}

public cmdGagMenuTime(id)
{
	new iMenu = menu_create("\wSelect minutes?", "cmdGagMenuTimeFunc");
	menu_additem(iMenu, "\y1 minute", "1");
	menu_additem(iMenu, "\y5 minutes", "5");
	menu_additem(iMenu, "\y10 minutes", "10");
	menu_additem(iMenu, "\y15 minutes", "15");
	menu_additem(iMenu, "\y20 minutes", "20");
	menu_setprop(iMenu, MPROP_EXIT, MEXIT_ALL);
	menu_display(id, iMenu, 0);
}

public cmdGagMenuTimeFunc(id, iMenu, Item)
{
	if(Item == MENU_EXIT)
	{
		menu_destroy(iMenu);
		return PLUGIN_HANDLED;
	}
	new iData[6];
	new access, callback;
	menu_item_getinfo(iMenu, Item, access, iData, sizeof iData - 1, _, _, callback);
	iTime = str_to_num(iData);
	client_cmd(id, "messagemode amx_gagreason");
	menu_destroy(iMenu);
	return PLUGIN_HANDLED;
}

public cmdGagReason(id, level, cid)
{
	if(!cmd_access(id, level, cid, 1))
		return PLUGIN_HANDLED;
	
	new iReason[64];
	read_argv(1, iReason, sizeof iReason - 1);
	GagPlayer(id, iCacheUserName, iCacheUserIp, iTime, iReason, iCacheAdmName);
	return PLUGIN_HANDLED;
}

stock GagPlayer(id, const iPlayer[], const PlayerIp[], iTime, const iReason[], const iAdminName[])
{
	new Handle:get;
	get = SQL_PrepareQuery(g_iSqlConn, "SELECT `player_ip` FROM `amx_gag` WHERE `player_ip` = ^"%s^"", PlayerIp);
	
	new ExpireDate = time() + (iTime * 60);
	
	if(SQL_Execute(get))
	{
		if(SQL_NumResults(get) > 0)
		{
			SQL_FreeHandle(get);
			client_print(id, print_console, "User ^"%s^" is already gaged", iPlayer);
		} else {
			new Handle:set;
			set = SQL_PrepareQuery(g_iSqlConn, "INSERT INTO `amx_gag` VALUES(NULL, ^"%s^", '%s', '%d', ^"%s^", ^"%s^")", iPlayer, PlayerIp, ExpireDate, iReason, iAdminName);
			SQL_Execute(set);
			SQL_FreeHandle(set);
			SQL_FreeHandle(get);
			client_print(id, print_console, "Player is gaged successfully!");
			
			switch(get_cvar_num("amx_show_activity"))
			{
				case 1:
				{
					set_hudmessage(0, 255, 0, 0.05, 0.30, 0, 6.0, 12.0, 0.1, 0.2, 12);
					ShowSyncHudMsg(0, MsgHudSync, "%s has been gaged. ^nReason: %s", iPlayer, iReason);
				}
				case 2:
				{
					set_hudmessage(0, 255, 0, 0.05, 0.30, 0, 6.0, 12.0, 0.1, 0.2, 12);
					ShowSyncHudMsg(0, MsgHudSync, "%s has been gaged. ^nReason: %s ^nBy admin %s", iPlayer, iReason, iAdminName);
				}
			}
		}
	} else {
		SQL_FreeHandle(get);
	}
}

stock UnGagPlayer(id, const PlayerIp[])
{
	new Handle:get;
	get = SQL_PrepareQuery(g_iSqlConn, "SELECT * FROM `amx_gag` WHERE `player_ip`= ^"%s^"", PlayerIp);
	
	if(SQL_Execute(get))
	{
		if(SQL_NumResults(get) > 0)
		{
			new iGetId = SQL_ReadResult(get, 0);
			new Handle:del;
			del = SQL_PrepareQuery(g_iSqlConn, "DELETE FROM `amx_gag` WHERE `id` = '%d'", iGetId);
			SQL_Execute(del);
			client_print(id, print_console, "Gag has been removed successfully!");
			SQL_FreeHandle(del);
			SQL_FreeHandle(get);
		} else {
			SQL_FreeHandle(get);
			client_print(id, print_console, "No user with that ipaddres in the database!");
		}
	} else {
		SQL_FreeHandle(get);
	}
}

stock CheckGagedPlayer(id, const iPlayerIP[])
{
	new Handle:get;
	get = SQL_PrepareQuery(g_iSqlConn, "SELECT * FROM `amx_gag` WHERE `player_ip` = ^"%s^"", iPlayerIP);
	
	if(SQL_Execute(get))
	{
		if(SQL_NumResults(get) > 0)
		{
			new iGetId = SQL_ReadResult(get, 0);
			new ExpireDate[11]; SQL_ReadResult(get, 3, ExpireDate, sizeof ExpireDate - 1);
			new iGetReason[129]; SQL_ReadResult(get, 4, iGetReason, sizeof iGetReason - 1);
			if(strlen(ExpireDate) > 0)
			{
				if(time() < str_to_num(ExpireDate))
				{
					new iGagChat[512], iMonth, iDay, iYear, iHour, iMinute, iSecond;
					new iUnixTime = str_to_num(ExpireDate);
					UnixToTime(iUnixTime , iYear , iMonth , iDay , iHour , iMinute , iSecond );
					formatex(iGagChat, sizeof iGagChat - 1, "^4You are gaged^1! Your gag will expire on: ^3%02d/%02d/%02d - %02d:%02d:%02d ^1: Reason: ^4%s", iDay, iMonth, iYear, iHour + 2, iMinute , iSecond, iGetReason);
					Gaged(id, "%s", iGagChat);
					iUserGaGed[id] = true;
					SQL_FreeHandle(get);
				} else {
					new Handle:del;
					del = SQL_PrepareQuery(g_iSqlConn, "DELETE FROM `amx_gag` WHERE `id` = '%d'", iGetId);
					iUserGaGed[id] = false;
					SQL_Execute(del);
					SQL_FreeHandle(del);
					SQL_FreeHandle(get);
				}
			}
		} else {
			iUserGaGed[id] = false;
		}
	} else {
		SQL_FreeHandle(get);
	}
}

stock Gaged(const id, const input[], any:...)
{
	new count = 1, players[32];
	static msg[191];
	vformat(msg, 190, input, 3);
	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, SayText, _, players[i]) ; 
				write_byte(players[i]);
				write_string(msg);
				message_end();
			}
		}
	}
}
Причина за бан: създаване нов акаунт след наложен бан.
Предишен акаунт: BornToPorn

Аватар
Action/A/
Извън линия
Баннат
Баннат
Мнения: 19
Регистриран на: 11 Дек 2018, 00:26

Заявка за промяна на Плъгин GagSystem "K0st0v"

Мнение от Action/A/ » 12 Дек 2018, 12:05

Оправих се лок! :lock:
Причина за бан: създаване нов акаунт след наложен бан.
Предишен акаунт: BornToPorn

Заключено
  • Подобни теми
    Отговори
    Преглеждания
     Последно мнение

Обратно към “Заявки за плъгини”

Кой е на линия

Потребители разглеждащи този форум: 0 регистрирани и 11 госта