#include #define FILTERSCRIPT #define File_To_Read "gmcycle.txt" new counter = 1; // Because we are running on gamemode0 at init. new gmcount = 0; forward GameModeExitEx(); forward GMCycleExists(); public OnFilterScriptInit() { print(" Unlimited Gamemode Cycle by Ramjet loaded."); return 1; } public OnFilterScriptExit() { print(" Unlimited Gamemode Cycle by Ramjet unloaded."); return 1; } // Our public function called remotely. public GameModeExitEx() { // Declare and initialise variables. gmcount = GetGamemodeCount(); new string[256]; new File:filename = fopen(File_To_Read, io_readwrite); // Start the fille processing. if(filename) { new i; while(fread(filename, string, 256)) { // The mode we want to change to. if(i == counter) { new temp[256]; StripNewLine(string); format(temp, sizeof(temp), "changemode %s", string); SendRconCommand(temp); counter++; break; } // We want to go back to gamemode0, so we will reset counter and reset the function. if(i == gmcount - 1) { counter = 0; fclose(filename); GameModeExitEx(); } i++; } fclose(filename); } return 1; } /** * Strips Newline from the end of a string. * Idea: Y_Less, Bugfixing (when length=1) by DracoBlue * @param string */ stock StripNewLine(string[]) { new len = strlen(string); if (string[0]==0) return ; if ((string[len - 1] == '\n') || (string[len - 1] == '\r')) { string[len - 1] = 0; if (string[0]==0) return ; if ((string[len - 2] == '\n') || (string[len - 2] == '\r')) string[len - 2] = 0; } } GetGamemodeCount() { new File:filename = fopen("gmcycle.txt", io_readwrite), temp[256], i; if(filename) { while(fread(filename, temp, 256)) i++; fclose(filename); } return i; }