
DCMD:menu ( playerid, params [ ] ) return ShowPlayerDialog ( playerid, DIALOG_MENU, DIALOG_STYLE_LIST, "{FFFFFF}Меню", "Статистика персонажа\nАвтомобили\nНедвижимость\nЛоги авторизаций\nНастройки\nБезопасность", "Выбрать", "Отмена" ) ;


DCMD:stats ( playerid, params [ ] )
{
	new list [ 1024 ] , to_list [ 248 ] , fid = ReturnFractionIndex ( PLAYER [ playerid ] [ FRAC ] ) ;
	
	echo ( list, "--------------------------- Статистика -----------------------------\n\n" ) ;
	
	echo ( to_list,
	"Игровой ник[ID]:  \t\t     %s[%d] \n\
	Рег. Номер:        \t\t     %d \n\
	Дата регистрации:  \t\t     %s \n\
	Уровень:           \t\t     %d \n\
	Пол:                   \t\t     %s \n\
	Раса:                  \t\t     %s \n",
	PlayerName [ playerid ] , playerid,
	PLAYER [ playerid ] [ ID ],
	PLAYER [ playerid ] [ REGDATE ],
	PLAYER [ playerid ] [ AGE ],
	StatSex [ PLAYER [ playerid ] [ SEX ] ] ,
	StatRace [ PLAYER [ playerid ] [ RACE ] ] ) ;
	strcat ( list, to_list ) ;
	
	new money [ 14 ], bank [ 14 ] ;
	echo ( money, "%d", PLAYER [ playerid ] [ MONEY ] ) ;
	echo ( bank, "%d", PLAYER [ playerid ] [ BANK ] ) ;
	new lenm = strlen ( money ), lenb = strlen ( bank ) ;
	switch ( lenm )
	{
		case 4: strins ( money, ".", 1 ) ; // 1000...9999
		case 5: strins ( money, ".", 2 ) ; // 10000...99999
		case 6: strins ( money, ".", 3 ) ; // 100000...999999
		case 7: strins ( money, ".", 1 ), strins ( money, ".", 5 ) ; // 1000000...9999999
		case 8: strins ( money, ".", 2 ), strins ( money, ".", 6 ) ; // 10000000...99999999
	}
	switch ( lenb )
	{
		case 4: strins ( bank, ".", 1 ) ; // 1000...9999
		case 5: strins ( bank, ".", 2 ) ; // 10000...99999
		case 6: strins ( bank, ".", 3 ) ; // 100000...999999
		case 7: strins ( bank, ".", 1 ), strins ( bank, ".", 5 ) ; // 1000000...9999999
		case 8: strins ( bank, ".", 2 ), strins ( bank, ".", 6 ) ; // 10000000...99999999
	}
	
	echo ( to_list, "Наличные:          \t\t     $%s \nБанк:                  \t\t     $%s \n", money, bank ) ;
	strcat ( list, to_list ) ;
	
	if ( fid != -1 )
	{
		echo ( to_list,
		"Фракция:          \t\t     %s \n\
		Ранг:                   \t\t     %s \n\
		Пост:                   \t\t     %s \n",
		FRACTION [ fid ] [ Name ],
		FRACRANG [ fid ] [ PLAYER [ playerid ] [ RANK ] ],
		FRACPOST [ fid ] [ PLAYER [ playerid ] [ POST ] ] ) ;
		strcat ( list, to_list ) ;
	}
	else
	{
		strcat ( list, "Фракция:          \t\t     Нету \nРанг:                   \t\t     Нету \nПост:                   \t\t     Нету \n" ) ;
	}
	
	strcat ( list, "\n-------------------------- Автомобили ----------------------------\n\n" ) ;
	
	for ( new idx = 0, vehicleid = 0, count = 1; idx < cvector_size ( PVEHICLES ) ; idx++ )
	{
		vehicleid = cvector_get ( PVEHICLES, idx ) ;
		if ( vehicleid == -1 ) continue;
		if ( GetVehicleModel ( vehicleid ) == 0 ) continue;
		if ( VEHICLE [ vehicleid ] [ TYPE ] != VPLAYER ) continue;
		if ( VEHICLE [ vehicleid ] [ OWNER ] != PLAYER [ playerid ] [ ID ] ) continue;
		
		echo ( to_list, "%d. %s \t\t %s \t\t ( ID: %d )\n", count, VehicleName [ VEHICLE [ vehicleid ] [ MODEL ] - 400 ], VEHICLE [ vehicleid ] [ PLATE ], vehicleid ) ;
		strcat ( list, to_list ) ;
		count++;
	}

	strcat ( list, "\n--------------------------------------------------------------------------" ) ;
	
	ShowPlayerDialog ( playerid, 0, DIALOG_STYLE_MSGBOX, "{FFFFFF}Статистика", list, "Ok", "" ) ;
	
	return 1;
}

