Pls remove MENU thing complete

В този раздел можете да подавате всякакви заявки за намиране, изработка или преработка на плъгини/модове.
Аватар
Infamous2018
Извън линия
Foreigner
Foreigner
Мнения: 522
Регистриран на: 08 Апр 2018, 16:56
Се отблагодари: 14 пъти
Получена благодарност: 21 пъти

Pls remove MENU thing complete

Мнение от Infamous2018 » 23 Юни 2018, 16:16

can anyone remove rules menu pls?

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

new hMenu = menu_create( szTitle, "MenuAgree" );
menu_additem( hMenu, "Yes", "1" );
menu_additem( hMenu, "No \r[ \wYou will be kicked! \r]", "2" );
menu_additem( hMenu, "Yes and don't ask again", "3" );
menu_setprop( hMenu, MPROP_EXIT, MEXIT_NEVER ); 

THANKS

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

#include <amxmodx>
#include <hamsandwich>
#include <fvault>

new cvar_legal_settings;

new fps_max = 101;

new const g_client_cvar_names[][] =
{
	"fps_max",
	"rate",
	"cl_cmdrate",
	"cl_updaterate",
	"developer",
	"fps_override"
};

new Trie:g_client_cvar_index;

new const g_client_cvar_values[sizeof(g_client_cvar_names)] =
{
	101,
	100000,
	102,
	102,
	0,
	0
};

new bool:g_agreed[33];

new const g_agree_vault[] = "jumpstats_agree";

public plugin_init()
{
	register_plugin("JumpStats Cvar Checker", "1.7.4", "Exolent");
	
	RegisterHam(Ham_Spawn, "player", "FwdPlayerSpawn", 1);
	
	g_client_cvar_index = TrieCreate();
	for( new i = 0; i < sizeof(g_client_cvar_names); i++ )
	{
		if( equal( g_client_cvar_names[ i ], "fps_max" ) )
		{
			fps_max = i;
		}
		
		TrieSetCell(g_client_cvar_index, g_client_cvar_names[i], i);
	}
	
	cvar_legal_settings = register_cvar("js_legal_settings", "1");
}

public plugin_end()
{
	TrieDestroy(g_client_cvar_index);
}

public client_authorized(client)
{
	if( !is_user_bot(client) )
	{
		if( get_pcvar_num(cvar_legal_settings) )
		{
			static authid[35];
			get_user_authid(client, authid, sizeof(authid) - 1);
			
			if( fvault_get_keynum(g_agree_vault, authid) == -1 )
			{
				g_agreed[client] = false;
			}
			else
			{
				g_agreed[client] = true;
				
				for( new i = 0; i < sizeof(g_client_cvar_names); i++ )
				{
					client_cmd(client, "%s %i", g_client_cvar_names[i], g_client_cvar_values[i]);
				}
				
				set_task(1.0, "TaskCheckCvars", client);
			}
		}
		else
		{
			g_agreed[client] = false;
		}
	}
}

public client_putinserver(client)
{
	if( is_user_bot(client) )
	{
		g_agreed[client] = true;
	}
}

public client_disconnect(client)
{
	remove_task(client);
}

public FwdPlayerSpawn(client)
{
	if( is_user_alive(client) )
	{
		if( !g_agreed[client] && get_pcvar_num(cvar_legal_settings) )
		{
			ShowAgreeMenu( client );
		}
	}
}

ShowAgreeMenu( client )
{
	static szTitle[ 256 ];
	if( !szTitle[ 0 ] )
	{
		new iLen = copy( szTitle, 255, "This server requires:^n" );
		
		for( new i = 0; i < sizeof( g_client_cvar_names ); i++ )
		{
			iLen += formatex( szTitle[ iLen ], 255 - iLen, "\d- \r%s %i^n", g_client_cvar_names[ i ], g_client_cvar_values[ i ] );
		}
		
		add( szTitle, 255, "^n\yDo you accept this?" );
	}
	
	new hMenu = menu_create( szTitle, "MenuAgree" );
	menu_additem( hMenu, "Yes", "1" );
	menu_additem( hMenu, "No \r[ \wYou will be kicked! \r]", "2" );
	menu_additem( hMenu, "Yes and don't ask again", "3" );
	menu_setprop( hMenu, MPROP_EXIT, MEXIT_NEVER );
	
	menu_display( client, hMenu );
}

