AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Correct parameter for using "TextMsg" (https://forums.alliedmods.net/showthread.php?t=318124)

iceeedr 08-14-2019 23:04

Correct parameter for using "TextMsg"
 
Hi allied, I'm having trouble printing the name of the player who sent the radio command, instead of the name of the sender, is printing the name of the receiver, I've tried both with the iMsgDest parameter, and with id, I'm a bit lost and I know the answer is probably obvious, thanks in advance.

PHP Code:

register_message(get_user_msgid("TextMsg"), "MessageHook_TextMsg"

public 
MessageHook_TextMsg(iMsgiMsgDestid)  
{  
        if(
get_msg_args() != || !g_eSettings[VarRadio]) return PLUGIN_CONTINUE  

        
static message200 ]
        static 
handleCvar
        
new str100 
    
        new const 
messageParam 5
        
new sz_Health get_user_health id )

        
get_msg_arg_string(messageParammessagecharsmax(message))
    
        if(
TrieGetCell(RadioDatasmessagehandleCvar) && get_pcvar_string(handleCvarmessagecharsmax(message)))
        {
            
formatex(strcharsmax (str ), "^3[^4%s^3]^1:^4 %n^x01 (RADIO) (^4HP^1:^x03%d^x01):^x04 %s"g_eSettings[VarTagPrefixWithoutColor], id sz_Health message 
            
            
set_msg_arg_string(3str
        } 
        return 
PLUGIN_CONTINUE  



Mistrick 08-15-2019 09:23

Re: Correct parameter for using "TextMsg"
 
Sender placed in first string param. NumAsString(entindex()) in ClientPrint.

https://github.com/s1lentq/ReGameDLL...hbang.cpp#L177
https://github.com/s1lentq/ReGameDLL...layer.cpp#L435
https://github.com/s1lentq/ReGameDLL.../util.cpp#L664

PHP Code:

public MessageHook_TextMsg(iMsgiMsgDestreciever)   
{   
        if(
get_msg_args() != || !g_eSettings[VarRadio]) return PLUGIN_CONTINUE   

        
static message200 
        static 
handleCvar 
        
new str100 ]  
     
        new const 
messageParam 

        
new sendertemp[8];
        
// first param is WRITE_BYTE(msg_dest);
        // second sender index as string
        
get_msg_arg_string(2tempcharsmax(temp));
        
sender str_to_num(temp);
        
        new 
sz_Health get_user_health sender 
        
        
get_msg_arg_string(messageParammessagecharsmax(message)) 
     
        if(
TrieGetCell(RadioDatasmessagehandleCvar) && get_pcvar_string(handleCvarmessagecharsmax(message))) 
        { 
            
formatex(strcharsmax (str ), "^3[^4%s^3]^1:^4 %n^x01 (RADIO) (^4HP^1:^x03%d^x01):^x04 %s"g_eSettings[VarTagPrefixWithoutColor], sender sz_Health message )  
             
            
set_msg_arg_string(3str)  
        }  
        return 
PLUGIN_CONTINUE   



iceeedr 08-15-2019 09:38

Re: Correct parameter for using "TextMsg"
 
Quote:

Originally Posted by Mistrick (Post 2663359)
Sender placed in first string param. NumAsString(entindex()) in ClientPrint.

https://github.com/s1lentq/ReGameDLL...hbang.cpp#L177
https://github.com/s1lentq/ReGameDLL...layer.cpp#L435
https://github.com/s1lentq/ReGameDLL.../util.cpp#L664

PHP Code:

public MessageHook_TextMsg(iMsgiMsgDestreciever)   
{   
        if(
get_msg_args() != || !g_eSettings[VarRadio]) return PLUGIN_CONTINUE   

        
static message200 
        static 
handleCvar 
        
new str100 ]  
     
        new const 
messageParam 

        
new sendertemp[8];
        
// first param is WRITE_BYTE(msg_dest);
        // second sender index as string
        
get_msg_arg_string(2tempcharsmax(temp));
        
sender str_to_num(temp);
        
        new 
sz_Health get_user_health sender 
        
        
get_msg_arg_string(messageParammessagecharsmax(message)) 
     
        if(
TrieGetCell(RadioDatasmessagehandleCvar) && get_pcvar_string(handleCvarmessagecharsmax(message))) 
        { 
            
formatex(strcharsmax (str ), "^3[^4%s^3]^1:^4 %n^x01 (RADIO) (^4HP^1:^x03%d^x01):^x04 %s"g_eSettings[VarTagPrefixWithoutColor], sender sz_Health message )  
             
            
set_msg_arg_string(3str)  
        }  
        return 
PLUGIN_CONTINUE   



Thanks for the links and the code I was looking for but I didn't know where to find it.


All times are GMT -4. The time now is 14:38.

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