This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Orpheu: Using virtual functions


Post New Thread Reply   
 
Thread Tools Display Modes
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 02-12-2010 , 08:27   Re: Orpheu: Using virtual functions
Reply With Quote #21

Quote:
Originally Posted by Dr.G View Post
I cant see any of the CHalfLifeMultiplay thats usefull atm.

But can we hook other stuff thats not inside CBasePlayer::vtbl ? Like CBasePlayer:opHelmet(Vector *) or use a function like CBaseEntity::FireBulletsNC(Vector,Vector,floa t,float,int,int,int,entvars_s*, int) ?
when they are in "::vtbl" you can hook them using this tutorial. For other functions (not virtual functions anymore) you need other techniques. About those spefic you talked about when they have the type "Vector", even if you can hook it you will not be able to get the vectors (calling it, forget it). That's because Vector is a C++ class and in Windows compiler it is treated differently from normal types (scalar). So, basically "Vector" is unsupported.

"Vector *" and "Vector &" are supported.

Me or Arkshine must make another tutorial to non virtual functions.
__________________

Last edited by joaquimandrade; 02-12-2010 at 08:30.
joaquimandrade is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 02-12-2010 , 08:46   Re: Orpheu: Using virtual functions
Reply With Quote #22

Roger that :) Thank you once again!
__________________
Dr.G is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 02-13-2010 , 21:39   Re: Orpheu: Using virtual functions
Reply With Quote #23

Hoping i under stand what you do with these sigs..

Below is a zip of ones i have been working with

Take damage and player killed work

Player spawn dosent.. Not sure if im doing it right in the plugin.

PHP Code:
new OrpheuFunction:Player_Spawn OrpheuGetFunctionFromClass("player""PlayerSpawn""CHalfLifeMultiplay" );
    
OrpheuRegisterHook(Player_Spawn,"OnPlayerSpawn"); 
Attached Files
File Type: zip Sigs.zip (1.8 KB, 185 views)

Last edited by Doc-Holiday; 02-14-2010 at 03:25.
Doc-Holiday is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-14-2010 , 05:21   Re: Orpheu: Using virtual functions
Reply With Quote #24

Quote:
Originally Posted by NcB_Sav View Post
Hoping i under stand what you do with these sigs..

Below is a zip of ones i have been working with

Take damage and player killed work

Player spawn dosent.. Not sure if im doing it right in the plugin.

PHP Code:
new OrpheuFunction:Player_Spawn OrpheuGetFunctionFromClass("player""PlayerSpawn""CBasePlayer" );
    
OrpheuRegisterHook(Player_Spawn,"OnPlayerSpawn"); 
CBasePlayer::.Spawn(void)

You put "PlayerSpawn" from HalfMultiPlay but it's "Spawn" from CBasePlayer
If you really want the one from HalfLifeMultiPlay you have to register it with CGameRules as class, read the first post of orpheu module thread for more information, i had the same problem yesterday and arkshine helped me with it.

->

PHP Code:
new OrpheuFunction:Player_Spawn OrpheuGetFunctionFromClass("player""Spawn""CBasePlayer" );
    
OrpheuRegisterHook(Player_Spawn,"OnPlayerSpawn"); 
or

PHP Code:
    OrpheuRegisterHook(OrpheuGetFunctionFromClass("player""Spawn""CBasePlayer" ),"OnPlayerSpawn"); 

The one you tried is not the code that make a player respawn, but the one where ammo and guns are given to player :
Code:
void CHalfLifeMultiplay :: PlayerSpawn( CBasePlayer *pPlayer )
{
	BOOL		addDefault;
	CBaseEntity	*pWeaponEntity = NULL;

	pPlayer->pev->weapons |= (1<<WEAPON_SUIT);
	
	addDefault = TRUE;

	while ( pWeaponEntity = UTIL_FindEntityByClassname( pWeaponEntity, "game_player_equip" ))
	{
		pWeaponEntity->Touch( pPlayer );
		addDefault = FALSE;
	}

	if ( addDefault )
	{
		pPlayer->GiveNamedItem( "weapon_crowbar" );
		pPlayer->GiveNamedItem( "weapon_9mmhandgun" );
		pPlayer->GiveAmmo( 68, "9mm", _9MM_MAX_CARRY );// 4 full reloads
	}
}
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 02-14-2010 at 05:57.
ConnorMcLeod is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-14-2010 , 06:49   Re: Orpheu: Using virtual functions
Reply With Quote #25

In CS, it seems to look like :

PHP Code:
void CHalfLifeMultiplay :: PlayerSpawnCBasePlayer *pPlayer )
{
    if ( !
pPlayer->m_bJustConnected )
    {
        
CBaseEntity *pWeaponEntity NULL;
        
pPlayer->pev->weapons |= ( << WEAPON_SUIT );
 
        while ( 
pWeaponEntity UTIL_FindEntityByClassnamepWeaponEntity"game_player_equip" ) )
        {
            
pWeaponEntity->TouchpPlayer );
        }
 
        if ( !
pPlayer->m_bNotKilled && pWeaponEntity || pPlayer->m_bIsVIP )
        {
            
CBasePlayer::GiveDefaultItemspPlayer );
        }
 
        
CBasePlayer::SetPlayerModelpPlayer );
    }

__________________

Last edited by Arkshine; 02-14-2010 at 07:11.
Arkshine is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 02-14-2010 , 08:05   Re: Orpheu: Using virtual functions
Reply With Quote #26

This is how to hook functions from CHalfLifeMultiplay object:

PHP Code:
#include <amxmodx>
#include <orpheu>
#include <orpheu_memory>
    