public MenuAgree(client, menu, item)
{
	if( item == MENU_EXIT ) return;
	
	static _access, info[3], callback;
	menu_item_getinfo(menu, item, _access, info, sizeof(info) - 1, _, _, callback);
	
	if( info[0] != '2' )
	{
		g_agreed[client] = true;
		
		for( new i = 0; i < sizeof(g_client_cvar_names); i++ )
		{
			client_cmd(client, "%s %i", g_client_cvar_names[i], g_client_cvar_values[i]);
		}
		
		set_task(1.0, "TaskCheckCvars", client);
		
		static authid[35];
		get_user_authid(client, authid, sizeof(authid) - 1);
		
		if( info[0] == '3' )
		{
			fvault_set_data(g_agree_vault, authid, "1");
		}
	}
	else
	{
		static const szReason[ ] = "You must agree to use legal jump settings to play here!";
		
		emessage_begin( MSG_ONE, SVC_DISCONNECT, _, client );
		ewrite_string( szReason );
		emessage_end( );
	}
}

public TaskCheckCvars(client)
{
	query_client_cvar(client, g_client_cvar_names[0], "QueryCvar");
}

enum
{
	STRINGTYPE_ERROR,
	STRINGTYPE_INTEGER,
	STRINGTYPE_FLOAT
};

public QueryCvar(client, const cvar_name[], const cvar_value[])
{
	new type = GetStringNumType(cvar_value);
	
	static cvar;
	TrieGetCell(g_client_cvar_index, cvar_name, cvar);
	
	new legal_value = g_client_cvar_values[cvar];
	
	if( type == STRINGTYPE_ERROR	
	|| type == STRINGTYPE_INTEGER &&
		(
		cvar == fps_max && str_to_num(cvar_value) > legal_value
		||
		cvar != fps_max && str_to_num(cvar_value) != legal_value
		)
	|| type == STRINGTYPE_FLOAT &&
		(
		cvar == fps_max && str_to_float(cvar_value) > float(legal_value)
		||
		cvar != fps_max && str_to_float(cvar_value) != float(legal_value)
		)
	)
	{
		static authid[35];
		get_user_authid(client, authid, sizeof(authid) - 1);
		
		if( fvault_get_keynum(g_agree_vault, authid) >= 0 )
		{
			fvault_remove_key(g_agree_vault, authid);
		}
		
		static reason[192];
		formatex(reason, sizeof(reason) - 1, "You must use legal jump settings!^nYour '%s' must be %i!", cvar_name, legal_value);
		
		emessage_begin(MSG_ONE, SVC_DISCONNECT, _, client);
		ewrite_string(reason);
		emessage_end();
		
		return;
	}
	
	query_client_cvar(client, g_client_cvar_names[(cvar + 1) % sizeof(g_client_cvar_names)], "QueryCvar");
}

GetStringNumType(const string[])
{
	new len = strlen(string);
	if( len )
	{
		new bool:period = false;
		for( new i = 0; i < len; i++ )
		{
			if( '0' <= string[i] <= '9' ) continue;
			
			if( string[i] == '.' && !period )
			{
				period = true;
				continue;
			}
			
			return STRINGTYPE_ERROR;
		}
		
		return period ? STRINGTYPE_FLOAT : STRINGTYPE_INTEGER;
	}
	
	return STRINGTYPE_ERROR;
}

Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

Pls remove MENU thing complete

Мнение от OciXCrom » 23 Юни 2018, 17:18

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

#include <amxmodx>
#include <hamsandwich>
#include <fvault>

