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

[HOWTO] Make a nice say-hook


Post New Thread Reply   
 
Thread Tools Display Modes
theqizmo
Member
Join Date: Oct 2004
Old 02-02-2005 , 22:50  
Reply With Quote #21

Quote:
Originally Posted by pyr0
How do I access the EntIndex or edict_t of the client that executed the command from the dispatch method. I know i can use the engine->Cmd_Arg methods to get at the command text, but what about the client entity?

Sorry if this is a noob question...still learning.
uh, PLUGIN_RESULT CYourPluginNameHere::ClientCommand( edict_t *pEntity )? that should hook any ClientCommand...
theqizmo is offline
Send a message via ICQ to theqizmo Send a message via AIM to theqizmo Send a message via MSN to theqizmo
imported_pyr0
Junior Member
Join Date: Feb 2005
Old 02-02-2005 , 23:08  
Reply With Quote #22

....uh no...I'm talking about hooking the say command...which ClientCommand will not. I'm using the class that was originally the topic of this discussion. Or maybe I'm misunderstanding, but my code to handle the say should go into the Dispatch() function right?

...


Well I suddenly had an idea...let me try this
imported_pyr0 is offline
imported_pyr0
Junior Member
Join Date: Feb 2005
Old 02-02-2005 , 23:34  
Reply With Quote #23

Got it! Added a public variable to the hook class for ClientCommandIndex and in my SetCommandClient() function let the class know about the ClientCommandIndex.
imported_pyr0 is offline
Ratman2000
New Member
Join Date: Dec 2004
Old 02-25-2005 , 03:03   hmm
Reply With Quote #24

I have an Problem... you can get the text with Engine->Cmd_Args();
but when you have edit the text, how can you give this text to the dispatch ?

So i will become an text like "test" and edit it so later printed on the screen comes "no test"

You know ?
Ratman2000 is offline
Send a message via ICQ to Ratman2000
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 02-25-2005 , 08:32   Re: hmm
Reply With Quote #25

Quote:
Originally Posted by Ratman2000
I have an Problem... you can get the text with Engine->Cmd_Args();
but when you have edit the text, how can you give this text to the dispatch ?

So i will become an text like "test" and edit it so later printed on the screen comes "no test"

You know ?
The only thing I can think about at the moment is hooking Cmd_Argc / Cmd_Argv / Cmd_Args and returning your own values...
__________________
hello, i am pm
PM is offline
Ratman2000
New Member
Join Date: Dec 2004
Old 02-26-2005 , 18:02   Hook
Reply With Quote #26

Hi,

so i reask my question...

I have seen, that Mani Mod can change the text like an badword check.
But when i use the class in this tread, i cant change the text.

Now i have tested to find special words and for this i have strapped the " from the text.

I have done this in the dispatch of the class...

It looks so:

Code:
int length= strlen( sText );

if ( *sText == '"' )
{
	sText++;
	length -= 2;
	sText[ length] = 0;
}
So when i print my text out( Msg( sText ) )
the text is all rigth... But the text what comes out and where displayed has lost the last character...

Example...

The player tipes: "Hi all ! My Name iss Boris"
than the text what where displayd is: "Hi all ! My Name iss Bori"

He cutted out the last "s"

But i think i cant so edit the text ?
So now i have the question...

How can i send an edited text for an badword check with the class at the top from this tread ?
Ratman2000 is offline
Send a message via ICQ to Ratman2000
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 02-27-2005 , 04:59  
Reply With Quote #27

You could send your own saytext message. I think there was an example on these forums somewhere... If not, I'm sure you could find something out from the SDK
__________________
hello, i am pm
PM is offline
Ruckus
Junior Member
Join Date: Feb 2005
Old 03-04-2005 , 16:31  
Reply With Quote #28

I'd really like to incorporate a say hook for the plugin I'm working on, but I'm having a hard time. I'm obviously doing something wrong but I don't know what. Here's what I've been trying (on a Linux system):

-Put PM's say hook code in a header file, sayhook.h
-Declare g_pICvar as an extern
-Include sayhook.h in my plugin's cpp file
-Declare an object of type CSayHook

From here I do a make and everything compiles fine. But, when I try to load my plugin the server console just says "Unable to load plugin". If I comment out the line where I declare the CSayHook object and recompile, the plugin loads fine.

I must be overlooking something obvious but I'm at a loss. Any suggestions?
Ruckus is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 03-05-2005 , 09:16  
Reply With Quote #29

Quote:
Originally Posted by Ruckus
I'd really like to incorporate a say hook for the plugin I'm working on, but I'm having a hard time. I'm obviously doing something wrong but I don't know what. Here's what I've been trying (on a Linux system):

-Put PM's say hook code in a header file, sayhook.h
-Declare g_pICvar as an extern
-Include sayhook.h in my plugin's cpp file
-Declare an object of type CSayHook

From here I do a make and everything compiles fine. But, when I try to load my plugin the server console just says "Unable to load plugin". If I comment out the line where I declare the CSayHook object and recompile, the plugin loads fine.

I must be overlooking something obvious but I'm at a loss. Any suggestions?
Are you compiling tier1/convar.cpp from the SDK? If yes, and you are on linux, you can always do a little app to see what is going wrong:

Code:
#include <dlfcn.h>
#include <stdio.h>

int main(int argc, const char *argv[])
{
   if (!dlopen("your_file.so_or_whatever"))
      printf("Error: %s\n", dlerror() ? dlerror() : "NOTHING!");
   else
      printf("Mwah:D \n");
}
Or something like that.
__________________
hello, i am pm
PM is offline
Mani
Veteran Member
Join Date: Dec 2004
Location: UK
Old 03-05-2005 , 11:45   Re: Hook
Reply With Quote #30

Quote:
Originally Posted by Ratman2000
Hi,

so i reask my question...

I have seen, that Mani Mod can change the text like an badword check.
But when i use the class in this tread, i cant change the text.

Now i have tested to find special words and for this i have strapped the " from the text.

I have done this in the dispatch of the class...

It looks so:

Code:
int length= strlen( sText );

if ( *sText == '"' )
{
	sText++;
	length -= 2;
	sText[ length] = 0;
}
So when i print my text out( Msg( sText ) )
the text is all rigth... But the text what comes out and where displayed has lost the last character...

Example...

The player tipes: "Hi all ! My Name iss Boris"
than the text what where displayd is: "Hi all ! My Name iss Bori"

He cutted out the last "s"

But i think i cant so edit the text ?
So now i have the question...

How can i send an edited text for an badword check with the class at the top from this tread ?
I didn't hook the engine->Cmd_Args() etc but I wrote a parser to make them generic across the range of different ways that commands can be processed (from say command, from client console, from server console). The say Cmd_Args() is a pain because it's formatted differently when run from the console and used in game.

As for the the say hook, if you find a say string that you don't want to be output, create your own processed say string then force the player to re-say the processed say string using ClientCommand(). The next time it's parsed it will be let through (you've filtered the bad words out) via dispatch. Not exactly efficient but it works.

Mani
__________________
Installation files, documentation and help can be found at: -

www.mani-admin-plugin.com
Mani 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 06:38.


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