
/***************************************************************************
 * amx_ejl_crazyvote.sma   version 2.1     Date: 3/2/2003
 *  Author: Eric Lidman      ejlmozart@hotmail.com
 *  Alias: Ludwig van        Upgrade: http://lidmanmusic.com/cs/plugins.html  
 *
 *  This is a fun plugin which generates random 'crazy votes' on the server.
 *   It draws from a pool of questions you provide in the crazy_votes.ini 
 *   file then takes players names from the server and randomly uses them
 *   as the multiple choice vote answers. Everyone likes to see thier name
 *   up for a fun vote, like "who's the hottest?". Great fun! It does yes/no
 *   votes, multiple choice votes about the admins, about non-admins, and
 *   also has a pool of questions for everyone in general -- see setup below.
 *   The plugin was inspired by an admin on my server who likes 'fun stuff'
 *   which is what my server is all about, hence the official name of the
 *   plugin "BATGIRLs Crazy Votes" and the original command amx_batgirl.
 *
 *  COMMANDS:
 *
 *   amx_batgirl     --The original command to start a random crazy vote
 *                    
 *  CVARS:
 *  
 *   amx_crazyvotes 1          --enable crazyvotes automatically on a timer
 *   amx_crazyvotes_interval 600.0   --delay in seconds between crazy votes
 *
 *  SETUP:
 *
 *   You will need to generate a file called crazy_votes.ini . Some rules:
 *   PREFIXES FOR VOTES:
 *   *YN = Yes/no vote, no names in answer options
 *   *AV = Multiple choice vote where only admins are included in the answer
 *   *PV = Multiple choice vote where only non-admins are included in answer
 *   *+V = Multiple choice vote where all player names can be used as answer
 *   *-V = Multiple choice vote where some players are excluded from options
 *         for example a vote that says something negative about a person
 *   *EXEMPT_NEG = the wonid of the players you want exempt from "*-V" votes
 *   *OWNER = Name of server owner to be included in some votes, keep short
 *   Variable: to include the *OWNER's name in a vote use this  %s
 *   Note: All Votes must be enclosed in quotation marks. No question marks
 *   at end are necessary though.
 *   EXAMPLE CONTENTS:
 *   *YN "Do you like ths map"
 *   *YN "Do you like pizza"
 *   *AV "The best admin"
 *   *AV "Funniest admin"
 *   *PV "Next admin here"
 *   *PV "Will never be admin here"
 *   *-V "Still wears diapers"
 *   *-V "Most pathetic"
 *   *+V "The ONE"
 *   *OWNER Lud
 *   *EXEMPT_NEG 2260692
 *
 *   See forum post at amxmod site for my own crazy_votes.ini file to use as
 *   an example, or heck, just to use. If you do not create one, the server
 *   will try to prompt you to everytime you attemp to creat a crazy vote. If
 *   you fail to make one, the plugin will use its limited repertoire of 
 *   default crazy votes until you make the file.
 *
 **************************************************************************/

#include <amxmod>
#include <amxmisc>

#define MAX_EXEMPT_NEG 8
#define MAX_YES_NO 32
#define MAX_ADMINONLY 10
#define MAX_PLAYERONLY 10
#define MAX_NAMESVOTE1 32
#define MAX_NAMESVOTE2 32

new OWNER[10]
new EXEMPT_NEG[MAX_EXEMPT_NEG][16]
new YES_NO[MAX_YES_NO][33]
new ADMINONLY[MAX_ADMINONLY][33]
new PLAYERONLY[MAX_PLAYERONLY][33]
new NAMESVOTE1[MAX_NAMESVOTE1][33]
new NAMESVOTE2[MAX_NAMESVOTE2][33]
new iOWNER, iEXEMPT_NEG, iYES_NO, iADMINONLY, iPLAYERONLY, iNAMESVOTE1, iNAMESVOTE2
new noConfig,noyesno
new bool:cstrike_running

new vault_value[128]
new votenumber = 0
new votecontroller[33][2]
new answer[128]
new option_name[4][32]
new option[4]

