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

Menu Confusion


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
/̵͇̿̿/'̿-̅-̅-̅° PIG
Member
Join Date: Jul 2009
Old 02-03-2011 , 21:36   Menu Confusion
Reply With Quote #1

I am trying to Build a menu that can be read from a file. I want to have 3 to 5 sections and then inside the section have a list of items to change model too. I have tried many ways to BuildMainMenu and have had no luck in displaying the main menu in game. I also don't understand how the keyvalues work, like which to use to get the section name and then in that section to display the item.

Here is the .txt file i have set up to retrieve the info from, is this wrong?
Code:
"Props"
{
    "Office Items"
        {
            
            "Hand Truck"
            {
                "models/props/cs_assault/handtruck.mdl"
            }
        }
    "Inside Items"
        {
            "ventilation duct"
            {    
                "models/props/cs_assault/ventilationduct01.mdl"    
            }
            "flood light"
            {
                "props/cs_assault/floodlight02.mdl"
            }
        }
    "Outside Items"
        {
            "no parking"
            {    
                "models/props/cs_assault/noparking.mdl"    
            }
            "old television"
            {
                "models/props/cs_militia/television_console01.mdl"
            }
        }
}
I would post my BuildMainMenu code but i know it is wrong and is a mess. can anyone help me learn this.

Last edited by /̵͇̿̿/'̿-̅-̅-̅° PIG; 02-03-2011 at 21:47.
/̵͇̿̿/'̿-̅-̅-̅° PIG is offline
meng
Veteran Member
Join Date: Oct 2005
Location: us
Old 02-03-2011 , 22:23   Re: Menu Confusion
Reply With Quote #2

Yes, it's wrong. A KV file would look like this.
PHP Code:
"Props"
{
    
"Outside Items"
    
{
        
"no parking"
        
{    
            
"model"    "models/props/cs_assault/noparking.mdl"    
        
}
        
"old television"
        
{
            
"model"    "models/props/cs_militia/television_console01.mdl"
        
}
    }

Then you could use KvGetSectionName properly. If you are still having trouble, post your code and/or a more specific problem.
__________________
.
[ 1 Dumerils Boa | 1 Cali King ]...
.
I'm a lil' spirituous.
meng is offline
Send a message via Yahoo to meng
/̵͇̿̿/'̿-̅-̅-̅° PIG
Member
Join Date: Jul 2009
Old 02-03-2011 , 22:33   Re: Menu Confusion
Reply With Quote #3

ok thanks i have changed the props file. here is my code. I know it is wrong cause it doesn't work. Can anyone help me get this menu to load. It compiles but doesn't show menu in game.

PHP Code:
#include <sourcemod>

#define PLUGIN_VERSION "1.0"

new Handle:g_PropsMenu;
new 
Handle:kv;

public 
Plugin:myinfo 
{
    
name "Props Menu",
    
author "Mr.Pig",
    
description "Props Menu",
    
version PLUGIN_VERSION,
    
url "http://www.sourcemod.net",
}

public 
OnPluginStart()
{
    
RegConsoleCmd("sm_props"Command_PropsMenu);
}
 
public 
OnMapStart()
{
    
g_PropsMenu BuildMainMenu();
}
 
public 
OnMapEnd()
{
    if (
g_PropsMenu != INVALID_HANDLE)
    {
        
CloseHandle(g_PropsMenu);
        
g_PropsMenu INVALID_HANDLE;
    }
}
 
Handle:BuildMainMenu()
{    
    
    
kv CreateKeyValues("Props");
    new 
String:file[256], String:title[64], String:finalOutput[100];
    
BuildPath(Path_SMfile255"configs/props.ini");
    
FileToKeyValues(kvfile);
    
    if (!
KvGotoFirstSubKey(kv))
    {
        
SetFailState("Can't parse props file");
        return 
INVALID_HANDLE;
    }
    
    
decl String:name[30];
    
decl String:model[100];
    do
    {
        
KvGetSectionName(kvmodelsizeof(model));
        
FormatEx(finalOutputsizeof(finalOutput), model);
        
PrecacheModel(finalOutputtrue);
        
//height
        
decl String:sHeightFix[32];
        
KvGetString(kv"heightfix"sHeightFixsizeof(sHeightFix), "noo");
        if(!
StrEqual(sHeightFix"noo"))
        {
            
Format(finalOutputsizeof(finalOutput), "%s||%s"finalOutputsHeightFix);
        }
    
    } 
    while (
KvGotoNextKey(kv));
    
KvRewind(kv);
    
SetMenuTitle(g_PropsMenu"Choose a Prop");
    return 
g_PropsMenu;
}
  
public 
Action:Command_PropsMenu(clientargs)
{
    if (
g_PropsMenu == INVALID_HANDLE)
    {
        
PrintToConsole(client"The props file file was not found! command_PropsMenu");
        return 
Plugin_Handled;
    }    
 
    
DisplayMenu(g_PropsMenuclientMENU_TIME_FOREVER);
 
    return 
Plugin_Handled;


Last edited by /̵͇̿̿/'̿-̅-̅-̅° PIG; 02-04-2011 at 00:46.
/̵͇̿̿/'̿-̅-̅-̅° PIG is offline
meng
Veteran Member
Join Date: Oct 2005
Location: us
Old 02-04-2011 , 22:28   Re: Menu Confusion
Reply With Quote #4

AddMenuItem
__________________
.
[ 1 Dumerils Boa | 1 Cali King ]...
.
I'm a lil' spirituous.
meng is offline
Send a message via Yahoo to meng
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 14:21.


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