Page 1 of 1

UserMessage Menu

Posted: Sun Dec 02, 2012 8:23 pm
by Tuck
for some reason i can only hit option 1 in menu......

UserMessage = GameEngine.UserMessageBegin(Recipients, 10, None)
UserMessage.WriteShort(1)
UserMessage.WriteByte(2)
UserMessage.WriteByte(0)
UserMessage.WriteString(text)
GameEngine.MessageEnd()

when i change the highlighted i can choose more options but i would really like some information :) on what types/bytes/shorts to edit for me to have a menu with 10 menuselect 0 included

Posted: Sun Dec 02, 2012 8:43 pm
by Ayuto
You can use this helper function in order to get the required value:

Syntax: Select all

def keysToBits(keys):
return sum((1 << x for x in set(keys)))

If you want to enable 0-9 you would do it like the following:

Syntax: Select all

UserMessage.WriteShort(keysToBits((0, 1, 2, 3, 4, 5, 6, 7, 8, 9)))

# Or more simple
UserMessage.WriteShort(keysToBits(range(9)))

Posted: Tue Dec 04, 2012 6:36 pm
by Tuck
how do i catch player hitting 0 ? :/ tried range(1, 11) and range(11) nothing :/

edit, im listening to menuselect via ClientCMD, using your example of setting the SHORT i can catch the keys 1-9 however cannot catch 0 ;(

Posted: Tue Dec 04, 2012 6:59 pm
by L'In20Cible
Hey Tuck,

Sadly, this is not available on CS:GO.

L'In20Cible

Posted: Tue Dec 04, 2012 7:20 pm
by Tuck
L'In20Cible wrote:Hey Tuck,

Sadly, this is not available on CS:GO.

L'In20Cible


if it's default bound to some kinda "weapon_slot" couldn't i just listen to that so it would work for users with standard weapon slots :/

Posted: Tue Dec 04, 2012 7:21 pm
by satoon101
It works with 0 if you bind your 0 key to "menuselect 0"... Otherwise, it doesn't seem to work properly.

Satoon

Posted: Tue Dec 04, 2012 7:23 pm
by satoon101
Once we get dynamic function hooking, we can try to see if we can hook the slotx commands. I would also love to find a "proper" way to close menus, which used to be possible before the OrangeBox update in ES' popuplib.

Satoon

Posted: Tue Dec 04, 2012 10:33 pm
by L'In20Cible
Hey guys,

I don't think that we can do anything server-side since slots are handled by clients: CBaseHudWeaponSelection::HandleHudMenuInput. Then, it tells the server by sending menuselect: CHudMenu::SelectMenuItem. I compared the file ../game/client/weapon_selection.cpp from CSS to CS:GO and it seems that thr problem is at line 254:

Syntax: Select all

if ( down >= 1 && keynum >= KEY_1 && keynum <= KEY_9 )
{
if ( HandleHudMenuInput( keynum - KEY_0 ) )
return 0;
}
The menu never handles the selection if the slot is not between 1 and 9. So well, there's really nothing we can do...

Anyways, Ayuto's function is wrong. It should be:

Syntax: Select all

def keysToBits(keys):
return sum((1 << (x - 1) for x in set(keys)))
Where "0" need to be handled as "10".

L'In20Cible

Posted: Wed Dec 05, 2012 7:20 pm
by Tuck
L'In20Cible wrote:Anyways, Ayuto's function is wrong. It should be:[python]def keysToBits(keys):
return sum((1 << (x - 1) for x in set(keys)))[/python]Where "0" need to be handled as "10".

L'In20Cible


Yours chrashes the server? last thing i see is: negative shift count

Posted: Wed Dec 05, 2012 7:27 pm
by L'In20Cible
Hey Tuck,

You quoted the answer. :)

L'In20Cible wrote:Where "0" need to be handled as "10".


And it crashed cause you started a message and didn't send it (cause of the raised error).

L'In20Cible

Posted: Wed Dec 05, 2012 7:35 pm
by Tuck
ye i though it over after i posted and tried doing range(1, 11) worked perfectly fine :P thanks

However the radio menus used for doing ingame sounds suchas need backup blah blah.. 0 is used to close in them ?

Posted: Wed Dec 05, 2012 7:37 pm
by L'In20Cible
Again, they are client-side. It send the command based on the radio message to the server (in example, "go", "backup", etc.).

L'In20Cible

Posted: Wed Dec 05, 2012 7:49 pm
by Tuck
L'In20Cible wrote:Again, they are client-side. It send the command based on the radio message to the server (in example, "go", "backup", etc.).

L'In20Cible


Is it possible to force client to bind a key?

and would it be possible to retrieve what client has a bound a key to :/

Posted: Wed Dec 05, 2012 7:54 pm
by L'In20Cible
No you can't force a client to bind a key. And I doubt you can get which command is bound to it since the server doesn't have to know that directly so well, why sending more data than needed? Not sure if it works on CSGO but on CSS, you can print them into a hudhint message. In example:

Code: Select all

Press %+jump% to jump!


L'In20Cible

Posted: Wed Dec 05, 2012 8:16 pm
by Tuck
L'In20Cible wrote:No you can't force a client to bind a key. And I doubt you can get which command is bound to it since the server doesn't have to know that directly so well, why sending more data than needed? Not sure if it works on CSGO but on CSS, you can print them into a hudhint message. In example:

Code: Select all

Press %+jump% to jump!


L'In20Cible


i think %+jump% is converted client side :/

Posted: Wed Dec 05, 2012 8:17 pm
by L'In20Cible
It is, was just for your information.

L'In20Cible