new cvar_legal_settings;

new fps_max = 101;

new const g_client_cvar_names[][] =
{
	"fps_max",
	"rate",
	"cl_cmdrate",
	"cl_updaterate",
	"developer",
	"fps_override"
};

new Trie:g_client_cvar_index;

new const g_client_cvar_values[sizeof(g_client_cvar_names)] =
{
	101,
	100000,
	102,
	102,
	0,
	0
};

new bool:g_agreed[33];

new const g_agree_vault[] = "jumpstats_agree";

public plugin_init()
{
	register_plugin("JumpStats Cvar Checker", "1.7.4", "Exolent");
	
	RegisterHam(Ham_Spawn, "player", "FwdPlayerSpawn", 1);
	
	g_client_cvar_index = TrieCreate();
	for( new i = 0; i < sizeof(g_client_cvar_names); i++ )
	{
		if( equal( g_client_cvar_names[ i ], "fps_max" ) )
		{
			fps_max = i;
		}
		
		TrieSetCell(g_client_cvar_index, g_client_cvar_names[i], i);
	}
	
	cvar_legal_settings = register_cvar("js_legal_settings", "1");
}

public plugin_end()
{
	TrieDestroy(g_client_cvar_index);
}

public client_authorized(client)
{
	if( !is_user_bot(client) )
	{
		if( get_pcvar_num(cvar_legal_settings) )
		{
			static authid[35];
			get_user_authid(client, authid, sizeof(authid) - 1);
			
			if( fvault_get_keynum(g_agree_vault, authid) == -1 )
			{
				g_agreed[client] = false;
			}
			else
			{
				g_agreed[client] = true;
				
				for( new i = 0; i < sizeof(g_client_cvar_names); i++ )
				{
					client_cmd(client, "%s %i", g_client_cvar_names[i], g_client_cvar_values[i]);
				}
				
				set_task(1.0, "TaskCheckCvars", client);
			}
		}
		else
		{
			g_agreed[client] = false;
		}
	}
}

public client_putinserver(client)
{
	if( is_user_bot(client) )
	{
		g_agreed[client] = true;
	}
}

public client_disconnect(client)
{
	remove_task(client);
}

/*public FwdPlayerSpawn(client)
{
	if( is_user_alive(client) )
	{
		if( !g_agreed[client] && get_pcvar_num(cvar_legal_settings) )
		{
			ShowAgreeMenu( client );
		}
	}
}

ShowAgreeMenu( client )
{
	static szTitle[ 256 ];
	if( !szTitle[ 0 ] )
	{
		new iLen = copy( szTitle, 255, "This server requires:^n" );
		
		for( new i = 0; i < sizeof( g_client_cvar_names ); i++ )
		{
			iLen += formatex( szTitle[ iLen ], 255 - iLen, "\d- \r%s %i^n", g_client_cvar_names[ i ], g_client_cvar_values[ i ] );
		}
		
		add( szTitle, 255, "^n\yDo you accept this?" );
	}
	
	new hMenu = menu_create( szTitle, "MenuAgree" );
	menu_additem( hMenu, "Yes", "1" );
	menu_additem( hMenu, "No \r[ \wYou will be kicked! \r]", "2" );
	menu_additem( hMenu, "Yes and don't ask again", "3" );
	menu_setprop( hMenu, MPROP_EXIT, MEXIT_NEVER );
	
	menu_display( client, hMenu );
}

public MenuAgree(client, menu, item)
{
	if( item == MENU_EXIT ) return;
	
	static _access, info[3], callback;
	menu_item_getinfo(menu, item, _access, info, sizeof(info) - 1, _, _, callback);
	
	if( info[0] != '2' )
	{
		g_agreed[client] = true;
		
		for( new i = 0; i < sizeof(g_client_cvar_names); i++ )
		{
			client_cmd(client, "%s %i", g_client_cvar_names[i], g_client_cvar_values[i]);
		}
		
		set_task(1.0, "TaskCheckCvars", client);
		
		static authid[35];
		get_user_authid(client, authid, sizeof(authid) - 1);
		
		if( info[0] == '3' )
		{
			fvault_set_data(g_agree_vault, authid, "1");
		}
	}
	else
	{
		static const szReason[ ] = "You must agree to use legal jump settings to play here!";
		
		emessage_begin( MSG_ONE, SVC_DISCONNECT, _, client );
		ewrite_string( szReason );
		emessage_end( );
	}
}*/

