Raised This Month: $ Target: $400
 0% 

different weapon configs?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
SpideyFusion
SourceMod Donor
Join Date: Oct 2010
Old 08-21-2012 , 19:10   Re: different weapon configs?
Reply With Quote #2

Sure. I modified the tf2items_manager plugin to include a ConVar (tf2items_manager_config) which allows you to switch the config file from which the plugin will read custom items.

Plugin changes:
  • Added under variable declaration section:
    PHP Code:
    new Handle:g_hCvarConfigFile
  • Added under OnPluginStart() forward:
    PHP Code:
    g_hCvarConfigFile CreateConVar("tf2items_manager_config""tf2items.weapons.txt""Specifies the name of the config from which the plugin will read custom items."); 
  • Moved item parsing from OnPluginStart() to OnConfigsExecuted():
    PHP Code:
    public OnConfigsExecuted()
    {
        
    decl String:configName[PLATFORM_MAX_PATH];
        
    GetConVarString(g_hCvarConfigFileconfigNamesizeof(configName));
        
        
    // Parse the items list
        
    ParseItems(configName);

  • Updated the CmdReload() callback:
    PHP Code:
    decl String:configName[PLATFORM_MAX_PATH];
    GetConVarString(g_hCvarConfigFileconfigNamesizeof(configName));
        
    // Call the ParseItems function.
    ParseItems(configName); 
  • Updated the ParseItems() function to take the config name as an argument:
    PHP Code:
    ParseItems(const String:configName[])

    ...

    // Create key values object and parse file.
    BuildPath(Path_SMstrBuffersizeof(strBuffer), "configs/%s"configName); 
Attached Files
File Type: sp Get Plugin or Get Source (tf2items_manager.sp - 122 views - 15.8 KB)
File Type: smx tf2items_manager.smx (7.6 KB, 131 views)

Last edited by SpideyFusion; 08-21-2012 at 19:10.
SpideyFusion is offline
 


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 20:55.


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