DCMD:pas ( playerid, params [ ] )
{
	new pid;
	if ( !sscanf ( params, "u", pid ) ) 
	{
		if ( ! IsPlayerConnected ( pid ) || !IsLogged ( pid ) ) return Send ( playerid, COLOR_GRAY, "Игрок не авторизован!" ) ;
		
		new Float:_Position [ 3 ] ;
		GetPlayerPos ( pid, _Position [ 0 ], _Position [ 1 ], _Position [ 2 ] ) ;
		
		if ( !IsPlayerInRangeOfPoint ( playerid, 2.0, _Position [ 0 ], _Position [ 1 ], _Position [ 2 ] ) ) return Send ( playerid, COLOR_GRAY, "Игрок слишком далеко!" ) ;
		
		new string [ 128 ] ;
		echo ( string, "/me сунув руку в карман, достал от туда паспорт, и показал его %s.", PlayerName [ pid ] ) ;
		OnPlayerCommandText ( playerid, string ) ;
	}
	else pid = playerid;
	
	new date [ 3 ] ;
	sscanf ( PLAYER [ playerid ] [ REGDATE ] , "p<->ddd", date [ 0 ], date [ 1 ], date [ 2 ] ) ;
	new list [ 256 ] ;
	echo ( list, 
	"ФИО:                     \t  %s\n\
	Дата рождения: \t  %d.%d.%d \n\
	Дата выдачи:   \t  %d.%d.%d \n\
	Пол:                   \t  %s \n\
	Регистрация:   \t  Отсутствует", 
	PlayerName [ playerid ],
	date [ 2 ], date [ 1 ], date [ 0 ] - PLAYER [ playerid ] [ AGE ],
	( date [ 2 ] + ( date [ 1 ] / 2 ) ), date [ 1 ], ( ( date [ 0 ] - PLAYER [ playerid ] [ AGE ] ) + 16 ),
	StatSex [ PLAYER [ playerid ] [ SEX ] ] ) ;
	
	ShowPlayerDialog ( pid, 0, DIALOG_STYLE_MSGBOX, "{FFFFFF}Паспорт", list, "Ok", "" ) ;
	
	return 1;
}


