Доступ к готовым решениям

Переход в группу "Пользователь"

300.00 ₽
Одноразовый платёж
Быстрый переход в группу "Пользователи", без надобности написания постов и ожидания.

Покупка дает возможность:
Быть полноправным участником форума
Нормальное копирование кода
Создавать темы
Скачивать файлы
Доступ к архиву Pawno-Info

Мануал Система домов на TextDraw's+Dynamic Area

Статус
В этой теме нельзя размещать новые ответы.

#Mars#

Новичок
И так, в данном мануале я покажу как сделать систему домов динамической зоне и текстдравах. (Работоспособность гарантируется на игровым модах с основой Skrillax)


Для начала в pEnum добавляем SetHPos (в структуру не вносим) и в hInfo hUPICKUP

в OnPlayerSpawn добавляем SetPVarInt(playerid,"AntiFlood_Area",gettime()+5); да бы текст дравы не показывались нам при спавне.

В OnPlayerConnect PlayerInfo[playerid][SetHPos] = 0;


Заменяем свой старый BuyHouse на новый | Учитываем свой функционал и адаптируем.

PHP:
stock BuyHouse(h)
{
	if(HouseInfo[h][hOwned] == 0)
	{
		DestroyDynamicMapIcon(HouseInfo[h][hMIcon]);
		DestroyPickup(HouseInfo[h][hPickup]);
		AddStaticPickup(1273, 23, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]);
		HouseInfo[h][hMIcon] = CreateDynamicMapIcon(HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez], 31, COLOR_WHITE, 0, -1, -1, 200.0);
	}
	if(HouseInfo[h][hOwned] == 1)
	{
		DestroyDynamicMapIcon(HouseInfo[h][hMIcon]);
		DestroyPickup(HouseInfo[h][hPickup]);
		AddStaticPickup(1272, 23, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]);
		HouseInfo[h][hMIcon] = CreateDynamicMapIcon(HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez], 32, COLOR_WHITE, 0, -1, -1, 200.0);
	}
	return true;
}

в UpdateIconHouse(h) заменяем обновление иконок
PHP:
	DestroyDynamicMapIcon(HouseInfo[h][hMIcon]);
	DestroyPickup(HouseInfo[h][hUPICKUP]);

В загрузку домов (LoadProperty) добавляем

PHP:
HouseInfo[he][hPickup] = CreateDynamicSphere(HouseInfo[he][hEntrancex], HouseInfo[he][hEntrancey], HouseInfo[he][hEntrancez],0.9,0,0,-1)
и заменяем создание пикапов

PHP:
			if HouseInfo[he][hOwned] == 0 *then
			{
				HouseInfo[he][hMIcon] = CreateDynamicMapIcon(HouseInfo[he][hEntrancex], HouseInfo[he][hEntrancey], HouseInfo[he][hEntrancez], 31, COLOR_WHITE, 0, -1, -1, 50.0);
				HouseInfo[he][hUPICKUP] = CreatePickup(1273, 23, HouseInfo[he][hEntrancex], HouseInfo[he][hEntrancey], HouseInfo[he][hEntrancez],-1);
			}
			else if HouseInfo[he][hOwned] == 1 *then
			{
				HouseInfo[he][hMIcon] = CreateDynamicMapIcon(HouseInfo[he][hEntrancex], HouseInfo[he][hEntrancey], HouseInfo[he][hEntrancez], 32, COLOR_WHITE, 0, -1, -1, 50.0);
				HouseInfo[he][hUPICKUP] = CreatePickup(1272, 23, HouseInfo[he][hEntrancex], HouseInfo[he][hEntrancey], HouseInfo[he][hEntrancez],-1);
			}


Дальше идем в стандартный паблик OnPlayerEnterDynamicArea

