AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   TextMsg - Alter content (https://forums.alliedmods.net/showthread.php?t=54933)

regalis 05-08-2007 09:34

TextMsg - Alter content
 
Hi there :)
I have a big problem with messages...
I can block messages without problems :up:

- 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:45:33] #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! :up:

greetz regalis

VEN 05-08-2007 11:40

Re: TextMsg - Alter content
 
Use set_msg_arg_string()
But note that game will not understand non-standalone text code. So you have to set "real" string.

regalis 05-08-2007 11:52

Re: TextMsg - Alter content
 
Quote:

Originally Posted by VEN (Post 474650)
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

VEN 05-08-2007 13:13

Re: TextMsg - Alter content
 
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.

mogel 05-08-2007 13:37

Re: TextMsg - Alter content
 
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


All times are GMT -4. The time now is 06:34.

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