randommap-voter
Posted: Wed Mar 28, 2012 12:52 pm
Anyone still has this and wants to share?
could use one..
thanks
could use one..
thanks
cheers nico :>nico wrote:Hello,
See attached zip.
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;
}