Raised This Month: $ Target: $400
 0% 

Hooking Metamod's ConPrintf


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jmgr
Member
Join Date: Aug 2007
Location: Paris, France
Old 03-23-2008 , 21:29   Hooking Metamod's ConPrintf
Reply With Quote #1

Hello people.

I'm am currently coding a plugin for Metamod:Source, which posts bans made with Sourcemod to a forum. I looked at the sourcecode of SM and MM:S and found two possible ways to get the information that someone was banned.

As SM doesn't use the LogPrint from Valve so I can't detect bans as I made it for Mani Admin Plugin.

First try to use the same method as in MM:S for getting the address of ConPrintf : complicated, and I'm not sure I can get a callback each time the function is called... And it will probably need more CPU power to analyse each string written to the console.

Second, try to "hook" the method directly from MM:S, but I doesn't know if this is possible (I failed for now), so I'm asking you

If someone has a better idea, or a solution...

Thanks,
Jmgr
__________________
My Metamod:Source plugins :
ServerPolls, ask your players !
ServerBans, share a banlist between multiple servers
ServerWiper, watch a Source server to punish bad behaviour

Last edited by Jmgr; 03-24-2008 at 07:08. Reason: Bad spelling
Jmgr is offline
Jmgr
Member
Join Date: Aug 2007
Location: Paris, France
Old 03-24-2008 , 08:15   Re: Hooking Metamod's ConPrintf
Reply With Quote #2

I have tried to hook ISmmAPI::ConPrint, but my hook is never called.
And I cannot hook ISmmAPI::ConPrintf because of the "..." in the parameter list :/
__________________
My Metamod:Source plugins :
ServerPolls, ask your players !
ServerBans, share a banlist between multiple servers
ServerWiper, watch a Source server to punish bad behaviour
Jmgr is offline
BAILOPAN
Join Date: Jan 2004
Old 03-24-2008 , 10:30   Re: Hooking Metamod's ConPrintf
Reply With Quote #3

SourceMod provides scripting callbacks for banning. You should just write a plugin which does what you need, or at least does something that you can intercept from MM:S (like fire an event). You could even make an MM:S extension that externally attaches to SourceMod, and provides a native that your plugin uses.

Docs: http://wiki.alliedmods.net/Writing_E...Source_Plugins

For example:
Code:
public OnBanIdentity(blah blah blah) {     MyNativeThatDoesStuff(); }

That solution is a bit tougher to implement than a simple event, but it's bit more programmatic.

Side note: You can hook vararg functions, there are special SH macros for them. However, hooking internal and unrelated functions might even break since it's not guaranteed we'll keep using ISmmAPI::ConPrintf forever. It's also not guaranteed the message text won't change.
__________________
egg

Last edited by BAILOPAN; 03-24-2008 at 10:35.
BAILOPAN is offline
Jmgr
Member
Join Date: Aug 2007
Location: Paris, France
Old 03-27-2008 , 17:40   Re: Hooking Metamod's ConPrintf
Reply With Quote #4

If I see it correctly, the OnBanIdentity and OnBanClient callbacks does not give which admin banned the client. Is there a method to get that information ?

EDIT : Or is "source" the admin who made the ban, if any ?
__________________
My Metamod:Source plugins :
ServerPolls, ask your players !
ServerBans, share a banlist between multiple servers
ServerWiper, watch a Source server to punish bad behaviour

Last edited by Jmgr; 03-27-2008 at 17:43.
Jmgr is offline
BAILOPAN
Join Date: Jan 2004
Old 03-27-2008 , 17:49   Re: Hooking Metamod's ConPrintf
Reply With Quote #5

Yes. I clarified this on the doc page: http://docs.sourcemod.net/api/index....d=show&id=292&

Note that that isn't guaranteed if the command isn't "sm_ban". I.e. someone else might call BanClient() with a different convention for interpreting "source".
__________________
egg
BAILOPAN is offline
Jmgr
Member
Join Date: Aug 2007
Location: Paris, France
Old 03-27-2008 , 18:08   Re: Hooking Metamod's ConPrintf
Reply With Quote #6

Yay, thanks

I now have to see how to send custom events, but that does not seem to be very difficult.

It's the first time I look at SourceMod's plugin functionnality, and I have to say that it's simply fantastic !

for all the work for MM:S and SM.
__________________
My Metamod:Source plugins :
ServerPolls, ask your players !
ServerBans, share a banlist between multiple servers
ServerWiper, watch a Source server to punish bad behaviour

Last edited by Jmgr; 03-27-2008 at 19:09. Reason: "beyond" was not the correct word :p
Jmgr is offline
Jmgr
Member
Join Date: Aug 2007
Location: Paris, France
Old 03-28-2008 , 18:36   Re: Hooking Metamod's ConPrintf
Reply With Quote #7

I post here the method I used so people can have an idea how to catch SM bans from a MM:S plugin. It's probably not the best method, but I think it's the simplest one.

I created a plugin for SM who have the OnBanClient callback and call ServerCommand to execute a custom server command to warn the MM:S plugin. That's all

Creating an extension is probably a better method, but I think this one will do the job until I'm less lazy
__________________
My Metamod:Source plugins :
ServerPolls, ask your players !
ServerBans, share a banlist between multiple servers
ServerWiper, watch a Source server to punish bad behaviour
Jmgr is offline
BAILOPAN
Join Date: Jan 2004
Old 03-29-2008 , 00:19   Re: Hooking Metamod's ConPrintf
Reply With Quote #8

That works too ;) glad you solved it
__________________
egg
BAILOPAN 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 19:20.


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