AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Make a menu that shows up names (https://forums.alliedmods.net/showthread.php?t=10347)

XunTric 02-16-2005 15:22

Make a menu that shows up names
 
1 Attachment(s)
I made a plugin that changes a players team in counter-strike.
And i want to add a menu on it too. (called amx_team_menu)
Like the first menu shows all names on the server, and when you choose a player you can choose if you want him to go on ct, terror or spectate.
Ive read the menu help in amxmodx doc a lot of times, but i just dont get this menu to work.
Can somebody help me make this menu?
And here is the plugin that i want to add a menu on if that helps...

Peli 02-16-2005 17:18

Would this AMX(X) Menu Tutorial by Xeroblood help? :)

XunTric 02-17-2005 10:23

Thats for amx? And ive read somewhere that the "add" thing is really waste of code. You can make it with much less code and and "add" maybe crashes the server. am i right?
-----------------------------------
EDIT:
Thats just a one page menu. What im looking for is a multi-menu tutorial. Like the first page shows all the name on the server, and when you choose a name you get a new menu where you can choose to set the player in counter-terrorists, terrorists or spectate. Thanks for the help anyway peli.
----------------------------------
EDIT AGAIN:
Ok i found a multi-menu tutorial there too, but its still for amx and it doesnt stand anything about how to make the menu show up all the names on the server...

xeroblood 02-17-2005 11:22

Just an example, I didnt actually test this, but it is pretty straight-forward:

Code:
#include <amxmodx> #include <amxmisc> #define MAX_DISPLAY 8   //  This is the number of Options per page (Dont change) // Tracks what page in menu admin is on.. new g_nMenuPosition[33] public plugin_init() {     register_menucmd( register_menuid("\yPlayer Menu:"), 1023, "MenuCommand" )     register_clcmd( "player_menu", "DoShowMenu", ADMIN_MENU, "Shows The Player menu" ) } public MenuCommand( id, key ) {     switch( key )     {         case 8: PlayerMenu( id, ++g_nMenuPosition[id] )         case 9: PlayerMenu( id, --g_nMenuPosition[id] )         default:         {             // This is the Chosen Player Index             new iIndex = g_nMenuPosition[id] * MAX_DISPLAY + key             // Get the Chosen Players Name             new szUsername[32]             get_user_name( iIndex, szUsername, 31 )             // Print Username to Admin who called Menu             client_print( id, print_chat, "You Selected: %s", szUsername )         }     }     return PLUGIN_HANDLED } public PlayerMenu( id, pos ) {     if( pos < 0 ) return     new iMenuPlayers[32], iNum     get_players( iMenuPlayers, iNum )     new i, j, nCurrKey = 0     new szUserName[32]     new szMenuBody[256]     new nStart = pos * MAX_DISPLAY     if( nStart >= iNum )         nStart = pos = g_nMenuPosition[id-1] = 0     new nLen = format( szMenuBody, 255, "\yPlayer Menu:\R%d/%d^n\w^n", (pos+1), (iNum / MAX_DISPLAY + ((iNum % MAX_DISPLAY) ? 1 : 0 )) )     new nEnd = nStart + MAX_DISPLAY     new nKeys = (1<<9)     if( nEnd > iNum ) nEnd = iNum     for( i = nStart; i < nEnd; i++ )     {         j = iMenuPlayers[i]         get_user_name( j, szUserName, 31 )         if( access( j, ADMIN_IMMUNITY ) )         {             nCurrKey++             nLen += format( szMenuBody[nLen], (255-nLen), "\d%d. %s^n\w", nCurrKey, szUserName )         }else         {             nKeys |= (1<<nCurrKey++)             nLen += format( szMenuBody[nLen], (255-nLen), "%d. %s^n", nCurrKey, szUserName )         }     }     if( nEnd != iNum )     {         format( szMenuBody[nLen], (255-nLen), "^n9. More...^n0. Back" )         nKeys |= (1<<8)     }     else     {         format( szMenuBody[nLen], (255-nLen), "^n0. Back" )     }     show_menu( id, nKeys, szMenuBody )     return } public DoShowMenu( id, lvl, cid ) {     if( cmd_access( id, lvl, cid, 0 ) )         PlayerMenu( id, g_nMenuPosition[id] = 0 )     return PLUGIN_HANDLED }

I hope that helps!

XunTric 02-17-2005 14:00

It works :D thanks
It shows up the names and when you click on it nothing happends.
Can you help me add that too?
Here is the command lines to change team if that helps:

Terror:
Code:
cs_set_user_team(player, CS_TEAM_T, CS_T_TERROR)
CT:
Code:
cs_set_user_team(player, CS_TEAM_CT, CS_CT_SAS)
Spectate:
Code:
cs_set_user_team(player, CS_TEAM_SPECTATOR, CS_DONTCHANGE)
-------------------------------------
EDIT:
And make the player die when the command is used.

XunTric 02-19-2005 04:37

...xeroblood?

xeroblood 02-19-2005 10:52

It should print the name of the player you chose..

To make it change a players team, you would edit this function:

Code:
public MenuCommand( id, key ) {     switch( key )     {         case 8: PlayerMenu( id, ++g_nMenuPosition[id] )         case 9: PlayerMenu( id, --g_nMenuPosition[id] )         default:         {             // This is the Chosen Player Index             new iIndex = g_nMenuPosition[id] * MAX_DISPLAY + key             // Get the Chosen Players Name             new szUsername[32]             get_user_name( iIndex, szUsername, 31 )             // Print Username to Admin who called Menu             client_print( id, print_chat, "You Selected: %s", szUsername )         }     }     return PLUGIN_HANDLED }

Where iIndex is the ID of the chosen player...

Now, you want the player to be changed to a different team?? Which team?? Are you gonna pick the team for them, or just put them on opposite team?

XunTric 02-19-2005 11:51

I want to choose a team for them. I want to choose Counter-Terrorists, Terrorists or Spectate. The commands to do that did i say in other post...

Quote:

Originally Posted by XunTric
Terror:
Code:
cs_set_user_team(player, CS_TEAM_T, CS_T_TERROR)
CT:
Code:
cs_set_user_team(player, CS_TEAM_CT, CS_CT_SAS)
Spectate:
Code:
cs_set_user_team(player, CS_TEAM_SPECTATOR, CS_DONTCHANGE)


XunTric 02-21-2005 04:52

...xeroblood???? :lol:

xeroblood 02-21-2005 10:19

You will need a secondary menu for that... After choosing a player, you should open a second menu to display the choices of teams..

I will whip something together for ya later on, but you will be happier if you're able to figure it out yourself...

Either way, I'm kinda busy ATM, so I will throw something together later on...


All times are GMT -4. The time now is 19:28.

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