Raised This Month: $ Target: $400
 0% 

Optimize ChooseTeam Menu?


Post New Thread Reply   
 
Thread Tools Display Modes
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
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-28-2013 , 05:07   Re: Optimize ChooseTeam Menu?
Reply With Quote #2

You can't set teams properly like this.
Better to just edit the menu text that the game send to player, and to remove some keys from it if you need, then when player chooses the key, game gonna handle it and properly set teams.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 04-28-2013 , 05:18   Re: Optimize ChooseTeam Menu?
Reply With Quote #3

thanks. could you give small example on how to correctly. or a link for me to read up on it?
__________________
Blizzard_87 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-28-2013 , 05:28   Re: Optimize ChooseTeam Menu?
Reply With Quote #4

Example is on the forum, let's search for it.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 04-28-2013 , 09:49   Re: Optimize ChooseTeam Menu?
Reply With Quote #5

ive now changed it with usage of
Code:
new CsTeams:g_szTeams[ 33 ];

is this a more efficient way of changing teams?
__________________

Last edited by Blizzard_87; 04-28-2013 at 09:49.
Blizzard_87 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-28-2013 , 17:59   Re: Optimize ChooseTeam Menu?
Reply With Quote #6

No no no...


You are lucky : http://forums.alliedmods.net/showpos...35&postcount=4
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 04-28-2013 , 20:26   Re: Optimize ChooseTeam Menu?
Reply With Quote #7

Quote:
Originally Posted by ConnorMcLeod View Post
thats editing the current default choose team menu....

the one i made is a custom one that replaces the original one instead of using the default ones (menu / gui )
__________________
Blizzard_87 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-29-2013 , 00:38   Re: Optimize ChooseTeam Menu?
Reply With Quote #8

And you can't do that, has already been tested in the past and doesn't work at all.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 04-29-2013 , 02:23   Re: Optimize ChooseTeam Menu?
Reply With Quote #9

Quote:
Originally Posted by ConnorMcLeod View Post
And you can't do that, has already been tested in the past and doesn't work at all.
ok thanks for your help.
__________________
Blizzard_87 is offline
Reply



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