DCMD:lic ( playerid, params [ ] )
{
	new pid;
	if ( !sscanf ( params, "u", pid ) ) 
	{
		if ( ! IsPlayerConnected ( pid ) || !IsLogged ( pid ) ) return Send ( playerid, COLOR_GRAY, "Игрок не авторизован!" ) ;
		
		new Float:_Position [ 3 ] ;
		GetPlayerPos ( pid, _Position [ 0 ], _Position [ 1 ], _Position [ 2 ] ) ;
		
		if ( !IsPlayerInRangeOfPoint ( playerid, 2.0, _Position [ 0 ], _Position [ 1 ], _Position [ 2 ] ) ) return Send ( playerid, COLOR_GRAY, "Игрок слишком далеко!" ) ;
		
		new string [ 128 ] ;
		echo ( string, "/me сунув руку в карман, достал от туда водительские права, и показал их %s.", PlayerName [ pid ] ) ;
		OnPlayerCommandText ( playerid, string ) ;
	}
	else pid = playerid;
	
	new list [ 256 ] ;
	echo ( list, 
	"ФИО:                     \t  %s  \n\
	Категория A:    \t  %s  \n\
	Категория B:    \t  %s  \n\
	Категория C:    \t  %s  \n\
	Категория D:    \t  %s  \n\
	Категория H:    \t  %s  ", 
	PlayerName [ playerid ],
	( !PLAYER [ playerid ] [ LICENSES ] [ LIC_CAT_A ] ) ? ( "Отсуствует" ) : ( "Есть" ),
	( !PLAYER [ playerid ] [ LICENSES ] [ LIC_CAT_B ] ) ? ( "Отсуствует" ) : ( "Есть" ),
	( !PLAYER [ playerid ] [ LICENSES ] [ LIC_CAT_C ] ) ? ( "Отсуствует" ) : ( "Есть" ),
	( !PLAYER [ playerid ] [ LICENSES ] [ LIC_CAT_D ] ) ? ( "Отсуствует" ) : ( "Есть" ),
	( !PLAYER [ playerid ] [ LICENSES ] [ LIC_CAT_H ] ) ? ( "Отсуствует" ) : ( "Есть" ) ) ;
	
	ShowPlayerDialog ( pid, 0, DIALOG_STYLE_MSGBOX, "{FFFFFF}Водительские права", list, "Ok", "" ) ;
	
	return 1;
}

DCMD:admins ( playerid, params [ ] )
{
	new list [ 248 ], to_list [ 48 ], count = 0 ;
	for ( new idx = 0, pid = 0; idx < cvector_size ( PLAYERS ) ; idx++ )
	{
		pid = cvector_get ( PLAYERS, idx ) ;
		if ( pid == -1 ) continue;
		
		if ( PLAYER [ pid ] [ ADMIN ] > 0 )
		{
			echo ( to_list, "**%s[%d]      \t      %s **\n", PlayerName [ pid ], pid, AdminRanks [ PLAYER [ pid ] [ ADMIN ] - 1 ] ) ;
			strcat ( list, to_list );
			count++;
		}
	}
	
	if ( count == 0 ) Send ( playerid, COLOR_GRAY, "Администраторов нет в сети" ) ;
	else ShowPlayerDialog ( playerid, 0, DIALOG_STYLE_MSGBOX, "{FFFFFF}Администрация", list, "Закрыть", "" ) ;
	
	return 1;
}

DCMD:job ( playerid, params [ ] )
{
	for ( new jid = 1; jid < sizeof ( JOBS ) ; jid++ )
	{
		if ( IsPlayerInRangeOfPoint ( playerid, 2.00, JOBS [ jid ] [ Position ] [ 0 ] , JOBS [ jid ] [ Position ] [ 1 ] , JOBS [ jid ] [ Position ] [ 2 ]  ) )
		{
			if ( PLAYER [ playerid ] [ JOB ] != JOBS [ jid ] [ ID ] )
			{
				Send ( playerid, COLOR_GRAY, "Сначало необходимо устроится на работу!" ) ;
			}
			else
			{
				switch ( PLAYER [ playerid ] [ JOB ] )
				{
					case OIL_TRUCKER:
					{
						if ( GetPVarInt ( playerid, "JobDuty" ) == 0 )
						{
							SetPVarInt ( playerid, "JobDuty", 1 ) ;
							SetPlayerJobSkin ( playerid, 27, 27, 260, 27 ) ;
							Send ( playerid, -1, "Начальник смены говорит: Отлично, ты как раз во время, иди садись в фургон, и езжай на нефтевышку!" ) ;
						}
						else
						{
							SetPVarInt ( playerid, "JobDuty", 0 ) ;
							SetPlayerSkin ( playerid, PLAYER [ playerid ] [ SKIN ] ) ;
							Send ( playerid, -1, "Начальник смены говорит: Неплохо поработал, вот держи свои деньги!" ) ;
						}
					}
				}
			}
			return 1;
		}
	}
	Send ( playerid, COLOR_GRAY, "Ты далеко от места работы." ) ;
	return 1;
}

