Raised This Month: $51 Target: $400
 12% 

Config Bool Help


Post New Thread Reply   
 
Thread Tools Display Modes
Skippy
Senior Member
Join Date: Nov 2011
Old 04-03-2013 , 23:27   Re: Config Bool Help
Reply With Quote #11

I have another thing I'm wanting to add that would be exactly the same as the enable / disable. I'm adding another menu that enables or disables color for the message that prints to chat. Now can I use the same message_trie or should I create a new one?

I will edit the coding and show you in a bit (Wait to answer until the coding is up)
__________________
Plugins:
[Any] Aim Menu

Want a TF2 plugin? Feel free to pm me to discuss it.

Last edited by Skippy; 04-03-2013 at 23:30.
Skippy is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 04-03-2013 , 23:32   Re: Config Bool Help
Reply With Quote #12

you can use the same or not. that's up to you. if you use the same, add a prefix or sufix to it, like "c_Welcome to the Server!", otherwise, you don't need any prefix or sufix, as it's a new trie and won't overwrite the other one.
Bimbo1 is offline
Skippy
Senior Member
Join Date: Nov 2011
Old 04-03-2013 , 23:48   Re: Config Bool Help
Reply With Quote #13

Here look at this. I'm wanting to enable and disable colors for the messages. How am I suppose to format it now? With the same trie?

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <morecolors>

new Handle:message_trie;
new 
Handle:configFile INVALID_HANDLE;

new 
String:MenuTitle[64];

public 
OnPluginStart() 
{
    
RegAdminCmd("sm_message"Command_MessageADMFLAG_SLAY"Menu of Messages");
    
message_trie CreateTrie();
}

public 
Action:Command_Message(clientargs)
{
    if(
IsClientInGame(client))
    {
        
decl Handle:Menu;
        
Menu CreateMenu(MessageCallback);
        
        
SetMenuTitle(Menu"Message Menu");
        
AddMenuItem(Menu"0""Sayings");
        
AddMenuItem(Menu"1""Enable / Disable Sayings");
        
AddMenuItem(Menu"2""Enable / Disable Colored Sayings");
        
DisplayMenu(MenuclientMENU_TIME_FOREVER);
    }    
    return 
Plugin_Handled;
}

public 
MessageCallback(Handle:menuMenuAction:actionclientparam2)
{
    if(
action == MenuAction_Select)
    {
        
decl String:info[64];
        
GetMenuItem(menuparam2infosizeof(info));
        
        if (
StrEqual(info,"0"))
        {
            
SayingsMenu(client);
        }
        if (
StrEqual(info,"1"))
        {
            
ControlSayingsMenu(client); 
        }
        if (
StrEqual(info,"2"))
        {
            
SayingColorMenu(client); 
        }    
    }
    else if(
action == MenuAction_End)
    {
        
CloseHandle(menu);
    }
}    

public 
SayingsMenu(client)
{
    if(
IsClientInGame(client))
    {
        
decl Handle:menu;
        
menu CreateMenu(SayingsCallback);
        
        
SetMenuTitle(menu"Sayings");
        
        new 
String:sMessage[32];
        
        
decl String:path[64];
    
        
configFile CreateKeyValues("Sayings");
        
BuildPath(Path_SMpathsizeof(path), "configs/Sayings.cfg");
    
        if (
FileToKeyValues(configFilepath))
        {
            
KvRewind(configFile);            
            
KvGotoFirstSubKey(configFile);
            do
            {
                
KvGetString(configFile"saying"sMessagesizeof(sMessage));
                
                if(
SayingEnabled(sMessage))
                {
                    
AddMenuItem(menusMessagesMessage);
                }
            }
            while(
KvGotoNextKey(configFile));
        }                
        
SetMenuExitBackButton(menutrue);
        
DisplayMenu(menuclientMENU_TIME_FOREVER);
    }    
}

