This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

need help, replace hud messages


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bazhenov93
Veteran Member
Join Date: Oct 2010
Old 03-26-2012 , 04:53   need help, replace hud messages
Reply With Quote #1

ok so I get this code, but i don't need replace texts to random colours..
i want set a colour for every text

PHP Code:
#include <amxmodx> 

#define VERSION "0.0.2" 
#define PLUGIN "" 

new Trie:g_tReplacements 

public plugin_init() 

    
register_plugin(PLUGINVERSION"ConnorMcLeod"
    
register_message(get_user_msgid("TextMsg"), "Message_TextMsg"

    
g_tReplacements TrieCreate() 
    
TrieSetString(g_tReplacements"#Bomb_Planted",                "The Bomb Has Been Planted"
    
TrieSetString(g_tReplacements"#CTs_Win",                                "Counter-Terrorists Win!"
    
TrieSetString(g_tReplacements"#Terrorists_Win",                        "Terrorists Win!"
    
TrieSetString(g_tReplacements"#Round_Draw",                            "Round Draw!"
    
TrieSetString(g_tReplacements"Cstrike_TitlesTXT_Game_Commencing",        "Game Commencing"


public 
Message_TextMsg(iMsgIdiMsgDestid

    if( !
id && get_msg_arg_int(1) == print_center 
    { 
        new 
szMessage[64
        
get_msg_arg_string(2szMessagecharsmax(szMessage)) 
        if( 
equal(szMessage"#Game_will_restart_in") ) 
        { 
            new 
szArg1[4
            
get_msg_arg_string(3szArg1charsmax(szArg1)) 
            
formatex(szMessagecharsmax(szMessage), "The game will restart in %s seconds"szArg1
            
set_hudmessage(1272550, .channel=-1
            
show_hudmessage(0szMessage
            return 
PLUGIN_HANDLED 
        

        else if( 
TrieGetString(g_tReplacementsszMessageszMessagecharsmax(szMessage)) ) 
        { 
            
set_hudmessage(random(256), random(256), random(256), .channel=-1
            
show_hudmessage(0szMessage
            return 
PLUGIN_HANDLED 
        

    } 
    return 
PLUGIN_CONTINUE 

example:

#Bomb_Planted
set_hudmessage ...

#CTs_Win
set_hudmessage ...

HELP?

Last edited by bazhenov93; 03-26-2012 at 05:58.
bazhenov93 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-26-2012 , 09:35   Re: need help, replace hud messages
Reply With Quote #2

PHP Code:
#include <amxmodx> 

#define VERSION "0.0.2" 
#define PLUGIN "" 

new const g_szOriginal[][] = {
    
"#Bomb_Planted",
    
"#CTs_Win",
    
"#Terrorists_Win",
    
"#Round_Draw",
    
"Cstrike_TitlesTXT_Game_Commencing"
};

#define MAX_REPLACE sizeof(g_szOriginal)

new const g_szReplace[MAX_REPLACE][] =
{
    
"The Bomb Has Been Planted",
    
"Counter-Terrorists Win!",
    
"Terrorists Win!",
    
"Round Draw!",
    
"Game Commencing"
};

enum _:RGB RG};

// use -1 to be random
new const g_iColor[MAX_REPLACE][RGB] =
{
    {-
1, -1, -1},
    {-
1, -1, -1},
    {-
1, -1, -1},
    {-
1, -1, -1},
    {-
1, -1, -1}
};

// hud effects:
// 0 = none
// 1 = flicker
// 2 = write out
new const g_iEffect[MAX_REPLACE] =
{
    
0,
    
0,
    
0,
    
0,
    
0
};

// hud time
new const Float:g_fTime[MAX_REPLACE] =
{
    
12.0,
    
12.0,
    
12.0,
    
12.0,
    
12.0
};

new 
Trie:g_tReplacements

#define toColor(%1) (%1 == -1 ? random(256) : %1)

public plugin_init() 

    
register_plugin(PLUGINVERSION"ConnorMcLeod"
    
register_message(get_user_msgid("TextMsg"), "Message_TextMsg"
    
    
g_tReplacements TrieCreate()
    
    for(new 
0MAX_REPLACEi++)
    {
        
TrieSetCell(g_tReplacementsg_szOriginal[i], i);
    }


public 
Message_TextMsg(iMsgIdiMsgDestid

    if( !
id && get_msg_arg_int(1) == print_center 
    { 
        new 
szMessage[64], index
        get_msg_arg_string
(2szMessagecharsmax(szMessage)) 
        if( 
equal(szMessage"#Game_will_restart_in") ) 
        { 
            new 
szArg1[4
            
get_msg_arg_string(3szArg1charsmax(szArg1)) 
            
formatex(szMessagecharsmax(szMessage), "The game will restart in %s seconds"szArg1
            
set_hudmessage(1272550, .channel=-1
            
show_hudmessage(0szMessage
            return 
PLUGIN_HANDLED 
        

        else if( 
TrieGetCell(g_tReplacementsszMessageindex) ) 
        {
            
set_hudmessage(
                .
red      toColor(g_iColor[index][R]),
                .
green    toColor(g_iColor[index][G]),
                .
blue     toColor(g_iColor[index][B]),
                .
effects  g_iEffect[index],
                .
holdtime g_fTime[index],
                .
fxtime   g_fTime[index],
                .
channel  = -1
            
);
            
show_hudmessage(0g_szReplace[index]) 
            return 
PLUGIN_HANDLED 
        

    } 
    return 
PLUGIN_CONTINUE 

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 03-26-2012 at 16:02.
Exolent[jNr] is offline
bazhenov93
Veteran Member
Join Date: Oct 2010
Old 03-26-2012 , 09:43   Re: need help, replace hud messages
Reply With Quote #3

Error: Undefined symbol "g_iColor" on line 68
Error: Invalid expression, assumed zero on line 68
Error: Invalid expression, assumed zero on line 68
Error: Too many error messages on one line on line 68
bazhenov93 is offline
bazhenov93
Veteran Member
Join Date: Oct 2010
Old 03-26-2012 , 10:08   Re: need help, replace hud messages
Reply With Quote #4

If you will fix it start from this code, I just added all messages that I want to edit.

PHP Code:
#include <amxmodx>  

#define VERSION "0.0.2"  
#define PLUGIN ""  

new const g_szOriginal[][] = { 
    
"#Bomb_Planted"
    
"#CTs_Win"
    
"#Terrorists_Win"
    
"#Round_Draw"
    
"#Game_Commencing",
    
"#All_Hostages_Rescued",
    
"#All_Teams_Full",
    
"#Already_Have_One",
    
"#Bomb_Defused",
    
"#C4_Plant_At_Bomb_Spot",
    
"#CTs_Full",
    
"#Cannot_Buy_This",
    
"#Carry_Anymore",
    
"#Defusing_Bomb_With_Defuse_Kit",
    
"#Defusing_Bomb_Without_Defuse_Kit",
    
"#Game_bomb_drop",
    
"#Game_bomb_pickup",
    
"#Got_bomb",
    
"#Got_defuser",
    
"#Hint_press_buy_to_purchase",
    
"#Hint_spotted_a_friend",
    
"#Hint_spotted_an_enemy",
    
"#Hint_you_have_the_bomb",
    
"#OBS_ROAMING"
}; 

#define MAX_REPLACE sizeof(g_szOriginal) 

new const g_szReplace[MAX_REPLACE][] = { 
    
"The bomb has been planted"
    
"Counter-Terrorists Win"
    
"Terrorists Win"
    
""// Round Draw - hide
    
"Game Commencing",
    
""// All Hostages have been rescued! - hide
    
"All teams are full!",
    
"You already have one!",
    
"The bomb has been defused!",
    
"C4 must be planted at a bomb site!",
    
"The CT team is full!",
    
"You cannot buy this item!",
    
"You cannot carry anymore!",
    
"Defusing bomb WITH Defuse kit",
    
"Defusing bomb WITHOUT Defuse kit",
    
"%s1 dropped the bomb",
    
"%s1 picked up the bomb",
    
"You picked up the bomb!",
    
"You picked up a defuser kit!",
    
""// Press the BUY key to purchase items - hide
    
"You have spotted a friend",
    
"You have spotted an enemy",
    
"You have the bomb!",
    
"" // Free Look - hide
    
}; 

enum _:RGB RG}; 

// use -1 to be random 
new const g_iColors[MAX_REPLACE][RGB] = { 
    {
2556464}, // The bomb has been planted
    
{0127255}, // Counter-Terrorists Win
    
{2552020}, // Terrorists Win
    
{000}, // Round Draw
    
{16220590},  // Game Commencing
    
{000}, // All Hostages have been rescued!
    
{0250154}, // All teams are full!
    
{17923858}, // You already have one!
    
{32178170}, // The bomb has been defused!
    
{3413934}, // C4 must be planted at a bomb site!
    
{240230140}, // The CT team is full!
    
{2381180}, // You cannot buy this item!
    
{23810680}, // You cannot carry anymore!
    
{173234234}, // Defusing bomb WITH Defuse kit
    
{25518515}, // Defusing bomb WITHOUT Defuse kit
    
{205181205}, // %s1 dropped the bomb
    
{216191216}, // %s1 picked up the bomb
    
{245204176}, // You picked up the bomb!
    
{255131250}, // You picked up a defuser kit!
    
{000}, // Press the BUY key to purchase items
    
{000}, // You have spotted a friend
    
{000}, // You have spotted an enemy
    
{205550}, // You have the bomb!
    
{000// Free Look
}; 

new 
Trie:g_tReplacements 

#define toColor(%1) (%1 == -1 ? random(256) : %1) 

public plugin_init()  
{  
    
register_plugin(PLUGINVERSION"ConnorMcLeod")  
    
register_message(get_user_msgid("TextMsg"), "Message_TextMsg")  

    
g_tReplacements TrieCreate() 
     
    for(new 
0MAX_REPLACEi++) { 
        
TrieSetCell(g_tReplacementsg_szOriginal[i], i); 
    } 
}  

public 
Message_TextMsg(iMsgIdiMsgDestid)  
{  
    if( !
id && get_msg_arg_int(1) == print_center )  
    {  
        new 
szMessage[64], index 
        get_msg_arg_string
(2szMessagecharsmax(szMessage))  
        if( 
equal(szMessage"#Game_will_restart_in") )  
        {  
            new 
szArg1[4]  
            
get_msg_arg_string(3szArg1charsmax(szArg1))  
            
formatex(szMessagecharsmax(szMessage), "The game will restart in %s seconds"szArg1)  
            
set_hudmessage(1272550, .channel=-1)  
            
show_hudmessage(0szMessage)  
            return 
PLUGIN_HANDLED  
        
}  
        else if( 
TrieGetCell(g_tReplacementsszMessageindex) )  
        {  
            
set_hudmessage(toColor(g_iColor[index][R]), toColor(g_iColor[index][G]), toColor(g_iColor[index][B]), .channel=-1)  
            
show_hudmessage(0szMessage)  
            return 
PLUGIN_HANDLED  
        
}  
    }  
    return 
PLUGIN_CONTINUE  

Also I want blinking effect and set time to 4 seconds

Last edited by bazhenov93; 03-26-2012 at 10:32.
bazhenov93 is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 03-26-2012 , 10:18   Re: need help, replace hud messages
Reply With Quote #5

Quote:
Originally Posted by bazhenov93 View Post
Also where to add hud effects?
http://forums.alliedmods.net/showthread.php?t=149210
__________________
You can do anything you set your mind to, man.

Devil259 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-26-2012 , 14:12   Re: need help, replace hud messages
Reply With Quote #6

Quote:
Originally Posted by bazhenov93 View Post
Error: Undefined symbol "g_iColor" on line 68
Error: Invalid expression, assumed zero on line 68
Error: Invalid expression, assumed zero on line 68
Error: Too many error messages on one line on line 68
Quote:
Originally Posted by bazhenov93 View Post
Also I want blinking effect and set time to 4 seconds
Fixed and added customizable effects and times. See my previous post.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
bazhenov93
Veteran Member
Join Date: Oct 2010
Old 03-26-2012 , 15:07   Re: need help, replace hud messages
Reply With Quote #7

Warning: Tag mismatch on line 53
Warning: Tag mismatch on line 54
Warning: Tag mismatch on line 55
Warning: Tag mismatch on line 56
Warning: Tag mismatch on line 58
Warning: Tag mismatch on line 94
Warning: Tag mismatch on line 94
Warning: Symbol is never used: "g_szReplace" on line 108
Header size: 392 bytes
Code size: 1716 bytes
Data size: 892 bytes
Stack/heap size: 16384 bytes; estimated max. usage=87 cells (348 bytes)
Total requirements: 19384 bytes

8 Warnings.
Done.
bazhenov93 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-26-2012 , 16:02   Re: need help, replace hud messages
Reply With Quote #8

Fixed
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
bazhenov93
Veteran Member
Join Date: Oct 2010
Old 03-26-2012 , 16:50   Re: need help, replace hud messages
Reply With Quote #9

Quote:
Originally Posted by Exolent[jNr] View Post
Fixed
Thanks so much Exolent! Work just great, not all messages are replaced, I suppose that the text is wrong on new const g_szOriginal[][] = {

I will search for correct codes, anyway thankyou again! HF & GL
bazhenov93 is offline
bazhenov93
Veteran Member
Join Date: Oct 2010
Old 03-26-2012 , 17:47   Re: need help, replace hud messages
Reply With Quote #10

I Already found it, but don't know why the message does not replace

Post by Connor
bazhenov93 is offline
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:20.


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