public plugin_init(){
	register_plugin("BATGIRLs Crazy Votes","0.9","EJL")
	register_concmd("amx_batgirl","crazy_votes_c",ADMIN_LEVEL_A,": Makes a random crazy vote")
	register_cvar("amx_crazyvotes","1")	
	register_cvar("amx_crazyvotes_interval","600.0")
	register_cvar("amx_luds_batgirlcrazyvote","v2.1",FCVAR_SERVER )
	register_menucmd(register_menuid("Hey: ") ,(1<<0)|(1<<1)|(1<<2)|(1<<3),"vote_count")
	register_srvcmd("amx_vote123","admin_vote1")
	register_cvar("amx_vote_time","15")
	register_cvar("amx_vote_answers","1")
	register_cvar("amx_vote_delay","1")
	register_cvar("amx_last_voting","0")
	set_cvar_float("amx_last_voting",0.0)
	register_cvar("amx_vote_inprogress","0")

	new inprogress[32]
	get_cvar_string("amx_vote_inprogress",inprogress,32)
	if(equal(inprogress, "1",1)){
		set_cvar_string("amx_vote_inprogress","0")
	}
	ejl_vault("WRITE","CURRENT_VOTE","NULL")

	if(file_exists("addons/amx/crazy_votes_warning.txt") == 1)
		delete_file("addons/amx/crazy_votes_warning.txt")
	if(file_exists("addons/amx/crazy_votes.ini") == 1){
		new line = 0
		new data[192]
		new stextsize = 0
		new type[4]
		new question[33]
		while((line=read_file("addons/amx/crazy_votes.ini",line,data,191,stextsize))!=0){
			parse(data,type,4,question,32)
			if(equali(type,"*OWNER",2)){
				if(!iOWNER)
					copy(OWNER,9,question)
				iOWNER = 1	
			}
			else if(equali(type,"*EXEMPT_NEG",2)){
				if(iEXEMPT_NEG < MAX_EXEMPT_NEG){
					copy(EXEMPT_NEG[iEXEMPT_NEG],15,question)
					iEXEMPT_NEG +=1
				}
			}
			else if(equali(type,"*YN",2)){
				if(iYES_NO < MAX_YES_NO){
					copy(YES_NO[iYES_NO],32,question)
					iYES_NO += 1
				}
			}
			else if(equali(type,"*AV",2)){
				if(iADMINONLY < MAX_ADMINONLY){
					copy(ADMINONLY[iADMINONLY],32,question)
					iADMINONLY += 1
				}
			}
			else if(equali(type,"*PV",2)){
				if(iPLAYERONLY < MAX_PLAYERONLY){
					copy(PLAYERONLY[iPLAYERONLY],32,question)
					iPLAYERONLY += 1
				}
			}
			else if(equali(type,"*-V",2)){
				if(iNAMESVOTE1 < MAX_NAMESVOTE1){
					copy(NAMESVOTE1[iNAMESVOTE1],32,question)
					iNAMESVOTE1 += 1
				}
			}
			else if(equali(type,"*+V",2)){
				if(iNAMESVOTE2 < MAX_NAMESVOTE2){
					copy(NAMESVOTE2[iNAMESVOTE2],32,question)
					iNAMESVOTE2 += 1
				}
			}
		}
	}else{
		write_file("addons/amx/crazy_votes_warning.txt","IF YOU SEE THIS THEN YOU PROBABLY DIDNT READ THE INSTRUCTIONS",-1)
		write_file("addons/amx/crazy_votes_warning.txt","GO TO AMXMOD WEBSITE AND LOOK AT THE FORUM THREAD FOR THIS PLUGIN",-1)
		write_file("addons/amx/crazy_votes_warning.txt","A DEFAULT VOTES HAVE BEEN ADDED FOR YOU BUT YOU SHOULD",-1)
		write_file("addons/amx/crazy_votes_warning.txt","create:   crazy_votes.ini as proscribed in the forum",-1)
		noConfig = 1 
		copy(YES_NO[0],32, "Do you like crazy votes")
		copy(YES_NO[1],32, "Do you like pizza")
		copy(YES_NO[2],32, "Klondike Bar anyone")
		copy(YES_NO[3],32, "Do you like this map")
		iYES_NO = 4
		copy(ADMINONLY[0],32, "Admin most likely to get fired")
		copy(ADMINONLY[1],32, "Most abusive admin")
		copy(ADMINONLY[2],32, "The best admin")
		copy(ADMINONLY[3],32, "Funniest admin")
		iADMINONLY = 4
		copy(PLAYERONLY[0],32, "Should become admin here")
		copy(PLAYERONLY[1],32, "Would be a bad admin")
		copy(PLAYERONLY[2],32, "Next admin here")
		copy(PLAYERONLY[3],32, "Will never be admin here")
		iPLAYERONLY = 4
		copy(NAMESVOTE1[0],32, "Worst player in all of CS")
		copy(NAMESVOTE1[1],32, "Whines the most")
		copy(NAMESVOTE1[2],32, "Stupidest")
		copy(NAMESVOTE1[3],32, "Cant get a kill")
		copy(NAMESVOTE1[4],32, "Smells the worst")
		copy(NAMESVOTE1[5],32, "Cries whenever he gets fragged")
		copy(NAMESVOTE1[6],32, "Still wears diapers")
		copy(NAMESVOTE1[7],32, "Most pathetic")
		copy(NAMESVOTE1[8],32, "Cant get a date")
		copy(NAMESVOTE1[9],32, "Biggest H4x0r")
		iNAMESVOTE1 = 10
		copy(NAMESVOTE2[0],32, "Everyone loves")
		copy(NAMESVOTE2[1],32, "The Pwnz0r")
		copy(NAMESVOTE2[2],32, "Best looking")
		copy(NAMESVOTE2[3],32, "Best CS player ever")
		copy(NAMESVOTE2[4],32, "Should be president")
		copy(NAMESVOTE2[5],32, "Hottest")
		copy(NAMESVOTE2[6],32, "The ONE")
		iNAMESVOTE2 = 7
	}

	if(iYES_NO < 1){
		write_file("addons/amx/crazy_votes_warning.txt","You did not provide enough yes/no votes in crazy_votes.ini",-1)
		write_file("addons/amx/crazy_votes_warning.txt","Some default yes/no votes have been added for you",-1)
		noyesno = 1
		copy(YES_NO[0],32, "Do you like crazy votes")
		copy(YES_NO[1],32, "Do you like pizza")
		copy(YES_NO[2],32, "Klondike Bar anyone")
		copy(YES_NO[3],32, "Do you like this map")
		iYES_NO = 4
	}

	set_task(10.2,"delay_cvstart")

	new mod_name[32]
	get_modname(mod_name,31)
	cstrike_running = equal(mod_name,"cstrike") ? true : false

	return PLUGIN_CONTINUE
}