PHP:
public OnPlayerEnterDynamicArea(playerid, areaid)
{
	if areaid >= HouseInfo[0][hPickup] && GetPVarInt(playerid,"AntiFlood_Area") < gettime() *then
	{
		new h = areaid - HouseInfo[0][hPickup];
	 	new house = PlayerInfo[playerid][pPhousekey];
		PlayerInfo[playerid][SetHPos] = h;
		new platas;
		new Float:x, Float:y, Float:z, pos[15];
		GetPlayerPos(playerid,x,y,z);
		if(x < 0) strcat(pos,"San Fiero");
		else if(y > 100.0) strcat(pos,"Las Venturas");
		else strcat(pos,"Los Santos");
		new stringer[54];
		new ttextt[32],owner[44],posh[100],onnoffman[15],platasyk[30],press[20];
		if(HouseInfo[h][hOwned] == 1)
		{
			if(IsPlayerConnected(GetPlayerID(HouseInfo[h][hOwner]))) { ttextt = "~g~Online"; }
			else if(!IsPlayerConnected(GetPlayerID(HouseInfo[h][hOwner]))) { ttextt = "~r~Offline"; }
		    //platas = 500;
			switch(HouseInfo[h][hKlass])
			{
				case 0: format(stringer, sizeof(stringer), "Type: Economy class", h),platas = 50000;
				case 1: format(stringer, sizeof(stringer), "Type: Middle class", h),platas = 80000;
				case 2: format(stringer, sizeof(stringer), "Type: Business class", h),platas = 100000;
				case 3: format(stringer, sizeof(stringer), "Type: Elite class", h),platas = 200000;
				case 4: format(stringer, sizeof(stringer), "Type: Apartment class", h),platas = 400000;
				case 5: format(stringer, sizeof(stringer), "Type: VIP class", h),platas = 600000;
				default: format(stringer, sizeof(stringer), "Type: Economy class", h),platas = 50000;
			}
			format(posh, sizeof(posh), "%s, %s, %d", pos,GetHouseZone(h),h);
			format(owner, sizeof(owner), "Owner: %s", HouseInfo[h][hOwner]);
			format(onnoffman, sizeof(onnoffman), "%s", ttextt);
			format(platasyk, sizeof(platasyk), "Prise: %d ~g~$", platas);
			format(press, sizeof(press), "PRESS 'N' TO JOIN!");
			
			TextDrawSetString(TDhouse1[0][playerid],posh);
			TextDrawSetString(TDhouse1[1][playerid],owner);
			TextDrawSetString(TDhouse1[2][playerid],stringer);
			TextDrawSetString(TDhouse1[3][playerid],platasyk);
			TextDrawSetString(TDhouse1[4][playerid],onnoffman);
			TextDrawSetString(TDhouse[4],press);

			
			TextDrawShowForPlayer(playerid, TDhouse[0]);
			TextDrawShowForPlayer(playerid, TDhouse[1]);
			TextDrawShowForPlayer(playerid, TDhouse[2]);
			TextDrawShowForPlayer(playerid, TDhouse[3]);
			TextDrawShowForPlayer(playerid, TDhouse[4]);
			TextDrawShowForPlayer(playerid, TDhouse1[0][playerid]);
			TextDrawShowForPlayer(playerid, TDhouse1[1][playerid]);
			TextDrawShowForPlayer(playerid, TDhouse1[2][playerid]);
			TextDrawShowForPlayer(playerid, TDhouse1[3][playerid]);
			TextDrawShowForPlayer(playerid, TDhouse1[4][playerid]);
			SetPVarInt(playerid, "_HOUSE", 1);
		}
		else
		{
			//platas = 500;
			switch(HouseInfo[h][hKlass])
			{
				case 0: format(stringer, sizeof(stringer), "Type: Economy class", h),platas = 50000;
				case 1: format(stringer, sizeof(stringer), "Type: Middle class", h),platas = 80000;
				case 2: format(stringer, sizeof(stringer), "Type: Business class", h),platas = 100000;
				case 3: format(stringer, sizeof(stringer), "Type: Elite class", h),platas = 200000;
				case 4: format(stringer, sizeof(stringer), "Type: Apartment class", h),platas = 400000;
				case 5: format(stringer, sizeof(stringer), "Type: VIP class", h),platas = 600000;
				default: format(stringer, sizeof(stringer), "Type: Economy class", h),platas = 50000;
			}
			format(posh, sizeof(posh), "%s, %s, %d", pos,GetHouseZone(h),h);
			format(owner, sizeof(owner), "Owner: The State");
			format(onnoffman, sizeof(onnoffman), "%s", ttextt);
			format(platasyk, sizeof(platasyk), "Prise: %d ~g~$", platas);
			format(press, sizeof(press), "PRESS 'N' TO BUY!");

			TextDrawSetString(TDhouse1[0][playerid],posh);
			TextDrawSetString(TDhouse1[1][playerid],owner);
			TextDrawSetString(TDhouse1[2][playerid],stringer);
			TextDrawSetString(TDhouse1[3][playerid],platasyk);
			TextDrawSetString(TDhouse1[4][playerid],onnoffman);
			TextDrawSetString(TDhouse[4],press);


			TextDrawShowForPlayer(playerid, TDhouse[0]);
			TextDrawShowForPlayer(playerid, TDhouse[1]);
			TextDrawShowForPlayer(playerid, TDhouse[2]);
			TextDrawShowForPlayer(playerid, TDhouse[3]);
			TextDrawShowForPlayer(playerid, TDhouse[4]);
			TextDrawShowForPlayer(playerid, TDhouse1[0][playerid]);
			TextDrawShowForPlayer(playerid, TDhouse1[1][playerid]);
			TextDrawShowForPlayer(playerid, TDhouse1[2][playerid]);
			TextDrawShowForPlayer(playerid, TDhouse1[3][playerid]);
			SetPVarInt(playerid, "_HOUSE", 1);
		}
	}
	return 1;
}

