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

[Solved] set_msg_arg_int (AMXX -> Module ?)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dias
BANNED
Join Date: Jul 2009
Location: South Vietnam
Old 03-02-2013 , 08:50   [Solved] set_msg_arg_int (AMXX -> Module ?)
Reply With Quote #1

In AMXX, i have:
PHP Code:
register_message(get_user_msgid("Health"), "Message_Health")

public 
Message_Health(msg_idmsg_destid)
{
    
// Get player's health
    
static health
    health 
get_msg_arg_int(1)
    
    
//// Don't bother
    
if(health 1
        return
    
    static 
Float:NewHealthRealHealthHealth
    
    NewHealth 
= (float(health) / float(g_StartHealth[id])) * 100.0
    
RealHealth floatround(NewHealth)
    
Health clamp(RealHealth1255)
    
    
set_msg_arg_int(1get_msg_argtype(1), Health)

how to do that "set_msg_arg_int(1, get_msg_argtype(1), Health)" in hooking in the Module ?
PHP Code:
void MessageBegin(int destint TYPE, const float *Originedict_t *ed
{
    if(
TYPE == GET_USER_MSG_ID(NULL"Health"NULL))
    {
        
g_200Health true;
    }
    
    
RETURN_META(MRES_IGNORED); 
}

void WriteByte(int BYTE)
{
    if(
g_200Health && BYTE == 1)
    {
        
// What i need to do here ?
    
}
    
    
RETURN_META(MRES_IGNORED); 
}

void MessageEnd()
{
    
g_200Health false;

    
RETURN_META(MRES_IGNORED); 


Last edited by dias; 03-02-2013 at 08:50.
dias is offline
Send a message via Yahoo to dias Send a message via Skype™ to dias
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-02-2013 , 09:15   Re: [NOT Solved] set_msg_arg_int (AMXX -> Module ?)
Reply With Quote #2

Check the AMXX source code, see how it's done, then reproduce in your module ?
__________________
Arkshine is offline
dias
BANNED
Join Date: Jul 2009
Location: South Vietnam
Old 03-02-2013 , 18:12   Re: [NOT Solved] set_msg_arg_int (AMXX -> Module ?)
Reply With Quote #3

I've checked the message.cpp, hard to understand but as i can see, It blocks old message and send a new message with new config, right ?

Last edited by dias; 03-02-2013 at 19:44.
dias is offline
Send a message via Yahoo to dias Send a message via Skype™ to dias
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 03-03-2013 , 17:43   Re: [NOT Solved] set_msg_arg_int (AMXX -> Module ?)
Reply With Quote #4

Quote:
Originally Posted by dias View Post
In AMXX, i have:
PHP Code:
register_message(get_user_msgid("Health"), "Message_Health")

public 
Message_Health(msg_idmsg_destid)
{
    
// Get player's health
    
static health
    health 
get_msg_arg_int(1)
    
    
//// Don't bother
    
if(health 1
        return
    
    static 
Float:NewHealthRealHealthHealth
    
    NewHealth 
= (float(health) / float(g_StartHealth[id])) * 100.0
    
RealHealth floatround(NewHealth)
    
Health clamp(RealHealth1255)
    
    
set_msg_arg_int(1get_msg_argtype(1), Health)

how to do that "set_msg_arg_int(1, get_msg_argtype(1), Health)" in hooking in the Module ?
PHP Code:
void MessageBegin(int destint TYPE, const float *Originedict_t *ed
{
    if(
TYPE == GET_USER_MSG_ID(NULL"Health"NULL))
    {
        
g_200Health true;
    }
    
    
RETURN_META(MRES_IGNORED); 
}

void WriteByte(int BYTE)
{
    if(
g_200Health && BYTE == 1)
    {
        
// What i need to do here ?
    
}
    
    
RETURN_META(MRES_IGNORED); 
}

void MessageEnd()
{
    
g_200Health false;

    
RETURN_META(MRES_IGNORED); 

I don't know about C++, i've never coded on it, but as I saw on the source code, I didn't find it hard, it's one of the most easiest things that I've ever seen ._.

PHP Code:
void WriteByte(int BYTE)
{
    if(
g_200Health && BYTE == 1)
    {
        
WRITE_BYTE(100)
        
RETURN_META(MRES_SUPERCEDE); 
    }
    
    
RETURN_META(MRES_IGNORED); 

__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
dias
BANNED
Join Date: Jul 2009
Location: South Vietnam
Old 03-04-2013 , 04:44   Re: [NOT Solved] set_msg_arg_int (AMXX -> Module ?)
Reply With Quote #5

^
- Have you test it ?
dias is offline
Send a message via Yahoo to dias Send a message via Skype™ to dias
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 03-04-2013 , 17:19   Re: [NOT Solved] set_msg_arg_int (AMXX -> Module ?)
Reply With Quote #6

Quote:
Originally Posted by dias View Post
^
- Have you test it ?
I don't see anything bad or illogic, you won't lose time testing it lol it's how AMXx dones message arguments changing
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
dias
BANNED
Join Date: Jul 2009
Location: South Vietnam
Old 03-04-2013 , 18:21   Re: [Solved] set_msg_arg_int (AMXX -> Module ?)
Reply With Quote #7

^
- Cool, i thought that i need to block old message and send a new message with new condition
Your method works well
PHP Code:
void MessageBegin(int destint TYPE, const float *Originedict_t *ed
{
    if(
TYPE == GET_USER_MSG_ID(NULL"Health"NULL) && !g_200Health_InHook)
    {
        
g_200Health_InHook 1;
        
g_200Health true;
    }
    
    
RETURN_META(MRES_IGNORED); 
}

void WriteByte(int BYTE)
{
    if(
g_200Health && g_200Health_InHook == 1)
    {
        
g_200Health_Data BYTE;
        
WRITE_BYTE(200);
        
RETURN_META(MRES_SUPERCEDE);
    }
    
    
RETURN_META(MRES_IGNORED); 
}

void MessageEnd()
{
    if(
g_200Health && g_200Health_InHook == 1)
    {
        
g_200Health_InHook 0;
        
g_200Health false;
    }

    
RETURN_META(MRES_IGNORED); 

dias is offline
Send a message via Yahoo to dias Send a message via Skype™ to dias
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 13:21.


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