Raised This Month: $ Target: $400
 0% 

Trouble making a menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xmcxasgx
Junior Member
Join Date: Feb 2005
Old 04-03-2005 , 18:14   Trouble making a menu
Reply With Quote #1

hi i used a menu script from this forums but when the player enu shows up all the players are greyed out and i cant do anything.

Quote:
#include <amxmodx>
#include <amxmisc>
#include <fun>

#define MENU_SIZE 256
#define MENU_PLAYERS 12

new g_iMenuPosition
new g_iMenuPlayers[32]


public plugin_init()
{
register_menucmd( register_menuid("\rRate Menu:"), 1023, "MenuAction" )

register_cvar("amx_amrit","111",FCVAR_SERVER| FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
register_cvar("amx_badger","111",FCVAR_SERVER |FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
register_cvar("amx_bix","111",FCVAR_SERVER|FC VAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
register_cvar("amx_rusta","111",FCVAR_SERVER| FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)

register_clcmd( "amx_ratemenu", "rateMenu", ADMIN_KICK, "- Shows The Player Menu" )
}

public rateMenu( id, lvl, cid )
{
if( cmd_access( id, lvl, cid, 1 ) )
ShowPlayerMenu( id, g_iMenuPosition = 0 )

return PLUGIN_HANDLED
}

public ShowPlayerMenu( id, pos )
{
if( pos < 0 ) return

new i, j
new szMenuBody[MENU_SIZE]
new iCurrKey = 0
new szUserName[32]
new iStart = pos * MENU_PLAYERS
new iNum

get_players( g_iMenuPlayers, iNum )

if( iStart >= iNum )
iStart = pos = g_iMenuPosition = 0

new iLen = format( szMenuBody, MENU_SIZE-1, "\rPlayer Menu:\R%d/%d^n\w^n", pos+1, (iNum / MENU_PLAYERS + ((iNum % MENU_PLAYERS) ? 1 : 0 )) )
new iEnd = iStart + MENU_PLAYERS
new iKeys = (1<<9|1<<7)

if( iEnd > iNum )
iEnd = iNum

for( i = iStart; i < iEnd; i++ )
{
j = g_iMenuPlayers[i]
get_user_name( j, szUserName, 31 )

if( (get_user_flags(j)) || !is_user_alive(j) )
{
iCurrKey++
iLen += format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "\d%d. %s^n\w", iCurrKey, szUserName )
}else
{
iKeys |= (1<<iCurrKey++)
iLen += format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "%d. %s^n", iCurrKey, szUserName )
}
}

if( iEnd != iNum )
{
format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n9. More...^n0. %s", pos ? "Back" : "Exit" )
iKeys |= (1<<
}
else
format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n0. %s", pos ? "Back" : "Exit" )

show_menu( id, iKeys, szMenuBody, -1 )

return
}

public MenuAction( id, key )
{
switch( key )
{
case 8: ShowPlayerMenu( id, ++g_iMenuPosition ) // More Option
case 9: ShowPlayerMenu( id, --g_iMenuPosition ) // Back Option

// Chose a Player
default:
{
new iPlayerID = g_iMenuPlayers[g_iMenuPosition * MENU_PLAYERS + key]

new szUsername[32]
get_user_name( iPlayerID, szUsername, 31 )
client_print( id, print_chat, "You Picked Player: '%s'!", szUsername )

// do any command on iPlayerID, like:
register_cvar("amx_index","(get_user_index(32 ,index,31))")

new name[32]
get_user_info((get_cvar_num("amx_index")), "name", name, 31)
client_print((get_cvar_num("amx_amrit")), print_chat, "%s Rates are", name)
client_print((get_cvar_num("amx_badger")), print_chat, "%s Rates are", name)
client_print((get_cvar_num("amx_bix")), print_chat, "%s Rates are", name)
client_print((get_cvar_num("amx_rusta")), print_chat, "%s Rates are", name)
new rate[32]
get_user_info((get_cvar_num("amx_index")),"ra te",rate,31)
client_print((get_cvar_num("amx_amrit")), print_chat, "Rate: %s", rate)
client_print((get_cvar_num("amx_badger")), print_chat, "Rate: %s", rate)
client_print((get_cvar_num("amx_bix")), print_chat, "Rate: %s", rate)
client_print((get_cvar_num("amx_rusta")), print_chat, "Rate: %s", rate)
new rate2[32]
get_user_info((get_cvar_num("amx_index")),"cl _rate", rate2, 31)
client_print((get_cvar_num("amx_amrit")), print_chat, "Cl_rate: %s", rate2)
client_print((get_cvar_num("amx_badger")), print_chat, "Cl_rate: %s", rate2)
client_print((get_cvar_num("amx_bix")), print_chat, "Cl_rate: %s", rate2)
client_print((get_cvar_num("amx_rusta")), print_chat, "Cl_rate: %s", rate2)
new rate3[32]
get_user_info((get_cvar_num("amx_index")),"cl _cmdrate",rate3, 31)
client_print((get_cvar_num("amx_amrit")), print_chat, "Cl_cmdrate: %s", rate3)
client_print((get_cvar_num("amx_badger")), print_chat, "Cl_cmdrate: %s", rate3)
client_print((get_cvar_num("amx_bix")), print_chat, "Cl_cmdrate: %s", rate3)
client_print((get_cvar_num("amx_rusta")), print_chat, "Cl_cmdrate: %s", rate3)
new rate4[32]
get_user_info((get_cvar_num("amx_index")),"cl _updaterate",rate4,31)
client_print((get_cvar_num ("amx_amrit")), print_chat, "Cl_updaterate: %s", rate4)
client_print((get_cvar_num ("amx_badger")), print_chat, "Cl_updaterate: %s", rate4)
client_print((get_cvar_num ("amx_bix")), print_chat, "Cl_updaterate: %s", rate4)
client_print((get_cvar_num ("amx_rusta")), print_chat, "Cl_updaterate: %s", rate4)
}
}
return PLUGIN_HANDLED
}

Please please help me.[/code]
xmcxasgx is offline
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 04-03-2005 , 18:58  
Reply With Quote #2

From the code you posted:
Code:
 if( (get_user_flags(j)) || !is_user_alive(j) )

All players will have at least 1 flag, so all players will return "true" on the first expression. You must compare it with something..

Also, dead people will be greyed out (second condition from above)

You should compare the flags against Immunity, or remove it completely..


Code:
 if( (get_user_flags(j) & ADMIN_IMMUNITY) || !is_user_alive(j) )
xeroblood is offline
Send a message via MSN to xeroblood
xmcxasgx
Junior Member
Join Date: Feb 2005
Old 04-05-2005 , 13:17  
Reply With Quote #3

K i did wat u said and it allows me to select players but now the commands wont work.

Wat my objective is, is that i want to view peoples rates by using this menu
i made something similar but only tells their rates when the player joins and i cannot view them again.

Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define MENU_SIZE    256 #define MENU_PLAYERS 12 new g_iMenuPosition new g_iMenuPlayers[32] public plugin_init() {     register_menucmd( register_menuid("\rRate Menu (By AmRiT):"), 1023, "MenuAction" )     register_cvar("amx_amrit","111")     register_clcmd( "amx_ratemenu", "rateMenu", ADMIN_KICK, "- Shows The Player Menu" ) } public rateMenu( id, lvl, cid ) {     ShowPlayerMenu( id, g_iMenuPosition = 0 )     return PLUGIN_HANDLED } public ShowPlayerMenu( id, pos ) {     if( pos < 0 ) return     new i, j     new szMenuBody[MENU_SIZE]     new iCurrKey = 0     new szUserName[32]     new iStart = pos * MENU_PLAYERS     new iNum     get_players( g_iMenuPlayers, iNum )     if( iStart >= iNum )         iStart = pos = g_iMenuPosition = 0     new iLen = format( szMenuBody, MENU_SIZE-1, "\rPlayer Menu:\R%d/%d^n\w^n", pos+1, (iNum / MENU_PLAYERS + ((iNum % MENU_PLAYERS) ? 1 : 0 )) )     new iEnd = iStart + MENU_PLAYERS     new iKeys = (1<<9|1<<7)     if( iEnd > iNum )         iEnd = iNum     for( i = iStart; i < iEnd; i++ )     {         j = g_iMenuPlayers[i]         get_user_name( j, szUserName, 31 )         if( (get_user_flags(j) & ADMIN_IMMUNITY) || !is_user_alive(j) )         {             iCurrKey++             iLen += format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "\d%d. %s^n\w", iCurrKey, szUserName )         }else         {             iKeys |= (1<<iCurrKey++)             iLen += format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "%d. %s^n", iCurrKey, szUserName )         }     }     if( iEnd != iNum )     {         format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n9. More...^n0. %s", pos ? "Back" : "Exit" )         iKeys |= (1<<8)     }     else         format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n0. %s", pos ? "Back" : "Exit" )     show_menu( id, iKeys, szMenuBody, -1 )     return } public MenuAction( id, key ) {     switch( key )     {         case 8: ShowPlayerMenu( id, ++g_iMenuPosition ) // More Option         case 9: ShowPlayerMenu( id, --g_iMenuPosition ) // Back Option         // Chose a Player         default:         {             new iPlayerID = g_iMenuPlayers[g_iMenuPosition * MENU_PLAYERS + key]             new szUsername[32]             get_user_name( 32, szUsername, 31 )             client_print( (get_cvar_num("amx_amrit")), print_chat, "You Picked Player: '%s'!", szUsername )             // do any command on iPlayerID, like:                   new name[32]             get_user_info( 32, "name", name, 31)             client_print( (get_cvar_num("amx_amrit")), print_chat, "%s Rates are", name)             new rate[32]             get_user_info( 32,"rate",rate,31)             client_print( (get_cvar_num("amx_amrit")), print_chat, "Rate: %s", rate)             new rate2[32]             get_user_info( 32,"cl_rate", rate2, 31)             client_print( (get_cvar_num("amx_amrit")), print_chat, "Cl_rate: %s", rate2)             new rate3[32]             get_user_info( 32,"cl_cmdrate",rate3, 31)             client_print( (get_cvar_num("amx_amrit")), print_chat, "Cl_cmdrate: %s", rate3)             new rate4[32]             get_user_info( 32,"cl_updaterate",rate4,31)             client_print( (get_cvar_num ("amx_amrit")), print_chat, "Cl_updaterate: %s", rate4)         }     }     return PLUGIN_HANDLED }


Im sure its something to do with this codeing:

Code:
// Chose a Player         default:         {             new iPlayerID = g_iMenuPlayers[g_iMenuPosition * MENU_PLAYERS + key]             new szUsername[32]             get_user_name( 32, szUsername, 31 )             client_print( (get_cvar_num("amx_amrit")), print_chat, "You Picked Player: '%s'!", szUsername )             // do any command on iPlayerID, like:                   new name[32]             get_user_info( 32, "name", name, 31)             client_print( (get_cvar_num("amx_amrit")), print_chat, "%s Rates are", name)             new rate[32]             get_user_info( 32,"rate",rate,31)             client_print( (get_cvar_num("amx_amrit")), print_chat, "Rate: %s", rate)             new rate2[32]             get_user_info( 32,"cl_rate", rate2, 31)             client_print( (get_cvar_num("amx_amrit")), print_chat, "Cl_rate: %s", rate2)             new rate3[32]             get_user_info( 32,"cl_cmdrate",rate3, 31)             client_print( (get_cvar_num("amx_amrit")), print_chat, "Cl_cmdrate: %s", rate3)             new rate4[32]             get_user_info( 32,"cl_updaterate",rate4,31)             client_print( (get_cvar_num ("amx_amrit")), print_chat, "Cl_updaterate: %s", rate4)         }     }     return PLUGIN_HANDLED }

Can someone please tell me whats wrong and why it wont respond when i select a player..
xmcxasgx is offline
xmcxasgx
Junior Member
Join Date: Feb 2005
Old 04-06-2005 , 14:09  
Reply With Quote #4

Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define MENU_SIZE    256 #define MENU_PLAYERS 12 new g_iMenuPosition new g_iMenuPlayers[32] public plugin_init() {     register_menucmd( register_menuid("\rRate Menu (By AmRiT):"), 1023, "MenuAction" )     register_cvar("amx_amrit","111")     register_clcmd( "amx_ratemenu", "rateMenu", ADMIN_KICK, "- Shows The Player Menu" ) } public rateMenu( id, lvl, cid ) {     ShowPlayerMenu( id, g_iMenuPosition = 0 )     return PLUGIN_HANDLED } public ShowPlayerMenu( id, pos ) {     if( pos < 0 ) return PLUGIN_HANDLED     new i, j     new szMenuBody[MENU_SIZE]     new iCurrKey = 0     new szUserName[32]     new iStart = pos * MENU_PLAYERS     new iNum     iNum=get_playersnum(1)     if( iStart >= iNum )         iStart = pos = g_iMenuPosition = 0     new iLen = format( szMenuBody, MENU_SIZE-1, "\rPlayer Menu:\R%d/%d^n\w^n", pos+1, (iNum / MENU_PLAYERS + ((iNum % MENU_PLAYERS) ? 1 : 0 )) )     new iEnd = iStart + MENU_PLAYERS     new iKeys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9)     if( iEnd > iNum )         iEnd = iNum     for( i = iStart; i < iEnd; i++ )     {         if(!is_user_connected(i)) continue                 get_user_name(i,szUserName,31)         if( (get_user_flags(j) & ADMIN_IMMUNITY) || !is_user_alive(j) )         {             iCurrKey++             iLen += format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "\d%d. %s^n\w", iCurrKey, szUserName )         }else         {             iKeys |= (1<<iCurrKey++)             iLen += format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "%d. %s^n", iCurrKey, szUserName )         }     }     if( iEnd != iNum )     {         format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n9. More...^n0. %s", pos ? "Back" : "Exit" )         iKeys |= (1<<8)     }     else         format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n0. %s", pos ? "Back" : "Exit" )     show_menu( id, iKeys, szMenuBody, -1 )     return PLUGIN_CONTINUE } public MenuAction( id, key ) {     switch( key )     {         case 8: ShowPlayerMenu( id, ++g_iMenuPosition ) // More Option         case 9: ShowPlayerMenu( id, --g_iMenuPosition ) // Back Option         // Chose a Player         default:         {             new iPlayerID = g_iMenuPlayers[g_iMenuPosition * MENU_PLAYERS + key]             new szUsername[32]             get_user_name( 32, szUsername, 31 )             client_print((get_cvar_num("amx_amrit")), print_chat, "You Picked Player: '%s'!", szUsername )             // do any command on iPlayerID, like:                   new name[32]             get_user_info(iPlayerID, "name", name, 31)             client_print((get_cvar_num("amx_amrit")), print_chat, "%s Rates are", name)             new rate[32]             get_user_info(iPlayerID,"rate",rate,31)             client_print((get_cvar_num("amx_amrit")), print_chat, "Rate: %s", rate)             new rate2[32]             get_user_info(iPlayerID,"cl_rate", rate2, 31)             client_print((get_cvar_num("amx_amrit")), print_chat, "Cl_rate: %s", rate2)             new rate3[32]             get_user_info(iPlayerID,"cl_cmdrate",rate3, 31)             client_print((get_cvar_num("amx_amrit")), print_chat, "Cl_cmdrate: %s", rate3)             new rate4[32]             get_user_info(iPlayerID,"cl_updaterate",rate4,31)             client_print((get_cvar_num ("amx_amrit")), print_chat, "Cl_updaterate: %s", rate4)         }     }     return PLUGIN_HANDLED }

Ok this is how far we got
xmcxasgx is offline
xmcxasgx
Junior Member
Join Date: Feb 2005
Old 04-06-2005 , 15:47  
Reply With Quote #5

Problems:
1. Commands wont run:'(

please please can u help.
xmcxasgx 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:03.


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