One House Per Player
#1

Can anyone help me

I want to make just one house per player. In my server player buy a house as they can so i want one house per player anyone can help me?

Код:
enum hInfo
{
	Owner[MAX_PLAYER_NAME],
	Price,
	Interior,
	Exterior,
	VirtualWorld, // Useful for making 2 houses with the same interior
	Locked,
	Float:InteriorX,
	Float:InteriorY,
	Float:InteriorZ,
	Float:ExteriorX,
	Float:ExteriorY,
	Float:ExteriorZ,
	// Storage
	Money,
	Weapon[13],
	Ammo[13],
	// Furniture
	FCount,
	FModel[MAX_FURNITURE],
	FurnitureObj[MAX_FURNITURE],
	Float:FPosX[MAX_FURNITURE],
	Float:FPosY[MAX_FURNITURE],
	Float:FPosZ[MAX_FURNITURE],
	Float:FRotX[MAX_FURNITURE],
	Float:FRotY[MAX_FURNITURE],
	Float:FRotZ[MAX_FURNITURE]
};
Код:
stock BuyHouse(playerid, houseid)
{
	new string[64];
	new name[24];
	GetPlayerName(playerid, name, 24);
	GivePlayerMoney(playerid, -HouseInfo[houseid][Price]);
	format(HouseInfo[houseid][Owner], 24, name);
	HouseInfo[houseid][Locked] = 0;
	format(string, 64, HOUSE_FILE, houseid);
	INI_Open(string);
	INI_WriteString("Owner", HouseInfo[houseid][Owner]);
	INI_WriteInt("Locked", HouseInfo[houseid][Locked]);
	INI_Save();
	INI_Close();

	DestroyDynamicPickup(HousePickup[houseid]);
	HousePickup[houseid] = CreateDynamicPickup(19522, 23, HouseInfo[houseid][ExteriorX], HouseInfo[houseid][ExteriorY], HouseInfo[houseid][ExteriorZ]);
	#if MAP_ICONS == 1
	DestroyDynamicMapIcon(HouseIcon[houseid]);
	HouseIcon[houseid] = CreateDynamicMapIcon(HouseInfo[houseid][ExteriorX], HouseInfo[houseid][ExteriorY], HouseInfo[houseid][ExteriorZ], 32, 0, _, _, _, 800.0);
	#endif

	#if CONSOLE == 1
	printf("Player %s(%d) bought house ID %d.", name, playerid, houseid);
	#endif
	FS_MsgBox(playerid, "{33AA33}ACTION", "You bought this house.");
	return 1;
}
Anyone :3
Reply
#2

Just add in your PlayerInfo a variable which marks if the player owns a house or not
PHP код:
// pInfo
    
House,
//BuyHouse
    
if(GetPlayerMoney(playerid) > HouseInfo[houseid][Price]) { // guess you forgot that
        
return SendClientMessage(playerid, -1"You don't have enough money!");
    }
    if(
PlayerInfo[playerid][House] != -1) {
        return 
SendClientMessage(playerid, -1"You already own a house!");
    }
    
PlayerInfo[playerid][House] = houseid;
//SellHouse
    
if(PlayerInfo[playerid][House] == -1) {
        return 
SendClientMessage(playerid, -1"You don't own a house!");
    }
    
PlayerInfo[playerid][House] = -1;
//At register
    
PlayerInfo[playerid][House] = -1// or any other invalid id
// at login, load variable from file
// at disconnect, save variable to file 
I think that's enough help, the rest is up to you
Reply
#3

Add a check in the command whether a player owns a house or not. If the player owns a house, return a message or something. If the player doesn't own a house, then continue. Maybe add a new variable with the owner ID and store it, so it's easier to check.
Reply
#4

This filterscript is from sasinosoft house system.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)