randommap-voter

Post Reply
F3mm3
Posts: 37
Joined: Sun Dec 04, 2011 4:50 pm

randommap-voter

Post by F3mm3 »

Anyone still has this and wants to share?
could use one.. :)

thanks
nico
Site Admin
Posts: 168
Joined: Mon Nov 07, 2011 11:40 pm

Re: randommap-voter

Post by nico »

Hello,

See attached zip.
Attachments
random_map_voter.zip
(18.14 KiB) Downloaded 2865 times
--
>Nico*
Contact: pm me
F3mm3
Posts: 37
Joined: Sun Dec 04, 2011 4:50 pm

Re: randommap-voter

Post by F3mm3 »

nico wrote:Hello,

See attached zip.
cheers nico :>
Zero
Posts: 12
Joined: Sun Jan 15, 2012 4:13 pm

Re: randommap-voter

Post 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;
}
Attachments
RandomMapVoter.rar
(11.5 KiB) Downloaded 2851 times
Post Reply