
 |
| Author |
Topic: Rcon login in quickmenu |
|
|
Category: CoD2 Scripting Posted: Saturday, Nov. 21, 2009 09:52 am |
 |
Hiya!
I need some help with a way to do /rcon login from quickmenu. I wanted it to be like the normal password popup (from the server selection window), so i found the code, and implented in my mod. It can open the menu and the popup box, but theres a few problems with it.
1. When opening it, you need to move your mouse over the text field, before you can start typing the password.
2. I can't make it login using the password typed in the box.
Heres the code i use:
Code: menuDef {
name "EQrconpass_input"
visible 0
fullscreen 0
rect 204 190 235 235
focusColor GLOBAL_FOCUSED_COLOR
style 1
border 1
popup
onESC { close EQrconpass_input }
onOpen
{
setDvar cl_bypassMouseInput "0"
}
onClose
{
setDvar cl_bypassMouseInput "1"
}
itemDef
{
name window
group grpControlbutton
rect 0 40 235 135
style WINDOW_STYLE_FILLED
border 1
bordercolor .5 .5 .5 .5
forecolor 1 1 1 1
backcolor .1 .1 .1 1
visible 1
decoration
}
itemDef
{
name window2
group grpControlbutton
rect 2 42 231 20
style WINDOW_STYLE_FILLED
border 1
bordercolor .1 .1 .1 .2
forecolor 1 1 1 1
backcolor .3 0.5 0.2 0.5
visible 1
decoration
}
// PASSWORD //
itemDef {
name window_title
text "@MENU_PASSWORD"
style 0
decoration
textscale .3
rect 1 44 110 20
textalign 1
textalignx 117
textaligny 16
forecolor 1 1 1 1
visible 1
}
itemDef {
name passwordEntry
group grpControls
TYPE 4
text " "
dvar "eq_rconlogin1"
rect 30 75 179 12
maxchars 12
maxpaintchars 12
textalign ITEM_ALIGN_RIGHT
textalignx 0
textaligny 10
textfont UI_FONT_NORMAL
textscale .25
forecolor OPTIONS_CONTROL_FORECOLOR
style WINDOW_STYLE_FILLED
backcolor 1 1 1 .3
visible 1
mouseenter { show keyBindStatus; play "mouse_over"; }
mouseexit { hide keyBindStatus }
}
itemDef {
name yes
text "@MENU_OK"
type ITEM_TYPE_BUTTON
textfont UI_FONT_NORMAL
textscale GLOBAL_TEXTSCALE1
textstyle UI_BUTTON_TEXT_STYLE
style UI_BUTTON_STYLE
border UI_BUTTON_BORDER
bordercolor UI_BUTTON_BORDER_COLOR
rect 70 150 100 15
textalign 1
textalignx 51 // center
textaligny 11
backcolor UI_BUTTON_BACK_COLOR
forecolor UI_BUTTON_TEXT_COLOR
visible 1
action {
play "mouse_click"
close EQrconpass_input
exec "rcon login {vstr eq_rconlogin1}"; //<---- THE PROBLEM!!
}
mouseEnter { setitemcolor yes backcolor UI_BUTTON_BACK_COLOR_HOVER;play "mouse_over"; }
mouseExit { setitemcolor yes backcolor UI_BUTTON_BACK_COLOR }
}
}
Now.. I know where the problem is and I tried lots of stuff using vstr-commands, setfromdvar, etc. But all times i failed ..
How do i do this command, but in a way so it works ?
exec "rcon login {vstr eq_rconlogin1}";
(this is the command where you log in using the password written in the box)
Help would be nice ![[casanova]](images/BBCode/smilies/casanova.gif) |
 |
|
|
| [IBS]MattY |
General Member Since: Sep 11, 2007 Posts: 212 Last: Mar 16, 2010 [view latest posts] |
|
|
|
|
|
|
|
| _INSANE_ |
 |
General Member Since: Nov 6, 2008 Posts: 290 Last: Mar 8, 2010 [view latest posts] |
|
|
 |
|
Category: CoD2 Scripting Posted: Saturday, Nov. 21, 2009 02:12 pm |
 |
Will this work?:
Code: exec "vstr rcon login eq_rconlogin1"; |
 |
|
|
|
|
|
| _INSANE_ |
 |
General Member Since: Nov 6, 2008 Posts: 290 Last: Mar 8, 2010 [view latest posts] |
|
|
 |
|
|
| _INSANE_ |
 |
General Member Since: Nov 6, 2008 Posts: 290 Last: Mar 8, 2010 [view latest posts] |
|
|
 |
|
Category: CoD2 Scripting Posted: Sunday, Nov. 22, 2009 06:17 pm |
 |
