// plugin_textcheats.sma
// Thanks to Wipeout
// Author: Wonderbread
// 1/17/02
// ICQ: 17595125
//
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
#define GODMODE_TIME 120
#define NOCLIP_TIME 120
new bCheating = 0;
new STRING_VERSION[MAX_DATA_LENGTH] = "2.50.0";
 
 
public plugin_init() 
{
	plugin_registerinfo("Cheat plugin!", "Gives ya cheats!", STRING_VERSION);
 
	plugin_registercmd("say", "HandleSay", ACCESS_ALL);
 
	return PLUGIN_CONTINUE;
}
 
 
public HandleSay(HLCommand, HLData, HLUserName, UserIndex) 
{
	new Command[MAX_COMMAND_LENGTH];
	new Speech[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
	new Text[MAX_TEXT_LENGTH];
 
	convert_string(HLCommand, Command, MAX_COMMAND_LENGTH);
	convert_string(HLData, Speech, MAX_DATA_LENGTH);
	convert_string(HLUserName, User, MAX_NAME_LENGTH);
	strstripquotes(Speech);
 
 
	if ( bCheating==1 && ((strcasestr(Speech, "upupdowndownleftrightleftrightbastart") != -1) || (strcasestr(Speech, "updownupdownleftrightleftrightabstart") != -1))  ){
		snprintf(Text, MAX_TEXT_LENGTH,  "Whoah there, %s !..... Not too many cheats in a day!", User);
		say(Text);
		return PLUGIN_CONTINUE;
	} else if ( (strcasestr(Speech, "upupdowndownleftrightleftrightbastart") != -1) ) {
		snprintf(Text, MAX_TEXT_LENGTH, "Oooh! %s did the godmode cheat!", User);
     		say(Text);
		godmode(User, 1);
		set_timer("Godmode_Timer", 1, GODMODE_TIME);
	} else if ( (strcasestr(Speech, "updownupdownleftrightleftrightabstart") != -1) ) {
		snprintf(Text, MAX_TEXT_LENGTH, "Oooh! %s did the noclip cheat!", User);
     		say(Text);
		noclip(User, 1);
		set_timer("Noclip_Timer", 1, NOCLIP_TIME);
	}
 
	return PLUGIN_CONTINUE;
}
public Godmode_Timer(Timer, Repeat, HLUserName, HLParam)
{
	new Text[MAX_TEXT_LENGTH];
	new User[MAX_NAME_LENGTH];
 
	new Red = random(256);
	new Green = random(256);
	new Blue = random(256);
 
	convert_string(HLUserName, User, MAX_NAME_LENGTH);
 
	if (Repeat-1 == 0)
	{
		godmode(User, 0);
		snprintf(Text, MAX_TEXT_LENGTH, "%s no longer has the godmode cheat on!", User);
		bCheating=0;
	}
	else
	{
		snprintf(Text, MAX_TEXT_LENGTH, "%s has the godmode cheat on for %d more seconds.", User, Repeat-1);
		bCheating=1;
	}
 
	typesay(Text, 1, Red, Green, Blue);
}
public Noclip_Timer(Timer, Repeat, HLUserName, HLParam)
{
	new Text[MAX_TEXT_LENGTH];
	new User[MAX_NAME_LENGTH];
 
	new Red = random(256);
	new Green = random(256);
	new Blue = random(256);
 
	convert_string(HLUserName, User, MAX_NAME_LENGTH);
 
	if (Repeat-1 == 0)
	{
		noclip(User, 0);
		snprintf(Text, MAX_TEXT_LENGTH, "%s no longer has the noclip cheat on!", User);
		bCheating=0;
	}
	else
	{
		snprintf(Text, MAX_TEXT_LENGTH, "%s has the noclip cheat on for %d more seconds.", User, Repeat-1);
		bCheating=1;
	}
 
	typesay(Text, 1, Red, Green, Blue);
}