Raised This Month: $ Target: $400
 0% 

hud colors with cvar


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GhostMan
Senior Member
Join Date: Jun 2012
Old 06-04-2013 , 06:53   hud colors with cvar
Reply With Quote #1

How can i put hud message color in cvar? So that i wouldn't need to recompile plugin if i want to change its collor.

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

new const PLUGIN[]  = "Connect adv"
new const VERSION[] = "1.3"
new const AUTHOR[]  = "none"

new hudmessage1HudOnChatOn

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
hudmessage1 CreateHudSyncObj()
    
    
ChatOn register_cvar("conn_chat""1")
    
HudOn register_cvar("conn_hud""1")
    
    
register_dictionary("connrekl.txt")
}

public 
client_putinserver(id
{    
    if(!
is_user_bot(id)) 
    {
        
set_task(20.0"ShowMsg"id)
    }
}

public 
ShowMsg(id)
{
    if(
get_pcvar_num(ChatOn))
    {
        
client_print(idprint_chat"%L"id"REKLAMA_CHAT")
    }
    
    if(
get_pcvar_num(HudOn))
    {
        
set_hudmessage(42170420.020.2710.510.0)
        
ShowSyncHudMsg(idhudmessage1"%L"id"REKLAMA_HUD")
    }
}

public 
client_disconnect(id)

    
remove_task(id)

GhostMan is offline
Clauu
Senior Member
Join Date: Feb 2008
Location: RO
Old 06-04-2013 , 07:03   Re: hud colors with cvar
Reply With Quote #2

You will need a cvar string for colors in rgb format and after parse them 3 by 3 or split them after some delimitator in a vector or how do you want and then replace the first 3 values with your own in the hud set_hudmessage(val1,val2,val3,rest of code..);

Last edited by Clauu; 06-04-2013 at 07:04.
Clauu is offline
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 06-04-2013 , 07:58   Re: hud colors with cvar
Reply With Quote #3

Try something like this:
Code:
#include <amxmodx> #include <amxmisc> new const PLUGIN[]  = "Connect adv" new const VERSION[] = "1.3" new const AUTHOR[]  = "none" new hudmessage1, HudOn, ChatOn, HudColor public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         hudmessage1 = CreateHudSyncObj()         ChatOn = register_cvar("conn_chat", "1")     HudOn = register_cvar("conn_hud", "1")     HudColor = register_cvar("conn_hud_color", "000 255 000" );         register_dictionary("connrekl.txt") } public client_putinserver(id) {         if(!is_user_bot(id))     {         set_task(20.0, "ShowMsg", id)     } } public ShowMsg(id) {     if(get_pcvar_num(ChatOn))     {         client_print(id, print_chat, "%L", id, "REKLAMA_CHAT")     }         if(get_pcvar_num(HudOn))     {     static Colors[ 12 ], RealColors[ 9 ]; // instead of [ 3 ][ 3 ], let's make it  3 * 3     get_pcvar_string( HudColor, Colors, charsmax( Colors ) );     parse( Colors, RealColors[ 0 ], charsmax( RealColors ), RealColors[ 1 ], charsmax( RealColors ), RealColors[ 2 ], charsmax( RealColors ) );     set_hudmessage(str_to_num( RealColors[ 0 ] ), str_to_num( RealColors[ 3 ] ), str_to_num( RealColors[ 7 ] ), 0.02, 0.27, 1, 0.5, 10.0)     ShowSyncHudMsg(id, hudmessage1, "%L", id, "REKLAMA_HUD")     } } public client_disconnect(id) {     remove_task(id) }

Last edited by TheDS1337; 06-05-2013 at 04:19.
TheDS1337 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-05-2013 , 04:11   Re: hud colors with cvar
Reply With Quote #4

Quote:
Originally Posted by DeagLe.Studio View Post
Try something like this:
Code:
#include <amxmodx> #include <amxmisc> new const PLUGIN[]  = "Connect adv" new const VERSION[] = "1.3" new const AUTHOR[]  = "none" new hudmessage1, HudOn, ChatOn, HudColor public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         hudmessage1 = CreateHudSyncObj()         ChatOn = register_cvar("conn_chat", "1")     HudOn = register_cvar("conn_hud", "1")     HudColor = register_cvar("conn_hud_color", "000 255 000" );         register_dictionary("connrekl.txt") } public client_putinserver(id) {         if(!is_user_bot(id))     {         set_task(20.0, "ShowMsg", id)     } } public ShowMsg(id) {     if(get_pcvar_num(ChatOn))     {         client_print(id, print_chat, "%L", id, "REKLAMA_CHAT")     }         if(get_pcvar_num(HudOn))     {     static Colors[ 12 ], RealColors[ 9 ]; // instead of [ 3 ][ 3 ], let's make it  3 * 3     get_pcvar_string( HudColor, Colors, charsmax( Colors ) );     parse( Colors, RealColors[ 0 ], charsmax( RealColors ), RealColors[ 1 ], charsmax( RealColors ), RealColors[ 2 ], charsmax( RealColors ) );     set_hudmessage(str_to_num( RealColors[ 0 ] ), str_to_num( RealColors[ 2 ] ), str_to_num( RealColors[ 3 ] ), 0.02, 0.27, 1, 0.5, 10.0)     ShowSyncHudMsg(id, hudmessage1, "%L", id, "REKLAMA_HUD")     } } public client_disconnect(id) {     remove_task(id) }
No! You need to learn how strings work.

PHP Code:
    new szColors[16]
    new 
szRed[4], szGreen[4], szBlue[4]
    new 
iRediGreeniBlue
    
    get_pcvar_string
(cvar_pointer_hereszColorscharsmax(szColors))
    
parse(szColorsszRedcharsmax(szRed), szGreencharsmax(szGreen), szBluecharsmax(szBlue))
    
iRed str_to_num(szRed); iGreen str_to_num(szGreen); iBlue str_to_num(szBlue); 
__________________
fysiks is offline
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 06-05-2013 , 04:17   Re: hud colors with cvar
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
No! You need to learn how strings work.

PHP Code:
    new szColors[16]
    new 
szRed[4], szGreen[4], szBlue[4]
    new 
iRediGreeniBlue
    
    get_pcvar_string
(cvar_pointer_hereszColorscharsmax(szColors))
    
parse(szColorsszRedcharsmax(szRed), szGreencharsmax(szGreen), szBluecharsmax(szBlue))
    
iRed str_to_num(szRed); iGreen str_to_num(szGreen); iBlue str_to_num(szBlue); 
you are right
TheDS1337 is offline
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 16:20.


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