[Help] Limited Time House
#1

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

PHP код:
CMD:buyhouse(playeridparams[])
{
    new
        
string[128]
    ;
    new 
h_ID[playerid];
    if(
== -1) return SendClientMessage(playeridCOLOR_RED"[ERROR] "white"You are not near any house.");
    if(
IsPlayerInRangeOfPoint(playerid1.5hInfo[i][hPickupP][0], hInfo[i][hPickupP][1], hInfo[i][hPickupP][2]))
    {
        if(
hInfo[i][hSale] == 1) return SendClientMessage(playeridCOLOR_RED"[ERROR] "white"This house isn't for sale.");
        if(
GetPlayerMoney(playerid) < hInfo[i][hPrice]) return SendClientMessage(playeridCOLOR_RED"[ERROR] "white" You don't have enough money to buy this house!");
        if(
GetPlayerScore(playerid) < hInfo[i][hLevel]) return SendClientMessage(playeridCOLOR_RED"[ERROR] "white" You don't have enough score to buy this house!");
        if(
jpInfo[playerid][OwnedHouses] == 1) return SendClientMessage(playeridCOLOR_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(string128"You have bought this house for $%d."hInfo[i][hPrice]);
        
SendClientMessage(playeridCOLOR_YELLOWstring);
        
SaveHouse(i);
        
DestroyDynamicCP(hInfo[i][hCP]);
        
DestroyDynamicPickup(hInfo[i][hPickup]);
        
DestroyDynamicMapIcon(hInfo[i][hMapIcon]);
        
DestroyDynamic3DTextLabel(hInfo[i][hLabel]);
        
LoadHouse(i);
    }
    else
    {
        
SendClientMessage(playeridCOLOR_RED"[ERROR] "white"You are not near any house.");
    }
    return 
1;

PHP код:
CMD:addhouse(playeridparams[])
{
    
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"hidlevelpriceworldinterior)) return SendClientMessage(playeridCOLOR_YELLOW"USAGE: /addhouse <houseid> <level> <price> <world> <interiorid(0-12)>");
        if(
hid || hid MAX_HOUSES) return SendClientMessage(playeridCOLOR_RED"[ERROR] "white"Do not exceed the house limitations of JakHouse.");
        if(
interior || interior 12) return SendClientMessage(playeridCOLOR_RED"[ERROR] "white"Do not exceed the interior limitations of JakHouse.");
        if(
level 0) return SendClientMessage(playeridCOLOR_RED"[ERROR] "white"Level Requirements shouldn't go below under 0.");
        if(
fexist(HousePath(hid))) return SendClientMessage(playeridCOLOR_RED"[ERROR] "white"House Slot used.");
        
GetPlayerPos(playeridp_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(stringsizeof(string), "[HOUSE] "white"HouseID %d created, Price $%d, Level %d, Virtaul World %d"hidpricelevelworld);
        
SendClientMessage(playeridCOLOR_GREENstring);
        
format(stringsizeof(string), "House created under the interior %s (Int %d)"intInfo[interior][Name], interior);
        
SendClientMessage(playerid, -1string);
        
printf("...HouseID %d created - JakHouse log"hid);
    }
    else
    {
        
SendClientMessage(playerid, -1"» "red"You are not authorized to use this command.");
    }
    return 
1;

Now please tell me where and what to add in the code to have that function .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)