Raised This Month: $ Target: $400
 0% 

Solved Help with config file!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KennYSwe
Member
Join Date: Nov 2016
Old 01-29-2017 , 18:52   Help with config file!
Reply With Quote #1

Hello!
Someone who can help me make a config file for this?
PHP Code:
public ShopItem()
{
    
// CreateItem(Num, "Name", "Skin path or colors", type, price, trade check);
    // type = 1 --> Player Model, type = 2 --> Normal Item, type = 3 --> Name Color, type = 4 --> Chat Tags, type = 5 --> Message Colors
    // trade check --> true = can trade, false = can't trade
    
CreateItem(1"item"""2500false);
    
CreateItem(2"Bugs Bunny""models/player/custom_player/legacy/bugs_bunny/bugs_bunny.mdl"150000true);
    
CreateItem(3"Bloat""models/player/custom_player/kodua/bloat_albinov2/bloat.mdl"125000true);
    
CreateItem(4"Ray Man""models/player/custom_player/voikanaa/rayman.mdl"175000true);
    
CreateItem(5"Octodad""models/player/custom_player/kuristaja/octodad/octodad_tuxedo.mdl"125000true);
    
CreateItem(6"Snowman""models/player/custom_player/kodua/snowman/snowman.mdl"1100000true);
    
CreateItem(7"Red""\x07"35000true);
    
CreateItem(8"Pink""\x0E"37000true);
    
CreateItem(9"[Tag]""\x10"475000true);
    
CreateItem(10"[Tag]""\x07"43000true);
    
CreateItem(11"[Tag]""\x0E"41000true);
    
CreateItem(12"[Tag]""\x0B"4100000true);
    
CreateItem(13"Orange""\x10"510true);
    
CreateItem(14"Blue""\x0B"510true);
}
public 
CreateItem(NumString:ItemName[256], String:ItemModel[256], ItemNumberItemPricebool:itemtradeCheck)
{
    
Item_Name[Num] = ItemName;
    
Item_Model[Num] = ItemModel;
    
Item_Number[Num] = ItemNumber;
    
Item_Price[Num] = ItemPrice;
    
Item_trade[Num] = itemtradeCheck;

I want to set all this in a config so i dont need to recompile for everytime i want to add a new skin or tag.

How i would like to have it:
PHP Code:
 .
Num>"1"
    
{
        
        
"name" "<name>"
        "model" "<skin path/color>"
        "type" "<1-5>"
        "price" "<price>"
        "trade" "<true/false>"
    
}
Num>"2"
    
{
        
        
"name" "<name>"
        "model" "<skin path/color>"
        "type" "<1-5>"
        "price" "<price>"
        "trade" "<true/false>"
    
}
Num>"3"
    
{
        
        
"name" "<name>"
        "model" "<skin path/color>"
        "type" "<1-5>"
        "price" "<price>"
        "trade" "<true/false>"
    
}


Hope someone can help

Last edited by KennYSwe; 01-31-2017 at 11:01.
KennYSwe is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 01-30-2017 , 05:01   Re: Help with config file!
Reply With Quote #2

What path to config needed?
Kailo is offline
KennYSwe
Member
Join Date: Nov 2016
Old 01-30-2017 , 06:34   Re: Help with config file!
Reply With Quote #3

Quote:
Originally Posted by Kailo View Post
What path to config needed?
I can Edit that myself, it's just all the other i need help with
KennYSwe is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 01-30-2017 , 07:11   Re: Help with config file!
Reply With Quote #4

PHP Code:
if (KvGotoFirstSubKey(kv))
{
    
decl String:Num[12], String:ItemName[256], String:ItemModel[256], String:itemtradeCheck[8];
    do
    {
        
KvGetSectionName(kvNumsizeof(Num));
        
KvGetString(kv"name"ItemNamesizeof(ItemName));
        
KvGetString(kv"model"ItemModelsizeof(ItemModel));
        
KvGetString(kv"trade"itemtradeChecksizeof(itemtradeCheck));
        
CreateItem(StringToInt(Num), ItemNameItemModelKvGetNum(kv"type"), KvGetNum(kv"price"), StrEqual(itemtradeCheck"true"));
    }
    while(
KvGotoNextKey(kv));

Kailo is offline
KennYSwe
Member
Join Date: Nov 2016
Old 01-30-2017 , 09:34   Re: Help with config file!
Reply With Quote #5

Quote:
Originally Posted by Kailo View Post
PHP Code:
if (KvGotoFirstSubKey(kv))
{
    
decl String:Num[12], String:ItemName[256], String:ItemModel[256], String:itemtradeCheck[8];
    do
    {
        
KvGetSectionName(kvNumsizeof(Num));
        
KvGetString(kv"name"ItemNamesizeof(ItemName));
        
KvGetString(kv"model"ItemModelsizeof(ItemModel));
        
KvGetString(kv"trade"itemtradeChecksizeof(itemtradeCheck));
        
CreateItem(StringToInt(Num), ItemNameItemModelKvGetNum(kv"type"), KvGetNum(kv"price"), StrEqual(itemtradeCheck"true"));
    }
    while(
KvGotoNextKey(kv));

Thanks, but i think i need help with that buildpath also, sry
KennYSwe is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 01-30-2017 , 10:14   Re: Help with config file!
Reply With Quote #6

PHP Code:
public ShopItems() 

    
decl String:file[PLATFORM_MAX_PATH];
    
BuildPath(Path_SMfilesizeof(file), "data/ShopItems.txt");
    new 
Handle:kv CreateKeyValues("ShopItems");
    
FileToKeyValues(kvfile);
    if (
KvGotoFirstSubKey(kv))
    {
        
decl String:Num[12], String:ItemName[256], String:ItemModel[256], String:itemtradeCheck[8];
        do
        {
            
KvGetSectionName(kvNumsizeof(Num));
            
KvGetString(kv"name"ItemNamesizeof(ItemName));
            
KvGetString(kv"model"ItemModelsizeof(ItemModel));
            
KvGetString(kv"trade"itemtradeChecksizeof(itemtradeCheck));
            
CreateItem(StringToInt(Num), ItemNameItemModelKvGetNum(kv"type"), KvGetNum(kv"price"), StrEqual(itemtradeCheck"true"));
        }
        while(
KvGotoNextKey(kv));
    } 
    
CloseHandle(kv);


Last edited by Kailo; 01-30-2017 at 10:14.
Kailo is offline
KennYSwe
Member
Join Date: Nov 2016
Old 01-30-2017 , 10:47   Re: Help with config file!
Reply With Quote #7

Quote:
Originally Posted by Kailo View Post
PHP Code:
public ShopItems() 

    
decl String:file[PLATFORM_MAX_PATH];
    
BuildPath(Path_SMfilesizeof(file), "data/ShopItems.txt");
    new 
Handle:kv CreateKeyValues("ShopItems");
    
FileToKeyValues(kvfile);
    if (
KvGotoFirstSubKey(kv))
    {
        
decl String:Num[12], String:ItemName[256], String:ItemModel[256], String:itemtradeCheck[8];
        do
        {
            
KvGetSectionName(kvNumsizeof(Num));
            
KvGetString(kv"name"ItemNamesizeof(ItemName));
            
KvGetString(kv"model"ItemModelsizeof(ItemModel));
            
KvGetString(kv"trade"itemtradeChecksizeof(itemtradeCheck));
            
CreateItem(StringToInt(Num), ItemNameItemModelKvGetNum(kv"type"), KvGetNum(kv"price"), StrEqual(itemtradeCheck"true"));
        }
        while(
KvGotoNextKey(kv));
    } 
    
CloseHandle(kv);

Thanks, it works!

But now, the color codes does not work, any idea how i can fix that?
KennYSwe is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 01-30-2017 , 12:14   Re: Help with config file!
Reply With Quote #8

Quote:
Originally Posted by KennYSwe View Post
Thanks, it works!

But now, the color codes does not work, any idea how i can fix that?
Yep, create (and hardcode fill) a hashmap (like "red" = "\x01", ...) and use these color names in config. Then just translate it in plugin.

Check this for the hashmap.
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
KennYSwe
Member
Join Date: Nov 2016
Old 01-30-2017 , 12:32   Re: Help with config file!
Reply With Quote #9

Quote:
Originally Posted by KissLick View Post
Yep, create (and hardcode fill) a hashmap (like "red" = "\x01", ...) and use these color names in config. Then just translate it in plugin.

Check this for the hashmap.
Like this?
PHP Code:
ReplaceString(nameMAXLENGTH_NAME"blue""\x0B"); 
i dont get it, never done this hings before
KennYSwe is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 01-30-2017 , 16:12   Re: Help with config file!
Reply With Quote #10

Show me how you use "[Tag]"
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick 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 19:38.


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