public delay_cvstart(){
	if(get_cvar_num("amx_crazyvotes"))		
		set_task(get_cvar_float("amx_crazyvotes_interval"),"crazy_votes",4331,"",0,"a", 10)	
	return PLUGIN_HANDLED
}

public crazy_votes_c(id,level,cid){
	if (!cmd_access(id,level,cid,1))
		return PLUGIN_HANDLED
	if(noyesno)
		console_print(id,"[AMX] Hey, you didnt make enough yes no votes. Using defaults now.") 		
	else if(noConfig)
		console_print(id,"[AMX] Hey, you didnt make a addons/amx/crazy_votes.ini yet! Using defaults.") 

	crazy_votes(id)

	return PLUGIN_HANDLED
}

public crazy_votes(id){

	if(get_playersnum() < 1)
		return PLUGIN_HANDLED

	new Question[192]
	new I
	new MaxResponses
	new iMaxPlayers = get_maxplayers()
	new Name[32]
	new Authid[40]
	new i
	new plcount
	new admcount
	new whograb
	new votetype
	new pquest
	new pquest_01
	new neg
	new VoteResponses[4][32]
	new Dummy[32]

	new VRpl[4][32]
	new bool:admvote =false
	new bool:YNVote = false

	YNVote = false

	votetype = random_num(0,19)
	if(votetype > 16){
		pquest = random_num(0,iYES_NO-1)
		format(Question,32,YES_NO[pquest],OWNER)
		copy(VoteResponses[0],32, "Yes")
		copy(VoteResponses[1],32, "No")
		MaxResponses = 2
		YNVote = true		
	}

	if((get_playersnum() > 1) && (YNVote == false)){
		admcount = 0
		plcount = 0
		for (i = 1; i <= iMaxPlayers; i++) {
			if(is_user_connected(i) == 1){
				get_user_name(i,Name,32)
				if (get_user_flags(i)&ADMIN_MAP){
					if(admcount < 4){
						copy(VoteResponses[admcount],32, Name)
						admcount +=1
					} 
				}else{
					whograb = random_num(0,9)
					if(get_playersnum() < 5){
						if(plcount < 4) {
							copy(VRpl[plcount],32, Name)
							plcount +=1
						}					
					}else{
						if((whograb < 3) && (plcount < 4)) {
							copy(VRpl[plcount],32, Name)
							plcount +=1
						}					
					}
				} 					
			}
		}
		admvote = false
		if(admcount > 1) {
			pquest_01=random_num(0,8)
			if(pquest_01 > 7){
				admvote = true
				pquest = random_num(0,iADMINONLY-1)
				format(Question,32,ADMINONLY[pquest],OWNER)
				MaxResponses = admcount
			}else{
				for (I = 0;I < 4;I++){
					copy(VoteResponses[I],32,Dummy)
				}
			}

		}
		if((plcount > 1) && (admvote == false)) {
			pquest_01=random_num(0,6)
			if(pquest_01 > 5){
				admvote = true
				pquest = random_num(0,iPLAYERONLY-1)
				format(Question,32,PLAYERONLY[pquest],OWNER)
				for (I = 0;I < 4;I++){
					copy(VoteResponses[I],32, VRpl[I])
				}
				MaxResponses = plcount				
			}
		}						
		if(admvote == false){
			pquest_01=random_num(0,1)
			if(pquest_01 == 0){
				neg=1
				pquest = random_num(0,iNAMESVOTE1-1)
				format(Question,32,NAMESVOTE1[pquest],OWNER)
			}else{
				neg=0
				pquest = random_num(0,iNAMESVOTE2-1)
				format(Question,32,NAMESVOTE2[pquest],OWNER)
			}
			plcount = 0
			for (i = 1; i <= iMaxPlayers; i++) {
				if(is_user_connected(i) == 1){
					get_user_name(i,Name,32)
					get_user_authid(i,Authid,32)
					whograb = random_num(0,9)
					if(get_playersnum() < 5){
						if(plcount < 4) {
							copy(VoteResponses[plcount],32, Name)
							plcount +=1
							if(neg == 1){
								for (new a = 0; a <= iEXEMPT_NEG; a++) {
									 if(equal(Authid,EXEMPT_NEG[a])){
										plcount -=1
									}
								}
							}
						}					
					}else{
						if((whograb > 5) && (plcount < 4)) {
							copy(VoteResponses[plcount],32, Name)
							plcount +=1
							if(neg == 1){
								for (new a = 0; a <= iEXEMPT_NEG; a++) {
									 if(equal(Authid,EXEMPT_NEG[a])){
										plcount -=1
									}
								}
							}
						}					
					}
				}			
			}
			MaxResponses = plcount
		}
	}
	if((MaxResponses > 1) && (YNVote == false)){
		new above = random_num(0,2)
		if(above == 1){
			if(MaxResponses == 2){
				copy(VoteResponses[MaxResponses],32, "None of the above")
				MaxResponses = 3
			}
			else if (MaxResponses == 3){
				copy(VoteResponses[MaxResponses],32, "None of the above")
				MaxResponses = 4
			}
			else if (MaxResponses == 4){
				copy(VoteResponses[3],32, "None of the above")
				MaxResponses = 4
			}
		}
		else if(above == 2){
			if(MaxResponses == 2){
				copy(VoteResponses[MaxResponses],32, "All of the above")
				MaxResponses = 3
			}
			else if (MaxResponses == 3){
				copy(VoteResponses[MaxResponses],32, "All of the above")
				MaxResponses = 4
			}
			else if (MaxResponses == 4){
				copy(VoteResponses[3],32, "All of the above")
				MaxResponses = 4
			}
		}
	}		

	new FinalVote[192]
	if (MaxResponses <= 1){
		set_task(0.1,"crazy_votes")
		console_print(id,"[AMX] Sorry, but I failed to make enough responses. Trying again.")
	}
	else if (MaxResponses == 2){
		format(FinalVote,192,"amx_vote123 ^"%s^" ^"%s^" ^"%s^"",Question,VoteResponses[0],VoteResponses[1]) 
		server_cmd(FinalVote)
	}
	else if (MaxResponses == 3){
		format(FinalVote,192,"amx_vote123 ^"%s^" ^"%s^" ^"%s^" ^"%s^"",Question,VoteResponses[0],VoteResponses[1],VoteResponses[2]) 
		server_cmd(FinalVote)
	}
	else if (MaxResponses == 4){
		format(FinalVote,192,"amx_vote123 ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^"",Question,VoteResponses[0],VoteResponses[1],VoteResponses[2],VoteResponses[3]) 
		server_cmd(FinalVote)
	}

	return PLUGIN_HANDLED
}

public check_votes()
{
	set_cvar_string("amx_vote_inprogress","0")
	ejl_vault("WRITE","CURRENT_VOTE","NULL")
	for(new a = 0; a < 33; a++){
		votecontroller[a][1] = 0
	}

	new best = 0
	new best_count = 0
	for(new a = 0; a < 4; ++a) {
		if (option[a] > best_count){
			best_count = option[a]
			best = a
		}
	}
	if(!best_count){
		client_print(0,print_chat,"[AMX] Crazy Vote: Failed, no votes")	
		log_to_file("addons/amx/admin.log","[CRAZY_VOTE] ^"%s^": FAILURE: NO VOTES",answer)
		return PLUGIN_HANDLED			
	}
	client_print(0,print_chat,"[AMX] Crazy Vote: %s  >>>  %s",answer,option_name[best])		
	set_hudmessage(200,100,100, -1.0, 0.70, 2, 0.02, 10.0, 0.01, 0.1, 4)
	if(strlen(option_name[3])>0){
		show_hudmessage(0,"Voting Results: %s^n^n%d for %s^n%d for %s^n%d for %s^n%d for %s^n^n%s -- WINS!!!",answer,option[0],option_name[0],
		option[1],option_name[1],option[2],option_name[2],option[3],option_name[3],option_name[best])
	}
	else if(strlen(option_name[2])>0){
		show_hudmessage(0,"Voting Results: %s^n^n%d for %s^n%d for %s^n%d for %s^n^n%s -- WINS!!!",answer,option[0],option_name[0],
		option[1],option_name[1],option[2],option_name[2],option_name[best])
	}else{
		show_hudmessage(0,"Voting Results: %s^n^n%d for %s^n%d for %s^n^n%s -- WINS!!!",answer,option[0],option_name[0],
		option[1],option_name[1],option_name[best])
	}
	log_to_file("addons/amx/admin.log","[CRAZY_VOTE] ^"%s^": WINNER: ^"%s^"",answer,option_name[best])
	return PLUGIN_HANDLED
}

public vote_count(id,key)
{
	ejl_vault("READ","CURRENT_VOTE","")
	if(equal(vault_value,"CRAZYVOTE")){
	new name[32]
	get_user_name(id,name,32)
	if(votenumber != votecontroller[id][0]){
		votecontroller[id][0] = votenumber
		if (get_cvar_float("amx_vote_answers")) {
			client_print(0,print_chat,"[AMX] %s voted for option # %d",name,key+1)
		}
		option[key] += 1
	}else{
		votecontroller[id][1] +=1
	}
	}else{
		return PLUGIN_CONTINUE
	}
	return PLUGIN_HANDLED
}

// I know this cheap, I just stole vote code from adminvote plugin to save time
public admin_vote1(id){ 
	new Float:voting = get_cvar_float("amx_last_voting")
	if (voting > get_gametime()){ 
		console_print(id,"There is already one voting...") 
		return PLUGIN_HANDLED 
	} 
	if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) { 
		console_print(id,"Voting not allowed at this time") 
		return PLUGIN_HANDLED 
	}

	new argc = read_argc()
	if (argc > 6) 
		argc = 6
	if (argc < 2){ 
		client_print(id,print_console,"[AMX] Usage: amx_vote < question in quotation marks> < answer1 > < anwser2 > < answer3 > < anwser4 >")
		return PLUGIN_HANDLED
	}
	
	new inprogress[32]
	get_cvar_string("amx_vote_inprogress",inprogress,32)
	if(equal(inprogress, "0",1)){

	new quest[128]
	read_argv(1,quest,128)
	read_argv(2,option_name[0],32)	
	read_argv(3,option_name[1],32)
	read_argv(4,option_name[2],32)
	read_argv(5,option_name[3],32)

	new authid[16],name[32]
	get_user_authid(id,authid,16)
	get_user_name(id,name,32)
	log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^" vote crazy (question ^"%s^") (option1 ^"%s^") (option2 ^"%s^")",
		name,get_user_userid(id),authid,quest,option_name[0],option_name[1],option_name[2],option_name[3])

	new menu_msg[256]
	new keys
	if(argc == 2){
		keys = (1<<0)|(1<<1)
		copy(option_name[0],32,"Yes")
		copy(option_name[1],32,"No")
		if (cstrike_running)	
			format(menu_msg,256,"\yHey: %s?\w^n^n1.  %s^n2.  %s",quest,option_name[0],option_name[1])
		else
			format(menu_msg,256,"Hey: %s?^n^n1.  %s^n2.  %s",quest,option_name[0],option_name[1])
	}
	if(argc == 3){
		keys = (1<<0)|(1<<1)
		copy(option_name[1],32,"No")
		if (cstrike_running)	
			format(menu_msg,256,"\yHey: %s?\w^n^n1.  %s^n2.  %s",quest,option_name[0],option_name[1])
		else
			format(menu_msg,256,"Hey: %s?^n^n1.  %s^n2.  %s",quest,option_name[0],option_name[1])
	}
	if(argc == 4){
		keys = (1<<0)|(1<<1)
		if (cstrike_running)	
			format(menu_msg,256,"\yHey: %s?\w^n^n1.  %s^n2.  %s",quest,option_name[0],option_name[1])
		else
			format(menu_msg,256,"Hey: %s?^n^n1.  %s^n2.  %s",quest,option_name[0],option_name[1])
	}
	else if(argc == 5){
		keys = (1<<0)|(1<<1)|(1<<2)
		if (cstrike_running)	
			format(menu_msg,256,"\yHey: %s?\w^n^n1.  %s^n2.  %s^n3.  %s",quest,option_name[0],option_name[1],option_name[2])
		else
			format(menu_msg,256,"Hey: %s?^n^n1.  %s^n2.  %s^n3.  %s",quest,option_name[0],option_name[1],option_name[2])
	}
	else if(argc == 6){
		keys = (1<<0)|(1<<1)|(1<<2)|(1<<3)
		if (cstrike_running)	
			format(menu_msg,256,"\yHey: %s?\w^n^n1.  %s^n2.  %s^n3.  %s^n4.  %s",quest,option_name[0],option_name[1],option_name[2],option_name[3])
		else
			format(menu_msg,256,"Hey: %s?^n^n1.  %s^n2.  %s^n3.  %s^n4.  %s",quest,option_name[0],option_name[1],option_name[2],option_name[3])	
	}
	new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0 
	set_cvar_float("amx_last_voting",  get_gametime() + vote_time )
	format(answer,128,"%s %s",quest)
	for(new a = 0; a < 33; a++){
		votecontroller[a][1] = 0
	}
	votenumber++
	set_cvar_string("amx_vote_inprogress","1")
	ejl_vault("WRITE","CURRENT_VOTE","CRAZYVOTE")

	new Team[33]
	new maxpl = get_maxplayers()+1
	for(new k = 1; k < maxpl; k++){
		get_user_team(k,Team,33)
		if(!((equali(Team,"UNAS",4)) || (equali(Team,"SPEC",4)) || (get_user_time(k)== 0) )){
			show_menu(k,keys,menu_msg,floatround(vote_time))
		}
	}

	set_task(vote_time,"check_votes")
	client_print(id,print_console,"[AMX] Voting has started...")
	for(new j = 0; j < 4;++j) option[j] = 0
	}else{
	console_print(id,"[AMX] Voting not allowed yet.")	
	}
	return PLUGIN_HANDLED
}

