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

Orpheu: Using virtual functions


Post New Thread Reply   
 
Thread Tools Display Modes
Dr.G
Senior Member
Join Date: Nov 2008
Old 02-11-2010 , 17:04   Re: Orpheu: Using virtual functions
Reply With Quote #11

Ive just tryed with CBasePlayer::Killed(entvars_s *, int)

But how should my Killed file look? If it looks like this it gives me a native error (invallid func.), :

PHP Code:
{
    
"name" "Killed",
    
"class" "CBasePlayer",
    
"library" "mod",
    
"arguments" 
    [
        {
        
"type" "entvars_s *"
        "type" 
"int"
        
}
    ],
        
"indexes" 
    [
        {
        
"os" "windows",
        
"mod" "dod",
        
"value" 20
        
},
        {
        
"os" "linux",
        
"mod" "dod",
        
"value" 22
        
}
    ]

If i leave out "type" : "int" it loads but, crash my server when i kill my self.

This is all of it :

PHP Code:
#include <amxmodx>
#include <Orpheu>

/*
Offset WIN32 = 20

CBasePlayer::Killed(entvars_s *, int)
*/

public plugin_init() 
{
    new 
OrpheuFunction:Player_Killed OrpheuGetFunctionFromClass("player","Killed""CBasePlayer" )
    
OrpheuRegisterHook(Player_Killed,"Killed")
}
public 
Killed(playersomething)
{
    
client_print(03"* funcPlayerKilled")
}
/*

Killed file :
/////////////////////////////////////////////////////////////////////////
{
    "name" : "Killed",
    "class" : "CBasePlayer",
    "library" : "mod",
    "arguments" : 
    [
        {
        "type" : "entvars_s *"
        "type" : "int"
        }
    ],
        "indexes" : 
    [
        {
        "os" : "windows",
        "mod" : "dod",
        "value" : 20
        },
        {
        "os" : "linux",
        "mod" : "dod",
        "value" : 22
        }
    ]
}
//////////////////////////////////////////////////////////////////////////
Path to Killed is:
\dod\addons\amxmodx\configs\orpheu\virtualFunctions\CBasePlayer

*/ 
__________________
Dr.G is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-11-2010 , 17:29   Re: Orpheu: Using virtual functions
Reply With Quote #12

It would be more :

Code:
{     "name"      : "Killed",     "class"     : "CBasePlayer",     "library"   : "mod",     "arguments" :     [         {             "type" : "entvars_s *"         },         {             "type" : "int"         }     ],     "indexes" :     [         {             "os"    : "windows",             "mod"   : "dod",             "value" : 20         },         {             "os"    : "linux",             "mod"   : "dod",             "value" : 22         }     ] }
__________________
Arkshine is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 02-11-2010 , 17:56   Re: Orpheu: Using virtual functions
Reply With Quote #13

Dr.G, i'm pleasantly surprised you understood how to work with orpheu promptly since most people complained it was hard.

About your problem it should work like Arkshine said. You were basically saying that it only had one argument and that will always crash the server because you must provide the right number of arguments.

Apart from this, your hook receiver should look like:

PHP Code:
Killed(killedkillersomething
Because the first is the owner of the object. I mean, the object itself
__________________

Last edited by joaquimandrade; 02-11-2010 at 18:36.
joaquimandrade is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 02-11-2010 , 18:28   Re: Orpheu: Using virtual functions
Reply With Quote #14

hehehe well this module gives us ALOT of options, so why not give it a try ;)

And yes it works fine now after placeing the args. right. Thanks! ->

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <Orpheu>
#include <fakemeta>

/*
Offset WIN32 = 20

CBasePlayer::Killed(entvars_s *, int)
*/

public plugin_init() 
{
    new 
OrpheuFunction:Player_Killed OrpheuGetFunctionFromClass("player","Killed""CBasePlayer" )
    
OrpheuRegisterHook(Player_Killed,"Killed")
}
public 
Killed(victimkillersomething)
{
    new 
victim1[32]
    
get_user_name(victimvictim131)
    
    new 
killer1[32]
    
get_user_name(killerkiller131)
    
    new 
isomething[32]
    
pev(somethingpev_classnameisomething31)
    
    
    
client_print(03"%s killed %s with %s"killer1victim1isomething)
    
// FYI isomething printet player...
}
/*

Killed file :
/////////////////////////////////////////////////////////////////////////
{
    "name"      : "Killed",
    "class"     : "CBasePlayer",
    "library"   : "mod",
    "arguments" : 
    [
        {
            "type" : "entvars_s *"
        },
        {
            "type" : "int"
        }
    ],
    "indexes" : 
    [
        {
            "os"    : "windows",
            "mod"   : "dod",
            "value" : 20
        },
        {
            "os"    : "linux",
            "mod"   : "dod",
            "value" : 22
        }
    ]
}
//////////////////////////////////////////////////////////////////////////
Path to Killed is:
\dod\addons\amxmodx\configs\orpheu\virtualFunctions\CBasePlayer

*/ 

One more, what if the function returns void -> CBasePlayer::Spawn(void) e.g.

It doesnt like void ->

Code:
    "arguments" : 
    [
        {
            "type" : "void"
        }
    ],
__________________
Dr.G is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-11-2010 , 18:29   Re: Orpheu: Using virtual functions
Reply With Quote #15

Perhaps if it is void, you don't put any arguments?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 02-11-2010 , 18:32   Re: Orpheu: Using virtual functions
Reply With Quote #16

Yes, void means nothing is just for making it explicit. No arguments.
__________________
joaquimandrade is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 02-11-2010 , 18:37   Re: Orpheu: Using virtual functions
Reply With Quote #17

Yea well i tryed :

Code:
"arguments" : 
    [
        {
            "type" : ""
        }
    ],

Before i posted, but it should just be completly removed ->

Code:
{
    "name"      : "Spawn",
    "class"     : "CBasePlayer",
    "library"   : "mod",
  
    "indexes" : 
    [
        {
            "os"    : "windows",
            "mod"   : "dod",
            "value" : 3
        },
        {
            "os"    : "linux",
            "mod"   : "dod",
            "value" : 5
        }
    ]
}
Thanks again!
Attached Files
File Type: sma Get Plugin or Get Source (player_spawn.sma - 644 views - 1.2 KB)
__________________

Last edited by Dr.G; 02-11-2010 at 19:13. Reason: attached sample for hooking spawn
Dr.G is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 02-11-2010 , 18:44   Re: Orpheu: Using virtual functions
Reply With Quote #18

By the way, another interesting way of using virtual functions is to hook stuff from CHalfLifeMultiplay. It needs an extra step that deals with getting the game rules object. Give it a look to those function and if you want to use some tell me that I will search the functions to get the object for your mod.
__________________
joaquimandrade is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 02-12-2010 , 08:15   Re: Orpheu: Using virtual functions
Reply With Quote #19

I cant see any of the CHalfLifeMultiplay thats usefull atm.

But can we hook other stuff thats not inside CBasePlayer::vtbl ? Like CBasePlayer::PopHelmet(Vector *) or use a function like CBaseEntity::FireBulletsNC(Vector,Vector,floa t,float,int,int,int,entvars_s*, int) ?
__________________
Dr.G is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-12-2010 , 08:18   Re: Orpheu: Using virtual functions
Reply With Quote #20

You can hook almost all what you want.
__________________
Arkshine 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:30.


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