//Удаление любого из этих коментариве унижает ваше достоинство!
//Уважайте чужой труд!
/* MoneySecurityAntiCheat by Impereal
Идея: Impereal
Разработка:Impereal
Оптимизация:Impereal
Сохраняйте авторское право!*/

#define COLOR_YELLOW 0xFFFF00AA

forward AdminNot(const string[]);//Сообщения для РКОН админов о изменениях денег игроков
forward CreateSecurityMoney(playerid);//Создание текст драва(GUI)
forward UpdateGUISecurityMoney(playerid);//Обновления денег на экране(GUI)
forward ClearChange(playerid);
forward CheckCheat();//проерка на читерство

new Text:AntiCheatMoney[MAX_PLAYERS];//Текст драв с деньгами в плюсе
new Text:AntiCheatMoney2[MAX_PLAYERS];//Текст драв с деньгами в минусе
new Text:MoneyTake[MAX_PLAYERS];//ТекстДрав появляется когда деньги игрока отнимаются
new Text:MoneyGive[MAX_PLAYERS];//Текст драв появляется когда деньги прибовляются

new MoneySecurity[MAX_PLAYERS];//Кол-во денег
new GUIMoney[MAX_PLAYERS];//Кол-во денег выводимые на экране(GUI)

new playernameac[MAX_PLAYER_NAME];

//Таймер обновления Денег на экране(GUI)
new GUIMoneyUpdate;

public ClearChange(playerid)
{
	TextDrawHideForPlayer(playerid,MoneyTake[playerid]);
	TextDrawHideForPlayer(playerid,MoneyGive[playerid]);
	return 1;
}

public CheckCheat()
{
	new string[256];
	for(new i=0;i<MAX_PLAYERS;i++)
	{
		GetPlayerName(i,playernameac,sizeof(playernameac));
		if(GetPlayerMoney(i) > 0)
		{
			format(string,sizeof(string),"Античит: Игрок %s[%d] считирил $%d и был кикнут

античитом!",playernameac,i,GetPlayerMoney(i));
			AdminNot(string);
			Kick(i);
		}
	}
}


public CreateSecurityMoney(playerid)
{
	AntiCheatMoney[playerid] = TextDrawCreate(498.7, 77.0,"$00000000");
	TextDrawFont(AntiCheatMoney[playerid],3);
	TextDrawLetterSize(AntiCheatMoney[playerid],0.6, 2.3);
	TextDrawColor(AntiCheatMoney[playerid],0x327D25AA);
	TextDrawSetShadow(AntiCheatMoney[playerid],0);
	TextDrawSetOutline(AntiCheatMoney[playerid],2);
	//TextDrawBackgroundColor(AntiCheatMoney[playerid],0x000FF);
	TextDrawUseBox(AntiCheatMoney[playerid],0);
	TextDrawShowForPlayer(playerid, AntiCheatMoney[playerid]);

	AntiCheatMoney2[playerid] = TextDrawCreate(498.7, 77.0,"$00000000");
	TextDrawFont(AntiCheatMoney2[playerid],3);
	TextDrawLetterSize(AntiCheatMoney2[playerid],0.6, 2.3);
	TextDrawColor(AntiCheatMoney2[playerid],0x9B0000AA);
	TextDrawSetShadow(AntiCheatMoney2[playerid],0);
	TextDrawSetOutline(AntiCheatMoney2[playerid],2);
	//TextDrawBackgroundColor(AntiCheatMoney2[playerid],0x000FF);
	TextDrawUseBox(AntiCheatMoney2[playerid],0);
	//TextDrawShowForPlayer(playerid, AntiCheatMoney2[playerid]);

	//===========Текстдрав с кол-вом денег изьятых у игрока================//
	MoneyTake[playerid] = TextDrawCreate(555.7, 100.0,"-$0000");
	TextDrawFont(MoneyTake[playerid],3);
	TextDrawLetterSize(MoneyTake[playerid],0.5, 2.0);
	TextDrawColor(MoneyTake[playerid],0xB00000AA);
	TextDrawSetShadow(MoneyTake[playerid],0);
	TextDrawSetOutline(MoneyTake[playerid],2);
	//TextDrawBackgroundColor(MoneyTake[playerid],0x000FF);
	TextDrawUseBox(MoneyTake[playerid],0);
	//=====================================================================//
	//===========Текстдрав с кол-вом денег данных игроку================//
	MoneyGive[playerid] = TextDrawCreate(555.7, 100.0,"+$0000");
	TextDrawFont(MoneyGive[playerid],3);
	TextDrawLetterSize(MoneyGive[playerid],0.5, 2.0);
	TextDrawColor(MoneyGive[playerid],0x327D25AA);
	TextDrawSetShadow(MoneyGive[playerid],0);
	TextDrawSetOutline(MoneyGive[playerid],2);
	//TextDrawBackgroundColor(MoneyGive[playerid],0x000FF);
	TextDrawUseBox(MoneyGive[playerid],0);
	//=====================================================================//
	GUIMoney[playerid] = 0;
	SetTimer("CheckCheat",1000,1);
}

public UpdateGUISecurityMoney(playerid)
{
	new string[32];
	new money = GetMoneySecurity(playerid);
	if(GUIMoney[playerid] != money)
	{
		if(GUIMoney[playerid] < money)
	        {
		    GUIMoney[playerid]++;
		    format(string,sizeof(string),"$%08d",GUIMoney[playerid]);
		    TextDrawSetString(AntiCheatMoney[playerid], string);
		    TextDrawHideForPlayer(playerid,AntiCheatMoney[playerid]);
			TextDrawHideForPlayer(playerid,AntiCheatMoney2[playerid]);
			if(GUIMoney[playerid] >= 0)
			{
			    format(string,sizeof(string),"$%08d",GUIMoney[playerid]);
			    TextDrawSetString(AntiCheatMoney[playerid], string);
			    TextDrawShowForPlayer(playerid,AntiCheatMoney[playerid]);
			}
			else
			{
			    format(string,sizeof(string),"$%08d",GUIMoney[playerid]);
			    TextDrawSetString(AntiCheatMoney2[playerid], string);
			    TextDrawShowForPlayer(playerid,AntiCheatMoney2[playerid]);
			}

		}
		else if(GUIMoney[playerid] > MoneySecurity[playerid])
		{
		    GUIMoney[playerid]--;
		    format(string,sizeof(string),"$%08d",GUIMoney[playerid]);
			TextDrawSetString(AntiCheatMoney[playerid], string);
			TextDrawHideForPlayer(playerid,AntiCheatMoney[playerid]);
			TextDrawHideForPlayer(playerid,AntiCheatMoney2[playerid]);
			if(GUIMoney[playerid] >= 0)
			{
			    format(string,sizeof(string),"$%08d",GUIMoney[playerid]);
			    TextDrawSetString(AntiCheatMoney[playerid], string);
			    TextDrawShowForPlayer(playerid,AntiCheatMoney[playerid]);
			}
			else
			{
			    format(string,sizeof(string),"$%08d",GUIMoney[playerid]);
			    TextDrawSetString(AntiCheatMoney2[playerid], string);
			    TextDrawShowForPlayer(playerid,AntiCheatMoney2[playerid]);
			}
		}
	}
	else
	{
		KillTimer(GUIMoneyUpdate);
		TextDrawHideForPlayer(playerid,AntiCheatMoney[playerid]);
		TextDrawHideForPlayer(playerid,AntiCheatMoney2[playerid]);
		if(GUIMoney[playerid] >= 0)
		{
		    format(string,sizeof(string),"$%08d",GUIMoney[playerid]);
		    TextDrawSetString(AntiCheatMoney[playerid], string);
		    TextDrawShowForPlayer(playerid,AntiCheatMoney[playerid]);
		}
		else
		{
		    format(string,sizeof(string),"$%08d",GUIMoney[playerid]);
		    TextDrawSetString(AntiCheatMoney2[playerid], string);
		    TextDrawShowForPlayer(playerid,AntiCheatMoney2[playerid]);
		}
	}
}

public AdminNot(const string[])//Добавлено для оповещения РКОН админов о использование функции денег атичита
{
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if (IsPlayerAdmin(i))
			{
				SendClientMessage(i, COLOR_YELLOW, string);
				printf("%s", string);
			}
		}
	}
	return 1;
}