public plugin_init()
{    
    new 
g_pGameRules OrpheuMemoryGet("g_pGameRules")

    new 
OrpheuFunction:GetNextBestWeapon OrpheuGetFunctionFromObject(g_pGameRules,"GetNextBestWeapon","CGameRules")
    
    
OrpheuRegisterHook(GetNextBestWeapon,"OnGetNextBestWeapon")    
}

public 
OnGetNextBestWeapon(obj,id,ent)
{



It must be on plugin_init.
Attached Files
File Type: zip stuff.zip (1.7 KB, 187 views)
__________________
joaquimandrade is offline
Empowers
BANNED
Join Date: Feb 2009
Location: Ukraine
Old 02-14-2010 , 09:11   Re: Orpheu: Using virtual functions
Reply With Quote #27

I used code and sigs from main post.

But It gives me an error
Code:
L 02/14/2010 - 16:14:33: [ORPHEU] Invalid virtual function "CBasePlayer::OnTouch
ingWeapon"
L 02/14/2010 - 16:14:33: [AMXX] Displaying debug trace (plugin "test.amxx")
L 02/14/2010 - 16:14:33: [AMXX] Run time error 10: native error (native "OrpheuG
etFunctionFromClass")
L 02/14/2010 - 16:14:33: [AMXX]    [0] test.sma::plugin_init (line 6)

Last edited by Empowers; 02-14-2010 at 09:15.
Empowers is offline
Send a message via ICQ to Empowers
Old 02-14-2010, 09:12
Empowers
This message has been deleted by Empowers.
Dr.G
Senior Member
Join Date: Nov 2008
Old 02-14-2010 , 16:03   Re: Orpheu: Using virtual functions
Reply With Quote #28

Quote:
Originally Posted by NcB_Sav View Post
Hoping i under stand what you do with these sigs..

Below is a zip of ones i have been working with

Take damage and player killed work

Player spawn dosent.. Not sure if im doing it right in the plugin.

PHP Code:
new OrpheuFunction:Player_Spawn OrpheuGetFunctionFromClass("player""PlayerSpawn""CHalfLifeMultiplay" );
    
OrpheuRegisterHook(Player_Spawn,"OnPlayerSpawn"); 

The Spawn function is pre when i tested it on dod.


PHP Code:
/* Plugin generated by AMXX-Studio */
////////////////////////////////////////////////////////////////////////////////////////////////////
#include <amxmodx>
#include <Orpheu>
////////////////////////////////////////////////////////////////////////////////////////////////////
#define PLUGIN "DoD Orpheu testing"
#define VERSION "1.0 by Dr.G"
#define AUTHOR "AMXX DoD Team"
////////////////////////////////////////////////////////////////////////////////////////////////////
/* NOTE: */
/* CBasePlayer::PreThink(void) -> Offset WIN32 = 132 */

/* CBasePlayer::Spawn(void) -> Offset WIN32 = 3 */

/* CBasePlayer::Killed(entvars_s *, int) -> Offset WIN32 = 20 */

/* THESE are offsets for Day of Defeat! */
////////////////////////////////////////////////////////////////////////////////////////////////////
new i[33] = 0
new time_to_run 
new counter[33] = 0
new is_alive[33] = 0
////////////////////////////////////////////////////////////////////////////////////////////////////
public plugin_init() 
{
    
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    new 
OrpheuFunction:iThink OrpheuGetFunctionFromClass("player""PreThink""CBasePlayer" )
    
OrpheuRegisterHook(iThink,"think_Player")
    
    new 
OrpheuFunction:Player_Spawn OrpheuGetFunctionFromClass("player""Spawn""CBasePlayer" )
    
OrpheuRegisterHook(Player_Spawn,"Spawn")
    
    new 
OrpheuFunction:Player_Killed OrpheuGetFunctionFromClass("player","Killed""CBasePlayer" )
    
OrpheuRegisterHook(Player_Killed,"player_Killed")
    
    
time_to_run register_cvar("time_to_run","30")
    
    
register_clcmd("say /thinktest","start_Test")
    
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public start_Test(id)
{
    
set_taskget_pcvar_float(time_to_run), "stop_Test"id )
    
counter[id] = 0
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public stop_Test(id)
{
    
client_print(id3"*Thinks per Sec: %d", (counter[id]/get_pcvar_num(time_to_run)))
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public Spawn(player//looks like its pre..
{
    
set_task(1.0"Spawn_Delayed"player)
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public Spawn_Delayed(id)
    
is_alive[id] = is_user_alive(id)
////////////////////////////////////////////////////////////////////////////////////////////////////
public think_Player(player)
{
    
counter[player]++
    
    
    if(
i[player] == 600)
    {
        
i[player] = 0
        
        
if(is_alive[player])
        {
            
client_print(player3"*Thinkin' and alive..")
            return
        }
        else
            
client_print(player3"*Thinkin' and dead..")
        
    }
    
i[player]++
    
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public player_Killed(victimkillersomething)
{
    
is_alive[victim] = 0
    client_print
(victim3"*You died!")
}
//////////////////////////////////////////////////////////////////////////////////////////////////// 
Attached Files
File Type: sma Get Plugin or Get Source (orpheu-testing.sma - 710 views - 3.0 KB)
File Type: txt CBasePlayer_offsets_DoD.txt (5.8 KB, 180 views)
File Type: zip CBasePlayer.zip (749 Bytes, 163 views)
__________________
Dr.G is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 02-14-2010 , 17:36   Re: Orpheu: Using virtual functions
Reply With Quote #29

Hmm So say want to strip wepaons and give weapons. I can use a delay to make spawn post?
Doc-Holiday is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 02-14-2010 , 17:40   Re: Orpheu: Using virtual functions
Reply With Quote #30

yea should work
__________________
Dr.G 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 09:25.


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