Raised This Month: $32 Target: $400
 8% 

TextMsg - Alter content


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 05-08-2007 , 09:34   TextMsg - Alter content
Reply With Quote #1

Hi there
I have a big problem with messages...
I can block messages without problems

- But is it possible to alter the content of the message and let the message pass my plugin?
For example add a timestamp like "[10:453] #Fire_in_the_hole"....

Code:
#include <amxmodx>
#include <amxmisc>

public plugin_init()
{
    register_message(get_user_msgid("TextMsg"), "block_message");
}

public block_message(msg_id, msg_dest, entity)
{
    if(get_msg_args() == 5)
    {
        if(get_msg_argtype(5) == ARG_STRING)
        {
            new value5[64];
            get_msg_arg_string(5 ,value5 ,63);
            if(equal(value5, "#Fire_in_the_hole"))
            {
                return PLUGIN_HANDLED; //blocks the message
                //How do i alter the message content??
            }
        }
    }
    return PLUGIN_CONTINUE;
}
Here is the message which i logged with DS's msglogging.amxx
(http://forums.alliedmods.net/showthread.php?p=65983)
Code:
/*
MessageBegin (TextMsg "77") (Destination "One<1>") (Args "5") (Entity "1") (Classname "player") (Netname "~regalis~") (Origin "0.000000 0.000000 0.000000")
Arg 1 (Byte "5")
Arg 2 (String "1")
Arg 3 (String "#Game_radio")
Arg 4 (String "~regalis~")
Arg 5 (String "#Fire_in_the_hole")
MessageEnd (TextMsg "77")
*/
Any help will be appreciated!

greetz regalis
__________________

Last edited by regalis; 05-08-2007 at 09:36.
regalis is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 05-08-2007 , 11:40   Re: TextMsg - Alter content
Reply With Quote #2

Use set_msg_arg_string()
But note that game will not understand non-standalone text code. So you have to set "real" string.
VEN is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 05-08-2007 , 11:52   Re: TextMsg - Alter content
Reply With Quote #3

Quote:
Originally Posted by VEN View Post
Use set_msg_arg_string()
But note that game will not understand non-standalone text code. So you have to set "real" string.
First thank you for the reply!
I don't understand what you mean with "non-standalone text code" though i will play a little with set_msg_arg_string and see if it works

greetz regalis
__________________
regalis is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 05-08-2007 , 13:13   Re: TextMsg - Alter content
Reply With Quote #4

By standalone text code i mean string like "#Fire_in_the_hole". If you would going to prepend/append something to that string text code will not be standalone anymore so game will not translate that text code into actual text.
VEN is offline
mogel
Senior Member
Join Date: Jan 2007
Old 05-08-2007 , 13:37   Re: TextMsg - Alter content
Reply With Quote #5

Hi,

an example for replacing the voice-commands for both sides

Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>
#include <csx>
#include "include/blackmesa.inc"



#define PLUGIN "BM-Radio"
#define VERSION "0.4.1"
#define AUTHOR "mogel"



//    Hilfe -> http://www.databasesystemscorp.com/psivrttv.htm
//         David & Split Personality
//         Damien & Old Robot



#define MAXRADIO 23



new newradio[MAXRADIO][] = {
    "newradio11.wav",
    "newradio12.wav",
    "newradio13.wav",
    "newradio14.wav",
    "newradio15.wav",
    "newradio16.wav",
    "newradio21.wav",
    "newradio22.wav",
    "newradio23.wav",
    "newradio24.wav",    // 10
    "newradio25.wav",
    "newradio26.wav",
    "newradio31b.wav",
    "newradio31a.wav",
    "newradio32.wav",
    "newradio33.wav",
    "newradio34.wav",
    "newradio35.wav",
    "newradio36.wav",
    "newradio37.wav",    // 20
    "newradio38.wav",
    "newradio39.wav",
    "newradio01.wav"    // Fire In The Hole
}
new message[MAXRADIO][] = {
    "%!MRAD_COVERME",
    "%!MRAD_TAKEPOINT",
    "%!MRAD_POSITION",
    "%!MRAD_REGROUP",
    "%!MRAD_FOLLOWME",
    "%!MRAD_HITASSIST",
    "%!MRAD_GO",
    "%!MRAD_FALLBACK",
    "%!MRAD_STICKTOG",
    "%!MRAD_GETINPOS",
    "%!MRAD_STORMFRONT",
    "%!MRAD_REPORTIN",
    "%!MRAD_AFFIRM",
    "%!MRAD_ROGER",
    "%!MRAD_ENEMYSPOT",
    "%!MRAD_BACKUP",
    "%!MRAD_CLEAR",
    "%!MRAD_INPOS",
    "%!MRAD_REPRTINGIN",
    "%!MRAD_BLOW",
    "%!MRAD_NEGATIVE",
    "%!MRAD_ENEMYDOWN",
    "%!MRAD_FIREINHOLE"
}



//    Hilfe -> http://forums.alliedmods.net/showthread.php?t=54110
//         http://forums.alliedmods.net/showthread.php?p=193239



new msgid_sendaudio
new CsTeam:hs = CsTeam:CS_TEAM_UNASSIGNED



public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    RegisterVersionCVar("radio", VERSION)
    
    msgid_sendaudio = get_user_msgid("SendAudio")
    
    register_message(msgid_sendaudio, "Msg_SendAudio") 
    
    hs = HumanSide()
}
public plugin_precache() {
    new path[200]
    for (new i = 0; i < MAXRADIO; i++)
    {
        format(path, 199, "sound/blackmesa/human/%s", newradio[i])
        precache_generic(path)
        if (!equal(newradio[i], "newradio01.wav"))
        {
            format(path, 199, "sound/blackmesa/zombie/%s", newradio[i])
            precache_generic(path)
        }
    }
}
/*
L 04/18/2007 - 18:05:35: MessageBegin (SendAudio "100") (Destination "One<1>") (Args "3") (Entity "1") (Classname "player") (Netname "<BlackMesa> Invader Zim") (Origin "0.000000 0.000000 0.000000")
L 04/18/2007 - 18:05:35: Arg 1 (Byte "1")
L 04/18/2007 - 18:05:35: Arg 2 (String "%!MRAD_AFFIRM")
L 04/18/2007 - 18:05:35: Arg 3 (Short "100")
L 04/18/2007 - 18:05:35: MessageEnd (SendAudio "100")
*/
public Msg_SendAudio() {
    new sound[50]
    //new patched = 0
    get_msg_arg_string(2, sound, 49)
    new player = get_msg_arg_int(1)
    
    // es muss nicht alles kontrolliert werden
    if (contain(sound, "%!MRAD_") == -1) return PLUGIN_CONTINUE
    
    for(new i = 0; i < MAXRADIO; i++)
    {
        if (equali(sound, message[i]))  
        {
            new sound[200]
            if (cs_get_user_team(player) == hs)
            {
                format(sound, 199, "blackmesa/human/%s", newradio[i])
            } else
            {
                format(sound, 199, "blackmesa/zombie/%s", newradio[i])
            }
            
            set_msg_arg_string(2, sound)
            //patched = 1
            break;
        }
    }
    
    //if (!patched) log_amx("unpatched sound -> '%s'", sound)
    
    return PLUGIN_CONTINUE
}
hand, mogel
__________________
mogel is offline
Old 05-08-2007, 14:15
regalis
This message has been deleted by regalis. Reason: i hate -karma
Reply


Thread Tools
Display Modes

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 22:09.


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