public void UpdatePluginData(params String[] parms)
{
/*
parms[0]: Name of caller (plugin class)
parms[1]: Name of the type of parm[3]: "bool", "double", "int", "string" (not possible to pass object type)
parms[2]: Key or Data Field name
parms[3]: Stringification of value
*/
if (parms.Length != 4)
{
if (DebugLevel >= 5) ConsoleWarn("UpdatePluginData called with incorrect parameter count: " + parms.Length);
return;
}
if (String.IsNullOrEmpty(parms[0])) {
if (DebugLevel >= 5) ConsoleWarn("UpdatePluginData parms[0]: caller name is invalid!");
return;
}
if (String.IsNullOrEmpty(parms[1])) {
if (DebugLevel >= 5) ConsoleWarn("UpdatePluginData parms[1]: type is invalid!");
return;
}
if (String.IsNullOrEmpty(parms[2])) {
if (DebugLevel >= 5) ConsoleWarn("UpdatePluginData parms[2]: key is invalid!");
return;
}
try
{
String calledFrom = parms[0];
Type type = typeof(String);
switch (parms[1])
{
case "bool": type = typeof(bool); break;
case "double": type = typeof(double); break;
case "int": type = typeof(int); break;
default: break;
}
String key = parms[2];
Object value = parms[3];
if (type == typeof(bool))
{
bool v = false;
Boolean.TryParse(parms[3], out v);
value = (Boolean)v;
}
else if (type == typeof(double))
{
double v = 0;
Double.TryParse(parms[3], out v);
value = (Double)v;
}
else if (type == typeof(int))
{
int v = 0;
Int32.TryParse(parms[3], out v);
value = (Int32)v;
}
switch (key) {
case "SetScrambleByCommand":
if (type != typeof(bool)) {
if (DebugLevel >= 5) ConsoleWarn("UpdatePluginData(" + calledFrom + ", " + key + ") expected bool, got " + parms[1]);
return;
} else {
fScrambleByCommand = (bool)value;
if (fScrambleByCommand) {
DebugWrite("Plugin " + calledFrom + " turned team scrambling ON for this round!", 4);
} else {
DebugWrite("Plugin " + calledFrom + " turned team scrambling OFF for this round!", 4);
}
}
break;
case "DisableUnswitcher":
if (type != typeof(bool)) {
if (DebugLevel >= 5) ConsoleWarn("UpdatePluginData(" + calledFrom + ", " + key + ") expected bool, got " + parms[1]);
return;
} else {
fDisableUnswitcherByRemote = (bool)value;
if (fDisableUnswitcherByRemote) {
DebugWrite("Plugin " + calledFrom + " turned unswitching OFF for this round!", 4);
} else {
DebugWrite("Plugin " + calledFrom + " turned unswitching ON for this round!", 4);
}
}
break;
default:
if (DebugLevel >= 5) ConsoleWarn("UpdatePluginData unknown key " + key + ", called from " + calledFrom);
return;
}
DebugWrite("Plugin ^b" + calledFrom + "^n, updated (" + parms[1] + ") " + key + " <- " + parms[3], 5);
} catch (Exception e) {
if (DebugLevel >= 5) ConsoleException(e);
}
}