Add default keys for polls (#1001)

add hardcoded default keys for polls
This commit is contained in:
cat_or_not 2026-06-04 21:27:38 -04:00 committed by GitHub
parent 4fb9574dd3
commit f2a6cdd14a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -56,6 +56,8 @@
float duration
bool pollActive
array<var> ruis
bool keysInit = false
array<int> keys = [ KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9 ]
} poll
string id
@ -297,6 +299,7 @@ enum eDataType
{
case eMessageType.POLL:
thread ShowPollMessage_Threaded()
InitDefaultKeyBinds()
break
case eMessageType.LARGE:
@ -443,6 +446,25 @@ enum eDataType
client.poll.pollActive = false
}
void function InitDefaultKeyBinds()
{
if ( client.poll.keysInit )
return
foreach ( int index, int key in client.poll.keys )
{
RegisterButtonPressedCallback(
key,
void function( var button ) : ( index )
{
if ( client.poll.pollActive )
GetLocalClientPlayer().ClientCommand( "vote " + ( index + 1 ) )
}
)
}
client.poll.keysInit = true
}
void function InfoMessageHandler_Threaded()
{
while ( true )