DCMD:me ( playerid, params [ ] )
{
	if ( !sscanf ( params, "s[128]", params [ 0 ] ) ) 
	{
		new string [ 128 ] ;
		echo ( string, "* %s %s", PlayerName [ playerid ], params [ 0 ] ) ;
		ProxDetector ( 15.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE ) ;
		SetPlayerChatBubble ( playerid, params [ 0 ], COLOR_PURPLE, 15.0 , 5000 ) ;
	}
	else Send ( playerid, COLOR_GRAY, "Используй /я (/me) [действие]" ) ;
	return 1;
}
	
DCMD:do ( playerid, params [ ] )
{
	if ( !sscanf ( params, "s[128]", params [ 0 ] ) ) 
	{
		new string [ 128 ] ;
		echo ( string, "* %s (( %s ))", params [ 0 ], PlayerName [ playerid ] ) ;
		ProxDetector ( 15.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE ) ;
		SetPlayerChatBubble ( playerid, params [ 0 ], COLOR_PURPLE, 15.0 , 5000 ) ;
	}
	else Send ( playerid, COLOR_GRAY, "Используй /до (/do) [действие]" ) ;
	return 1;
}

DCMD:try ( playerid, params [ ] )
{
	new string [ 128 ], amount ;
	if ( !sscanf ( params, "s[128]", params [ 0 ] ) ) 
	{
		if ( random ( 2 ) == 1 )
			echo ( string, "*** %s попытался %s, и унего получилось", PlayerName [ playerid ], params [ 0 ] ), amount = 1 ;
		else
			echo ( string, "*** %s пытается %s, но ничего не получается", PlayerName [ playerid ], params [ 0 ] ), amount = 0 ;
			
		ProxDetector ( 15.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE ) ;
		
		if ( amount == 1 )
			echo ( string, "попытался %s, и унего получилось", params [ 0 ] ) ;
		else
			echo ( string, "пытается %s, но ничего не получается", params [ 0 ] ) ;
		
		SetPlayerChatBubble ( playerid, string, COLOR_PURPLE, 15.0 , 5000 ) ;
	}
	else Send ( playerid, COLOR_GRAY, "Используй /тру (/try) [действие]" ) ;
	return 1;
}
	
DCMD:b ( playerid, params [ ] )
{
	if ( !sscanf ( params, "s[128]", params [ 0 ] ) ) 
	{
		new string [ 128 ] ;
		echo ( string, "(( %s[%d]: %s ))", PlayerName [ playerid ] , playerid, params [ 0 ] ) ;
		ProxDetector ( 15.0, playerid, string, -1, -1, -1, COLOR_GRAY, COLOR_GRAY ) ;
	}
	else Send ( playerid, COLOR_GRAY, "Используй /б (/b) [текст]" ) ;
	return 1;
}

DCMD:s ( playerid, params [ ] )
{
	if ( !sscanf ( params, "s[128]", params [ 0 ] ) ) 
	{
		new string [ 128 ] ;
		SetPlayerChatBubble ( playerid, params [ 0 ], COLOR_GRAY7, 30.0 , 5000 ) ;
		
		echo ( string, "%s[%d] КРИЧИТ: %s", PlayerName [ playerid ] , playerid, params [ 0 ] ) ;
		ProxDetector ( 30.0, playerid, string, COLOR_GRAY7, COLOR_GRAY7, COLOR_GRAY6, COLOR_GRAY4, COLOR_GRAY0 ) ;
		
		ApplyAnimation ( playerid, "RIOT", "RIOT_shout", 4.1, 0, 1, 1, 0, 500, 1 ) ;
	}
	else Send ( playerid, COLOR_GRAY, "Используй /к (/s) [текст]" ) ;
	return 1;
}

