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

Solved Orpheu natives


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-15-2018 , 08:43   Orpheu natives
Reply With Quote #1

Hi,

Most likely HamletEagle will be the one to explain the stuff to me as there's not many people interested on Orpheu, so thanks Hamlet lol.

1. Does OrpheuRegisterHook handler have no parameters or they're hidden?
2. #1 question is what confuses me about #2, OrpheuGetParamStructMember parameter is 'num' which is argument number, how do we know what parameter we need to retrieve when we have something like this

Code:
#include < amxmodx > #include < orpheu > public plugin_init( ) {     register_plugin( "Orpheu Example", "1.0", "DoNii" );     new OrpheuFunction:Spawn = OrpheuGetFunction( "Spawn" );     OrpheuRegisterHook( Spawn, "@Spawn" ); } public @Spawn( ) {
    new id = OrpheuGetParamStructMember( num,const memberName[],any:... )
}

Thanks!

EDIT:

I think I found the answer for #2
PHP Code:
void Spawn(entvars_t *pevOwner); 
__________________

Last edited by edon1337; 07-15-2018 at 11:24.
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-15-2018 , 09:08   Re: Orpheu natives
Reply With Quote #2

No, it passes the parameters that are listed in the orpheu file.
OrpheuGetParamStructMember is to be used with structures, not needed in this case.

For DropPlayerItem the function is:
PHP Code:
CBasePlayer::DropPlayerItem(const char *pszItemName
Meaning that the function gets a parameter that is a char array, which in pawn translates to ItemName[MAX_DIM].
But that's not the only parameter. Functions that are member of a class pass the object as the first parameter("this") which in a plugin translates to the entity index. In your case it would be the player index since DropPlayerItem is member of CBasePlayer class.

The correct header would be:
PHP Code:
public @DropPlayerItem(idItemName[32]). 
The OrpheuGetFunction would look like this:
PHP Code:
new OrpheuFunction:DropPlayerItem OrpheuGetFunction("DropPlayerItem""CBasePlayer"); 
And the signature would be:
PHP Code:
{
    
"name" "DropPlayerItem",
    
"class" "CBasePlayer",
    
"library" "mod",
    
"arguments" :
    [
        {
            
"type" "char *"
        
}
    ],
    
"identifiers" :
    [
        {
            
"os" "windows",
            
"mod" "cstrike",
            
"value" : [0x83,"*","*",0x33,"*",0x53,0x55,0x56,0x8b,"*","*","*",0x57,0x8B,"*",0x8B]
        },
        {
            
"os" "linux",
            
"mod" "cstrike",
            
"value" "_ZN11CBasePlayer14DropPlayerItemEPKc"
        
}
    ]

Notice the arguments part, you don't need to specify the object(the entity index), we only mention the ItemName argument.

But I see you are trying to hook Spawn. What spawn are you trying to hook? For what entity?
__________________

Last edited by HamletEagle; 07-15-2018 at 09:15.
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-15-2018 , 09:24   Re: Orpheu natives
Reply With Quote #3

Quote:
Originally Posted by HamletEagle View Post
No, it passes the parameters that are listed in the orpheu file.
OrpheuGetParamStructMember is to be used with structures, not needed in this case.

For DropPlayerItem the function is:
PHP Code:
CBasePlayer::DropPlayerItem(const char *pszItemName
Meaning that the function gets a parameter that is a char array, which in pawn translates to ItemName[MAX_DIM].
But that's not the only parameter. Functions that are member of a class pass the object as the first parameter("this") which in a plugin translates to the entity index. In your case it would be the player index since DropPlayerItem is member of CBasePlayer class.

The correct header would be:
PHP Code:
public @DropPlayerItem(idItemName[32]). 
The OrpheuGetFunction would look like this:
PHP Code:
new OrpheuFunction:DropPlayerItem OrpheuGetFunction("DropPlayerItem""CBasePlayer"); 
And the signature would be:
PHP Code:
{
    
"name" "DropPlayerItem",
    
"class" "CBasePlayer",
    
"library" "mod",
    
"arguments" :
    [
        {
            
"type" "char *"
        
}
    ],
    
"identifiers" :
    [
        {
            
"os" "windows",
            
"mod" "cstrike",
            
"value" : [0x83,"*","*",0x33,"*",0x53,0x55,0x56,0x8b,"*","*","*",0x57,0x8B,"*",0x8B]
        },
        {
            
"os" "linux",
            
"mod" "cstrike",
            
"value" "_ZN11CBasePlayer14DropPlayerItemEPKc"
        
}
    ]

Notice the arguments part, you don't need to specify the object(the entity index), we only mention the ItemName argument.

But I see you are trying to hook Spawn. What spawn are you trying to hook? For what entity?
Thanks for the explanation, I accidentally used @DropPlayerItem as the handler name, because I was dealing with it before, I was hooking CBasePlayer::Spawn.

So why is the parameter not specified here? I do know now that in class functions the first parameter is the entity index, in my case the player.

https://github.com/s1lentq/ReGameDLL.../player.h#L329

This is pretty much the code to hook player spawn with Orpheu, if I'm not mistaken?
PHP Code:
#include < amxmodx >
#include < orpheu >

public plugin_init( )
{
    
register_plugin"Orpheu Example""1.0""DoNii" );

    new 
OrpheuFunction:Spawn OrpheuGetFunction"Spawn" );
    
OrpheuRegisterHookSpawn"@Spawn" );
}

public @
Spawnid )
{
    
client_printidprint_chat"You just spawned!" );

