it is too hard for your level
You can prepare 64 scriptMenuResponse-Buttons and 64 Textfields, which display 64 DVar's.
Thats the basic idea, I guess you can already do it know, since you made that menu already.
timescale 0.01
how to do to read a player id and name?
dvar
self setClientCvar("id0", ID : ** , NAME : ** );
getEntityNumber();
player.name
Last edited by malyczolg; 30th April 2013 at 15:50.
The only way to show any variable on a menu is through text. And the usual way to do that is with the use of a dvar. And as Kung says, you would need as many dvars as there are players. So, if you have 64 players on your server, you need 64 dvars for the name, and 64 dvars for the client entity number. And of course, you will need 128 itemDef{} to show them all (64 for the names, and 64 for the client entity number).
Now, once you've got all that set up, to show the player's name and his entity number, you have to save the values to a dvar. Then set the dvar in the menu itemDef{}:
Example:
Set the Dvars:
Set the itemDef{}:PHP Code:
players = getEntArray( "player", "classname" );
for( i=0; i < players.size; i++ )
{
player = players[i];
if( player getEntityNumber() == i )
{
player setClientCvar( "ui_player_name_" + i, player.name );
player setClientCvar( "ui_player_entNum_" + i, i );
}
}
[php]PHP Code:
itemDef
{
name "player_name_1"
visible 1
rect 0 0 128 24
origin ORIGIN_POSITION1
forecolor 1.000 0.647 0.290 1
type ITEM_TYPE_BUTTON
dvar "ui_player_name_1"
textfont UI_FONT_NORMAL
textscale COUNT_SIZE
textstyle ITEM_TEXTSTYLE_SHADOWED
textaligny 20
textalignx 20
decoration
}
PHP Code:
itemDef
{
name "player_entNum_1"
visible 1
rect 0 0 128 24
origin ORIGIN_POSITION1
forecolor 1.000 0.647 0.290 1
type ITEM_TYPE_BUTTON
dvar "ui_player_entNum_1"
textfont UI_FONT_NORMAL
textscale COUNT_SIZE
textstyle ITEM_TEXTSTYLE_SHADOWED
textaligny 20
textalignx 20
decoration
}
Last edited by Tally; 1st May 2013 at 06:20.
PHP Code:
itemDef
{
name p0
type ITEM_TYPE_BUTTON
style WINDOW_STYLE_FILLED
dvar "ui_player_name_1"
rect 195 76 190 11
visible 1
mouseEnter
{
play "mouse_over";
setitemcolor p0 backcolor 1 0 0 0.3
}
mouseExit
{
setitemcolor p0 backcolor 0 0 0 0
}
action
{
play "mouse_click";
scriptmenuresponse "0"
}
}
why not work ?PHP Code:
Callback_PlayerConnect()
{
players = getEntArray( "player", "classname" );
for( i=0; i < players.size; i++ )
{
player = players[i];
if( player getEntityNumber() == i )
{
player setClientCvar( "ui_player_name_" + i, player.name );
player setClientCvar( "ui_player_entNum_" + i, i );
}
}
...
You wont be able to show the result of a dvar if you use the action{} element in an itemDef{}. Also, you aren't defining the font and fontstyle and size. It wont show unless you do that.
So, you will have to make 2 itemDef{} and use them as one. What I usually do is use the one with the action{} element to show the other, like this:
PHP Code:
itemDef
{
name p0
type ITEM_TYPE_BUTTON
dvar "ui_player_name_1"
rect 195 76 190 11
type ITEM_TYPE_BUTTON
dvar "ui_allies_assault_total"
textfont UI_FONT_NORMAL
textscale COUNT_SIZE
textstyle ITEM_TEXTSTYLE_SHADOWED
textaligny 10
textalignx 10
visible 0
decoration
}
itemDef
{
name p0
type ITEM_TYPE_BUTTON
rect
visible 1
decoration
mouseEnter
{
show p0;
play "mouse_over";
setitemcolor p0 backcolor 1 0 0 0.3;
}
mouseExit
{
setitemcolor p0 backcolor 0 0 0 0;
hide p0;
}
action
{
play "mouse_click";
scriptmenuresponse "0";
}
}
kung foo man (1st May 2013)
Using a dvar as text, checking dvar to show at all, and with an action... shows perfectly fine.Code:itemDef { name rcon_button type ITEM_TYPE_BUTTON dvar "rcon_rsp_player0" rect 0 0 SLOT_SIZE origin ORIGIN_SLOT textstyle OPTIONS_ITEM_TEXT_STYLE textalign OPTIONS_ITEM_ALIGN textalignx SLOT_ALIGNX textaligny SLOT_ALIGNY textscale SLOT_TXTSCALE style WINDOW_STYLE_FILLED backcolor OPTIONS_CONTROL_BACKCOLOR forecolor OPTIONS_CONTROL_FORECOLOR visible 1 dvartest "rcon_rsp_result" showDvar { "1" } action { play "mouse_click"; scriptMenuResponse "rcon_cmd_player0"; } mouseEnter { play "mouse_over"; } }
kung foo man (2nd May 2013)
i did hours of testing and came up with some goodies to bring the max dynamic in cod2 .menu modding
the following menu contains everything what is possible in cod2
heres the result for those, who will understand and use it:
you are allowed to use strings in a macro combined with the stringify operator (##)Code:#define POS_TEXT_1 100 100 #define DRAW_BUTTON_DVAR_TEXT( _id , _name , _dvar ) \ itemDef \ { \ visible 1 \ rect POS_ ## _id 80 80 HORIZONTAL_ALIGN_RIGHT VERTICAL_ALIGN_CENTER \ origin 10 10 \ forecolor GLOBAL_UNFOCUSED_COLOR \ type ITEM_TYPE_BUTTON \ dvar _dvar ## "_text" \ textscale 0.3 \ textstyle ITEM_TEXTSTYLE_SHADOWEDMORE \ textalign ITEM_ALIGN_CENTER \ textalignx 40 \ textaligny 45 \ dvartest _dvar ## "_text" \ hideDvar \ { \ ""; \ } \ action \ { \ play "mouse_click"; \ scriptMenuResponse "response_" ## _name; \ } \ } \ ... ... ... DRAW_BUTTON_DVAR_TEXT( TEXT_1 , "button_next" , "ui_next_" )
restrictions:
-only 1 macro can be defined in another macro
-dont use global defined vars in a macro combined with the stringify
kung foo man (2nd May 2013)