DCMD:buy ( playerid, params [ ] )
{
	new type [ 24 ] ;
	
	if ( !sscanf ( params, "s[24]", type ) ) 
	{
		if ( !strcmp ( type, "бизнес", true ) ) 
		{
			new sid = ReturnNearIndexSBusines ( playerid, 2.0 ) ;
			
			if ( sid == -1 )
				return Send ( playerid, COLOR_GRAY, "Ты не у бизнеса!" ) ;
			
			if ( SBUSINESS [ sid ] [ Owner ] != -1 )
				return Send ( playerid, COLOR_GRAY, "Бизнес не продается!" ) ;
			
			if ( SBUSINESS [ sid ] [ Price ] > PLAYER [ playerid ] [ MONEY ] )
				return Send ( playerid, COLOR_GRAY, "Недостаточно денег на покупку бизнеса!" ) ;
			
			SBUSINESS [ sid ] [ Owner ] = PLAYER [ playerid ] [ ID ] ;
			sscanf ( PlayerName [ playerid ], "s[24]", SBUSINESS [ sid ] [ OwnerName ] ) ;
			
			GivePlayerMoneyAC ( playerid, -SBUSINESS [ sid ] [ Price ] ) ;
			
			DeleteSbusinesItems ( sid ) ;
			CreateSbusinesItems ( sid ) ;
			
			Send ( playerid, COLOR_BLUE, "Поздравляем с успешной покупкой бизнеса!" ) ;
			return 1;
		}
		else if ( !strcmp ( type, "дом", true ) ) 
		{
			new hid = ReturnNearIndexHouse ( playerid, 2.0, 5.0 ) ;
			
			if ( hid == -1 )
				return Send ( playerid, COLOR_GRAY, "Ты не у дома!" ) ;
			
			if ( HOUSE [ hid ] [ Owner ] != -1 )
				return Send ( playerid, COLOR_GRAY, "Дом не продается!" ) ;
			
			if ( HOUSE [ hid ] [ Price ] > PLAYER [ playerid ] [ MONEY ] )
				return Send ( playerid, COLOR_GRAY, "Недостаточно денег на покупку дома!" ) ;
			
			HOUSE [ hid ] [ Owner ] = PLAYER [ playerid ] [ ID ] ;
			sscanf ( PlayerName [ playerid ], "s[24]", HOUSE [ hid ] [ OwnerName ] ) ;
			
			GivePlayerMoneyAC ( playerid, -HOUSE [ hid ] [ Price ] ) ;
			
			DeleteHouseItems ( hid ) ;
			CreateHouseItems ( hid ) ;
			
			Send ( playerid, COLOR_BLUE, "Поздравляем с успешной покупкой дома!" ) ;
			return 1;
		}
		return Send ( playerid, COLOR_GRAY, "Неверный параметр!" ) ;
	}
	else
	{
		new text[] = "\n\nИспользуй:  \t  /купить [параметр]\n\
					 Параметры:   \t  сбизнес, бизнес, дом\n\n";
		HelpDialog ( playerid, text ) ;
	}
	
	return 1;
}


