UserMessage Menu

Please post any questions about developing your plugin here. Please use the search function before posting!
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

UserMessage Menu

Postby Tuck » Sun Dec 02, 2012 8:23 pm

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
-Tuck
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Sun Dec 02, 2012 8:43 pm

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)))
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Tue Dec 04, 2012 6:36 pm

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 ;(
-Tuck
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Tue Dec 04, 2012 6:59 pm

Hey Tuck,

Sadly, this is not available on CS:GO.

L'In20Cible
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Tue Dec 04, 2012 7:20 pm

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 :/
-Tuck
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Tue Dec 04, 2012 7:21 pm

It works with 0 if you bind your 0 key to "menuselect 0"... Otherwise, it doesn't seem to work properly.

Satoon
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Tue Dec 04, 2012 7:23 pm

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
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Tue Dec 04, 2012 10:33 pm

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
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Wed Dec 05, 2012 7:20 pm

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
-Tuck
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Wed Dec 05, 2012 7:27 pm

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
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Wed Dec 05, 2012 7:35 pm

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 ?
-Tuck
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Wed Dec 05, 2012 7:37 pm

Again, they are client-side. It send the command based on the radio message to the server (in example, "go", "backup", etc.).

L'In20Cible
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Wed Dec 05, 2012 7:49 pm

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 :/
-Tuck
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Wed Dec 05, 2012 7:54 pm

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
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Wed Dec 05, 2012 8:16 pm

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 :/
-Tuck
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Wed Dec 05, 2012 8:17 pm

It is, was just for your information.

L'In20Cible

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 35 guests