View Single Post
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 02-27-2019 , 16:08   Re: [Any]Binding button for server
Reply With Quote #2

Thanks.

Code:
			if(StrEqual(item, command_1, false))
			{
				strcopy(tab_command[param1], 32, command_1);
			}	
			else if(StrEqual(item, command_2, false))
			{
				strcopy(tab_command[param1], 32, command_2);
			}
			else if(StrEqual(item, command_3, false))
			{
				strcopy(tab_command[param1], 32, command_3);
			}
			else if(StrEqual(item, command_4, false))
			{
				strcopy(tab_command[param1], 32, command_4);
			}
			else if(StrEqual(item, command_5, false))
			{
				strcopy(tab_command[param1], 32, command_5);
			}
you can cut to:
Code:
strcopy(tab_command[param1], sizeof(tab_command[]), item);
Code:
strcopy(tab_command[param1], 32, command_6);
>>>
Code:
tab_command[param1][0] = '\0';
All code could be cut to 1/2 size. All menus can be "packed" to 1. You can just create one more global variable g_iClientChoose[MAXPLAYERS+1] (int or string) and store there currently selected item. Next, in the final menu handler you can check that variable and such a way you know what string array you need to copy item to.

Also, instead of FindConVar you can use globally declared handles (ConVar). Just assign values returned by CreateConVar. Usually, for that kind of job people use HookConVarChange instead of OnMapStart.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 02-27-2019 at 16:14.
Dragokas is offline