DCMD:sell ( playerid, params [ ] )
{
	new type [ 24 ], to [ 24 ], amount, id ;
	
	if ( !sscanf ( params, "s[24]s[24]", type, to ) ) 
	{
		if ( !strcmp ( type, "бизнес", true ) ) 
		{
			new sid = ReturnNearIndexSBusines ( playerid, 2.0 ) ;
			
			if ( sid == -1 )
				return Send ( playerid, COLOR_GRAY, "Ты не у бизнеса!" ) ;
			
			if ( SBUSINESS [ sid ] [ Owner ] != PLAYER [ playerid ] [ ID ] )
				return Send ( playerid, COLOR_GRAY, "Ты не владелец этого бизнеса!" ) ;
			
			if ( !strcmp ( to, "агенту", true ) ) 
			{
				SBUSINESS [ sid ] [ Owner ] = -1 ;
				GivePlayerMoneyAC ( playerid, SBUSINESS [ sid ] [ Price ] ) ;
				
				DeleteSbusinesItems ( sid ) ;
				CreateSbusinesItems ( sid ) ;
				
				new string [ 128 ] ;
				echo ( string, "Ты продал свой бизнес %s (#%d) за $%d, Агенту по недвижимости!", SBUSINESS [ sid ] [ Name ], SBUSINESS [ sid ] [ ID ], SBUSINESS [ sid ] [ Price ] ) ;
				Send ( playerid, COLOR_BLUE, string ) ;
				
				return 1;
			}
			else if ( !sscanf ( to, "dd", id, amount ) ) 
			{
				if ( !IsLogged ( id ) )
					return Send ( playerid, COLOR_GRAY, "Игрок не найден!" ) ;
				
				if ( id == playerid )
					return Send ( playerid, COLOR_GRAY, "Ты не можешь продать себе свою же собственность!" ) ;
				
				new Float:PPOS [ 3 ];
				GetPlayerPos ( playerid, PPOS [ 0 ], PPOS [ 1 ], PPOS [ 2 ] ) ;
				
				if ( !IsPlayerInRangeOfPoint ( playerid, 5.0, PPOS [ 0 ], PPOS [ 1 ], PPOS [ 2 ] ) )
					return Send ( playerid, COLOR_GRAY, "Игрок слишком далеко!" ) ;
				
				if ( amount < 1 )
					return Send ( playerid, COLOR_GRAY, "Сумма должна быть от 1$!" ) ;
				
				return 1;
			}
			return Send ( playerid, COLOR_GRAY, "Ошибка! /продать бизнес [ид] [цена] ИЛИ /продать бизнес агенту" ) ;
		}
		else if ( !strcmp ( type, "дом", true ) ) 
		{
			new hid = ReturnNearIndexHouse ( playerid, 2.0, 5.0 ) ;
			
			if ( hid == -1 )
				return Send ( playerid, COLOR_GRAY, "Ты не у дома!" ) ;
			
			if ( HOUSE [ hid ] [ Owner ] != PLAYER [ playerid ] [ ID ] )
				return Send ( playerid, COLOR_GRAY, "Ты не владелец этого дома!" ) ;
			
			if ( !strcmp ( to, "агенту", true ) ) 
			{
				HOUSE [ hid ] [ Owner ] = -1 ;
				GivePlayerMoneyAC ( playerid, HOUSE [ hid ] [ Price ] ) ;
				
				DeleteHouseItems ( hid ) ;
				CreateHouseItems ( hid ) ;
				
				new string [ 128 ] ;
				echo ( string, "Ты продал свой дом %s (#%d) за $%d, Агенту по недвижимости!", HOUSE [ hid ] [ Name ], HOUSE [ hid ] [ ID ], HOUSE [ hid ] [ Price ] ) ;
				Send ( playerid, COLOR_BLUE, string ) ;
				
				return 1;
			}
			else if ( !sscanf ( to, "dd", id, amount ) ) 
			{
				if ( !IsLogged ( id ) )
					return Send ( playerid, COLOR_GRAY, "Игрок не найден!" ) ;
				
				if ( id == playerid )
					return Send ( playerid, COLOR_GRAY, "Ты не можешь продать себе свою же собственность!" ) ;
				
				new Float:PPOS [ 3 ];
				GetPlayerPos ( playerid, PPOS [ 0 ], PPOS [ 1 ], PPOS [ 2 ] ) ;
				
				if ( !IsPlayerInRangeOfPoint ( playerid, 5.0, PPOS [ 0 ], PPOS [ 1 ], PPOS [ 2 ] ) )
					return Send ( playerid, COLOR_GRAY, "Игрок слишком далеко!" ) ;
				
				if ( amount < 1 )
					return Send ( playerid, COLOR_GRAY, "Сумма должна быть от 1$!" ) ;
				
				return 1;
			}
			return Send ( playerid, COLOR_GRAY, "Ошибка! /продать дом [ид] [цена] ИЛИ /продать дом агенту" ) ;
		}
		return Send ( playerid, COLOR_GRAY, "Неверный параметр!" ) ;
	}
	else 
	{
		new text[] = "\n\nИспользуй:  \t  /продать [параметр] [ид] [цена]\n\
					 Или:         \t  /продать [параметр] [агенту]\n\
					 Параметры:   \t  cбизнес, бизнес, дом\n\n";
		HelpDialog ( playerid, text ) ;
	}
	
	return 1;
}

