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

[HELP] Writing a module hooking CBasePlayer::SetAnimation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wiwi249
Member
Join Date: Oct 2013
Old 04-11-2015 , 14:02   [HELP] Writing a module hooking CBasePlayer::SetAnimation
Reply With Quote #1

Hello.
After a lot of trying with orpheu in this topic: https://forums.alliedmods.net/showthread.php?p=2282651 I've decided to write a new module to hook the CBasePlayer::SetAnimation, because it's the last thing I can do in that case. The problem is, that I've never written a module. I've got basic knowledge in C++ though. So:
1. Is there any tutorial or something written to help me learn module coding? I've been trying to search the forum but I didn't find it. Or maybe is there some basic code I can use to learn on (I don't need much, that will do).
2. How to hook the CBasePlayer::SetAnimation event in my module? In amxx it was (almost) all about byte signature in orpheu. How to make it with a module only?
3. How to make an AMXX Forward based on the functions I want to hook? If I "hook" this function, I think that I should make a hookable forward with AMXX and then supercede it (that's what I need to do, unfortunately). If you have any other ideas, can you tell me?

Thanks in advance and sorry for a problem. I just need to hook this function finally.
wiwi249 is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 04-11-2015 , 14:37   Re: [HELP] Writing a module hooking CBasePlayer::SetAnimation
Reply With Quote #2

Are you sure you need it?

https://forums.alliedmods.net/showpo...87&postcount=2
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
wiwi249
Member
Join Date: Oct 2013
Old 04-11-2015 , 17:25   Re: [HELP] Writing a module hooking CBasePlayer::SetAnimation
Reply With Quote #3

Yes, I'm pretty sure.
Check the link I've provided in the first post. HLDS has been updated and It's much harder to hook it now.
wiwi249 is offline
wiwi249
Member
Join Date: Oct 2013
Old 04-12-2015 , 06:15   Re: [HELP] Writing a module hooking CBasePlayer::SetAnimation
Reply With Quote #4

Alright, an update.
I've managed to open the example module (dod_mm) and find a tutorial.
It seems to make sense ;)
Now how to hook the SetAnimation functions?

Last edited by wiwi249; 04-12-2015 at 06:20.
wiwi249 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-12-2015 , 06:29   Re: [HELP] Writing a module hooking CBasePlayer::SetAnimation
Reply With Quote #5

Maybe look at how orpheu or okapi does that ? It may help, idk.
__________________
HamletEagle is offline
wiwi249
Member
Join Date: Oct 2013
Old 04-12-2015 , 07:22   Re: [HELP] Writing a module hooking CBasePlayer::SetAnimation
Reply With Quote #6

I was trying to understand how Arkshine did it in the AdminFreeLook module ( https://github.com/Arkshine/AdminFre.../master/module ), but I don't understand shit. I think I have to wait until he explains something.
By the way, Orpheu is much more complicated, especially that it hooks functions registered in signatures and used in plugins. I just cant get to read that thing in the code and I dont know what is what in the Orpheu source.
wiwi249 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-14-2015 , 06:27   Re: [HELP] Writing a module hooking CBasePlayer::SetAnimation
Reply With Quote #7

Try that.

Unzip setanimation-files in /dlls (1.8.2) or /modules (1.8.3-dev)

In your plugin use the OnSetAnimation forward:

Code:
public OnSetAnimation(player, anim) {     // return PLUGIN_HANDLED to block the call }

EDIT: I guess I could add a native later.
Attached Files
File Type: zip setanimation-files.zip (62.1 KB, 533 views)
File Type: zip setanimation-source.zip (128.7 KB, 503 views)
__________________

Last edited by Arkshine; 04-14-2015 at 13:23.
Arkshine is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 04-21-2015 , 23:47   Re: [HELP] Writing a module hooking CBasePlayer::SetAnimation
Reply With Quote #8

Quote:
Originally Posted by Arkshine View Post
Try that.

Unzip setanimation-files in /dlls (1.8.2) or /modules (1.8.3-dev)

In your plugin use the OnSetAnimation forward:

Code:
public OnSetAnimation(player, anim) {     // return PLUGIN_HANDLED to block the call }

EDIT: I guess I could add a native later.
Wow. Arkshine, I have a question about that code. Can be that code be modified for hooking another functions? I haven't got any example of how to hook an specific function of the engine providing his sig with a module..
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-25-2018 , 06:02   Re: [HELP] Writing a module hooking CBasePlayer::SetAnimation
Reply With Quote #9

Quote:
Originally Posted by Arkshine View Post
Try that.

Unzip setanimation-files in /dlls (1.8.2) or /modules (1.8.3-dev)

In your plugin use the OnSetAnimation forward:

Code:
public OnSetAnimation(player, anim) {     // return PLUGIN_HANDLED to block the call }

EDIT: I guess I could add a native later.
Any chance you could add the ability to call SetAnimation with a native? I tried to add it but I get a crash as soon as it gets called.
PHP Code:
 cell AMX_NATIVE_CALL CallSetAnimation(AMX Handlecell Parameter)
{

    
int id       Parameter[1];
    
int anim   Parameter[2];

    const 
void *pvPlayer reinterpret_cast<const void*>((INDEXENT(id)->pvPrivateData));

    
SetAnimationDetour->DisableDetour();
    
SetAnimationOrig(pvPlayeranim);
    
SetAnimationDetour->EnableDetour();

    return 
1;

Testing on windows.
__________________

Last edited by HamletEagle; 08-25-2018 at 06:05.
HamletEagle is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-04-2018 , 19:22   Re: [HELP] Writing a module hooking CBasePlayer::SetAnimation
Reply With Quote #10

Quote:
Originally Posted by Arkshine View Post
Try that.

Unzip setanimation-files in /dlls (1.8.2) or /modules (1.8.3-dev)

In your plugin use the OnSetAnimation forward:

Code:
public OnSetAnimation(player, anim) {     // return PLUGIN_HANDLED to block the call }

EDIT: I guess I could add a native later.
There is a mistake in a include file called setanimation.h line 10.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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 08:27.


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