AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   TextMsg isnt working (https://forums.alliedmods.net/showthread.php?t=221578)

Jhob94 07-23-2013 19:27

TextMsg isnt working
 
Hello
I tried this:
PHP Code:

#include <amxmodx>

new tf

public plugin_init() {
    
register_plugin("Taking Fire Changer""0.0.1""Author")
    
    
register_message(get_user_msgid("TextMsg"), "message_textmsg")
    
    
tf register_cvar("msg_takingfire""Taking Fire, Save Me Guys!")
}

public 
message_textmsg(msg_idmsg_destmsg_entity) {
    static 
textmsg[32]
    
get_msg_arg_string(2textmsgsizeof textmsg 1)
    
    new 
new_message[121]
    
    if(
equal(textmsg"#Taking_fire"))
        
get_pcvar_string(tfnew_message120)
        
    else
        return
        
    
message_begin(msg_destmsg_id_msg_entity)
    
write_byte(get_msg_arg_int(1))
    
format(new_message120"%s"new_message)
    
write_string(new_message)
    
message_end()


Well idk if problem is about arguments or if it is because of format, but the message that is displayed is the default one...

^SmileY 07-23-2013 20:01

Re: TextMsg isnt working
 
Not tested

PHP Code:

#include <amxmodx>

#define BLOCK_MESSAGE     PLUGIN_HANDLED     // Change it to PLUGIN_CONTINUE to not block orignal message :)

new p_Message;

public 
plugin_init()
{
    
register_plugin("Taking Fire Message",AMXX_VERSION_STR,"SmileY");
    
    
register_message(get_user_msgid("TextMsg"),"message_TextMsg");
    
    
p_Message     register_cvar("msg_takingfire","Taking Fire, Save Me Guys!");
}

public 
message_TextMsg(iMsg,iDest,iEntity)
{
    static 
szMessage[64];
    
get_msg_arg_string(2,szMessage,charsmax(szMessage));
    
    if(
equal(szMessage,"#Taking_fire"))
    {
        new 
szReplace[128];
        
get_pcvar_string(p_Message,szReplace,charsmax(szReplace));
        
        if(
szReplace[0])
        {
            
message_begin(iDest,iMsg,_,iEntity);
            
write_byte(get_msg_arg_int(1));
            
write_string(szReplace);
            
message_end();
            
            return 
BLOCK_MESSAGE;
        }
    }
    return 
PLUGIN_CONTINUE;



UchihaSkills 07-23-2013 20:36

Re: TextMsg isnt working
 
OP your plugin cant work if you use this code..

^SmileY 07-23-2013 20:46

Re: TextMsg isnt working
 
Quote:

Originally Posted by UchihaSkills (Post 1997448)
OP your plugin cant work if you use this code..

Really its a mistake, try this.


PHP Code:

#include <amxmodx>

new p_Message;

public 
plugin_init()
{
    
register_plugin("Mensagens padroes",AMXX_VERSION_STR,"Giovanni ;)");
    
    
register_message(get_user_msgid("TextMsg"),"message_TextMsg");
    
    
p_Message register_cvar("amx_msg_taking_fire","Taking Fire, Save Me Guys!");
}

public 
message_TextMsg(iMsg,iDest,iEntity)
{
    if(
get_msg_args() != || get_msg_argtype(3) != ARG_STRING || get_msg_argtype(5) != ARG_STRING) return PLUGIN_CONTINUE;
    
    new 
szMessage[32];
    
get_msg_arg_string(5,szMessage,charsmax(szMessage));
    
    if(
equali(szMessage,"#Taking_fire"))
    {
        static 
szReplaced[128];
        
get_pcvar_string(p_Message,szReplaced,charsmax(szReplaced));
        
        if(
szReplaced[0])
        {
            
message_begin(iDest,iMsg,_,iEntity);
            
write_byte(print_chat);
            
write_string(szReplaced);
            
message_end();
            
            return 
PLUGIN_HANDLED;     // Replace to PLUGIN_CONTINUE to show original chat message.
        
}
    }
    return 
PLUGIN_CONTINUE;



ConnorMcLeod 07-24-2013 04:52

Re: TextMsg isnt working
 
Why you guys are sending a new TextMsg ?

Just change the msg arg with your string.

Jhob94 07-24-2013 07:39

Re: TextMsg isnt working
 
Why the one i did doesnt works? It dont change the msg arg with the string?

Arkshine 07-24-2013 07:57

Re: TextMsg isnt working
 
He meant : why you don't use set_msg_arg_string(), which is the whole point of such native in such callback.

^SmileY 07-24-2013 08:16

Re: TextMsg isnt working
 
Quote:

Originally Posted by ConnorMcLeod (Post 1997596)
Why you guys are sending a new TextMsg ?

Just change the msg arg with your string.

I only follow the given code :x

ConnorMcLeod 07-24-2013 09:24

Re: TextMsg isnt working
 
Quote:

Originally Posted by ^SmileY (Post 1997679)
I only follow the given code :x

That's not a good reason :p

Jhob94 07-24-2013 13:04

Re: TextMsg isnt working
 
This is full plugin:

PHP Code:

#include <amxmodx>

new c_01c_02c_03c_04c_05c_06c_07c_08c_09c_10c_11
new c_12c_13c_14c_15c_16c_17c_18c_19c_20c_21c_22

new MessageType
new Trietc

public plugin_init() {
    
register_plugin("Radio Messages Changer""0.0.1""Jhob94")
    
    
register_message(get_user_msgid("TextMsg"), "message_textmsg")
    
    
Register_Tries()
    
Register_Cvars()
}

Register_Tries() {
    
tc TrieCreate()
    
TrieSetCell(tc"#Taking_fire"1)
    
TrieSetCell(tc"#Follow_me"2)
    
TrieSetCell(tc"#Regroup_team"3)
    
TrieSetCell(tc"#Hold_this_position"4)
    
TrieSetCell(tc"#You_take_the_point"5)
    
TrieSetCell(tc"#Cover_me"6)
    
TrieSetCell(tc"#Report_in_team"7)
    
TrieSetCell(tc"#Storm_the_front"8)
    
TrieSetCell(tc"#Get_in_position_and_wait"9)
    
TrieSetCell(tc"#Stick_together_team"10)
    
TrieSetCell(tc"#Team_fall_back"11)
    
TrieSetCell(tc"#Go_go_go"12)
    
TrieSetCell(tc"#Enemy_down"13)
    
TrieSetCell(tc"#Negative"14)
    
TrieSetCell(tc"#Get_out_of_there"15)
    
TrieSetCell(tc"#Reporting_in"16)
    
TrieSetCell(tc"#In_position"17)
    
TrieSetCell(tc"#Sector_clear"18)
    
TrieSetCell(tc"#Need_backup"19)
    
TrieSetCell(tc"#Enemy_spotted"20)
    
TrieSetCell(tc"#Roger_that"21)
    
TrieSetCell(tc"#Affirmative"22)
}

Register_Cvars() {
    
c_01 register_cvar("msg_takingfire""Taking Fire, Save My Ass Guys!")
    
c_02 register_cvar("msg_followme""Just Follow My Ass!")
    
c_03 register_cvar("msg_regroup""Guys Regroup! What You Doing?!")
    
c_04 register_cvar("msg_holdposition""Hold The Position! I Will Shoot You If You Move!")
    
c_05 register_cvar("msg_takepoint""You Take The Fucking Point!")
    
c_06 register_cvar("msg_coverme""Cover My Fucking Ass!")
    
c_07 register_cvar("msg_reportteam""Fast! Report In Team!")
    
c_08 register_cvar("msg_stormfront""Storm That Shit Like A Pidgeot!")
    
c_09 register_cvar("msg_stormfront""Get In Position And Fucking Wait!")
    
c_10 register_cvar("msg_sticktogether""Guys Stick Together! I Am Fucking Afraid!")
    
c_11 register_cvar("msg_teamfallback""Guys Fall Back! NOW!")
    
c_12 register_cvar("msg_gogogo""GO! GO! GO! I Am Naruto Dattebayo!"// Wtf xD
    
c_13 register_cvar("msg_enemiedown""I Killed This Idiots! You Can Go Now!")
    
c_14 register_cvar("msg_negative""No Way Man!")
    
c_15 register_cvar("msg_getoutthere""Man Get The Fucking Out Of There!")
    
c_16 register_cvar("msg_reportingin""Reporting In!"// No idea for this one :S
    
c_17 register_cvar("msg_inposition""I Am In The Fucking Position!")
    
c_18 register_cvar("msg_sectorclear""This Sector Is Clear Like My Purse!"// LOL i was thinking in put paypal instead :3
    
c_19 register_cvar("msg_needbackup""I Need Backup Guys! FAST!")
    
c_20 register_cvar("msg_enemiespotted""Some Camper Is Here! Be Careful Guys!")
    
c_21 register_cvar("msg_rogerthat""Roger That!"// I like the Roger That so i dont want to change it :3
    
c_22 register_cvar("msg_affirmative""Affirmative!"// This one too :3
}

public 
message_textmsg(msg_idmsg_destmsg_entity) {
    static 
textmsg[32]
    
get_msg_arg_string(2textmsgsizeof textmsg 1)
    
    if(
TrieGetCell(tctextmsgMessageType))
    {
        new 
new_message[121]
        
        if(
MessageType == 1)
            
get_pcvar_string(c_01new_message120)
        
        else if(
MessageType == 2)
            
get_pcvar_string(c_02new_message120)
        
        else if(
MessageType == 3)
            
get_pcvar_string(c_03new_message120)
        
        else if(
MessageType == 4)
            
get_pcvar_string(c_04new_message120)
        
        else if(
MessageType == 5)
            
get_pcvar_string(c_05new_message120)
        
        else if(
MessageType == 6)
            
get_pcvar_string(c_06new_message120)
        
        else if(
MessageType == 7)
            
get_pcvar_string(c_07new_message120)
        
        else if(
MessageType == 8)
            
get_pcvar_string(c_08new_message120)
        
        else if(
MessageType == 9)
            
get_pcvar_string(c_09new_message120)
        
        else if(
MessageType == 10)
            
get_pcvar_string(c_10new_message120)
        
        else if(
MessageType == 11)
            
get_pcvar_string(c_11new_message120)
        
        else if(
MessageType == 12)
            
get_pcvar_string(c_12new_message120)
        
        else if(
MessageType == 13)
            
get_pcvar_string(c_13new_message120)
        
        else if(
MessageType == 14)
            
get_pcvar_string(c_14new_message120)
        
        else if(
MessageType == 15)
            
get_pcvar_string(c_15new_message120)
        
        else if(
MessageType == 16)
            
get_pcvar_string(c_16new_message120)
        
        else if(
MessageType == 17)
            
get_pcvar_string(c_17new_message120)
        
        else if(
MessageType == 18)
            
get_pcvar_string(c_18new_message120)
        
        else if(
MessageType == 19)
            
get_pcvar_string(c_19new_message120)
        
        else if(
MessageType == 20)
            
get_pcvar_string(c_20new_message120)
            
        else if(
MessageType == 21)
            
get_pcvar_string(c_21new_message120)
        
        else if(
MessageType == 21)
            
get_pcvar_string(c_22new_message120)
            
        
set_msg_arg_string(2new_message)
        
        return 
PLUGIN_HANDLED
    
}
    
    return 
PLUGIN_CONTINUE


Still not working :cry:


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

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