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

How to hook event curweapon?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bos93
Veteran Member
Join Date: Jul 2010
Old 12-17-2012 , 00:32   How to hook event curweapon?
Reply With Quote #1

PHP Code:
void MessageBegin(int msg_destint msg_type, const float *pOriginedict_t *ed)
{
    static 
bool LoadedMSGS false;

    if(!
LoadedMSGS)
    {
        
MSGID_CurWeapon REG_USER_MSG("CurWeapon"3);

        
LoadedMSGS true;
    }

    if(
msg_type == MSGID_CurWeapon && msg_dest == MSG_SPEC)
    {
        
EVENTS::Hook_CurWeapon_byte true;
    }

    
RETURN_META(MRES_IGNORED);
}

void WriteByte(int iValue)
{
    if(
EVENTS::Hook_CurWeapon_byte)
    {
        if(
iValue != 0)
            
EVENTS::Hook_CurWeapon_byte false;
    }

    
RETURN_META(MRES_IGNORED);
}

void MessageEnd()
{
    if(
EVENTS::Hook_CurWeapon_byte)
    {
        
EVENTS::Hook_CurWeapon_byte false;   
        
// is not called
        
Event_CurWeapon( ); 
    }

    
RETURN_META(MRES_IGNORED);

doesn't work.
__________________

Last edited by Bos93; 12-17-2012 at 00:32.
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 12-17-2012 , 00:51   Re: How to hook event curweapon?
Reply With Quote #2

Привет. Тут.
Hello, here is the code.

PHP Code:
int g_Message;
bool g_Now;
int g_Byte;
int g_Active;
int g_Weapon33 ];
int g_Ammo33 ];
edict_t g_pEdict;

int RegUserMsg_Post( const char pNameint ) {
  if( !
strcmppName"CurWeapon" ) )
    
g_Message META_RESULT_ORIG_RET( int );

  
RETURN_META_VALUEMRES_IGNORED);
}

void MessageBeginintint Type, const float *, edict_t pClient ) {
  if( 
g_Message == Type ) {
    
g_Byte 0;
    
g_Now true;
    
g_pEdict pClient;
  }

  
RETURN_METAMRES_IGNORED );
}

void MessageEndvoid ) {
  
g_Now false;

  
RETURN_METAMRES_IGNORED );
}

void WriteByteint Value ) {
  if( !
g_Now )
    
RETURN_METAMRES_IGNORED );

  switch( ++
g_Byte ) {
    case 
1:
      
g_Active Value;

      break;

    case 
2:
      if( 
g_Active == )
        
g_WeaponENTINDEXg_pEdict ) ] = Value;

     break;

    case 
3:
      if( 
Active == )
        
g_AmmoENTINDEXg_pEdict ) ] = Value;

      break;
  }

  
RETURN_METAMRES_IGNORED );

By the way, you have already requested something similar here: https://forums.alliedmods.net/showthread.php?t=192801
Is that not enough?

Just try to understand how a message is sent and how the bytes, strings, entities, et cetera are written.
__________________

Last edited by claudiuhks; 12-17-2012 at 13:18.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
Bos93
Veteran Member
Join Date: Jul 2010
Old 12-17-2012 , 00:52   Re: How to hook event curweapon?
Reply With Quote #3

Спасибо :d

Thanks!
__________________

Last edited by Bos93; 12-17-2012 at 06:43.
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-17-2012 , 01:04   Re: How to hook event curweapon?
Reply With Quote #4

This is an English forum (other than a few specific, labeled subforums). If you're going to post in another language, also add the text in English, even if from online translator.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 12-17-2012 at 01:04.
ConnorMcLeod is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 12-17-2012 , 08:48   Re: How to hook event curweapon?
Reply With Quote #5

claudiuhks,doesn't work Oo
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 12-17-2012 , 09:19   Re: How to hook event curweapon?
Reply With Quote #6

Change this

Quote:
if( Message == Type ) {
To this

Quote:
if( g_Message == Type ) {
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
Bos93
Veteran Member
Join Date: Jul 2010
Old 12-17-2012 , 09:37   Re: How to hook event curweapon?
Reply With Quote #7

Quote:
Originally Posted by joropito View Post
Change this



To this
Yes,but doesn't work.
__________________

Last edited by Bos93; 12-17-2012 at 09:38.
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 12-17-2012 , 09:53   Re: How to hook event curweapon?
Reply With Quote #8

Put some printouts to debug what is called and what not.

Have you enabled MessageBegin/MessageEnd/WriteByte at moduleconfig?
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
Bos93
Veteran Member
Join Date: Jul 2010
Old 12-17-2012 , 10:18   Re: How to hook event curweapon?
Reply With Quote #9

I am use meta_plugin,not amxx module.



only RegUserMsg_Post is called
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 12-17-2012 , 10:47   Re: How to hook event curweapon?
Reply With Quote #10

The you have to do something like this

meta_engfuncs.pfnMessageBegin = C_MessageBegin;
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
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 16:14.


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