/* plugin_cavey_vote911.sma version 1.01, By Caveman ICQ# 70710878
                     Please read the readme                          */
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
new STRING_VERSION[MAX_DATA_LENGTH] = "2.50.26";
/*If a user does "Vote 911", do you want to start a vote kick for 911 if he exists?
	0 No
	1 Yes										*/
#define DO_VOTE_KICK 1
/*If a user does a vote for 911, do you want it to anounce that he tried 911 or just that
    he voted?
	0 Give value
	1 Ignore value									*/
#define SILENT_VALUES 1
/*If you do not wish to fully disable the standard function, would you like it to then run with
   centered text as normal (including vote calculating etc...)?
	0 No
	1 Yes									*/
#define AS_NORMAL 0
 
public handlevote(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new UserName[MAX_NAME_LENGTH];
	new TargetIndex[MAX_NAME_LENGTH];
#if DO_VOTE_KICK == 1
	new TargetName[MAX_NAME_LENGTH];
#endif
	new text[MAX_TEXT_LENGTH];
 
	convert_string(HLUserName, UserName, MAX_NAME_LENGTH);
	convert_string(HLData, TargetIndex, MAX_NAME_LENGTH);
	convert_string(HLCommand, Command, MAX_COMMAND_LENGTH);
 
#if SILENT_VALUES == 1	
	snprintf(text, MAX_TEXT_LENGTH, "%s cast a vote.", UserName);
	say(text);
#endif
#if SILENT_VALUES == 0	
	snprintf(text, MAX_TEXT_LENGTH, "%s cast a vote against #%s.", UserName, TargetIndex);
	say(text);
#endif
#if DO_VOTE_KICK == 1
	if (check_user(TargetIndex)==1) {
		get_username(TargetIndex,TargetName,MAX_NAME_LENGTH);
		say_command(UserName,Command,TargetName);
		if(check_immunity(TargetName)==1) {
			snprintf(text, MAX_TEXT_LENGTH, "You can't kick %s, you silly bear.", TargetName);
			say(text);
		} else {
			plugin_exec("admin_vote_kick", TargetName);
		}
	} else {
		snprintf(text, MAX_TEXT_LENGTH, "%s chose an invalid user.", UserName);
		say(text);
	}
#endif
#if AS_NORMAL == 1
	return PLUGIN_CONTINUE;
#endif
#if AS_NORMAL == 0
	return PLUGIN_HANDLED;
#endif
}
 
public plugin_init() {
	plugin_registerinfo("Caveys vote handler","Does exactly what it says on the tin.",STRING_VERSION);
 
	plugin_registercmd("vote","handlevote",ACCESS_ALL,"admin_version");
	return PLUGIN_CONTINUE;
}