PDA

View Full Version : different weapon configs?


nergal
08-20-2012, 02:50
is it possible to make TF2Items run different weapon config files?

like the tf2items_weapons.txt but run different for say a different map utilizing map config plugins?
and then use the original for a different gametype?

SpideyFusion
08-21-2012, 19:10
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:
new Handle:g_hCvarConfigFile;

Added under OnPluginStart() forward:
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():
public OnConfigsExecuted()
{
decl String:configName[PLATFORM_MAX_PATH];
GetConVarString(g_hCvarConfigFile, configName, sizeof(configName));

// Parse the items list
ParseItems(configName);
}

Updated the CmdReload() callback:
decl String:configName[PLATFORM_MAX_PATH];
GetConVarString(g_hCvarConfigFile, configName, sizeof(configName));

// Call the ParseItems function.
ParseItems(configName);

Updated the ParseItems() function to take the config name as an argument:
ParseItems(const String:configName[])

...

// Create key values object and parse file.
BuildPath(Path_SM, strBuffer, sizeof(strBuffer), "configs/%s", configName);