DCMD:ad ( playerid, params [ ] )
{
	new advert [ 84 ], string [ 128 ] ;
	
	if ( !sscanf ( params, "s[84]", advert ) ) 
	{
		if ( ( gettime ( ) - LastAd ) < 60 )
		{
			echo ( string, "Следующая подача рекламы возможна через %0d секунд.", 60 - ( gettime ( ) - LastAd ) ) ;
			return Send ( playerid, COLOR_GRAY, string ) ;
		}
		
		new len_text = strlen ( advert ) ;
		
		if ( len_text > 80 ) return Send ( playerid, COLOR_GRAY, "Реклама слишком длинная. Используй менее 80 символов." ) ;
		
		new amount = len_text * SBUSINESS [ ADVERT ] [ Cost ] ;
		
		if ( amount > PLAYER [ playerid ] [ BANK ] )
		{
			echo ( string, "Недостаточно денег на счету. Стоимость рекламы: $%d. Стоимость символа: $%d. Нехватает: $%d.", amount, SBUSINESS [ ADVERT ] [ Cost ], amount - PLAYER [ playerid ] [ BANK ] ) ;
			Send ( playerid, COLOR_GRAY, string ) ;
		}
		else
		{
			GivePlayerBankMoney ( playerid, -amount ) ;
			SBUSINESS [ ADVERT ] [ Money ] += amount;
			SBUSINESS [ ADVERT ] [ MonthIncome ] += amount;
			
			echo ( string, "[Реклама] %s. ( %s[%d] )", advert, PlayerName [ playerid ], playerid ) ;
			SendToAll ( COLOR_AD, string ) ;
			
			AdvertLog ( playerid, advert ) ;
			LastAd = gettime ( ) ;
		}
	}
	else Send ( playerid, COLOR_GRAY, "Используй: /реклама (/ad) [текст]" ) ;
	
	return 1;
}

DCMD:heal ( playerid, params [ ] )
{
	if ( PLAYER [ playerid ] [ HOSPITAL ] != -1 || PLAYER [ playerid ] [ HOSPITAL_TIME ] != -1 )
		return Send ( playerid, COLOR_GRAY, "Ты уже проходишь курс лечения! Дождись его окончания!" );
	
	if ( PLAYER [ playerid ] [ HEALTH ] > 90 )
		return Send ( playerid, COLOR_GRAY, "Ты полностью здоров! Не стоит занимать койку без причины!" );
	
	new key = HoldHospitalBedCommand ( playerid ) ;
	
	if ( key == 0 ) Send ( playerid, COLOR_GRAY, "Эта койка занята!" ) ; 
	else if ( key == -1 ) Send ( playerid, COLOR_GRAY, "Рядом с тобой нету коек!" ) ;
		
	return 1;
}

