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 );
}
}
...
Any error message?
timescale 0.01
no , but if i add
i dont have msg : name : **PHP Code:
player setClientCvar( "ui_player_name_" + i, "name :" player.name );
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)
kung foo man (1st May 2013)