AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Orpheu natives (https://forums.alliedmods.net/showthread.php?t=309152)

edon1337 07-15-2018 08:43

Orpheu natives
 
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. :crab:

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); 


HamletEagle 07-15-2018 09:08

Re: Orpheu natives
 
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?

edon1337 07-15-2018 09:24

Re: Orpheu natives
 
Quote:

Originally Posted by HamletEagle (Post 2603804)
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!" );



HamletEagle 07-15-2018 09:55

Re: Orpheu natives
 
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.

edon1337 07-15-2018 10:49

Re: Orpheu natives
 
Quote:

Originally Posted by HamletEagle (Post 2603812)
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?

HamletEagle 07-15-2018 10:51

Re: Orpheu natives
 
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


All times are GMT -4. The time now is 12:49.

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