public 
SayingsCallback(Handle:menuMenuAction:actionclientparam2)
{
    if(
action == MenuAction_EndCloseHandle(menu);
    if(
action == MenuAction_Cancel && param2 == MenuCancel_ExitBackFakeClientCommand(client"sm_message");
    if(
action == MenuAction_Select)
    {
        new 
String:info[32];
        
GetMenuItem(menuparam2infosizeof(info));
        
        if(
SayingColorEnabled(sMessage)) //Help on This
        
{
            
CPrintToChat(client"{blue} %s"info);
        }
        else
        {
            
PrintToChat(clientinfo);
        }    
    }
}    

public 
SayingColorMenu(client)
{
    if(
IsClientInGame(client))
    {
        
decl Handle:Menu;
        
Menu CreateMenu(ColorCallback);
        
        
SetMenuTitle(MenuMenuTitle);
        
        new 
String:sMessage[32];
        
        
decl String:path[64];
        new 
String:dMessage[64];
    
        
configFile CreateKeyValues("Chat Colors");
        
BuildPath(Path_SMpathsizeof(path), "configs/Sayings.cfg");
    
        if (
FileToKeyValues(configFilepath))
        {
            
KvRewind(configFile);            
            
KvGotoFirstSubKey(configFile);
            do
            {
                
KvGetString(configFile"saying"sMessagesizeof(sMessage));
                                
                if(
SayingColorEnabled(sMessage)) //Help on This
                
{
                    
Format(dMessagesizeof(dMessage), "Disable Color: %s"sMessage);
                    
AddMenuItem(MenusMessagedMessage);  
                }
                else
                {
                    
Format(dMessagesizeof(dMessage), "Enable Color: %s"sMessage);
                    
AddMenuItem(MenusMessagedMessage);
                }    
            }
            while(
KvGotoNextKey(configFile));
        }                
        
SetMenuExitBackButton(Menutrue);
        
DisplayMenu(MenuclientMENU_TIME_FOREVER);
    }    
}

public 
ColorCallback(Handle:menuMenuAction:actionclientparam2)
{
    if(
action == MenuAction_EndCloseHandle(menu);
    if(
action == MenuAction_Cancel && param2 == MenuCancel_ExitBackFakeClientCommand(client"sm_message");
    if(
action == MenuAction_Select)
    {
        new 
String:info[32];
        
GetMenuItem(menuparam2infosizeof(info));
        
        
SwitchColorMessage(info); //Help on This
    
}
}

public 
ControlSayingsMenu(client)
{
    if(
IsClientInGame(client))
    {
        
decl Handle:Menu;
        
Menu CreateMenu(ControlCallback);
        
        
SetMenuTitle(Menu"Enable/Disable Sayings");
        
        new 
String:sMessage[32];
        
        
decl String:path[64];
        new 
String:dMessage[64];
    
        
configFile CreateKeyValues("Chat Colors");
        
BuildPath(Path_SMpathsizeof(path), "configs/Sayings.cfg");
    
        if (
FileToKeyValues(configFilepath))
        {
            
KvRewind(configFile);            
            
KvGotoFirstSubKey(configFile);
            do
            {
                
KvGetString(configFile"saying"sMessagesizeof(sMessage));
                
                
Format(dMessagesizeof(dMessage), "%s"sMessage);
                
                if(
SayingEnabled(sMessage))
                {
                    
Format(dMessagesizeof(dMessage), "Disable: %s"sMessage);
                    
AddMenuItem(MenusMessagedMessage);   
                }
                else
                {
                    
Format(dMessagesizeof(dMessage), "Enable: %s"sMessage);
                    
AddMenuItem(MenusMessagedMessage);    
                }
    
            }
            while(
KvGotoNextKey(configFile));
        }                
        
SetMenuExitBackButton(Menutrue);
        
DisplayMenu(MenuclientMENU_TIME_FOREVER);
    }    
}

public 
ControlCallback(Handle:menuMenuAction:actionclientparam2)
{
    if(
action == MenuAction_EndCloseHandle(menu);
    if(
action == MenuAction_Cancel && param2 == MenuCancel_ExitBackFakeClientCommand(client"sm_message");
    if(
action == MenuAction_Select)
    {
        new 
String:info[32];
        
GetMenuItem(menuparam2infosizeof(info));
        
        
SwitchMessage(info);    
    }
}

SwitchMessage(const String:message[32])
{
    new 
value;
    
GetTrieValue(message_triemessagevalue);
    
SetTrieValue(message_triemessage, (value+1)%2);    
}

bool:SayingEnabled(const String:message[32])
{
    new 
value;
    new 
found GetTrieValue(message_triemessagevalue);
    if(
found)
    {   
        if(
value == 0)
        {       
            return 
false;         
        }
        return 
true;        
    }
    
SetTrieValue(message_triemessage1);
    return 
true;    

__________________
Plugins:
[Any] Aim Menu

Want a TF2 plugin? Feel free to pm me to discuss it.

Last edited by Skippy; 04-03-2013 at 23:48.
Skippy is offline
Skippy
Senior Member
Join Date: Nov 2011
Old 04-04-2013 , 21:26   Re: Config Bool Help
Reply With Quote #14

Also with the Color Enabling and Disabling, How can I have the saying color enable for a certain client and not having it set for just the saying.
__________________
Plugins:
[Any] Aim Menu

Want a TF2 plugin? Feel free to pm me to discuss it.
Skippy is offline
Skippy
Senior Member
Join Date: Nov 2011
Old 04-06-2013 , 10:39   Re: Config Bool Help
Reply With Quote #15

Is it possible to create a bool like Color[client][sMessage] = true; ???
__________________
Plugins:
[Any] Aim Menu

Want a TF2 plugin? Feel free to pm me to discuss it.
Skippy is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 04-06-2013 , 12:10   Re: Config Bool Help
Reply With Quote #16

sorry for taking too long for answering. i've been quite busy. but, yes, it is possible to do that, everything(?) is! however, you would have to use a database to save that condition of whether the player should have the saying color enabled or not. anyway, i'm still busy and can't help you with the coding. look for sourcemod database or cookies(clientprefs) in google and if you work hard you will get to it.
__________________
sie sind das essen und wir sind die jäger!
Bimbo1 is offline
Skippy
Senior Member
Join Date: Nov 2011
Old 04-06-2013 , 12:34   Re: Config Bool Help
Reply With Quote #17

Quote:
Originally Posted by Bimbo1 View Post
sorry for taking too long for answering. i've been quite busy. but, yes, it is possible to do that, everything(?) is! however, you would have to use a database to save that condition of whether the player should have the saying color enabled or not. anyway, i'm still busy and can't help you with the coding. look for sourcemod database or cookies(clientprefs) in google and if you work hard you will get to it.
I think that you think that I want to save the bool settings? I don't want to save them. I just want a way for color be enabled for a client for a specific saying that the client sets himself. I don't want to save those settings.
__________________
Plugins:
[Any] Aim Menu

Want a TF2 plugin? Feel free to pm me to discuss it.
Skippy is offline
Skippy
Senior Member
Join Date: Nov 2011
Old 04-06-2013 , 13:25   Re: Config Bool Help
Reply With Quote #18

Well I got it to work with this but I don't think this is the best way to do it.

PHP Code:
SwitchColor(const String:message[32], const String:auth[64])
{
    new 
value1;
    
GetTrieValue(color_triemessagevalue1);
    new 
value2;
    
GetTrieValue(color_trieauthvalue2);
    if(
value1 == && value2 == 0)
    {
        
SetTrieValue(color_triemessage1);
        
SetTrieValue(color_trieauth1);     
    }
    else
    {
        
SetTrieValue(color_triemessage0); 
        
SetTrieValue(color_trieauth0); 
    }    
}

bool:ColorEnabled(const String:message[32], const String:auth[64])
{
    new 
value1;
    new 
found1 GetTrieValue(color_triemessagevalue1);
    new 
value2;
    new 
found2 GetTrieValue(color_trieauthvalue2);
    if(
found1 && found2)
    {   
        if(
value1 == && value2 == 0)
        {       
            return 
false;         
        }
        return 
true;        
    }
    else
    {
        
SetTrieValue(color_triemessage0);
        
SetTrieValue(color_trieauth0);
    }
    return 
true;    

__________________
Plugins:
[Any] Aim Menu

Want a TF2 plugin? Feel free to pm me to discuss it.
Skippy is offline
Skippy
Senior Member
Join Date: Nov 2011
Old 04-07-2013 , 00:59   Re: Config Bool Help
Reply With Quote #19

The coding above didn't work well because when I changed it for different clients with the auth setting it would also change the colored enabled for a message one for everyone!
__________________
Plugins:
[Any] Aim Menu

Want a TF2 plugin? Feel free to pm me to discuss it.
Skippy is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 04-07-2013 , 21:20   Re: Config Bool Help
Reply With Quote #20

Create a multidimensional array that contains client, enabled, and color.. One array of natives

Or create three arrays.. And index them in parallel.. One of natives, and two of boleans

Globals...
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.

Last edited by friagram; 04-07-2013 at 21:23.
friagram 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 20:58.


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