House System
#1

Hi, How would I do this storage system through the House Y_INI? Help me ..
Код:
#include <a_samp>
#include <icons_streamer.pwn>
#include <TDB>
#define B_MODRA	        0x4169FFAA
#define COLOR_GREEN	    0x4169FFAA
#define MAX_HOUSES      50
#define MAX_HOUSES_NAME 20
enum HOUSE_DATA
{
	HouseName[MAX_HOUSES_NAME],
    Float:p_X,
    Float:p_Y,
    Float:p_Z,
    Float:i_X,
	Float:i_Y,
	Float:i_Z,
	iin,
	Cena,
	Vlastnik,
	Dialog,
	Zamek,
	WiW,
	Float:auto_x,
	Float:auto_y,
	Float:auto_z,
	Float:auto_face,
	auto_dialog
};
new HouseInfo[MAX_HOUSES][HOUSE_DATA];
new HouseCount = 0;
new MajitelDomu[MAX_HOUSES][MAX_PLAYERS];
new AutoDomu[MAX_HOUSES];
//--------[ Forwards ]--------|
forward GetPlayerDistanceToPointEx(playerid,Float:x,Float:y,Float:z);
forward IsPlayerInSphere(playerid,Float:x,Float:y,Float:z,radius);
forward AddHouse(const h_Name[], Float:pX, Float:pY, Float:pZ, Float:iX, Float:iY, Float:iZ, ii, Cenik, iddialogu, VW, Float:a_x, Float:a_y, Float:a_z, Float:a_face, a_dialog);
//______________________________________________________________________________

