Page 1 of 1

randommap-voter

Posted: Wed Mar 28, 2012 12:52 pm
by F3mm3
Anyone still has this and wants to share?
could use one.. :)

thanks

Re: randommap-voter

Posted: Thu Mar 29, 2012 12:42 pm
by nico
Hello,

See attached zip.

Re: randommap-voter

Posted: Thu Mar 29, 2012 1:25 pm
by F3mm3
nico wrote:Hello,

See attached zip.
cheers nico :>

Re: randommap-voter

Posted: Fri May 11, 2012 1:38 pm
by Zero
New keys, skyence requested, f3 f4 f5

Code: Select all

#include <Windows.h>
#include <vector>
#include <string>
#include <fstream>
#include <cstdlib>
#include <ctime>

static HWND hWndEditWrite = NULL;

void ConsoleCommand(const char *text)
{
    SendMessage(hWndEditWrite, WM_SETTEXT, 0, (LPARAM)text);
    SendMessage(hWndEditWrite, WM_CHAR, 13, 0);
}

int main() {
    std::string                 mapName;
    std::ifstream               file("maplist.txt");
    std::vector<std::string>    mapList;

    srand(time(NULL));
    hWndEditWrite = FindWindowEx(FindWindow(0, "ET Console"), NULL, "Edit", 0);

    if(!file) { // couldn't open a file
        return 1;
    }

    while( file.peek() != EOF ) {
        // Get a line from file and save it to mapName
        std::getline( file, mapName );
        // Push it to the mapList vector
        mapList.push_back( mapName );
    }

    ConsoleCommand("say ^7Random map voter v0.1 by ^f_^7zero^k >:3");
    while( true ) {
		Sleep(100);
        if( GetAsyncKeyState(VK_F3) ) {
            std::string     command;
            command += "callvote map ";
            command += mapList.at(rand() % mapList.size());
            ConsoleCommand(command.c_str());
            Sleep(500);
        } else if( GetAsyncKeyState(VK_F4) ) {
            std::string     command;
            command += "say \"One random map: ";
            command += mapList.at(rand() % mapList.size());
            command += "\"";
            ConsoleCommand(command.c_str());
            Sleep(500);
        } else if( GetAsyncKeyState(VK_F5) ) {
            std::string     command;
            command += "say \"Three random maps: ";
            command += mapList.at(rand() % mapList.size());
            command += ", ";
            command += mapList.at(rand() % mapList.size());
            command += ", ";
            command += mapList.at(rand() % mapList.size());
            command += "\"";
            ConsoleCommand(command.c_str());
        }
	}
    return 0;
}