DCMD:close ( playerid, params [ ] )
{
	new vehicleid;
	
	if ( GetPlayerState ( playerid ) == PLAYER_STATE_ONFOOT ) vehicleid = ReturnNearIndexVehicle ( playerid, 3.0 );
	else vehicleid = GetPlayerVehicleID ( playerid ) ;
	
	if ( vehicleid != -1 )
	{
		switch ( VEHICLE  [ vehicleid ] [ TYPE ] )
		{
			case VPLAYER:
			{
				if ( VEHICLE  [ vehicleid ] [ OWNER ] == PLAYER [ playerid ] [ ID ] )
				{
					ToggleVehicleDoorsLocked ( vehicleid, VEHICLE_PARAMS_ON ) ;
					
					OnPlayerCommandText ( playerid, "/me достает ключи, и закрывает дверь авто." ) ;
					
					PlayerPlaySound ( playerid, 1145, 0, 0, 0 ) ;
					GameTextForPlayer ( playerid, "~r~ABЏO џAKPЁЏO", 2000, 4 ) ;
					return 1;
				}
				else return Send ( playerid, COLOR_GRAY, "У тебя нету ключей от этого авто!" ) ;
			}
		}
	}
	
	new key = -1;
	for ( new i = 0; i < sizeof ( PICKUP ); i++ )
	{
		if ( IsPlayerInRangeOfPoint ( playerid, 1.0, PICKUP [ i ] [ OutPosition ] [ 0 ], PICKUP [ i ] [ OutPosition ] [ 1 ], PICKUP [ i ] [ OutPosition ] [ 2 ] ) || IsPlayerInRangeOfPoint ( playerid, 1.0, PICKUP [ i ] [ InPosition ] [ 0 ] , PICKUP [ i ] [ InPosition ] [ 1 ], PICKUP [ i ] [ InPosition ] [ 2 ]  ) )
		{
			if ( PICKUP [ i ] [ Fraction ] != PLAYER [ playerid ] [ FRAC ] )
				key = 0;
			else
				PICKUP [ i ] [ Lock ] = 1, key = 1;
		}
	}
	
	if ( key == 1 )
	{
		OnPlayerCommandText ( playerid, "/me достает ключи, и закрывает дверь." ) ;
		PlayerPlaySound ( playerid, 1145, 0, 0, 0 ) ;
		GameTextForPlayer ( playerid, "~r~љBEP’ €AKP‘ЏA", 2000, 4 ) ;
	}
	else if ( key == 0 ) Send ( playerid, COLOR_GRAY, "У тебя нету ключей от этой двери!" ) ;
	
	return 1;
}

DCMD:open ( playerid, params [ ] )
{
	new vehicleid;
	
	if ( GetPlayerState ( playerid ) == PLAYER_STATE_ONFOOT ) vehicleid = ReturnNearIndexVehicle ( playerid, 3.0 );
	else vehicleid = GetPlayerVehicleID ( playerid ) ;
	
	if ( vehicleid != -1 )
	{
		switch ( VEHICLE  [ vehicleid ] [ TYPE ] )
		{
			case VPLAYER:
			{
				if ( VEHICLE  [ vehicleid ] [ OWNER ] == PLAYER [ playerid ] [ ID ] )
				{
					ToggleVehicleDoorsLocked ( vehicleid, VEHICLE_PARAMS_OFF ) ;
					
					OnPlayerCommandText ( playerid, "/me достает ключи, и открывает дверь авто." ) ;
					
					PlayerPlaySound ( playerid, 1145, 0, 0, 0 ) ;
					GameTextForPlayer ( playerid, "~g~ABЏO OЏKPЁЏO", 2000, 4 ) ;
					return 1;
				}
				else return Send ( playerid, COLOR_GRAY, "У тебя нету ключей от этого авто!" ) ;
			}
		}
	}
	
	new key = -1;
	for ( new i = 0; i < sizeof ( PICKUP ); i++ )
	{
		if ( IsPlayerInRangeOfPoint ( playerid, 1.0, PICKUP [ i ] [ OutPosition ] [ 0 ], PICKUP [ i ] [ OutPosition ] [ 1 ], PICKUP [ i ] [ OutPosition ] [ 2 ] ) || IsPlayerInRangeOfPoint ( playerid, 1.0, PICKUP [ i ] [ InPosition ] [ 0 ] , PICKUP [ i ] [ InPosition ] [ 1 ], PICKUP [ i ] [ InPosition ] [ 2 ]  ) )
		{
			if ( PICKUP [ i ] [ Fraction ] != PLAYER [ playerid ] [ FRAC ] )
				key = 0;
			else
				PICKUP [ i ] [ Lock ] = 0, key = 1;
		}
	}
	
	if ( key == 1 )
	{
		OnPlayerCommandText ( playerid, "/me достает ключи, и открывает дверь." ) ;
		PlayerPlaySound ( playerid, 1145, 0, 0, 0 ) ;
		GameTextForPlayer ( playerid, "~g~љBEP’ OЏKP‘ЏA", 2000, 4 ) ;
	}
	else if ( key == 0 ) Send ( playerid, COLOR_GRAY, "У тебя нету ключей от этой двери!" ) ;
	
	return 1;
}