public ejl_vault(rw[],key[],value[]){
	new data[192]
	new stxtsize = 0
	new line = 0 
	new skip = 0
	new vkey[64]
	new vvalue[128]
	new vaultwrite[192]
	if(equal(rw,"READ")){
		if(file_exists("addons/amx/ejl_vault.ini") == 1){
			copy(vault_value,128,"")
			while((line=read_file("addons/amx/ejl_vault.ini",line,data,192,stxtsize))!=0){
				parse(data,vkey,64,vvalue,128)
				if(equal(vkey,key)){
					copy(vault_value,128,vvalue)
				}
			}
		}else{
			write_file("addons/amx/ejl_vault.ini", "**** Plugins use to store values -- immune to crashes and map changes ****", 0)
		}
	}
	else if(equal(rw,"WRITE")){
		if(file_exists("addons/amx/ejl_vault.ini") == 1){		
			format(vaultwrite,192,"%s %s",key,value)
			while((line=read_file("addons/amx/ejl_vault.ini",line,data,192,stxtsize))!=0){
				parse(data,vkey,64,vvalue,128)
				if(skip == 0){
					if( (equal(data,"")) || (equal(vkey,key)) ){
						skip = 1
						write_file("addons/amx/ejl_vault.ini",vaultwrite,line-1)
					}
				}
				else if(equal(vkey,key)){
					write_file("addons/amx/ejl_vault.ini","",line-1)
				}
			}
			if(skip == 0){
				write_file("addons/amx/ejl_vault.ini",vaultwrite,-1)
			}
		}
	}
	return PLUGIN_CONTINUE
}


