Advertisement
Cobertozinho

Sistema de House Feito Por:[HiC] TheKiller e Traduzido: Mim

Jun 22nd, 2011
526
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.11 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dini>
  3. #define MAX_HOUSES 200
  4. #define house "/houses/Owners.ini"
  5. #pragma unused strtok
  6.  
  7. enum houseinfo
  8. {
  9.     HouseNames[60], //To save into the file
  10.     HouseCost, //The house cost
  11.     HouseOwner[24], // The house owners Name
  12.     Float:PickupX, // PickupX
  13.     Float:PickupY, //PickupY
  14.     Float:PickupZ, //PickupZ
  15.     Float:TeleX, //The house location
  16.     Float:TeleY, //The house location
  17.     Float:TeleZ, //The house location
  18.     Interior, //The house Interior
  19.     HouseSell, //House sell price
  20.     Owned,
  21.     Virtual
  22. }
  23.  
  24. new HouseInfo[MAX_HOUSES][houseinfo]; //It saves all the info in this variable.
  25. new HouseCount = -1; //House count
  26. new PickupID[MAX_HOUSES];
  27. new InHouse[MAX_PLAYERS] = -1;
  28.  
  29. stock CreateHouse(Filename[], Cost, Float:Pickupx, Float:Pickupy, Float:Pickupz, Float:Telex, Float:Teley, Float:Telez, interior, sell)
  30. {
  31.     if(!dini_Exists(house))
  32.     {
  33.         dini_Create(house);
  34.     }
  35.     HouseCount ++;
  36.     new ID = HouseCount; //HouseID
  37.     format(HouseInfo[ID][HouseNames], 60, "%s", Filename); //Saves the HouseName into a variable
  38.     HouseInfo[ID][HouseCost] = Cost;
  39.     HouseInfo[ID][PickupX] = Pickupx;
  40.     HouseInfo[ID][Virtual] = 2000000 + ID;
  41.     HouseInfo[ID][PickupY] = Pickupy;
  42.     HouseInfo[ID][PickupZ] = Pickupz;
  43.     HouseInfo[ID][TeleX] = Telex;
  44.     HouseInfo[ID][TeleY] = Teley;
  45.     HouseInfo[ID][TeleZ] = Telez;
  46.     HouseInfo[ID][Interior] = interior;
  47.     HouseInfo[ID][HouseSell] = sell;
  48.     format(HouseInfo[ID][HouseOwner], 24, "gj9043jg-er((23");
  49.     if(strlen(dini_Get(house, Filename))) //This is to see if there is any owner.
  50.     {
  51.     format(HouseInfo[ID][HouseOwner], 24, "%s", dini_Get(house, Filename));
  52.     HouseInfo[ID][Owned] = 1;
  53.     }
  54.     PickupID[ID] = CreatePickup(1273, 23, Pickupx, Pickupy, Pickupz, -1); //Creates the pickup :).
  55.     Create3DTextLabel("House", 0x00A0F6AA, Pickupx, Pickupy, Pickupz + 0.75, 15.0, 0, 1);
  56. }
  57. public OnFilterScriptInit()
  58. {
  59.     print("====================================================");
  60.     printf("Property Error: You forgot to give property #%d a name!");
  61.     print("        This property will not be created           ");
  62.     print("====================================================");
  63.     CreateHouse("TestHouse1", 1, 2317.130615, 692.398498, 11.460937, 266.857757, 305.001586, 999.148437, 2, 1);
  64.     return 1;
  65. }
  66.  
  67. public OnFilterScriptExit()
  68. {
  69.     return 1;
  70. }
  71.  
  72. public OnPlayerPickUpPickup(playerid, pickupid) //Pickup callback
  73. {
  74.   for(new J; J<MAX_HOUSES; J++) //Loops through all houses
  75.   {
  76.     if(pickupid == PickupID[J]) //If the pickupid is one of our house ones
  77.     {
  78.       new str[75];
  79.       if(HouseInfo[J][Owned] == 1)
  80.       {
  81.         format(str, sizeof(str), "~r~Casa Info~n~~g~Dono: ~w~%s", HouseInfo[J][HouseOwner]);
  82.       }
  83.       if(HouseInfo[J][Owned] == 0)
  84.       {
  85.         format(str, sizeof(str), "~r~Casa Info~n~~g~Dono: ~w~Sem dono");
  86.         SendClientMessage(playerid, 0x67F6F6AA, "Esta casa está à venda! Use /comprar para comprá-la");
  87.       }
  88.       new str2[100];
  89.       format(str2, sizeof(str2), "~g~Preço de Compra:~w~ %d ~n~~g~Preço de Venda:~w~ %d", HouseInfo[J][HouseCost], HouseInfo[J][HouseSell]);
  90.       new str3[175];
  91.       format(str3, sizeof(str3), "%s~n~%s", str, str2);
  92.       GameTextForPlayer(playerid, str3, 3500, 3);
  93.       return 1;
  94.     }
  95.   }
  96.   return 1;
  97. }
  98. public OnPlayerCommandText(playerid, cmdtext[])
  99. {
  100.     if (strcmp("/comprarcasa", cmdtext, true, 10) == 0)
  101.     {
  102.     for(new i; i<MAX_HOUSES; i++)
  103.     {
  104.     if(!IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][PickupX], HouseInfo[i][PickupY], HouseInfo[i][PickupZ])) continue;
  105.  
  106.     new Pname[24]; GetPlayerName(playerid, Pname, 24);
  107.     for(new S; S<MAX_HOUSES; S++)
  108.     {
  109.     if(!strcmp(dini_Get("Owned.ini", HouseInfo[S][HouseNames]), Pname)) return SendClientMessage(playerid, 0xF60000AA, "Você já tem uma casa!");
  110.     }
  111.     if(GetPlayerMoney(playerid) < HouseInfo[i][HouseCost]) return SendClientMessage(playerid, 0xF60000AA, "Você não tem dinheiro suficiente para comprar esta casa");
  112.     if(HouseInfo[i][Owned] == 1) return SendClientMessage(playerid, 0xF60000AA, "Esta casa já Tem Proprietario");
  113.     GivePlayerMoney(playerid, - HouseInfo[i][HouseCost]);
  114.     GameTextForPlayer(playerid, "~r~Casa Comprada", 2000, 3);
  115.     HouseInfo[i][Owned] = 1;
  116.     GetPlayerName(playerid, Pname, 24);
  117.     format(HouseInfo[i][HouseOwner], 24, "%s", Pname);
  118.     dini_Set(house, HouseInfo[i][HouseNames], Pname);
  119.     return 1;
  120.     }
  121.     SendClientMessage(playerid, 0xF60000AA, "Você não está perto o suficiente de uma casa");
  122.     return 1;
  123.   }
  124.     if (strcmp("/vendercasa", cmdtext, true, 10) == 0)
  125.     {
  126.     for(new i; i<MAX_HOUSES; i++)
  127.     {
  128.     if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][PickupX], HouseInfo[i][PickupY], HouseInfo[i][PickupZ]))
  129.     {
  130.     new Pname[24]; GetPlayerName(playerid, Pname, 24);
  131.     if(strcmp(Pname, HouseInfo[i][HouseOwner])) return SendClientMessage(playerid, 0xF60000AA, "Você não possui esta casa!");
  132.     GivePlayerMoney(playerid, HouseInfo[i][HouseSell]);
  133.     GameTextForPlayer(playerid, "~r~Casa Vendida!", 2000, 3);
  134.     HouseInfo[i][Owned] = 0;
  135.     format(HouseInfo[i][HouseOwner], 24, "0943jt3u9*egjlfd");
  136.     dini_Unset(house, HouseInfo[i][HouseNames]);
  137.     return 1;
  138.     }
  139.     }
  140.     SendClientMessage(playerid, 0xF60000AA, "Você não está perto o suficiente de uma casa");
  141.     return 1;
  142.   }
  143.     if (strcmp("/entrarcasa", cmdtext, true, 10) == 0)
  144.     {
  145.     for(new i; i<MAX_HOUSES; i++)
  146.     {
  147.     if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][PickupX], HouseInfo[i][PickupY], HouseInfo[i][PickupZ]))
  148.     {
  149.     new Pname[24]; GetPlayerName(playerid, Pname, 24);
  150.     if(strcmp(Pname, HouseInfo[i][HouseOwner])) return SendClientMessage(playerid, 0xF60000AA, "Você não possui esta casa!");
  151.     SetPlayerPos(playerid, HouseInfo[i][TeleX], HouseInfo[i][TeleY], HouseInfo[i][TeleZ]);
  152.     SetPlayerInterior(playerid, HouseInfo[i][Interior]);
  153.     InHouse[playerid] = i;
  154.     SetPlayerVirtualWorld(playerid, HouseInfo[i][Virtual]);
  155.     SendClientMessage(playerid, 0x00C4F6AA, "Você Entrou na sua casa");
  156.     return 1;
  157.     }
  158.     }
  159.     SendClientMessage(playerid, 0xF60000AA, "Você não está perto o suficiente de uma casa");
  160.     return 1;
  161.   }
  162.     if (strcmp("/saircasa", cmdtext, true, 10) == 0)
  163.   {
  164.     if(InHouse[playerid] == -1) return SendClientMessage(playerid, 0xF60000AA, "Você não está em uma casa");
  165.     SetPlayerPos(playerid, HouseInfo[InHouse[playerid]][PickupX], HouseInfo[InHouse[playerid]][PickupY], HouseInfo[InHouse[playerid]][PickupZ]);
  166.     SetPlayerInterior(playerid, 0);
  167.     SetPlayerVirtualWorld(playerid, 0);
  168.     SendClientMessage(playerid, 0x00C4F6AA, "Voçê saiu da sua casa");
  169.     InHouse[playerid] = -1;
  170.     return 1;
  171.   }
  172.     return 0;
  173. }
  174. strtok(const string[], &index)
  175. {
  176.     new length = strlen(string);
  177.     while ((index < length) && (string[index] <= ' '))
  178.     {
  179.         index++;
  180.     }
  181.  
  182.     new offset = index;
  183.     new result[20];
  184.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  185.     {
  186.         result[index - offset] = string[index];
  187.         index++;
  188.     }
  189.     result[index - offset] = EOS;
  190.     return result;
  191. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement