/*

Идея: Mite (icq: 421641709)
Кодинг: OKStyle (icq: 402747399)

Специально для проекта Samp-Rus от проекта GTA: Source

www.gtasource.ru
www.samp-rus.com
www.acf.2x4.ru
www.gtascript.ucoz.com

*/

#include <a_samp>

new wantkiss[MAX_PLAYERS];
new wantsex[MAX_PLAYERS];

public OnPlayerCommandText(playerid,cmdtext[])
{
	new cmd[30];
	new idx;
	cmd = strtok(cmdtext, idx);
	
if(!strcmp(cmd, "/pocelui", true))
{
	new tmp[30],PlayerName[30],string[256];
	tmp = strtok(cmdtext,idx);
	new otherplayer = strval(tmp);
		if(GetDistanceBetweenPlayers(playerid, otherplayer) < 2)
		{
			if(IsSkinFemale(otherplayer))
			{
				wantkiss[playerid]=1;
				wantkiss[otherplayer]=1;
				GetPlayerName(playerid,PlayerName,sizeof(PlayerName));
				format(string,sizeof(string)," Игрок %s предлагает вам поцеловаться. (/accpoc [id] - принять, /dispoc [id] - отказать)",PlayerName);
				SendClientMessage(otherplayer,0xFFFF00AA,string);
			}
			else
			{
				SendClientMessage(playerid,0xFF0000AA," Ваш оппонент мужского пола!");
			}
		}
		else
		{
			SendClientMessage(playerid,0xFF0000AA," Вы слишком далеко!");
		}
return 1;
}

if(!strcmp(cmd, "/accpoc", true))
{
	new tmp[30];
	tmp = strtok(cmdtext,idx);
	new otherplayer = strval(tmp);
		if(GetDistanceBetweenPlayers(playerid, otherplayer) < 2)
		{
			if(wantkiss[playerid]==1 && wantkiss[otherplayer]==1)
			{
				SendClientMessage(playerid,0x00FF00AA," Вы поцеловались!");
				SendClientMessage(otherplayer,0x00FF00AA," Вы поцеловались!");
				wantkiss[playerid]=0;
				ApplyAnimation(otherplayer,"KISSING","Grlfrd_Kiss_03",4.1,0,1,1,1,1);
				ApplyAnimation(playerid,"KISSING","Grlfrd_Kiss_03",4.1,0,1,1,1,1);
				wantkiss[otherplayer]=0;
			}
			else if(wantkiss[playerid]==0 || wantkiss[otherplayer]==0)
			{
				SendClientMessage(playerid,0x00FF00AA," Вам не предлагали целоваться!");
			}
		}
		else
		{
			SendClientMessage(playerid,0xFF0000AA," Вы слишком далеко!");
		}
return 1;
}

if(!strcmp(cmd, "/dispoc", true))
{
	new tmp[30];
	tmp = strtok(cmdtext,idx);
	new otherplayer = strval(tmp);
		if(GetDistanceBetweenPlayers(playerid, otherplayer) < 2)
		{
			if(wantkiss[playerid]==1 && wantkiss[otherplayer]==1)
			{
				SendClientMessage(playerid,0xFF0000AA," Вы отказались поцеловаться!");
				SendClientMessage(otherplayer,0x00FF00AA," С вами отказались поцеловаться!");
				wantkiss[playerid]=0;
				wantkiss[otherplayer]=0;
			}
			else if(wantkiss[playerid]==0 || wantkiss[otherplayer]==0)
			{
				SendClientMessage(playerid,0x00FF00AA," Вам не предлагали целоваться!");
			}
		}
		else
		{
			SendClientMessage(playerid,0xFF0000AA," Вы слишком далеко!");
		}
return 1;
}

if(!strcmp(cmd, "/iznas", true))
{
	new tmp[30];
	tmp = strtok(cmdtext,idx);
	new otherplayer = strval(tmp);
		if(GetDistanceBetweenPlayers(playerid, otherplayer) < 2)
		{
			if(IsSkinFemale(otherplayer))
			{
				SendClientMessage(playerid,0xFF0000AA," Вы изнасиловали игрока!");
				SendClientMessage(otherplayer,0x00FF00AA," Вас изнасиловали!");
				LoopingAnim(otherplayer,"SNM","SPANKINGW",4.1,0,1,1,1,1);
				LoopingAnim(playerid,"SNM","SPANKEDW",4.1,0,1,1,1,1);
			}
			else
			{
				SendClientMessage(playerid,0xFF0000AA," Ваш оппонент мужского пола!");
			}
		}
		else
		{
			SendClientMessage(playerid,0xFF0000AA," Вы слишком далеко!");
		}
return 1;
}

if(!strcmp(cmd, "/sexon", true))
{
	new tmp[30],PlayerName[30],string[256];
	tmp = strtok(cmdtext,idx);
	new otherplayer = strval(tmp);
		if(GetDistanceBetweenPlayers(playerid, otherplayer) < 2)
		{
			if(IsSkinFemale(otherplayer))
			{
				wantsex[playerid]=1;
				wantsex[otherplayer]=1;
				GetPlayerName(playerid,PlayerName,sizeof(PlayerName));
				format(string,sizeof(string)," Игрок %s предлагает вам заняться сексом. (/accsex [id] - принять, /dissex [id] - отказать)",PlayerName);
				SendClientMessage(otherplayer,0xFFFF00AA,string);
			}
			else
			{
				SendClientMessage(playerid,0xFF0000AA," Ваш оппонент мужского пола!");
			}
		}
		else
		{
			SendClientMessage(playerid,0xFF0000AA," Вы слишком далеко!");
		}
return 1;
}

if(!strcmp(cmd, "/accsex", true))
{
	new tmp[30];
	tmp = strtok(cmdtext,idx);
	new otherplayer = strval(tmp);
		if(GetDistanceBetweenPlayers(playerid, otherplayer) < 2)
		{
			if(wantsex[playerid]==1 && wantsex[otherplayer]==1)
			{
				SendClientMessage(playerid,0x00FF00AA," Вы занялись сексом!");
				SendClientMessage(otherplayer,0x00FF00AA," Вы занялись сексом!");
				wantsex[playerid]=0;
				wantsex[otherplayer]=0;
				ApplyAnimation(otherplayer,"SNM","SPANKING_IDLEW",4.1,0,1,1,1,1);
				LoopingAnim(playerid,"SNM","SPANKINGP",4.1,0,1,1,1,1);
			}
			else if(wantsex[playerid]==0 || wantsex[otherplayer]==0)
			{
				SendClientMessage(playerid,0x00FF00AA," Вам не предлагали заняться сексом!");
			}
		}
		else
		{
			SendClientMessage(playerid,0xFF0000AA," Вы слишком далеко!");
		}
return 1;
}

if(!strcmp(cmd, "/dissex ", true))
{
	new tmp[30];
	tmp = strtok(cmdtext,idx);
	new otherplayer = strval(tmp);
		if(GetDistanceBetweenPlayers(playerid, otherplayer) < 2)
		{
			if(wantsex[playerid]==1 && wantsex[otherplayer]==1)
			{
				SendClientMessage(playerid,0xFF0000AA," Вы отказались заняться сексом!");
				SendClientMessage(otherplayer,0x00FF00AA," С вами отказались заняться сексом!");
				wantsex[playerid]=0;
				wantsex[otherplayer]=0;
			}
			else if(wantsex[playerid]==0 || wantsex[otherplayer]==0)
			{
				SendClientMessage(playerid,0x00FF00AA," Вам не предлагали заняться сексом!");
			}
		}
		else
		{
			SendClientMessage(playerid,0xFF0000AA," Вы слишком далеко!");
		}
return 1;
}
return 0;
}

LoopingAnim(playerid,animlib[],animname[], Float:Speed, looping, lockx, locky, lockz, lp)
{
    ApplyAnimation(playerid, animlib, animname, Speed, looping, lockx, locky, lockz, lp);
}

stock GetDistanceBetweenPlayers(playerid, playerid2)
{
	new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
	new Float:tmpdis;
	GetPlayerPos(playerid,x1,y1,z1);
	GetPlayerPos(playerid2,x2,y2,z2);
	tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
return floatround(tmpdis);
}

stock IsSkinFemale(skinid)
{
	new Skins[] = {
	9, 10, 11, 12, 13, 31, 39, 40, 41, 54, 55,
	56, 63, 64, 69, 75, 76, 77, 85, 86, 87,
	88, 89, 90, 92, 93, 129, 130, 131, 138,
	140, 141, 145, 148, 150, 151, 152, 157,
	169, 172, 178, 190, 191, 192, 193, 194,
	195, 196, 197, 198, 199, 201, 205, 207,
	211, 214, 215, 216, 218, 219, 224, 225,
	226, 231, 232, 233, 237, 238, 243, 244,
	245, 246, 251, 256, 257, 263, 298
	};
	for(new i = 0; i < sizeof(Skins); i++)
	{
		if(skinid == i) return 1;
	}
	#pragma unused Skins
return 0;
}

strtok(const string[], &index)
{
	new length = strlen(string);
		while ((index < length) && (string[index] <= ' '))
		{
			index++;
		}
	new offset = index;
	new result[20];
		while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
		{
			result[index - offset] = string[index];
			index++;
		}
	result[index - offset] = EOS;
return result;
}
