Raised This Month: $ Target: $400
 0% 

Can anyone check if there is a better way to do this?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Alahmoh
Member
Join Date: Jun 2018
Old 08-07-2022 , 16:26   Can anyone check if there is a better way to do this?
Reply With Quote #1

Code:
public plugin_init( ) {
register_menucmd(register_menuid("Show_HudMenu")(1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9), "Handle_HudMenu");
}
ShowHud( player ) {
		new R,G,B,X,Y;
		
		
		if( g_iUserStatus[ player ] == 1 ) {
			X = 0.02;
			Y = 0.158;
			R = 0;
			G = 255;
			B = 255;
		}
		
		if( g_iHudLcr[ player ] == 1 ) {
			X = 0.02;
		}else if( g_iHudLcr[ player ] == 2 ) {
			X = 0.30;
		}else if( g_iHudLcr[ player ] == 3 ) {
			X = 1.0;
		}
		if( g_iUserColor[ player ] == 1 ) {
			R = 0;
			G = 255;
			B = 255;
		}else if( g_iUserColor[ player ] == 2 ) {
			R = 255;
			G = 0;
			B = 0;
		}else if( g_iUserColor[ player ] == 3 ) {
			R = 0;
			G = 255;
			B = 0;
		}else if( g_iUserColor[ player ] == 4 ) {
			R = 210;
			G = 180;
			B = 140;
		}else if( g_iUserColor[ player ] == 5 ) {
			R = 255;
			G = 20;
			B = 147;
		}else if( g_iUserColor[ player ] == 6 ) {
			R = 255;
			G = 140;
			B = 0;
		}else if( g_iUserColor[ player ] == 7 ) {
			R = 75;
			G = 0;
			B = 130;
		}
			
			
		if( g_iHudUcd[ player ] == 1 ) {
			Y = 0.158;
		}else if( g_iHudUcd[ player ] == 2 ) {
			Y = 0.50;
		}else if( g_iHudUcd[ player ] == 3 ) {
			Y = 1.0;
		}

		set_hudmessage( R, G, B, is_user_alive( player ) ? X : 0.6, is_user_alive( player ) ? Y : 0.5, 0, 6.0, 0.1 );
}

public Show_HudMenu( player ) {
	new szText[ 64 ], iKeys = (1<<0|1<<9);
	formatex( szText, charsmax( szText ), "\r%L", iPlayer, "ML_HUDMENU" );

	new iMenu = menu_create( szText, "Handle_HudMenu" );
	formatex( szText, charsmax( szText ), "%L %L", player, "ML_HUDPREFIX", player, g_szHudCN[g_iUserStatus[ player ]][1] );
	menu_additem( iMenu, szText );
		
	if(g_iUserStatus[ player ]) {
		formatex( szText, charsmax( szText ), "%L %L", player, "ML_HUDPREFIX", player, g_szHudMenu[g_iUserColor[ player ]][1] );
		menu_additem( iMenu, szText );
		
		formatex( szText, charsmax( szText ), "%L %L", player, "ML_HUDPREFIX", player, g_szHudMenuLcr[g_iHudLcr[ player ]][1] );
		menu_additem( iMenu, szText );
		
		formatex( szText, charsmax( szText ), "%L %L", player, "ML_HUDPREFIX", player, g_szHudMenuUcd[g_iHudUcd[ player ]][1] );
		menu_additem( iMenu, szText );
		iKeys |= (1<<1|1<<2|1<<3|1<<4);
	}else { 
		formatex( szText, charsmax( szText ), "%L %L", player, "ML_HUDPREFIX", player, "ML_LOCKED" );
		menu_additem( iMenu, szText );
		
		formatex( szText, charsmax( szText ), "%L %L", player, "ML_HUDPREFIX", player, "ML_LOCKED" );
		menu_additem( iMenu, szText );
		
		formatex( szText, charsmax( szText ), "%L %L", player, "ML_HUDPREFIX", player, "ML_LOCKED" );
		menu_additem( iMenu, szText );
	}
	
	formatex( szText, charsmax( szText ), "%L", player, "ML_DEFAULT" );
	menu_additem( iMenu, szText );
	
	formatex( szText, charsmax( szText ), "%L", player, "ML_SAVE" );
	menu_additem( iMenu, szText );
	
	menu_display( player, iMenu );
}

public Handle_HudMenu( player, iMenu, iItem ) {
	client_cmd( player, "spk select" );
	
	if( iItem == MENU_EXIT ) {
		menu_destroy( iMenu );
		return PLUGIN_CONTINUE;
	}
	
	switch( iItem ) {
		case 0: g_iUserStatus[ player ] = !g_iUserStatus[ player ];
		
		case 1: if((sizeof(g_szHudMenu) - 1) <= g_iUserColor[ player ]) g_iUserColor[ player ] = 1;
			else if(g_iUserStatus[ player ]) {
				g_iUserColor[ player ]++;
			}else return Show_HudMenu(iPlayer);
			
		case 2: if((sizeof(g_szHudMenuLcr) - 1) <= g_iHudLcr[ player ]) g_iHudLcr[ player ] = 1;
			else if(g_iUserStatus[ iPlayer ]) {
				g_iHudLcr[ player ]++;
			}else return Show_HudMenu(iPlayer);
			
		case 3: if((sizeof(g_szHudMenuUcd) - 1) <= g_iHudUcd[ player ]) g_iHudUcd[ player ] = 1;
			else if(g_iUserStatus[ player ]) {
				g_iHudUcd[ player ]++;
			}else return Show_HudMenu(player);
		
		case 4: {
			g_iHudUcd[ player ] = 1;
			g_iHudLcr[ player ] = 1;
			g_iUserColor[ player ] = 1;
			
			ColorChat( player,NORMAL, "!g[CoD:Mw] !n%L", player, "ML_BACK_TO_DEFAULT" );
		}

		case 5: {
			SaveHud( player );
			
			ColorChat( iPlayer, NORMAL,"!g[CoD:Mw] !n%L", player, "ML_SAVED" );
		}
	}
	
	return Show_HudMenu(player);
}
it works perfectly fine but when i compile i get like 17 warnings.
so i wonder if there is a better way to get the same results without getting 17 warnings?

Last edited by Alahmoh; 08-07-2022 at 16:30.
Alahmoh is offline
 


Thread Tools
Display Modes

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 15:41.


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