Raised This Month: $51 Target: $400
 12% 

Pls remove MENU thing complete


Post New Thread Closed Thread   
 
Thread Tools Display Modes
Author Message
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 06-23-2018 , 06:35   Pls remove MENU thing complete
#1

Code:
#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;
}
Godofwar is offline
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 06-23-2018 , 06:49   Re: Pls remove MENU thing complete
#2

What!?
You need to give more description.
__________________
CrAzY MaN is offline
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 06-23-2018 , 06:58   Re: Pls remove MENU thing complete
#3

i mean to remove the auto menu to accept rules

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 );
Godofwar is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 06-23-2018 , 10:34   Re: Pls remove MENU thing complete
#4

Quote:
Originally Posted by Godofwar View Post
i mean to remove the auto menu to accept rules

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 );
Line 111 in Public FwdPlayerSpawn

Delete the line that open your menu
Code:
ShowAgreeMenu

Last edited by Fuck For Fun; 06-23-2018 at 18:12.
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-23-2018 , 14:32   Re: Pls remove MENU thing complete
#5

Looks like that would make this a slowhacking plugin which is not supported here.
__________________
fysiks is offline
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:07.


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