и в OnPlayerLeaveDynamicArea(playerid, areaid)

PHP:
public OnPlayerLeaveDynamicArea(playerid, areaid)
{
	if areaid >= HouseInfo[0][hPickup] && GetPVarInt(playerid,"AntiFlood_Area") < gettime() *then
	{
		for(new r = 0; r < 5; r++) TextDrawHideForPlayer(playerid, TDhouse[r]);
		for(new b = 0; b < 5; b++) TextDrawHideForPlayer(playerid, TDhouse1[b][playerid]);
		SetPVarInt(playerid, "_HOUSE", 0);
	}
	return 1;
} //





Пример для входа в дом, цикл for(new i = 0; i < sizeof(HouseInfo); i++) не используется
PHP:
	case 10075:
		{
			if(response)
			{
				if(strcmp(PlayerInfo[playerid][pNames], HouseInfo[PlayerInfo[playerid][SetHPos]][hOwner], true) == 0 && PlayerInfo[playerid][pPhousekey] == 255) PlayerInfo[playerid][pPhousekey] = PlayerInfo[playerid][SetHPos];
				if(PlayerInfo[playerid][pPhousekey] == PlayerInfo[playerid][SetHPos] || HouseInfo[PlayerInfo[playerid][SetHPos]][hLock] == 0 || PlayerInfo[playerid][pPhousekey2] == PlayerInfo[playerid][SetHPos])
				{
					SetPlayerInterior(playerid,HouseInfo[PlayerInfo[playerid][SetHPos]][hInt]);
					SetPlayerVirtualWorld(playerid,PlayerInfo[playerid][SetHPos]+50);
					SetPPos(playerid,HouseInfo[PlayerInfo[playerid][SetHPos]][hExitx],HouseInfo[PlayerInfo[playerid][SetHPos]][hExity],HouseInfo[PlayerInfo[playerid][SetHPos]][hExitz]);
					PlayerInfo[playerid][pInt] = HouseInfo[PlayerInfo[playerid][SetHPos]][hInt];
					PlayerInfo[playerid][pLocal] = PlayerInfo[playerid][SetHPos];
					return true;
				}
				else GameTextForPlayer(playerid, "~r~Locked", 5000, 1);

			}
			else { return true; }
		}

Так же можно просто вместо данного цикла ставить new i = PlayerInfo[playerid][SetHPos];




PHP:
new Text:TDhouse[5],Text:TDhouse1[5][MAX_PLAYERS];

в OnPlayerDisconnect

PHP:
	TextDrawDestroy(TDhouse1[0][playerid]);
	TextDrawDestroy(TDhouse1[1][playerid]);
	TextDrawDestroy(TDhouse1[2][playerid]);
	TextDrawDestroy(TDhouse1[3][playerid]);
	TextDrawDestroy(TDhouse1[4][playerid]);

TDhouse[0] = TextDrawCreate(565.047790, 205.873352, "usebox");
TextDrawLetterSize(TDhouse[0], 0.000000, 4.741541);
TextDrawTextSize(TDhouse[0], 438.380828, 0.000000);
TextDrawAlignment(TDhouse[0], 1);
TextDrawColor(TDhouse[0], 0);
TextDrawUseBox(TDhouse[0], true);
TextDrawBoxColor(TDhouse[0], 102);
TextDrawSetShadow(TDhouse[0], 0);
TextDrawSetOutline(TDhouse[0], 0);
TextDrawFont(TDhouse[0], 0);

TDhouse[1] = TextDrawCreate(441.142883, 206.080001, "LD_SPAC:white");
TextDrawLetterSize(TDhouse[1], 0.000000, 0.000000);
TextDrawTextSize(TDhouse[1], 120.761901, 42.666725);
TextDrawAlignment(TDhouse[1], 1);
TextDrawColor(TDhouse[1], 1768516095);
TextDrawSetShadow(TDhouse[1], 0);
TextDrawSetOutline(TDhouse[1], 0);
TextDrawFont(TDhouse[1], 4);

TDhouse[2] = TextDrawCreate(565.048095, 187.953338, "usebox");
TextDrawLetterSize(TDhouse[2], 0.000000, 1.316349);
TextDrawTextSize(TDhouse[2], 438.380950, 0.000000);
TextDrawAlignment(TDhouse[2], 1);
TextDrawColor(TDhouse[2], 0);
TextDrawUseBox(TDhouse[2], true);
TextDrawBoxColor(TDhouse[2], 102);
TextDrawSetShadow(TDhouse[2], 0);
TextDrawSetOutline(TDhouse[2], 0);
TextDrawFont(TDhouse[2], 0);

