25.02.2013, 11:35
I got this
And i got this in /buyhouse command
What I want to do is when player buys the house it updates the labeltext from for sale to owned ... Can you guys help me do this ?
pawn Код:
for(new h = 0; h < sizeof(HouseInfo); h++)
{
if(HouseInfo[h][hOwned] == 0)
{
new string[140];
format(string, 128, "%s\n Owner: %s\n Price: %d$\n LS Time: %d",HouseInfo[h][hDiscription],HouseInfo[h][hOwner], HouseInfo[h][hValue],HouseInfo[h][hLevel]);
Create3DTextLabel(string, 0x00AE00FF, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]+0.75, 25.0, 0);
//Create3DTextLabel("[Property]",0x00AE00FF,HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]+0.75, 25.0, 0);
HouseInfo[h][hPickupID]=CreateDynamicPickup(1273, 1, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]);
pickups++;
}
if(HouseInfo[h][hOwned] == 1)
{
if(HouseInfo[h][hRentabil] == 0)
{
new string[140];
format(string, 128, "%s\n Owner: %s",HouseInfo[h][hDiscription],HouseInfo[h][hOwner], HouseInfo[h][hValue],HouseInfo[h][hLevel]);
Create3DTextLabel(string, 0x00AE00FF, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]+0.75, 25.0, 0);
//Create3DTextLabel("[Property]",0x00AE00FF,HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]+0.75, 25.0, 0);
HouseInfo[h][hPickupID]=CreateDynamicPickup(1239, 1, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]);
pickups++;
}
else
{
new string[140];
format(string, 128, "%s\n Owner: %s\n Rentable: %d$ (/rentroom)",HouseInfo[h][hDiscription],HouseInfo[h][hOwner], HouseInfo[h][hRent]);
Create3DTextLabel(string, 0x00AE00FF, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]+0.75, 25.0, 0);
//Create3DTextLabel("[Property]",0x00AE00FF,HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]+0.75, 25.0, 0);
HouseInfo[h][hPickupID]=CreateDynamicPickup(1239, 1, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]);
pickups++;
}
}
}
And i got this in /buyhouse command
pawn Код:
{
new Float:oldposx, Float:oldposy, Float:oldposz;
GetPlayerName(playerid, playername, sizeof(playername));
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
for(new h = 0; h < sizeof(HouseInfo); h++)
{
if(PlayerToPoint(2.0, playerid, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]) && HouseInfo[h][hOwned] == 0)
{
if(PlayerInfo[playerid][pConnectTime] < HouseInfo[h][hLevel])
{
format(string, sizeof(string), " You must be ConnevtTime %d to purchase this !", HouseInfo[h][hLevel]);
SendClientMessage(playerid, COLOR_GRAD5, string);
return 1;
}
if(PlayerInfo[playerid][pHousekey] != 255 && strcmp(playername, HouseInfo[PlayerInfo[playerid][pHousekey]][hOwner], true) == 0)
{
SendClientMessage(playerid, COLOR_WHITE, " You already own a house, type /sellhouse if you want to buy this one !");
return 1;
}
if(GetPlayerPCash(playerid) >= HouseInfo[h][hValue])
{
PlayerInfo[playerid][pHousekey] = h;
HouseInfo[h][hOwned] = 1;
PlayerInfo2[HouseEntered][playerid] = h;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(HouseInfo[h][hOwner], sendername, 0, strlen(sendername), 255);
GivePlayerPCash(playerid,-HouseInfo[h][hValue]);
SetPlayerInterior(playerid,HouseInfo[h][hInt]);
SetPlayerVirtualWorld(playerid,h+100);
DOO_SetPlayerPos(playerid,HouseInfo[h][hExitx],HouseInfo[h][hExity],HouseInfo[h][hExitz]);
GameTextForPlayer(playerid, "~w~Welcome Home~n~You can exit at any time by moving to this door and typing /exit", 5000, 3);
PlayerInfo[playerid][pInt] = HouseInfo[h][hInt];
PlayerInfo[playerid][pLocal] = h;
DestroyDynamicPickup(HouseInfo[h][hPickupID]);
HouseInfo[h][hPickupID]=CreateDynamicPickup(1239, 1, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]);
SendClientMessage(playerid, COLOR_WHITE, "Congratulations, on your new Purchase !");
SendClientMessage(playerid, COLOR_WHITE, "Type /help to review the new property help section !");
PlayerInfo2[HouseEntered][playerid] = h;
OnPlayerDataSave(playerid);
PlayerPlayMusic(playerid);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_WHITE, " You don't have the cash for that !");
return 1;
}
}
}
}
return 1;
}