Raised This Month: $ Target: $400
 0% 

Optimize ChooseTeam Menu?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 04-27-2013 , 19:18   Optimize ChooseTeam Menu?
Reply With Quote #1

ive made this choose team menu for when someone presses ( M ).

just wondering if it can be optimized smaller?

Code:
#include < amxmodx > #include < amxmisc > #include < cstrike > #define PLUGIN "Custom ChooseTeam" #define VERSION "1.0" #define AUTHOR "Blizzard" //new CsTeams:g_szTeam[ 32 ]; new bool:g_szCurrentTeam[ 33 ][ 4 ]; new g_CallBack; new const TeamNames[][] = {     "Terrorist",     "Counter-Terrorist",     "Auto-Select",     "Spectate" }; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         g_CallBack = menu_makecallback("CheckCurrentTeam");         register_clcmd("chooseteam", "cmdChooseTeam", 0); } public cmdChooseTeam(id) {     CheckTeam(id)         new Item[ 101 ], iNum;         formatex(Item, 100, "Choose Team:");     new menu = menu_create(Item, "ChooseTeam_handler");         for( iNum = 0; iNum < sizeof TeamNames; iNum++ )     {         formatex(Item, 100, "%s", TeamNames[ iNum ]);         menu_additem(menu, Item, "0", 0, g_CallBack);     }     menu_display(id, menu, 0);     return PLUGIN_HANDLED; } public CheckCurrentTeam(id, menu, item) {     switch(g_szCurrentTeam[ id ][ item ])     {         case true: return ITEM_DISABLED;         case false: return ITEM_ENABLED;     }         return PLUGIN_CONTINUE; } public ChooseTeam_handler(id, menu, item) {     if( item == MENU_EXIT )     {         menu_destroy(menu);         return PLUGIN_HANDLED;     }             set_user_team( id, item )     menu_destroy(menu);     return PLUGIN_HANDLED; } public CheckTeam(id) {     if(is_user_connected(id))     {         switch(cs_get_user_team(id))         {             case CS_TEAM_T:             {                 g_szCurrentTeam[ id ][ 0 ] = true;                 g_szCurrentTeam[ id ][ 1 ] = false;                 g_szCurrentTeam[ id ][ 2 ] = false;                 g_szCurrentTeam[ id ][ 3 ] = false;             }             case CS_TEAM_CT:             {                   g_szCurrentTeam[ id ][ 0 ] = false;                 g_szCurrentTeam[ id ][ 1 ] = true;                 g_szCurrentTeam[ id ][ 2 ] = false;                 g_szCurrentTeam[ id ][ 3 ] = false;             }             case CS_TEAM_SPECTATOR:             {                 g_szCurrentTeam[ id ][ 0 ] = false;                 g_szCurrentTeam[ id ][ 1 ] = false;                 g_szCurrentTeam[ id ][ 2 ] = false;                 g_szCurrentTeam[ id ][ 3 ] = true;             }         }     } } stock set_user_team( id, teamnum) {     new players[32], pNum;         get_players(players, pNum)         user_kill( id )     switch(teamnum)     {         case 0: cs_set_user_team( id, CS_TEAM_T );         case 1: cs_set_user_team( id, CS_TEAM_CT );         case 2:         {             switch( random_num( 1, 100 ) )             {                 case 1..49: cs_set_user_team( id, CS_TEAM_T );                 case 50..100: cs_set_user_team( id, CS_TEAM_CT );             }         }         case 3: cs_set_user_team( id, CS_TEAM_SPECTATOR );     }         if(pNum == 1)     {         server_cmd("sv_restart 1")     } }

EDIT: added Callback its a lil better....

but still need to know if i can do this whole plugin better?
__________________

Last edited by Blizzard_87; 04-27-2013 at 20:57.
Blizzard_87 is offline
 



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 10:48.


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