[HELP]Int selection system
#1

Hi guys,
I'm making an int selection system. In this system, when a player buy a house, they will be teleported to house ints, and he has a Button " Select". When select the int, his house will be with the interior that he selected.

But I have a problem. I don't know how to put the int in the house that player bought. That's some like GetPlayerHouseID, but I don't know how to make it. Can you help me?

Here is some script of the system:

Код:
if(strcmp(cmd, "/comprarcasa", true) == 0)
		{
		    if(IsPlayerConnected(playerid))
		    {
				new Float:oldposx, Float:oldposy, Float:oldposz;
				new playername[MAX_PLAYER_NAME];
				GetPlayerName(playerid, playername, sizeof(playername));
				GetPlayerPos(playerid, oldposx, oldposy, oldposz);
				for(new h = 0; h < sizeof(Houses); h++)
				{
					if(PlayerToPoint(2.0, playerid, Houses[h][EnterX], Houses[h][EnterY], Houses[h][EnterZ]) && Houses[h][Owned] == 0)
					{
					    if(Houses[h][HousePrice] == 0)
					    {
					        SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "*{FF0000} Erro:{FFFFFF} O preco da casa nao foi escolhido, poder nao ser para uso.");
							return 1;
					    }
						if(PlayerInfo[playerid][pHouseKey] != 255 && strcmp(playername, Houses[PlayerInfo[playerid][pHouseKey]][Owner], true) == 0)
						{
							SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "*{FF0000} Erro:{FFFFFF} Apenas poderas ter uma casa, para compares uma nova, teras que vernder a tua acutal primeiro.");
							return 1;
						}
						if(Houses[h][Owned] == 1)
						{
							SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "*{FF0000} Erro:{FFFFFF} Casa Jб tem Dono.");
							return 1;
						}
						if(GetPlayerEuros(playerid) >= Houses[h][HousePrice])
						{
						    if(PlayerInfo[playerid][pescritura] == 1)
					    	{
					    	    PlayerInfo[playerid][pescritura] = 0;
		      					PlayerInfo[playerid][pHouseKey] = h;
		      					PlayerInfo[playerid][pAluguer] = 0;
								Houses[h][Owned] = 1;
								Houses[h][Money] = 0;
								strmid(Houses[h][Owner], playername, 0, strlen(playername), 255);
								GivePlayerEuros(playerid,-Houses[h][HousePrice]);
								TextDrawShowForPlayer(playerid, HouseInt[playerid][3]);
								TextDrawShowForPlayer(playerid, HouseInt[playerid][4]);
								TextDrawShowForPlayer(playerid, HouseInt[playerid][5]);
								TextDrawShowForPlayer(playerid, HouseInt[playerid][6]);
								TextDrawShowForPlayer(playerid, HouseInt[playerid][7]);
								TextDrawShowForPlayer(playerid, HouseInt[playerid][8]);
								TextDrawSetSelectable(HouseInt[playerid][5], 1);
								TextDrawSetSelectable(HouseInt[playerid][8], 1);
								SetPlayerPos(playerid,Houses[h][ExitX],Houses[h][ExitY],Houses[h][ExitZ]);
								SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "*{CCCC00} Info:{FFFFFF} Compraste com sucesso a tua casa!");
			       				PlayerActionMessage(playerid,15.0,"entrega uma mala cheia de dinheiro б agencia imobliaria, que dao em troca a chave da casa.");
								ChangeStreamPickupModel(Houses[h][PickupID],1239);
								SaveHouses();
								UpdateHouses(h);
								OnPlayerDataSave(playerid);
								return 1;
							}
							else
							{
								SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "Tens de tratar da papelada na camara municipal!");
								return 1;
							}
						}
						else
						{
							SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "*{FF0000} Erro:{FFFFFF} Nao tens dinheiro suficiente!");
							return 1;
						}
					}
				}
			}
			return 1;
		}

Код:
public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
	if(clickedid == HouseInt[playerid][5]
	{
		SetPlayerCameraPos(playerid, 125,125,125);
	    TextDrawHideForPlayer(playerid, HouseInt[playerid][2]);
	    TextDrawHideForPlayer(playerid, HouseInt[playerid][5]);
	    TextDrawHideForPlayer(playerid, HouseInt[playerid][8]);
		TextDrawShowForPlayer(playerid, HouseInt[playerid][9]);
		TextDrawShowForPlayer(playerid, HouseInt[playerid][10]);
		TextDrawShowForPlayer(playerid, HouseInt[playerid][11]);
	}
	if(clickedid == HouseInt[playerid][8]
	{
	    Houses[id][ExitX] = 223.043991;
		Houses[id][ExitY] = 1289.259888;
		Houses[id][ExitZ] = 1082.199951;
		Houses[id][ExitInterior] = 1;

        }
	
	return 1;
}
PS: Sorry for my bad English.
Reply
#2

"House" aren't real samp instances (unlike objects, pickups, vehicles or players). It means that all the functions about houses can be written by the scripter using the pawn functions SAMP provides.

In your case, you have to create the houses yourself using a pickup (most common usage) and assigning each pickup to a house id through an enum (again, most common usage).

Here's an example of what you should do

pawn Код:
#include <YSI\y_iterate>

#define MAX_HOUSES 250

enum hInfo
{
      hOwner[MAX_PLAYER_NAME+1],
      hInterior,
      hWorld,
      Float:hEntrancex,
      Float:hEntrancey,
      Float:hEntrancez,
      hPickup,
};

new HouseInfo[MAX_HOUSES][hInfo];

new Iterator:Houses<MAX_HOUSES>;

stock House_Create(Float:x, Float:y, Float:z, ownerid)
{
      new id = Iter_Last(Houses);
      GetPlayerName(ownerid, HouseInfo[id][hOwner], MAX_PLAYER_NAME+1);
      HouseInfo[id][hEntrancex] = x;
      HouseInfo[id][hEntrancey] = y;
      HouseInfo[id][hEntrancez] = z;
      HouseInfo[id][hPickup] = CreatePickup(1273, x, y, z, -1);
      Iter_Add(Houses, id);
      return 1;
}

stock House_SetInterior(houseid, interior)
{
      HouseInfo[houseid][hInterior] = interior;
      return 1;
}

stock House_EnterPlayer(houseid, playerid)
{
      SetPlayerPos(playerid, HouseInfo[houseid][hEntrancex], HouseInfo[houseid][hEntrancey], HouseInfo[houseid][hEntrancez]);
      SetPlayerInterior(playerid, HouseInfo[houseid][hInterior]);
      SetPlayerVirtualWorld(playerid, HouseInfo[houseid][hWorld]);
      return 1;
}

stock House_SetWorld(houseid, worldid)
{
      HouseInfo[houseid][hWorld] = worldid;
      return 1;
}
Consider this code as a "bare house system".
Reply
#3

I have that. What I want is the function to, when the player select the Button "Select", his house be with the int that he selected...
Reply
#4

please guys help me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)