AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   hud colors with cvar (https://forums.alliedmods.net/showthread.php?t=217547)

GhostMan 06-04-2013 06:53

hud colors with cvar
 
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)



Clauu 06-04-2013 07:03

Re: hud colors with cvar
 
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..);

TheDS1337 06-04-2013 07:58

Re: hud colors with cvar
 
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) }

fysiks 06-05-2013 04:11

Re: hud colors with cvar
 
Quote:

Originally Posted by DeagLe.Studio (Post 1964273)
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); 


TheDS1337 06-05-2013 04:17

Re: hud colors with cvar
 
Quote:

Originally Posted by fysiks (Post 1964948)
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


All times are GMT -4. The time now is 16:20.

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