Stefantjuh97

sds

Dec 8th, 2012
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.53 KB | None | 0 0
  1. command(buyproperty, playerid, params[])
  2. {
  3.     if(IsPlayerInRangeOfPoint(playerid, 6, 355.0121,171.4519,1025.7891))
  4.     {
  5.         new Usage[128], Address[128], string[128];
  6.         if(sscanf(params, "sz", Usage, Address))
  7.         {
  8.             SendClientMessage(playerid, WHITE, "SYNTAX: /buyproperty [usage] [address]");
  9.             SendClientMessage(playerid, GREY, "Usage: House, Business");
  10.         }
  11.         else
  12.         {
  13.             if(strcmp(Usage, "house", true) == 0)
  14.             {
  15.                 if(Player[playerid][House] == 0)
  16.                 {
  17.                     for(new h = 0; h < sizeof(Houses); h++)
  18.                     {
  19.                         if(!strcmp(Houses[h][hAddress], Address, true))
  20.                         {
  21.                             if(strcmp(Houses[h][hOwner], "Nobody", true) == 0)
  22.                             {
  23.                                 if(Houses[h][HousePrice] == -1)
  24.                                 {
  25.                                     SendClientMessage(playerid, WHITE, "This house isn't purchasable.");
  26.                                 }
  27.                                 else
  28.                                 {
  29.                                     if(Player[playerid][Hotel] == 0)
  30.                                     {
  31.                                         if(Player[playerid][Money] >= Houses[h][HousePrice])
  32.                                         {
  33.                                             Player[playerid][Money] -= Houses[h][HousePrice];
  34.                                             GivePlayerMoney(playerid, -Houses[h][HousePrice]);
  35.                                             format(Houses[h][hOwner], 128, "%s", GetName(playerid));
  36.                                             format(string, sizeof(string), "You bought the house with address %s for $%d.", Address, Houses[h][HousePrice]);
  37.                                             SendClientMessage(playerid, ADMINBLUE, string);
  38.                                             Player[playerid][House] = h;
  39.                                             DestroyDynamicPickup(Houses[h][HPickupID]);
  40.                                             Houses[h][HPickupID] = CreateDynamicPickup(1318, 23, Houses[h][hExteriorX], Houses[h][hExteriorY], Houses[h][hExteriorZ], 0, -1, -1, 150.0);
  41.                                             SaveHouse(h);
  42.                                             SavePlayerData(playerid);
  43.                                         }
  44.                                         else
  45.                                         {
  46.                                             SendClientMessage(playerid, WHITE, "You do not have enough money to purchase this house.");
  47.                                         }
  48.                                     }
  49.                                     else
  50.                                     {
  51.                                         SCM(playerid, RED, "You already live in a hotel");
  52.                                     }
  53.                                 }
  54.                             }
  55.                             else
  56.                             {
  57.                                 SendClientMessage(playerid, WHITE, "Sorry, this house is already bought!");
  58.                             }
  59.                         }
  60.                         else
  61.                         {
  62.                             SendClientMessage(playerid, WHITE, "Sorry, but this address is not correct.");
  63.                         }
  64.                     }
  65.                 }
  66.                 else
  67.                 {
  68.                     SendClientMessage(playerid, WHITE, "You already have a house, type /sellproperty house.");
  69.                 }
  70.             }
  71.         }
  72.     }
  73.     else
  74.     {
  75.         SCM(playerid, WHITE, "You are not at the property office");
  76.     }
  77.     return 1;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment