29.12.2014, 03:52
Hello , i want a function in my server that when a player buy a house he/she owned that house only for 10 days and after 10 days the house again set for sale .
Following is my commands
Now please tell me where and what to add in the code to have that function .
Following is my commands
PHP код:
CMD:buyhouse(playerid, params[])
{
new
string[128]
;
new i = h_ID[playerid];
if(i == -1) return SendClientMessage(playerid, COLOR_RED, "[ERROR] "white"You are not near any house.");
if(IsPlayerInRangeOfPoint(playerid, 1.5, hInfo[i][hPickupP][0], hInfo[i][hPickupP][1], hInfo[i][hPickupP][2]))
{
if(hInfo[i][hSale] == 1) return SendClientMessage(playerid, COLOR_RED, "[ERROR] "white"This house isn't for sale.");
if(GetPlayerMoney(playerid) < hInfo[i][hPrice]) return SendClientMessage(playerid, COLOR_RED, "[ERROR] "white" You don't have enough money to buy this house!");
if(GetPlayerScore(playerid) < hInfo[i][hLevel]) return SendClientMessage(playerid, COLOR_RED, "[ERROR] "white" You don't have enough score to buy this house!");
if(jpInfo[playerid][OwnedHouses] == 1) return SendClientMessage(playerid, COLOR_RED, "[ERROR] "white" You already owned a house, You can't buy another one.");
jpInfo[playerid][OwnedHouses] = 1;
jpInfo[playerid][p_SpawnPoint][0] = hInfo[i][hEnterPos][0];
jpInfo[playerid][p_SpawnPoint][1] = hInfo[i][hEnterPos][1];
jpInfo[playerid][p_SpawnPoint][2] = hInfo[i][hEnterPos][2];
jpInfo[playerid][p_SpawnPoint][3] = hInfo[i][hEnterPos][3];
jpInfo[playerid][p_Interior] = hInfo[i][hInterior];
hInfo[i][hSale] = 1;
hInfo[i][hLocked] = 0;
format(hInfo[i][hOwner], 256, "%s", p_Name(playerid));
GivePlayerCash(playerid, -hInfo[i][hPrice]);
format(string, 128, "You have bought this house for $%d.", hInfo[i][hPrice]);
SendClientMessage(playerid, COLOR_YELLOW, string);
SaveHouse(i);
DestroyDynamicCP(hInfo[i][hCP]);
DestroyDynamicPickup(hInfo[i][hPickup]);
DestroyDynamicMapIcon(hInfo[i][hMapIcon]);
DestroyDynamic3DTextLabel(hInfo[i][hLabel]);
LoadHouse(i);
}
else
{
SendClientMessage(playerid, COLOR_RED, "[ERROR] "white"You are not near any house.");
}
return 1;
}
PHP код:
CMD:addhouse(playerid, params[])
{
LoginCheck(playerid);
SpawnCheck(playerid);
if(User[playerid][accountAdmin] >= 4)
{
new
string[250],
hid,
price,
world,
level,
interior,
Float:p_Pos[3]
;
if(sscanf(params, "iiiii", hid, level, price, world, interior)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /addhouse <houseid> <level> <price> <world> <interiorid(0-12)>");
if(hid < 0 || hid > MAX_HOUSES) return SendClientMessage(playerid, COLOR_RED, "[ERROR] "white"Do not exceed the house limitations of JakHouse.");
if(interior < 0 || interior > 12) return SendClientMessage(playerid, COLOR_RED, "[ERROR] "white"Do not exceed the interior limitations of JakHouse.");
if(level < 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR] "white"Level Requirements shouldn't go below under 0.");
if(fexist(HousePath(hid))) return SendClientMessage(playerid, COLOR_RED, "[ERROR] "white"House Slot used.");
GetPlayerPos(playerid, p_Pos[0], p_Pos[1], p_Pos[2]);
format(hInfo[hid][hName], 256, "None");
format(hInfo[hid][hOwner], 256, "None");
hInfo[hid][hLevel] = level;
hInfo[hid][hPrice] = price;
hInfo[hid][hSale] = 0;
hInfo[hid][hInterior] = intInfo[interior][i_Int];
hInfo[hid][hWorld] = world;
hInfo[hid][hLocked] = 1;
hInfo[hid][hEnterPos][0] = intInfo[interior][SpawnPointX];
hInfo[hid][hEnterPos][1] = intInfo[interior][SpawnPointY];
hInfo[hid][hEnterPos][2] = intInfo[interior][SpawnPointZ];
hInfo[hid][hEnterPos][3] = intInfo[interior][SpawnPointA];
hInfo[hid][hPickupP][0] = p_Pos[0];
hInfo[hid][hPickupP][1] = p_Pos[1];
hInfo[hid][hPickupP][2] = p_Pos[2];
hInfo[hid][ExitCPPos][0] = intInfo[interior][ExitPointX];
hInfo[hid][ExitCPPos][1] = intInfo[interior][ExitPointY];
hInfo[hid][ExitCPPos][2] = intInfo[interior][ExitPointZ];
format(hInfo[hid][hIName], 256, "%s", intInfo[interior][Name]);
format(hInfo[hid][hNotes], 256, "None");
hInfo[hid][MoneyStore] = 0;
dini_Create(HousePath(hid));
SaveHouse(hid);
DestroyDynamicCP(hInfo[hid][hCP]);
DestroyDynamicPickup(hInfo[hid][hPickup]);
DestroyDynamicMapIcon(hInfo[hid][hMapIcon]);
DestroyDynamic3DTextLabel(hInfo[hid][hLabel]);
LoadHouse(hid);
format(string, sizeof(string), "[HOUSE] "white"HouseID %d created, Price $%d, Level %d, Virtaul World %d", hid, price, level, world);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string, sizeof(string), "House created under the interior %s (Int %d)", intInfo[interior][Name], interior);
SendClientMessage(playerid, -1, string);
printf("...HouseID %d created - JakHouse log", hid);
}
else
{
SendClientMessage(playerid, -1, "» "red"You are not authorized to use this command.");
}
return 1;
}