Raised This Month: $51 Target: $400
 12% 

Command Listener... Not Working?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Spirrwell
Member
Join Date: Jul 2013
Old 12-12-2014 , 10:24   Command Listener... Not Working?
Reply With Quote #1

Hi there! In this mod I play Pirates, Vikings, and Knights II, there's a particular bug with its voice menus which under certain conditions causes the client to crash. Such as carrying an item that's intended for one gamemode, but used in another.

I know what the conditions are, and how to test for them, so the only thing left would be to block the voice menu that causes the crash when that happens. Since the voice menus are just commands that are bound to keys like voicemenu1, voicemenu2, and so on, I figured using "return Plugin_Handled" with a command listener would work just fine, like so:

Code:
public Action:VoiceMenuCheck(client, const String:command[], argc)
{
//Code Here
}

public OnPluginStart()
{
	AddCommandListener(VoiceMenuCheck, "voicemenu2");
}
The issue is, VoiceMenuCheck never seems to be called at all. I've tried simply making it print text saying "voicemenu2 called" but it does absolutely nothing.

I've had this work for another command just fine which was "dropitem."

So can anyone explain to me why it might not work?
Spirrwell is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 12-12-2014 , 10:50   Re: Command Listener... Not Working?
Reply With Quote #2

I don't have the game, but if the code is correct there maybe it a command that is not send to the server at all so you cannot capture it.
Mathias. is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-12-2014 , 10:54   Re: Command Listener... Not Working?
Reply With Quote #3

Are you sure it's voicemenu2?

I ask because in some games (TF2 for sure), it's voicemenu <menunumber> <commandnumber>... so item 2 in voicemenu 2 would be sent to the server as the command "voicemenu" with two arguments: "1" and "1"

"1" isn't a typo there, as the server-side stores these in an array and the first element of an array is element 0.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Spirrwell
Member
Join Date: Jul 2013
Old 12-12-2014 , 16:35   Re: Command Listener... Not Working?
Reply With Quote #4

Yeah, I'm pretty sure it's voicemenu2. If you type in "bind c" in the console (c is the key it's bound to...) it shows voicemenu2. For all the 0-9 keys they're bound as slot0, slot1, and etc. So if I were to type "voicemenu2;slot1" in the console it would pick the first voice command. Though it is interesting, if I type in just "voicemenu" or "voicemenu 2", it doesn't show up as an unknown command, but it still does absolutely nothing.

Anyway it would make sense to me that it's not server side at all, which is kind of odd, because the server's script for voice menus overrides the client script... So odd.

Would there be any other way to do it? Just ugh, I wish I could program for this game, it seems like it would be something that would be fixed with a simple if statement.

Last edited by Spirrwell; 12-12-2014 at 16:50.
Spirrwell is offline
psychonic

BAFFLED
Join Date: May 2008
Old 12-12-2014 , 17:16   Re: Command Listener... Not Working?
Reply With Quote #5

The client likely captures those commands and sends a different one to the server. You could monitor them with OnClientCommand.
psychonic is offline
Spirrwell
Member
Join Date: Jul 2013
Old 12-12-2014 , 19:31   Re: Command Listener... Not Working?
Reply With Quote #6

That actually turned out to be pretty cool. I just printed to chat to see what each command did, and it looks like there's some commands that I can't type in the console but seem to have some great importance... But it still didn't help me with the voice menu thing.

It's odd, because if I type in a non-existant command in the console, it will print it, but if I do voicemenu#, it doesn't.

Well, if there's any other way to do this, I'd appreciate it, but this is just getting kind of silly.
Spirrwell is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 12-12-2014 , 19:56   Re: Command Listener... Not Working?
Reply With Quote #7

try doing: voicemenu#;slot#
then see what the server receives
__________________
WildCard65 is offline
Wliu
Veteran Member
Join Date: Apr 2013
Old 12-12-2014 , 20:57   Re: Command Listener... Not Working?
Reply With Quote #8

Quote:
Originally Posted by Spirrwell View Post
That actually turned out to be pretty cool. I just printed to chat to see what each command did, and it looks like there's some commands that I can't type in the console but seem to have some great importance... But it still didn't help me with the voice menu thing.

It's odd, because if I type in a non-existant command in the console, it will print it, but if I do voicemenu#, it doesn't.

Well, if there's any other way to do this, I'd appreciate it, but this is just getting kind of silly.
I've ran into this before (somewhat).

What AddCommandListener really does is catch the command that the *client* sends. It doesn't care if the command actually exists, only whether it matches what you specified for ACL.

psychonic is probably right here with the client sending a different command than voicemenu2. Did you try sending voicemenu commands and seeing what OnClientCommand sent? There was a similar issue in TF2 where the actual command was change_class but the client sent it as joinclass.
__________________
~Wliu
Wliu is offline
Spirrwell
Member
Join Date: Jul 2013
Old 12-12-2014 , 21:43   Re: Command Listener... Not Working?
Reply With Quote #9

Yeah, I've tried sending voice commands, and it does show the command "menuselect" which is the equivalent of voicemenu#;slot#. So I could block a menuselect, but I'd first have to even check if they're in the voice menu, and the crash issue I'm trying to fix as I described in the first post happens as the menu is showing up.
Spirrwell is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:43.


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