TDhouse[3] = TextDrawCreate(441.142852, 187.733337, "LD_SPAC:white");
TextDrawLetterSize(TDhouse[3], 0.000000, 0.000000);
TextDrawTextSize(TDhouse[3], 120.761871, 12.373337);
TextDrawAlignment(TDhouse[3], 1);
TextDrawColor(TDhouse[3], 1768516095);
TextDrawSetShadow(TDhouse[3], 0);
TextDrawSetOutline(TDhouse[3], 0);
TextDrawFont(TDhouse[3], 4);

TDhouse[4] = TextDrawCreate(460.904724, 253.026687, "PRESS 'N' TO JOIN!");
TextDrawLetterSize(TDhouse[4], 0.230571, 0.947200);
TextDrawAlignment(TDhouse[4], 1);
TextDrawColor(TDhouse[4], -1);
TextDrawSetShadow(TDhouse[4], 0);
TextDrawSetOutline(TDhouse[4], 1);
TextDrawBackgroundColor(TDhouse[4], 51);
TextDrawFont(TDhouse[4], 1);
TextDrawSetProportional(TDhouse[4], 1);



onplayerconnect


TDhouse1[0][playerid] = TextDrawCreate(443.428527, 189.866638, "Los Santos, Santa Maria Beach, 176");
TextDrawLetterSize(TDhouse1[0][playerid], 0.179142, 0.785066);
TextDrawAlignment(TDhouse1[0][playerid], 1);
TextDrawColor(TDhouse1[0][playerid], -1);
TextDrawSetShadow(TDhouse1[0][playerid], 0);
TextDrawSetOutline(TDhouse1[0][playerid], 1);
TextDrawBackgroundColor(TDhouse1[0][playerid], 51);
TextDrawFont(TDhouse1[0][playerid], 1);
TextDrawSetProportional(TDhouse1[0][playerid], 1);

TDhouse1[1][playerid] = TextDrawCreate(444.190460, 207.786682, "Owner: Romas_Dalbaenko");
TextDrawLetterSize(TDhouse1[1][playerid], 0.230571, 0.947200);
TextDrawAlignment(TDhouse1[1][playerid], 1);
TextDrawColor(TDhouse1[1][playerid], -1);
TextDrawSetShadow(TDhouse1[1][playerid], 0);
TextDrawSetOutline(TDhouse1[1][playerid], 1);
TextDrawBackgroundColor(TDhouse1[1][playerid], 51);
TextDrawFont(TDhouse1[1][playerid], 1);
TextDrawSetProportional(TDhouse1[1][playerid], 1);

TDhouse1[2][playerid] = TextDrawCreate(444.428558, 219.026672, "Type: Economy class");
TextDrawLetterSize(TDhouse1[2][playerid], 0.230571, 0.947200);
TextDrawAlignment(TDhouse1[2][playerid], 1);
TextDrawColor(TDhouse1[2][playerid], -1);
TextDrawSetShadow(TDhouse1[2][playerid], 0);
TextDrawSetOutline(TDhouse1[2][playerid], 1);
TextDrawBackgroundColor(TDhouse1[2][playerid], 51);
TextDrawFont(TDhouse1[2][playerid], 1);
TextDrawSetProportional(TDhouse1[2][playerid], 1);

TDhouse1[3][playerid] = TextDrawCreate(445.047607, 231.973327, "Prise: 200000");
TextDrawLetterSize(TDhouse1[3][playerid], 0.230571, 0.947200);
TextDrawAlignment(TDhouse1[3][playerid], 1);
TextDrawColor(TDhouse1[3][playerid], -1);
TextDrawSetShadow(TDhouse1[3][playerid], 0);
TextDrawSetOutline(TDhouse1[3][playerid], 1);
TextDrawBackgroundColor(TDhouse1[3][playerid], 51);
TextDrawFont(TDhouse1[3][playerid], 1);
TextDrawSetProportional(TDhouse1[3][playerid], 1);

TDhouse1[4][playerid] = TextDrawCreate(535.237365, 239.786651, "offline");
TextDrawLetterSize(TDhouse1[4][playerid], 0.225238, 0.806400);
TextDrawAlignment(TDhouse1[4][playerid], 1);
TextDrawColor(TDhouse1[4][playerid], -1);
TextDrawUseBox(TDhouse1[4][playerid], true);
TextDrawBoxColor(TDhouse1[4][playerid], 0);
TextDrawSetShadow(TDhouse1[4][playerid], 0);
TextDrawSetOutline(TDhouse1[4][playerid], 1);
TextDrawBackgroundColor(TDhouse1[4][playerid], 51);
TextDrawFont(TDhouse1[4][playerid], 1);
TextDrawSetProportional(TDhouse1[4][playerid], 1);



 
Статус
В этой теме нельзя размещать новые ответы.
Сверху Снизу