diff --git a/config_reader_WIP.sp b/config_reader_WIP.sp index 11b014d8..86c0e591 100644 --- a/config_reader_WIP.sp +++ b/config_reader_WIP.sp @@ -80,205 +80,74 @@ public void ReadConfig() robot.health = health; robot.scale = scale; - AddRobot(robot, MakeGDeflectorH, PLUGIN_VERSION); - } - else + // Only continue if there are sounds to be added + if (g_hConfig.JumpToKey("sounds", false)) { - PrintToChatAll("Unable to retrieve 'name' from 'Robot'"); - } - + char sound[256]; // Adjust the size based on your expected maximum sound file path. -} - -public void DumpKeys(KeyValues kv, int depth) -{ - char buffer[256]; - char key[64], value[64]; - depth = 0; - - while (true) - { - kv.GetSectionName(key, sizeof(key)); - kv.GetString(NULL_STRING, value, sizeof(value)); - - for (int i = 0; i < depth; i++) // Add some indentation for depth + if (g_hConfig.GetString("spawn", sound, sizeof(sound))) { - buffer[i] = ' '; + PrintToChatAll("Spawn Sound: %s", sound); + robot.sounds.spawn = sound; } - Format(buffer[depth], sizeof(buffer) - depth, "%s : %s", key, value); - PrintToChatAll("%s", buffer); - if (kv.GotoFirstSubKey()) + if (g_hConfig.GetString("death", sound, sizeof(sound))) { - DumpKeys(kv, depth + 2); - kv.GoBack(); + PrintToChatAll("Death Sound: %s", sound); + robot.sounds.death = sound; } - - if (!kv.GotoNextKey()) - break; - } -} -// public void ReadConfig() -// { - -// // if (g_hConfig.JumpToKey("Robot", false)) -// // { -// // char robotName[64]; -// // if(g_hConfig.GetString("name", robotName, sizeof(robotName))) -// // { -// // PrintToChatAll("Robot Name: %s", robotName); -// // } -// // else -// // { -// // PrintToChatAll("Unable to retrieve 'name' from 'Robot'"); -// // } - -// // g_hConfig.GoBack(); -// // } -// // else -// // { -// // PrintToChatAll("'Robot' Key does not exist."); -// // } - -// // if (g_hConfig.JumpToKey("Robot", false)) -// // { -// // char robotName[64]; -// // g_hConfig.GetString("name", robotName, sizeof(robotName)); - -// // PrintToChatAll("Robot Name: %s", robotName); - -// // // ApplyChanges(client, entity, g_hConfig, sClass); // Uncomment if needed -// // g_hConfig.GoBack(); -// // } -// // if (g_hConfig.JumpToKey("Robot", false)) -// // { -// // char robotName[64]; -// // g_hConfig.GetString("name", robotName, sizeof(robotName)); - -// // PrintToChatAll("Robot Name: %s", robotName); - -// // // ApplyChanges(client, entity, g_hConfig, sClass); // Uncomment if needed -// // g_hConfig.GoBack(); -// // } -// } - -// public void ProcessCfgFile(const char[] fileName) -// { -// char fullPath[256]; -// char line[1024]; -// Format(fullPath, sizeof(fullPath), "%s/%s", PATH, fileName); - -// Handle file = OpenFile(fullPath, "r"); -// if(!file) -// { -// LogError("Failed to open file: %s", fullPath); -// return; -// } - -// ArrayList linesList = new ArrayList(); - -// while(ReadFileLine(file, line, sizeof(line))) -// { -// // For now, we just print the lines, but you can process them however you need. -// // LogMessage("File: %s, Line: %s", fileName, line); -// linesList.PushString(line); - -// } -// CloseHandle(file); -// // ParseRobotConfig(linesList); - -// delete linesList; -// } - -// public void ParseRobotConfig(ArrayList linesList) -// { -// RobotDefinition robot -// bool isFirstLine = true; -// for (int i = 0; i < linesList.Length; i++) -// { -// char line[2048]; -// linesList.GetString(i, line, sizeof(line)); + if (g_hConfig.GetString("loop", sound, sizeof(sound))) + { + PrintToChatAll("Loop Sound: %s", sound); + robot.sounds.loop = sound; + } -// char key[64]; -// char value[256]; -// ExtractKeyAndValue(line, key, sizeof(key), value, sizeof(value)); -// // PrintToChatAll("Key is %s value is %s",key, value); -// if(isFirstLine) -// { -// strcopy(robot.name, sizeof(robot.name), key); - -// isFirstLine = false; -// continue; -// } + if (g_hConfig.GetString("gunfire", sound, sizeof(sound))) + { + PrintToChatAll("Gunfire Sound: %s", sound); + robot.sounds.gunfire = sound; + } -// if (StrEqual(key, "role")) -// strcopy(robot.role, sizeof(robot.role), value); -// else if (StrEqual(key, "class")) -// strcopy(robot.class, sizeof(robot.class), value); -// else if (StrEqual(key, "subclass")) -// strcopy(robot.subclass, sizeof(robot.subclass), value); -// else if (StrEqual(key, "description")) -// strcopy(robot.shortDescription, sizeof(robot.shortDescription), value); -// else if (StrEqual(key, "tips")) -// strcopy(robot.tips, sizeof(robot.tips), value); -// else if (StrEqual(key, "on_death")) -// strcopy(robot.deathtip, sizeof(robot.deathtip), value); -// else if (StrEqual(key, "model")) -// strcopy(robot.model, sizeof(robot.model), value); -// else if (StrEqual(key, "difficulty")) -// robot.difficulty = StringToInt(value); -// else if (StrEqual(key, "health")) -// robot.health = StringToInt(value); -// else if (StrEqual(key, "scale")) -// robot.scale = StringToFloat(value); + if (g_hConfig.GetString("gunspin", sound, sizeof(sound))) + { + PrintToChatAll("Gunspin Sound: %s", sound); + robot.sounds.gunspin = sound; + } + if (g_hConfig.GetString("windup", sound, sizeof(sound))) + { + PrintToChatAll("Windup Sound: %s", sound); + robot.sounds.windup = sound; + } -// AddRobot(robot, MakeGDeflectorH, PLUGIN_VERSION); -// } -// } + if (g_hConfig.GetString("winddown", sound, sizeof(sound))) + { + PrintToChatAll("Winddown Sound: %s", sound); + robot.sounds.winddown = sound; + } -// public void ExtractKeyAndValue(const char[] line, char[] key, int keySize, char[] value, int valueSize) -// { -// int equalsPos = StrContains(line, "\" \""); -// if (equalsPos == -1) -// { -// PrintToChatAll("Invalid line format: %s", line); -// // LogError("Invalid line format: %s", line); -// return; -// } + g_hConfig.GoBack(); // Go back to the parent "Robot" key after processing all sounds. + } + else + { + PrintToChatAll("No sounds key found for the robot."); + } -// int lineLen = strlen(line); -// // Extract the key -// for (int i = 0; i < equalsPos && i < keySize - 1; i++) -// { -// key[i] = line[i]; -// } -// key[equalsPos] = '\0'; -// // Extract the value -// int valueStart = equalsPos + 3; // Skip past " \"" -// int valueEnd = lineLen - 1; // Exclude the trailing " character -// int valueLength = valueEnd - valueStart + 1; + AddRobot(robot, MakeRobot, PLUGIN_VERSION); + } + else + { + PrintToChatAll("Unable to retrieve 'name' from 'Robot'"); + } -// if (valueLength < 0 || valueLength >= valueSize) -// { -// LogError("Value too long or invalid format in line: %s", line); -// return; -// } -// for (int i = 0; i < valueLength; i++) -// { -// value[i] = line[valueStart + i]; -// } -// value[valueLength] = '\0'; +} -// TrimString(key); -// TrimString(value); -// } -MakeGDeflectorH(client) +MakeRobot(client) { PrintToChatAll("Robot stuff goes here"); } \ No newline at end of file