public TaskCheckCvars(client)
{
	query_client_cvar(client, g_client_cvar_names[0], "QueryCvar");
}

enum
{
	STRINGTYPE_ERROR,
	STRINGTYPE_INTEGER,
	STRINGTYPE_FLOAT
};

public QueryCvar(client, const cvar_name[], const cvar_value[])
{
	new type = GetStringNumType(cvar_value);
	
	static cvar;
	TrieGetCell(g_client_cvar_index, cvar_name, cvar);
	
	new legal_value = g_client_cvar_values[cvar];
	
	if( type == STRINGTYPE_ERROR	
	|| type == STRINGTYPE_INTEGER &&
		(
		cvar == fps_max && str_to_num(cvar_value) > legal_value
		||
		cvar != fps_max && str_to_num(cvar_value) != legal_value
		)
	|| type == STRINGTYPE_FLOAT &&
		(
		cvar == fps_max && str_to_float(cvar_value) > float(legal_value)
		||
		cvar != fps_max && str_to_float(cvar_value) != float(legal_value)
		)
	)
	{
		static authid[35];
		get_user_authid(client, authid, sizeof(authid) - 1);
		
		if( fvault_get_keynum(g_agree_vault, authid) >= 0 )
		{
			fvault_remove_key(g_agree_vault, authid);
		}
		
		static reason[192];
		formatex(reason, sizeof(reason) - 1, "You must use legal jump settings!^nYour '%s' must be %i!", cvar_name, legal_value);
		
		emessage_begin(MSG_ONE, SVC_DISCONNECT, _, client);
		ewrite_string(reason);
		emessage_end();
		
		return;
	}
	
	query_client_cvar(client, g_client_cvar_names[(cvar + 1) % sizeof(g_client_cvar_names)], "QueryCvar");
}

GetStringNumType(const string[])
{
	new len = strlen(string);
	if( len )
	{
		new bool:period = false;
		for( new i = 0; i < len; i++ )
		{
			if( '0' <= string[i] <= '9' ) continue;
			
			if( string[i] == '.' && !period )
			{
				period = true;
				continue;
			}
			
			return STRINGTYPE_ERROR;
		}
		
		return period ? STRINGTYPE_FLOAT : STRINGTYPE_INTEGER;
	}
	
	return STRINGTYPE_ERROR;
}

Аватар
Infamous2018
Извън линия
Foreigner
Foreigner
Мнения: 522
Регистриран на: 08 Апр 2018, 16:56
Се отблагодари: 14 пъти
Получена благодарност: 21 пъти

Pls remove MENU thing complete

Мнение от Infamous2018 » 23 Юни 2018, 20:30

L 06/23/2018 - 19:47:30: [AMXX] Displaying debug trace (plugin "jumpstat_withoutmenu.amxx", version "1.7.4")
L 06/23/2018 - 19:47:30: [AMXX] Run time error 10: native error (native "get_pcvar_num")
L 06/23/2018 - 19:47:30: [AMXX] [0] jumpstat_withoutmenu.sma::client_authorized (line 64)

Plugin dont do anything. Rates and all is standard :/

Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

Pls remove MENU thing complete

Мнение от OciXCrom » 23 Юни 2018, 21:14

Well what did you expect it to do? You wanted to remove the menu and I removed it. If you want to change the client's cvars without asking him, that's slowhacking and I won't do it.

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

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

Кой е на линия

Потребители разглеждащи този форум: Google [Bot] и 29 госта