AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Lock Menu Keys (https://forums.alliedmods.net/showthread.php?t=309219)

wAyz 07-17-2018 22:09

Lock Menu Keys
 
Hello,

I'd like to be able to lock the menu keys after someone has voted (so the menu wouldnt react at all).
Any ideas? I'm using galileo btw.

Code:

                for (new choiceIdx = 0; choiceIdx < g_choiceCnt; ++choiceIdx)
                {
                        voteCnt = g_mapVote[choiceIdx];
                        vote_getTallyStr(voteTally, sizeof(voteTally)-1, voteCnt);
                       
                        if(g_vote[0] == 0)
                        charCnt += formatex(voteStatus[charCnt], sizeof(voteStatus)-1-charCnt, "^n%s%i. \w%s%s", CLR_RED, choiceIdx+1, g_mapChoice[choiceIdx], voteTally);
                        else
                        charCnt += formatex(voteStatus[charCnt], sizeof(voteStatus)-1-charCnt, "^n%s%i. \d%s%s", CLR_RED, choiceIdx+1, g_mapChoice[choiceIdx], voteTally);
                        keys |= (1<<choiceIdx);
                }


fysiks 07-18-2018 00:17

Re: Lock Menu Keys
 
I thought galileo already had a workaround for that (effectively allowing the vote results to stay up without preventing people from changing weapons). If you could actually block the keys then people wouldn't be able to switch weapons since the same commands are used for both weapon slots and menu keys.

wAyz 07-18-2018 02:47

Re: Lock Menu Keys
 
Quote:

Originally Posted by fysiks (Post 2604407)
I thought galileo already had a workaround for that (effectively allowing the vote results to stay up without preventing people from changing weapons). If you could actually block the keys then people wouldn't be able to switch weapons since the same commands are used for both weapon slots and menu keys.

That's correct. In my case it's not THAT much of a deal though because I'm running a KZ Server where you basically only use 2 weapons. I will think about it once again but I'd still like to know what i'd have to do to make it work.
Code:

if(g_vote[0] == 0)
{
        charCnt += formatex(voteStatus[charCnt], sizeof(voteStatus)-1-charCnt, "^n%s%i. \w%s%s", CLR_RED, choiceIdx+1, g_mapChoice[choiceIdx], voteTally);
        keys |= (1<<choiceIdx);
}
else
{
        charCnt += formatex(voteStatus[charCnt], sizeof(voteStatus)-1-charCnt, "^n%s%i. \d%s%s", CLR_RED, choiceIdx+1, g_mapChoice[choiceIdx], voteTally);
        keys |= (0<<choiceIdx);
}

I actually tried this already but it seems to be incorrect since it blocks everything from start of the vote already.

maqi 07-18-2018 02:56

Re: Lock Menu Keys
 
I don't know what gallileo is ( can't lookup atm ).

But if you wan't to lock the menu keys in the old menu system ( make them unusable ), it's as simple as not adding the specific key to the keys bitsum
Code:
 keys |= (1<<choiceIdx);
Just delete it.

What fysiks said is a different story, but guess you don't need that :D

wAyz 07-18-2018 03:02

Re: Lock Menu Keys
 
Quote:

Originally Posted by maqi (Post 2604423)
I don't know what gallileo is ( can't lookup atm ).

But if you wan't to lock the menu keys in the old menu system ( make them unusable ), it's as simple as not adding the specific key to the keys bitsum
Code:
 keys |= (1<<choiceIdx);
Just delete it.

What fysiks said is a different story, but guess you don't need that :D

Well thanks but I guess I've tried this aswell already but it doesnt really work as intended.

Code:

if(g_vote[0] == 0)
{
        charCnt += formatex(voteStatus[charCnt], sizeof(voteStatus)-1-charCnt, "^n%s%i. \w%s%s", CLR_RED, choiceIdx+1, g_mapChoice[choiceIdx], voteTally);
        keys |= (1<<choiceIdx);
}
else
{
        charCnt += formatex(voteStatus[charCnt], sizeof(voteStatus)-1-charCnt, "^n%s%i. \d%s%s", CLR_RED, choiceIdx+1, g_mapChoice[choiceIdx], voteTally);
}


maqi 07-18-2018 03:12

Re: Lock Menu Keys
 
Explain what happens, because it's the right solution ( If we are thinking about the same thing )

Edit: Are you sure
Code:
g_vote[0] == 0
Is the right condition to check for, I guess it would be something like
Code:
 !g_vote[index]
Not sure since i didn't see the code and don't know what it does.

wAyz 07-18-2018 03:37

Re: Lock Menu Keys
 
Quote:

Originally Posted by maqi (Post 2604425)
Explain what happens, because it's the right solution ( If we are thinking about the same thing )

Edit: Are you sure
Code:
g_vote[0] == 0
Is the right condition to check for, I guess it would be something like
Code:
 !g_vote[index]
Not sure since i didn't see the code and don't know what it does.

yes it is, because the menu keys go grey right after i lock in a vote.

Code:

if(g_vote[0] == 0)
{
        charCnt += formatex(voteStatus[charCnt], sizeof(voteStatus)-1-charCnt, "^n%s%i. \w%s%s", CLR_RED, choiceIdx+1, g_mapChoice[choiceIdx], voteTally);
        keys |= (1<<choiceIdx);
}
else
charCnt += formatex(voteStatus[charCnt], sizeof(voteStatus)-1-charCnt, "^n%s%i. \d%s%s", CLR_RED, choiceIdx+1, g_mapChoice[choiceIdx], voteTally);

It should work like inteded, but there's something else making the menu work again after i lock in a vote. Gotta figure out what exactly.

maqi 07-18-2018 03:56

Re: Lock Menu Keys
 
Well without the code, I can't help you any further. I can tell you that only way that can happen is if a new menu has been created/shown.

Then again, check for your condition, debug it a bit, just because it worked in a specific situation doesn't mean it's the right answer.

wAyz 07-18-2018 04:01

Re: Lock Menu Keys
 
1 Attachment(s)
It's not a small plugin since it's a whole map manager, but if you have the patience helping me i'll just post it.

maqi 07-18-2018 04:02

Re: Lock Menu Keys
 
PHP Code:

if(g_vote[0] == 0)
charCnt += formatex(voteStatus[charCnt], sizeof(voteStatus)-1-charCnt"^n%s%i. \w%s%s"CLR_REDchoiceIdx+1g_mapChoice[choiceIdx], voteTally);
else
charCnt += formatex(voteStatus[charCnt], sizeof(voteStatus)-1-charCnt"^n%s%i. \d%s%s"CLR_REDchoiceIdx+1g_mapChoice[choiceIdx], voteTally);
keys |= (1<<choiceIdx); 

adding keys to the bitsum is not under the if/else statement, it's outside of it. Therefore it will always be set, the only thing that changes is the color \w to \d ( put it in the curly brackets together under the right condition )


All times are GMT -4. The time now is 12:32.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.