__________________
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-15-2018 , 09:55   Re: Orpheu natives
Reply With Quote #4

Your OrpheuGetFunction is incomplete. You want to hook Spawn from CBasePlayer class, not other class, so you need to mention that.
PHP Code:
 new OrpheuFunction:Spawn OrpheuGetFunction"Spawn" ); 
->
PHP Code:
 new OrpheuFunction:Spawn OrpheuGetFunction"Spawn""CBasePlayer" ); 
Same as I did with CBasePlayer:: DropPlayerItem.

If it still doesn't work please post the Spawn file from virtualFunctions/CBasePlayer folder.
__________________

Last edited by HamletEagle; 07-15-2018 at 09:57.
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-15-2018 , 10:49   Re: Orpheu natives
Reply With Quote #5

Quote:
Originally Posted by HamletEagle View Post
Your OrpheuGetFunction is incomplete. You want to hook Spawn from CBasePlayer class, not other class, so you need to mention that.
PHP Code:
 new OrpheuFunction:Spawn OrpheuGetFunction"Spawn" ); 
->
PHP Code:
 new OrpheuFunction:Spawn OrpheuGetFunction"Spawn""CBasePlayer" ); 
Same as I did with CBasePlayer:: DropPlayerItem.

If it still doesn't work please post the Spawn file from virtualFunctions/CBasePlayer folder.
Oh, I didn't read the include file carefully, thanks for the fix.
I don't really have the signature for it, I randomly picked CBasePlayer::Spawn. Don't really need it, as I can do it with Hamsandwich.

By the way, I'm unable to find non-class functions in ReGameDLL such as Host_Status_f, PM_Duck, I searched everywhere but couldn't find, do you know where I can find them?
__________________
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-15-2018 , 10:51   Re: Orpheu natives
Reply With Quote #6

Host_Status_f is a function from the game engine, so you should be searching that in rehlds: https://github.com/dreamstalker/rehl...e/host_cmd.cpp

PM_* are inside pm_shared.cpp from RegameDLL: https://github.com/s1lentq/ReGameDLL.../pm_shared.cpp
__________________

Last edited by HamletEagle; 07-15-2018 at 10:52.
HamletEagle 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 10:37.


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