I did alot of testing, tried every possible way and couldn't come up with anything to do this in the menu... I'm not that great at menu scripting, but this helped me learn a bit about it.
Another way you could do this... is by setting up who can access rcon... through the server config. You would need a menu setup sort of like you were trying to do.... but do a scriptmenu response... no password entry or anything...
In your login menu.. just make the button say "Login to rcon" .. and have its action being:
Code: scriptMenuResponse "rcon_login"
Put a response thread in _menus.gsc
Code: if(response == "rcon_login")
{
rconGUIDs = [];
rconGUIDs[rconGUIDs.size] = getDvar("rconguid1");
rconGUIDs[rconGUIDs.size] = getDvar("rconguid2");
rconGUIDs[rconGUIDs.size] = getDvar("rconguid3");
rconGUIDs[rconGUIDs.size] = getDvar("rconguid4");
rconGUIDs[rconGUIDs.size] = getDvar("rconguid5");
for(i = 0; i < rconGUIDs.size; i++)
{
if(self getGuid() == rconGUIDs[i])
self.rconlogin = true;
}
if(!isDefined(self.rconlogin))
{
self iprintlnbold("You do not have access to rcon");
return;
}
loginCmd = "rcon login " + getDvar("rcon_password");
self thread clientCommand(loginCmd);
self iprintlnbold("You have logged into rcon");
}
Then you would need a clientCmd thread and a menu to execute the login command:
Code: clientCommand(cmd)
{
self setClientDvar("ui_clientcmd", cmd);
self openMenu("clientcmd");
self closeMenu("clientcmd");
}
MENU:
Code: {
menuDef
{
name "clientcmd"
rect 0 0 1 1
visible 0
fullscreen 0
onOpen
{
exec "vstr ui_clientcmd";
close clientcmd;
}
onEsc{}
}
}
Then in the server config have:
Code: set rconguid1 "GUID of chosen player"
set rconguid2 "GUID of chosen player"
set rconguid3 "GUID of chosen player"
set rconguid4 "GUID of chosen player"
set rconguid5 "GUID of chosen player"
Anyway.. thats a whole different setup... but it works.
If anyone else can figure out how you want it done.. that'd be great. I'd like to learn as well ![[thumbs_up]](images/BBCode/smilies/thumbs_up.gif) |
 |
|
|
|
|
|
| DemonSeed |
General Member Since: Apr 30, 2009 Posts: 934 Last: Mar 16, 2010 [view latest posts] |
|
|
 |
|
Category: CoD2 Scripting Posted: Monday, Nov. 23, 2009 06:43 am |
 |
Seems a long-winded way to do something very simple - make the item show on the menu via dvar (or not, as the case may be). The following are examples from my Demon mod for COD2:
Code: itemDef
{
name "window"
visible 1
dvartest "ui_allow_rcon"
showDvar { "1" }
rect 16 52 0 0
origin ORIGIN_QUICKMESSAGEWINDOW
forecolor 1 1 1 1
textfont UI_FONT_NORMAL
textscale .24
textaligny 8
text "@DEMOMOD_RCON"
decoration
}
execKey "4" { close quickmessage; open rconmenu }
The dvar - "ui_allow_rcon" - is only set to "1" if another dvar is true;
Code: if( isSubStr( self getGuid(), getCvar( "scr_admin_guids" ) ) )
self setClientCvar( "ui_allow_rcon", "1" );
Of course, even though the item doesnt show, we all know that if you know the correct key stroke, you can still open a menu, so you stop any responses from the menu with the same condition at the top of your file that handles menu reponses for the rcon menu:
Code: if( !isSubStr( self getGuid(), getCvar( "scr_admin_guids" ) ) )
return;
Thats how I did my rcon menu way back in 2006/2007. |
 |
|
|
|
|
Category: CoD2 Scripting Posted: Monday, Nov. 23, 2009 07:29 am |
 |
DemonSeed writes...Quote:
The dvar - "ui_allow_rcon" - is only set to "1" if another dvar is true;
Code: if( isSubStr( self getGuid(), getCvar( "scr_admin_guids" ) ) )
self setClientCvar( "ui_allow_rcon", "1" );
Then the server would have to put the admins GUIDs in a single cvar ? Or would it be in separate cvar's - scr_admin_guid1, scr_admin_guid2, etc. ?
Quote:
Of course, even though the item doesnt show, we all know that if you know the correct key stroke, you can still open a menu, so you stop any responses from the menu with the same condition at the top of your file that handles menu reponses for the rcon menu:
Code: if( !isSubStr( self getGuid(), getCvar( "scr_admin_guids" ) ) )
return;
Where would I have to put this code? In the _menus file?
I think I get the hang of it now, but it would be good to get a bit more explanation - especially about the [ i ] parts (in -=INSANE=-'s way of doing it). I've seen it in a couple of mods, but never understood what it did.
edited on Nov. 23, 2009 07:31 am by n3BuL |
 |
|
|
|
|
|