public IsPlayerInSphere(playerid,Float:x,Float:y,Float:z,radius)
{
   if(GetPlayerDistanceToPointEx(playerid,x,y,z) < radius) return 1;
   return 0;
}
//==============================================================================
public GetPlayerDistanceToPointEx(playerid,Float:x,Float:y,Float:z)
{
	new Float:x1,Float:y1,Float:z12,Float:tmpdis;
	GetPlayerPos(playerid,x1,y1,z12);
	tmpdis = floatsqroot(floatpower(floatabs(floatsub(x,x1)),2)
	+floatpower(floatabs(floatsub(y,y1)),2)+floatpower(floatabs(floatsub(z,z12)),2));
	return floatround(tmpdis);
}
//==============================================================================
public AddHouse(const h_Name[], Float:pX, Float:pY, Float:pZ, Float:iX, Float:iY, Float:iZ, ii, Cenik, iddialogu, VW, Float:a_x, Float:a_y, Float:a_z, Float:a_face, a_dialog)
{
	if(HouseCount < MAX_HOUSES)
		{
		    format(HouseInfo[HouseCount][HouseName] , MAX_HOUSES_NAME, "%s", h_Name);
		
			HouseInfo[HouseCount][p_X]        = pX;
			HouseInfo[HouseCount][p_Y]        = pY;
			HouseInfo[HouseCount][p_Z]        = pZ;

			HouseInfo[HouseCount][i_X]        = iX;
			HouseInfo[HouseCount][i_Y]        = iY;
			HouseInfo[HouseCount][i_Z]        = iZ;
			HouseInfo[HouseCount][iin]        = ii;

			HouseInfo[HouseCount][Cena]       = Cenik;
			HouseInfo[HouseCount][WiW]        = VW;

			HouseInfo[HouseCount][Vlastnik] = 0;
			HouseInfo[HouseCount][Zamek]    = 0;

		 	CreatePickup(1273,1,pX, pY, pZ);
		 	HouseInfo[HouseCount][Dialog]   = iddialogu;
		 	
		 	HouseInfo[HouseCount][auto_x]        = a_x;
		 	HouseInfo[HouseCount][auto_y]        = a_y;
		 	HouseInfo[HouseCount][auto_z]        = a_z;
		 	HouseInfo[HouseCount][auto_face]     = a_face;
		 	HouseInfo[HouseCount][auto_dialog]   = a_dialog;
		 	
			HouseCount ++;
			}else{
			print("<!--  Kapacita AddHouse prekrocena, dum nebyl vytvoren  !-->");
		}
	return 1;
}
//==============================================================================
public OnFilterScriptInit()
{
	TdOnGameModeInt();
	AddHouse("Dum 1", 2126.6511,-1319.9645,26.6240, 225.8965,1022.1873,1084.0156, 7, 35010, 681, 24, 2136.1165,-1318.8456,24.6143,0.2171, 680);
	return 1;
}
//==============================================================================
public OnPlayerConnect(playerid)
{
	for(new h=0;h<HouseCount;h++)
		{
		    CreateMapIcon(31, COLOR_GREEN, HouseInfo[h][p_X],HouseInfo[h][p_Y],HouseInfo[h][p_Z]);
		}
	return 1;
}
//==============================================================================
public OnPlayerDisconnect(playerid, reason)
{
    ResetMapIconVariables(playerid);
	for(new h=0;h<HouseCount;h++)
		{
			new buyyng[150];
			format(buyyng, 150, "Cena: %d",HouseInfo[h][Cena]);
			Create3DTextLabel(buyyng,0x00FF00FF,HouseInfo[h][p_X],HouseInfo[h][p_Y],HouseInfo[h][p_Z] + 3,80.0,0);
		}
    return 1;
}
//==============================================================================
public OnPlayerPickUpPickup(playerid, pickupid)
{
	for(new h=0;h<HouseCount;h++)
		{
		if(IsPlayerInSphere(playerid,HouseInfo[h][p_X],HouseInfo[h][p_Y],HouseInfo[h][p_Z],2) == 1)
			{
				ShowPlayerDialog(playerid,HouseInfo[h][Dialog],DIALOG_STYLE_LIST,"Dům","Koupit\nProdat\nZamknout\nOdemknout\nInformace o domu\nVstoupit\nKoupit / Zmenit auto","Pouћнt","Nic");
			}
		}
	return 1;
}
//==============================================================================
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if((newkeys & (KEY_WALK | KEY_SPRINT)) == (KEY_WALK | KEY_SPRINT))
   		{
		for(new h=0;h<HouseCount;h++)
					{
					if(IsPlayerInSphere(playerid,HouseInfo[h][i_X],HouseInfo[h][i_Y],HouseInfo[h][i_Z],10) == 1)
						{
						if(GetPlayerVirtualWorld(playerid) == HouseInfo[h][WiW])
						    {
							SetPlayerPos(playerid,HouseInfo[h][p_X],HouseInfo[h][p_Y],HouseInfo[h][p_Z]);
							SetPlayerInterior(playerid,0);
							SetPlayerVirtualWorld(playerid, 0);
  		        	}
				}
  			}
   		}
	return 1;
}
//==============================================================================
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	for(new h=0;h<HouseCount;h++)
		{
		if(dialogid == HouseInfo[h][Dialog])
			{
			if(response == 1)
				{
				if(listitem == 0)
					{
								if(GetPlayerMoney(playerid) <= HouseInfo[h][Cena]) return SendClientMessage(playerid, 0xFFFFFFFF, "Mбљ mбlo peněz !");
								if(HouseInfo[h][Vlastnik] == 1) return SendClientMessage(playerid, 0xFFFFFFFF, "Tento dům jiћ někdo vlastnн !");
								HouseInfo[h][Vlastnik] = 1;
								MajitelDomu[h][playerid] = 1;
								GivePlayerMoney(playerid, -HouseInfo[h][Cena]);
								SendClientMessage(playerid, 0xFFFFFFFF, "Pořidil jsi si dům !");
							}
						else if(listitem == 1)
							{
							    new cena[150];
								if(MajitelDomu[h][playerid] == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Tento dům nenн tvůj !");
								HouseInfo[h][Vlastnik] = 0;
								MajitelDomu[h][playerid] = 0;
								GivePlayerMoney(playerid, HouseInfo[h][Cena]);
								format(cena, sizeof(cena), "Dům prodбn, bylo ti vrбceno zpět %d$ !",HouseInfo[h][Cena]);
								SendClientMessage(playerid, 0xFFFFFFFF, cena);
							}
						else if(listitem == 2)
							{
								if(MajitelDomu[h][playerid] == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Tento dům nenн tvůj !");
								HouseInfo[h][Zamek] = 0;
								SendClientMessage(playerid, 0xFFFFFFFF, "Dům zamknut !");
							}
						else if(listitem == 3)
							{
								if(MajitelDomu[h][playerid] == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Tento dům nenн tvůj !");
								SendClientMessage(playerid, 0xFFFFFFFF, "Dům odemknut !");
								HouseInfo[h][Zamek] = 1;
							}
						else if(listitem == 4)
							{
								SendClientMessage(playerid, 0xFFFFFFFF, "Informace o domu:");
								if(HouseInfo[h][Zamek] == 0)
									{
								 		SendClientMessage(playerid,0xFFFFFFFF,"Zбmek: Zamknutэ.");
								 		}else{
								 		SendClientMessage(playerid,0xFFFFFFFF,"Zбmek: Odemknutэ.");
									}
								if (HouseInfo[h][Vlastnik] == 0)
									{
								 		SendClientMessage(playerid,0xFFFFFFFF,"K Prodeji: Ano");
								 		}else{
								 		SendClientMessage(playerid,0xFFFFFFFF,"K Prodeji: Ne");
									}
							}
						else if(listitem == 5)
							{
					 			if(MajitelDomu[h][playerid] == 1)
								{
									SetPlayerPos(playerid, HouseInfo[h][i_X],HouseInfo[h][i_Y],HouseInfo[h][i_Z]);
									SetPlayerInterior(playerid, HouseInfo[h][iin]);
									SetPlayerVirtualWorld(playerid, HouseInfo[h][WiW]);
									SendDrawMessage(playerid, "Dum opustis ~r~L.ALT~w~ + ~r~Mezernik~w~ !");
									return 0;
								}
								else if(HouseInfo[h][Zamek] == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Tento dům je zamknut !");
								SetPlayerPos(playerid, HouseInfo[h][i_X],HouseInfo[h][i_Y],HouseInfo[h][i_Z]);
								SetPlayerInterior(playerid, HouseInfo[h][iin]);
								SetPlayerVirtualWorld(playerid, HouseInfo[h][WiW]);
								SendDrawMessage(playerid, "Dum opustis ~r~L.ALT~w~ + ~r~Mezernik~w~ !");
							}
						else if(listitem == 6)
							{
							    if(MajitelDomu[h][playerid] == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Tento dům nenн tvůj !");
                                ShowPlayerDialog(playerid,HouseInfo[h][auto_dialog],DIALOG_STYLE_LIST,"Koupit auto k domu","Admiral - 200$\nPCJ-600 - 150$\nTornado - 350$\nGreenwood - 250$\nHustler - 130$\nClover - 150$","Koupit","Nic");
						}
					}
				}
		if(dialogid == HouseInfo[h][auto_dialog])
			{
			if(response == 1)
				{
				if(listitem == 0)
					{
						if(GetPlayerMoney(playerid) < 200) return SendClientMessage(playerid, 0xFFFFFFFF, "Potřebujeљ 200$ !");
						DestroyVehicle(AutoDomu[h]);
						AutoDomu[h] = AddStaticVehicle(445,HouseInfo[h][auto_x],HouseInfo[h][auto_z],HouseInfo[h][auto_z],HouseInfo[h][auto_face],35,35);
					}
				else if(listitem == 1)
					{
						if(GetPlayerMoney(playerid) < 150) return SendClientMessage(playerid, 0xFFFFFFFF, "Potřebujeљ 150$ !");
						DestroyVehicle(AutoDomu[h]);
						AutoDomu[h] = AddStaticVehicle(522,HouseInfo[h][auto_x],HouseInfo[h][auto_z],HouseInfo[h][auto_z],HouseInfo[h][auto_face],35,35);
					}
				else if(listitem == 2)
					{
						if(GetPlayerMoney(playerid) < 350) return SendClientMessage(playerid, 0xFFFFFFFF, "Potřebujeљ 350$ !");
						DestroyVehicle(AutoDomu[h]);
						AutoDomu[h] = AddStaticVehicle(576,HouseInfo[h][auto_x],HouseInfo[h][auto_z],HouseInfo[h][auto_z],HouseInfo[h][auto_face],35,35);
					}
				else if(listitem == 3)
					{
						if(GetPlayerMoney(playerid) < 250) return SendClientMessage(playerid, 0xFFFFFFFF, "Potřebujeљ 250$ !");
						DestroyVehicle(AutoDomu[h]);
						AutoDomu[h] = AddStaticVehicle(492,HouseInfo[h][auto_x],HouseInfo[h][auto_z],HouseInfo[h][auto_z],HouseInfo[h][auto_face],35,35);
					}
				else if(listitem == 4)
					{
						if(GetPlayerMoney(playerid) < 130) return SendClientMessage(playerid, 0xFFFFFFFF, "Potřebujeљ 130$ !");
						DestroyVehicle(AutoDomu[h]);
						AutoDomu[h] = AddStaticVehicle(545,HouseInfo[h][auto_x],HouseInfo[h][auto_z],HouseInfo[h][auto_z],HouseInfo[h][auto_face],35,35);
					}
                else if(listitem == 5)
					{
						if(GetPlayerMoney(playerid) < 150) return SendClientMessage(playerid, 0xFFFFFFFF, "Potřebujeљ 150$ !");
						DestroyVehicle(AutoDomu[h]);
						AutoDomu[h] = AddStaticVehicle(542,HouseInfo[h][auto_x],HouseInfo[h][auto_z],HouseInfo[h][auto_z],HouseInfo[h][auto_face],122,113);
					}
				}
			}
		}
 	return 1;
}
Reply
#2

Help me?
Reply
#3

Help me??
Reply
#4

English please.
Reply
#5

I fixed topic
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)