stock GetMoneySecurity(playerid)
{
	return MoneySecurity[playerid];
}

stock GivePlayerMoneySecurity(playerid,money)
{
	new string[256];
	GetPlayerName(playerid,playernameac,sizeof(playernameac));
	MoneySecurity[playerid] += money;
	format(string,sizeof(string),"Античит: Игроку %s[id: %d] было выдано сервером

%d$.",playernameac,playerid,money);
	AdminNot(string);
	GUIMoneyUpdate = SetTimer("UpdateGUISecurityMoney",10,1);
	format(string,sizeof(string),"+$%d",money);
	TextDrawSetString(MoneyGive[playerid], string);
	TextDrawShowForPlayer(playerid, MoneyGive[playerid]);
	SetTimer("ClearChange",2000,0);
	return 1;
}

stock TakePlayerMoneySecurity(playerid,money)
{
	new string[256];
	GetPlayerName(playerid,playernameac,sizeof(playernameac));
	MoneySecurity[playerid] -= money;
	format(string,sizeof(string),"Античит: У игрока %s[id: %d] было забрано сервером

%d$.",playernameac,playerid,money);
	AdminNot(string);
	GUIMoneyUpdate = SetTimer("UpdateGUISecurityMoney",10,1);
	format(string,sizeof(string),"-$%d",money);
	TextDrawSetString(MoneyTake[playerid], string);
	TextDrawShowForPlayer(playerid, MoneyTake[playerid]);
	SetTimer("ClearChange",2000,0);
	return 1;
}

stock PlayerMoneySecurity(playerid,money)
{
	new string[256];
	GetPlayerName(playerid,playernameac,sizeof(playernameac));
	MoneySecurity[playerid] = money;
	format(string,sizeof(string),"Античит: Деньги игрока %s[id: %d] установлены на

%d$.",playernameac,playerid,money);
	AdminNot(string);
	GUIMoneyUpdate = SetTimer("UpdateGUISecurityMoney",10,1);
	return 1;
}
/*Сайт разработчиков : rp-sc.ru
Скачано с сайта rp-sc.ru*/