Advertisement
1PotH3Ad

Dynamic House System v0.7 - 7/12/14

Jul 8th, 2014
1,949
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 59.47 KB | None | 0 0
  1. #include <a_samp>
  2. #include <streamer>
  3. #include <sscanf2>
  4. #include <dini>
  5. #include <zcmd>
  6.  
  7. //=========[Internal Functions/Other]========
  8. #define BUILDINGHOUSE(%0) GetPVarInt(%0, "BuildingHouse")
  9. #define BUILDID(%0) GetPVarInt(%0, "BuildID")
  10. #define HOUSEID(%0) GetPVarInt(%0, "HouseID")
  11. //===========================
  12.  
  13. //=========[Internal Settings]========== [Don't not edit these unless you know what you are doing]
  14. //      [House Settings/Options]
  15. #define HOUSE_DIAG          5050    //Change if dialogs are interfering with another script
  16. #define MAX_HOUSES          30      //Important! - Change to total number of houses
  17. #define MAX_HOUSE_NAME      40      //Max house name
  18. #define MIN_PASS            3       //Minimum password length
  19. #define MAX_PASS            30      //Max password length
  20. #define RESPAWNTIME         1400    //Time until player is set in his house
  21. #define MAX_VEHICLE_SLOTS   3       //Max house vehicle slots per-player
  22.  
  23. //      [Model IDs]
  24. #define NOTFORSALE_PICKUP   1272
  25. #define FORSALE_PICKUP      1273
  26. #define NOTFORSALE_ICON     32
  27. #define FORSALE_ICON        31
  28. //      [Draw Distance]
  29. #define ICON_DRAW           150.0
  30. #define PICKUP_DRAW         30.0
  31. #define LABEL_DRAW          35.0
  32. #define ENTERCP_DRAW        15.0
  33. #define EXITCP_DRAW         15.0
  34. //      [Size]
  35. #define ENTERCP_SIZE        1.0
  36. #define EXITCP_SIZE         1.0
  37. //      [Properties]
  38. #define LABEL_LOS           1   //Labels show through objects? [1-Yes/0-No]
  39. //===========================
  40. #define LABEL_COLOR 0xFFFFFFF
  41. #define MSG_COLOR   0x37C83AFF
  42.  
  43. #define G>  009900  //Green
  44. #define R>  CC0000   //Red
  45. #define B>  0004B6  //Blue
  46. #define LB> 00EFFC  //Light Blue
  47. #define Y>  F8FF3D  //Yellow
  48. #define W>  FFFFFF //White
  49.  
  50. #define HOUSE_FILE  "/Houses/%d.ini"
  51. #define HUSER_FILE  "/Houses/users.ini"
  52.  
  53. new hfile[120];
  54. new hstr[800];
  55.  
  56. enum h_enum
  57. {
  58.     Name[MAX_HOUSE_NAME],
  59.     Owner[MAX_PLAYER_NAME],
  60.     Price,
  61.     ForSale,
  62.     Interior,
  63.     World,
  64.     Locked,
  65.     Float:EnterPos[4],
  66.     Float:ExitPos[4],
  67.     Float:SpawnPos[4],
  68.     Float:PickupPos[3],
  69.     Float:LabelPos[3],
  70.     Float:EnterCPPos[3],
  71.     Float:ExitCPPos[3],
  72.     Float:VehPos[4],
  73.     MapIcon,
  74.     Pickup,
  75.     Text3D:InfoLabel,
  76.     Text3D:NoticeLabel,
  77.     EnterCP,
  78.     ExitCP,
  79.     MoneyStash
  80. }
  81. new hInfo[MAX_HOUSES][h_enum];
  82.  
  83. enum h_veh
  84. {
  85.     Vehicle,
  86.     ModelID
  87. }
  88. new hVeh[MAX_HOUSES][MAX_VEHICLE_SLOTS][h_veh];
  89.  
  90. new Float:IntPos[37][3] = {
  91. {2450.071777, -1688.474609, 1013.507812}, //Ryder's House
  92. {1278.083740, -774.104187, 1091.906250}, //Madd Dogg's
  93. {2575.200683, -1281.903808, 1067.282348}, //Big Smoke's
  94. {2495.094238, -1697.413940, 1015.265625}, //CJ's House
  95. {2233.024414, -1106.857543, 1050.882812}, //Safe House 1
  96. {2193.356933, -1204.220092, 1049.513427}, //Safe House 2
  97. {2319.962158, -1024.064453, 1050.210937}, //Safe House 3
  98. {2263.350585, -1137.814697, 1050.632812}, //Safe House 4
  99. {2365.204589, -1131.669189, 1050.875000}, //Verdant Bluff safehouse
  100. {2283.675537, -1136.566406, 1050.898437}, //Willowfield Safehouse
  101. {2207.153320, -1075.087036, 1050.484375}, //Camel Toe Safehouse
  102. {2324.155273, -1184.790527, 1027.976562}, //Burning Desire
  103. {2808.903564, -1170.313354, 1025.570312}, //Colonel
  104. {-2162.869384, 643.826354, 1057.586059}, //Woozies Apt
  105. {-2646.922119, 1407.898681, 906.273437}, //Pleasure Dome
  106. {246.360671, 304.616027, 999.148437}, //Denise's
  107. {322.806274, 305.147125, 999.148437}, //Barbaras
  108. {269.487518, 306.877838, 1000.020385}, //Katies
  109. {306.081146, 306.673492, 1003.304687}, //Michelle's
  110. {347.518463, 307.700012, 999.148437}, //Millies
  111. {233.677841, 1193.183105, 1080.257812}, //Burglary 1
  112. {222.140792, 1241.278808, 1082.140625}, //Burglary 2
  113. {224.929153, 1291.060302, 1082.140625}, //Burglary 3
  114. {244.907913, 1115.963134, 1080.992187}, //Burglary 4
  115. {295.068664, 1480.463623, 1080.257812}, //Burglary 5
  116. {266.206146, 1287.478759, 1080.257812}, //Burglary 6
  117. {30.468364, 1350.344482, 1084.375000}, //Burglary 7
  118. {-264.832733, 1456.319213, 1084.367187}, //Burglary 8
  119. {22.478155, 1417.368652, 1084.429687}, //Burglary 9
  120. {139.954757, 1378.600097, 1088.367187}, //Burglary 10
  121. {234.361801, 1067.058105, 1084.207397}, //Burglary 11
  122. {-68.999641, 1364.879638, 1080.210937}, //Burglary 12
  123. {-297.281158, 1478.645751, 1084.375000}, //Burglary 13
  124. {-50.664768, 1408.467163, 1084.429687}, //Burglary 14
  125. {93.521530, 1326.241699, 1083.859375}, //Burglary 15
  126. {261.748474, 1248.680786, 1084.257812}, //Burglary 16
  127. {447.626403, 1407.644531, 1084.304687} //Burglary 17
  128. };
  129.  
  130. new IntID[37] = {2, 5, 2, 3, 5, 6, 9, 10, 8, 11, 1, 5, 8, 1, 3, 1, 5, 2, 4, 6, 3, 2, 1, 5, 15, 4, 10, 4, 5, 5, 6, 6, 15, 8, 9, 9, 2};
  131.  
  132. static stock VehicleNames[212][] = {
  133.     "Landstalker","Bravura","Buffalo","Linerunner","Pereniel","Sentinel","Dumper","Firetruck","Trashmaster","Stretch","Manana","Infernus",
  134.     "Voodoo","Pony","Mule","Cheetah","Ambulance","Leviathan","Moonbeam","Esperanto","Taxi","Washington","Bobcat","Mr Whoopee","BF Injection",
  135.     "Hunter","Premier","Enforcer","Securicar","Banshee","Predator","Bus","Rhino","Barracks","Hotknife","Trailer","Previon","Coach","Cabbie",
  136.     "Stallion","Rumpo","RC Bandit","Romero","Packer","Monster","Admiral","Squalo","Seasparrow","Pizzaboy","Tram","Trailer","Turismo","Speeder",
  137.     "Reefer","Tropic","Flatbed","Yankee","Caddy","Solair","Berkley's RC Van","Skimmer","PCJ-600","Faggio","Freeway","RC Baron","RC Raider",
  138.     "Glendale","Oceanic","Sanchez","Sparrow","Patriot","Quad","Coastguard","Dinghy","Hermes","Sabre","Rustler","ZR3 50","Walton","Regina",
  139.     "Comet","BMX","Burrito","Camper","Marquis","Baggage","Dozer","Maverick","News Chopper","Rancher","FBI Rancher","Virgo","Greenwood",
  140.     "Jetmax","Hotring","Sandking","Blista Compact","Police Maverick","Boxville","Benson","Mesa","RC Goblin","Hotring Racer A","Hotring Racer B",
  141.     "Bloodring Banger","Rancher","Super GT","Elegant","Journey","Bike","Mountain Bike","Beagle","Cropdust","Stunt","Tanker","RoadTrain",
  142.     "Nebula","Majestic","Buccaneer","Shamal","Hydra","FCR-900","NRG-500","HPV1000","Cement Truck","Tow Truck","Fortune","Cadrona","FBI Truck",
  143.     "Willard","Forklift","Tractor","Combine","Feltzer","Remington","Slamvan","Blade","Freight","Streak","Vortex","Vincent","Bullet","Clover",
  144.     "Sadler","Firetruck","Hustler","Intruder","Primo","Cargobob","Tampa","Sunrise","Merit","Utility","Nevada","Yosemite","Windsor","Monster A",
  145.     "Monster B","Uranus","Jester","Sultan","Stratum","Elegy","Raindance","RC Tiger","Flash","Tahoma","Savanna","Bandito","Freight","Trailer",
  146.     "Kart","Mower","Duneride","Sweeper","Broadway","Tornado","AT-400","DFT-30","Huntley","Stafford","BF-400","Newsvan","Tug","Trailer A","Emperor",
  147.     "Wayfarer","Euros","Hotdog","Club","Trailer B","Trailer C","Andromada","Dodo","RC Cam","Launch","Police Car (LSPD)","Police Car (SFPD)",
  148.     "Police Car (LVPD)","Police Ranger","Picador","S.W.A.T. Van","Alpha","Phoenix","Glendale","Sadler","Luggage Trailer A","Luggage Trailer B",
  149.     "Stair Trailer","Boxville","Farm Plow","Utility Trailer"
  150. };
  151.  
  152. new Text:IntScrollTD;
  153. new inmenu[MAX_PLAYERS];
  154.  
  155. forward SpawnPlayerAtHouse(playerid);
  156.  
  157. public OnFilterScriptInit()
  158. {
  159.     print("Dynamic House System v0.7 by '[ABK]PotH3Ad' [www.abkclan.com] started...");
  160.     if(!fexist(HUSER_FILE)) dini_Create(HUSER_FILE);
  161.  
  162.     LoadIntScrollTextdraw();
  163.     LoadHouses();
  164.     return 1;
  165. }
  166.  
  167. public OnFilterScriptExit()
  168. {
  169.     print("  Dynamic House System v0.7 by '[ABK]PotH3Ad' [www.abkclan.com] unloaded...");
  170.     for(new x=0; x<MAX_HOUSES; x++)
  171.     {
  172.         DestroyDynamicCP(hInfo[x][EnterCP]);
  173.         DestroyDynamicCP(hInfo[x][ExitCP]);
  174.         DestroyDynamicPickup(hInfo[x][Pickup]);
  175.         DestroyDynamicMapIcon(hInfo[x][MapIcon]);
  176.         DestroyDynamic3DTextLabel(hInfo[x][InfoLabel]);
  177.         for(new z=0; z<MAX_VEHICLE_SLOTS; z++) DestroyVehicle(hVeh[x][z][Vehicle]);
  178.     }
  179.     TextDrawDestroy(IntScrollTD);
  180.     return 1;
  181. }
  182.  
  183. CMD:hexit(playerid, params[])
  184. {
  185.     if(!BUILDINGHOUSE(playerid)) return SendClientMessage(playerid, MSG_COLOR, "ERROR: You are not building a house!");
  186.     SetPVarInt(playerid, "BuildingHouse", 0);
  187.     SendClientMessage(playerid, MSG_COLOR, "You are no longer in house build mode!");
  188.     return 1;
  189. }
  190.  
  191. CMD:intview(playerid, params[])
  192. {
  193.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, MSG_COLOR, "ERROR: You are not an admin!");
  194.     SetPVarInt(playerid, "InIntView", 1);
  195.     UpdateIntScrollTextdraw(playerid);
  196.     return 1;
  197. }
  198.  
  199. CMD:hmenu(playerid, params[])
  200. {
  201.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, MSG_COLOR, "ERROR: You are not an admin!");
  202.     if(BUILDINGHOUSE(playerid)) return SendClientMessage(playerid, MSG_COLOR, "ERROR: You are already building a house!");
  203.     ShowBuilderDialog(playerid);
  204.     return 1;
  205. }
  206.  
  207. CMD:hedit(playerid, params[])
  208. {
  209.     if(!BUILDINGHOUSE(playerid)) return SendClientMessage(playerid, MSG_COLOR, "ERROR: You are not building a house!");
  210.     ShowEditDialog(playerid);
  211.     return 1;
  212. }
  213.  
  214. CMD:hcmds(playerid, params[])
  215. {
  216.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, MSG_COLOR, "<House> You are not an admin to use the house builder!");
  217.     SendClientMessage(playerid, MSG_COLOR, "<House> Commands: /hedit, /hmenu, /hexit, /intview");
  218.     return 1;
  219. }
  220.  
  221. public OnPlayerSpawn(playerid)
  222. {
  223.     if(IsPlayerToSpawnAtHouse(playerid))
  224.     {
  225.         SetTimerEx("SpawnPlayerAtHouse", RESPAWNTIME, 0, "d", playerid);
  226.     }
  227.     return 1;
  228. }
  229.  
  230. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  231. {
  232.     if(!response) if(dialogid >= 12 && dialogid <= 19) inmenu[playerid] = 0;
  233.     if(dialogid == HOUSE_DIAG)
  234.     {
  235.         if(!response) return 1;
  236.         if(listitem == 0)          
  237.         {
  238.             new hid = GetLowestOpenSlot();
  239.             SetPVarInt(playerid, "BuildingHouse", 1);
  240.             format(hfile, sizeof(hfile), HOUSE_FILE, hid);
  241.             dini_Create(hfile);
  242.             dini_Set(hfile, "Builder", pName(playerid));
  243.             dini_Set(hfile, "Owner", "No Owner");
  244.             dini_Set(hfile, "Name", "Home");
  245.             SetPVarInt(playerid, "BuildID", hid);
  246.             SendClientMessage(playerid, MSG_COLOR, "You are now building a house! {0000FF}(Tip: Use '/hedit' to access the edit menu)");
  247.         }
  248.         else if(listitem == 1)
  249.         {
  250.             format(hstr, sizeof(hstr), "ID\tHouse Name\n");
  251.             for(new x=0; x<MAX_HOUSES; x++)
  252.             {
  253.                 format(hfile, sizeof(hfile), HOUSE_FILE, x);
  254.                 if(strlen(dini_Get(hfile, "Name")) > 0) format(hstr, sizeof(hstr), "%s%d\t%s\n", hstr, x, dini_Get(hfile, "Name"));
  255.                 else format(hstr, sizeof(hstr), "%s%d\tN/A\n", hstr, x);
  256.             }
  257.             ShowPlayerDialog(playerid, HOUSE_DIAG+1, DIALOG_STYLE_LIST, "Choose a house to edit", hstr, "Select", "Exit");
  258.         }
  259.         else if(listitem == 2)
  260.         {
  261.             format(hstr, sizeof(hstr), "ID\tHouse Name\n");
  262.             for(new x=0; x<MAX_HOUSES; x++)
  263.             {
  264.                 format(hfile, sizeof(hfile), HOUSE_FILE, x);
  265.                 if(strlen(dini_Get(hfile, "Name")) > 0) format(hstr, sizeof(hstr), "%s%d\t%s\n", hstr, x, dini_Get(hfile, "Name"));
  266.                 else format(hstr, sizeof(hstr), "%s%d\tN/A\n", hstr, x);
  267.             }
  268.             ShowPlayerDialog(playerid, HOUSE_DIAG+2, DIALOG_STYLE_LIST, "Delete a house", hstr, "Select", "Exit");
  269.         }
  270.         else if(listitem == 3)
  271.         {
  272.             format(hstr, sizeof(hstr), "ID\tHouse Name\n");
  273.             for(new x=0; x<MAX_HOUSES; x++)
  274.             {
  275.                 format(hfile, sizeof(hfile), HOUSE_FILE, x);
  276.                 if(strlen(dini_Get(hfile, "Name")) > 0) format(hstr, sizeof(hstr), "%s%d\t%s\n", hstr, x, dini_Get(hfile, "Name"));
  277.                 else format(hstr, sizeof(hstr), "%s%d\tN/A\n", hstr, x);
  278.             }
  279.             ShowPlayerDialog(playerid, HOUSE_DIAG+3, DIALOG_STYLE_LIST, "Select a house to view info", hstr, "Select", "Back");
  280.         }
  281.     }
  282.     else if(dialogid == HOUSE_DIAG+1)
  283.     {
  284.         if(response)
  285.         {
  286.             format(hfile, sizeof(hfile), HOUSE_FILE, listitem-1);
  287.             if(!dini_Exists(hfile)) return OnDialogResponse(playerid, HOUSE_DIAG, 1, 1, "blank");
  288.             SetPVarInt(playerid, "BuildingHouse", 1);
  289.             SetPVarInt(playerid, "BuildID", listitem-1);
  290.             SendClientMessage(playerid, MSG_COLOR, "You are now editing a house! {0000FF}(Tip: Use '/hedit' to access the edit menu)");
  291.         }
  292.         else ShowBuilderDialog(playerid);
  293.     }
  294.     else if(dialogid == HOUSE_DIAG+2)
  295.     {
  296.         if(response)
  297.         {
  298.             format(hfile, sizeof(hfile), HOUSE_FILE, listitem-1);
  299.             if(!dini_Exists(hfile)) return OnDialogResponse(playerid, HOUSE_DIAG, 1, 2, "blank");
  300.             DeleteHouse(listitem-1);
  301.         }
  302.         else ShowBuilderDialog(playerid);
  303.     }
  304.     else if(dialogid == HOUSE_DIAG+3)
  305.     {
  306.         if(response)
  307.         {
  308.             #define hid listitem-1
  309.             format(hfile, sizeof(hfile), HOUSE_FILE, hid);
  310.             if(!dini_Exists(hfile)) return OnDialogResponse(playerid, HOUSE_DIAG, 1, 3, "blank");
  311.             format(hstr, sizeof(hstr), "House Name\t\t%s (ID %d)\nOwner\t\t\t%s\nBuilder\t\t\t%s\nPrice\t\t\t$%d\nFor Sale\t\t%d\nInterior\t\t%d\nWorld\t\t\t%d", hInfo[hid][Name],
  312.             hid, hInfo[hid][Owner], dini_Get(hfile, "Builder"), hInfo[hid][Price], hInfo[hid][ForSale], hInfo[hid][Interior], hInfo[hid][World]);
  313.             ShowPlayerDialog(playerid, HOUSE_DIAG-1, DIALOG_STYLE_MSGBOX, "House Information", hstr, "Ok", "Exit");
  314.         }
  315.         else ShowBuilderDialog(playerid);
  316.     }
  317.     //Edit menu
  318.     else if(dialogid == HOUSE_DIAG+4)
  319.     {
  320.         if(!response) return 1;
  321.         if(listitem == 0)
  322.             ShowPlayerDialog(playerid, HOUSE_DIAG+5, DIALOG_STYLE_INPUT, "{"#B>"}House Edit - {"#G>"}House Name", "Enter a house name under 40 characters long in the field below", "Continue", "Cancel");
  323.         else if(listitem == 1)
  324.             ShowPlayerDialog(playerid, HOUSE_DIAG+6, DIALOG_STYLE_INPUT, "{"#B>"}House Edit - {"#G>"}House Price", "Set the price of the house in the field below", "Set", "Cancel");
  325.         else if(listitem == 2)
  326.         {
  327.             new houseid = BUILDID(playerid);
  328.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  329.             if(hInfo[houseid][ForSale])
  330.             {
  331.                 SetHouseForSale(houseid, 0);
  332.                 NotifyDialog(playerid, "{"#B>"}House Edit - {"#G>"}For Sale", "This house is no longer for sale!");
  333.             }
  334.             else
  335.             {
  336.                 SetHouseForSale(houseid, 1);
  337.                 NotifyDialog(playerid, "{"#B>"}House Edit - {"#G>"}For Sale", "This house is now for sale!");
  338.             }
  339.         }
  340.         else if(listitem == 3)
  341.             ShowPlayerDialog(playerid, HOUSE_DIAG+7, DIALOG_STYLE_INPUT, "{"#B>"}House Edit - {"#G>"}Interior", "Set the Interior ID of the house in the field below", "Set", "Cancel");
  342.         else if(listitem == 4)
  343.             ShowPlayerDialog(playerid, HOUSE_DIAG+8, DIALOG_STYLE_INPUT, "{"#B>"}House Edit - {"#G>"}Virtual World", "Set the virtual world ID of the house in the field below", "Set", "Cancel");
  344.         else if(listitem == 5)
  345.         {
  346.             new houseid = BUILDID(playerid);
  347.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  348.  
  349.             new Float:pcoords[4], key[75];
  350.             GetPlayerPos(playerid, pcoords[0], pcoords[1], pcoords[2]);
  351.             GetPlayerFacingAngle(playerid, pcoords[3]);
  352.             format(key, sizeof(key), "%f,%f,%f,%f", pcoords[0], pcoords[1], pcoords[2], pcoords[3]);
  353.             dini_Set(hfile, "EnterPos", key);
  354.             hInfo[houseid][EnterPos][0] = pcoords[0];
  355.             hInfo[houseid][EnterPos][1] = pcoords[1];
  356.             hInfo[houseid][EnterPos][2] = pcoords[2];
  357.             hInfo[houseid][EnterPos][3] = pcoords[3];
  358.  
  359.             NotifyDialog(playerid, "{"#B>"}House Edit - {"#G>"}Enter Position", "Enter position was successfully set!");
  360.             CreateHouseNotice3DLabel(houseid, "{"#W>"}House {"#R>"}enter\n{"#W>"}position set here!", MSG_COLOR, hInfo[houseid][EnterPos][0], hInfo[houseid][EnterPos][1], hInfo[houseid][EnterPos][2], 0, -1, -1, 8000);
  361.         }
  362.         else if(listitem == 6)
  363.         {
  364.             new houseid = BUILDID(playerid);
  365.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  366.  
  367.             new Float:pcoords[4], key[75];
  368.             GetPlayerPos(playerid, pcoords[0], pcoords[1], pcoords[2]);
  369.             GetPlayerFacingAngle(playerid, pcoords[3]);
  370.             format(key, sizeof(key), "%f,%f,%f,%f", pcoords[0], pcoords[1], pcoords[2], pcoords[3]);
  371.             dini_Set(hfile, "ExitPos", key);
  372.             hInfo[houseid][ExitPos][0] = pcoords[0];
  373.             hInfo[houseid][ExitPos][1] = pcoords[1];
  374.             hInfo[houseid][ExitPos][2] = pcoords[2];
  375.             hInfo[houseid][ExitPos][3] = pcoords[3];
  376.  
  377.             NotifyDialog(playerid, "{"#B>"}House Edit - {"#G>"}Exit Position", "Exit position was successfully set!");
  378.             CreateHouseNotice3DLabel(houseid, "{"#W>"}House {"#R>"}exit\n{"#W>"}position set here!", MSG_COLOR, hInfo[houseid][ExitPos][0], hInfo[houseid][ExitPos][1], hInfo[houseid][ExitPos][2], 0, -1, -1, 8000);
  379.         }
  380.         else if(listitem == 7)
  381.         {
  382.             new houseid = BUILDID(playerid);
  383.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  384.  
  385.             new Float:pcoords[4], key[75];
  386.             GetPlayerPos(playerid, pcoords[0], pcoords[1], pcoords[2]);
  387.             GetPlayerFacingAngle(playerid, pcoords[3]);
  388.             format(key, sizeof(key), "%f,%f,%f,%f", pcoords[0], pcoords[1], pcoords[2], pcoords[3]);
  389.             dini_Set(hfile, "SpawnPos", key);
  390.             hInfo[houseid][SpawnPos][0] = pcoords[0];
  391.             hInfo[houseid][SpawnPos][1] = pcoords[1];
  392.             hInfo[houseid][SpawnPos][2] = pcoords[2];
  393.             hInfo[houseid][SpawnPos][3] = pcoords[3];
  394.  
  395.             NotifyDialog(playerid, "{"#B>"}House Edit - {"#G>"}Spawn Position", "Spawn position was successfully set!");
  396.             CreateHouseNotice3DLabel(houseid, "{"#W>"}House {"#R>"}spawn\n{"#W>"}position set here!", MSG_COLOR, hInfo[houseid][SpawnPos][0], hInfo[houseid][SpawnPos][1], hInfo[houseid][SpawnPos][2], 0, -1, -1, 8000);
  397.         }
  398.         else if(listitem == 8)
  399.         {
  400.             new houseid = BUILDID(playerid);
  401.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  402.  
  403.             new Float:pcoords[3], key[60];
  404.             GetPlayerPos(playerid, pcoords[0], pcoords[1], pcoords[2]);
  405.             format(key, sizeof(key), "%f,%f,%f", pcoords[0], pcoords[1], pcoords[2]);
  406.             dini_Set(hfile, "PickupPos", key);
  407.             hInfo[houseid][PickupPos][0] = pcoords[0];
  408.             hInfo[houseid][PickupPos][1] = pcoords[1];
  409.             hInfo[houseid][PickupPos][2] = pcoords[2];
  410.  
  411.             DestroyDynamicPickup(hInfo[houseid][Pickup]);
  412.             DestroyDynamicMapIcon(hInfo[houseid][MapIcon]);
  413.  
  414.             if(dini_Int(hfile, "ForSale"))
  415.             {
  416.                 hInfo[houseid][Pickup] = CreateDynamicPickup(FORSALE_PICKUP, 1, hInfo[houseid][PickupPos][0], hInfo[houseid][PickupPos][1], hInfo[houseid][PickupPos][2], 0, 0, -1, PICKUP_DRAW);
  417.                 hInfo[houseid][MapIcon] = CreateDynamicMapIcon(hInfo[houseid][PickupPos][0], hInfo[houseid][PickupPos][1], hInfo[houseid][PickupPos][2], FORSALE_ICON, 0, 0, 0, -1, ICON_DRAW);
  418.             }
  419.             else
  420.             {
  421.                 hInfo[houseid][Pickup] = CreateDynamicPickup(NOTFORSALE_PICKUP, 1, hInfo[houseid][PickupPos][0], hInfo[houseid][PickupPos][1], hInfo[houseid][PickupPos][2], 0, 0, -1, PICKUP_DRAW);
  422.                 hInfo[houseid][MapIcon] = CreateDynamicMapIcon(hInfo[houseid][PickupPos][0], hInfo[houseid][PickupPos][1], hInfo[houseid][PickupPos][2], NOTFORSALE_ICON, 0, 0, 0, -1, ICON_DRAW);
  423.             }
  424.             NotifyDialog(playerid, "{"#B>"}House Edit - {"#G>"}Pickup Position", "Pickup position was successfully set!");
  425.             CreateHouseNotice3DLabel(houseid, "{"#W>"}House {"#R>"}pickup\n{"#W>"}position set here!", MSG_COLOR, hInfo[houseid][PickupPos][0], hInfo[houseid][PickupPos][1], hInfo[houseid][PickupPos][2], 0, -1, -1, 8000);
  426.         }
  427.         else if(listitem == 9)
  428.         {
  429.             new houseid = BUILDID(playerid);
  430.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  431.  
  432.             new Float:pcoords[3], key[60];
  433.             GetPlayerPos(playerid, pcoords[0], pcoords[1], pcoords[2]);
  434.             format(key, sizeof(key), "%f,%f,%f", pcoords[0], pcoords[1], pcoords[2]);
  435.             dini_Set(hfile, "LabelPos", key);
  436.             hInfo[houseid][LabelPos][0] = pcoords[0];
  437.             hInfo[houseid][LabelPos][1] = pcoords[1];
  438.             hInfo[houseid][LabelPos][2] = pcoords[2];
  439.  
  440.             new str[140];
  441.             format(str, sizeof(str), "{"#G>"}%s\n{"#B>"}Owner {"#W>"}%s\n{"#R>"}Price {"#W>"}$%d", hInfo[houseid][Name], hInfo[houseid][Owner], hInfo[houseid][Price]);
  442.             DestroyDynamic3DTextLabel(hInfo[houseid][InfoLabel]);
  443.             hInfo[houseid][InfoLabel] = CreateDynamic3DTextLabel(str, LABEL_COLOR, hInfo[houseid][LabelPos][0], hInfo[houseid][LabelPos][1], hInfo[houseid][LabelPos][2], LABEL_DRAW, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, LABEL_LOS, 0, 0, -1, LABEL_DRAW);
  444.             NotifyDialog(playerid, "{"#B>"}House Edit - {"#G>"}Label Position", "Label position was successfully set!");
  445.             CreateHouseNotice3DLabel(houseid, "{"#W>"}House {"#R>"}label\n{"#W>"}position set here!", MSG_COLOR, hInfo[houseid][LabelPos][0], hInfo[houseid][LabelPos][1], hInfo[houseid][LabelPos][2], 0, -1, -1, 8000);
  446.         }
  447.         else if(listitem == 10)
  448.         {
  449.             new houseid = BUILDID(playerid);
  450.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  451.  
  452.             new Float:pcoords[3], key[60];
  453.             GetPlayerPos(playerid, pcoords[0], pcoords[1], pcoords[2]);
  454.             format(key, sizeof(key), "%f,%f,%f", pcoords[0], pcoords[1], pcoords[2]);
  455.             dini_Set(hfile, "EnterCPPos", key);
  456.             hInfo[houseid][EnterCPPos][0] = pcoords[0];
  457.             hInfo[houseid][EnterCPPos][1] = pcoords[1];
  458.             hInfo[houseid][EnterCPPos][2] = pcoords[2];
  459.  
  460.             DestroyDynamicCP(hInfo[houseid][EnterCP]);
  461.             hInfo[houseid][EnterCP] = CreateDynamicCP(hInfo[houseid][EnterCPPos][0], hInfo[houseid][EnterCPPos][1], hInfo[houseid][EnterCPPos][2], ENTERCP_SIZE, -1, 0, -1, ENTERCP_DRAW);
  462.  
  463.             NotifyDialog(playerid, "{"#B>"}House Edit - {"#G>"}Entrance Checkpoint Position", "{"#B>"}House Edit - {"#G>"}Entrance Checkpoint Position");
  464.             CreateHouseNotice3DLabel(houseid, "{"#W>"}House {"#R>"}enter checkpoint\n{"#W>"}position set here!", MSG_COLOR, hInfo[houseid][EnterCPPos][0], hInfo[houseid][EnterCPPos][1], hInfo[houseid][EnterCPPos][2], 0, -1, -1, 8000);
  465.         }
  466.         else if(listitem == 11)
  467.         {
  468.             new houseid = BUILDID(playerid);
  469.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  470.  
  471.             new Float:pcoords[3], key[60];
  472.             GetPlayerPos(playerid, pcoords[0], pcoords[1], pcoords[2]);
  473.             format(key, sizeof(key), "%f,%f,%f", pcoords[0], pcoords[1], pcoords[2]);
  474.             dini_Set(hfile, "ExitCPPos", key);
  475.             dini_IntSet(hfile, "Interior", GetPlayerInterior(playerid));
  476.             dini_IntSet(hfile, "World", GetPlayerVirtualWorld(playerid));
  477.             hInfo[houseid][Interior] = GetPlayerInterior(playerid);
  478.             hInfo[houseid][World] = GetPlayerVirtualWorld(playerid);
  479.             hInfo[houseid][ExitCPPos][0] = pcoords[0];
  480.             hInfo[houseid][ExitCPPos][1] = pcoords[1];
  481.             hInfo[houseid][ExitCPPos][2] = pcoords[2];
  482.  
  483.             DestroyDynamicCP(hInfo[houseid][ExitCP]);
  484.             hInfo[houseid][ExitCP] = CreateDynamicCP(hInfo[houseid][ExitCPPos][0], hInfo[houseid][ExitCPPos][1], hInfo[houseid][ExitCPPos][2], EXITCP_SIZE, hInfo[houseid][World], hInfo[houseid][Interior], -1, ENTERCP_DRAW);
  485.  
  486.             NotifyDialog(playerid, "{"#B>"}House Edit - {"#G>"}Exit Checkpoint Position", "Exit Checkpoint position was successfully set!");
  487.             CreateHouseNotice3DLabel(houseid, "{"#W>"}House {"#R>"}exit checkpoint\n{"#W>"}position set here!", MSG_COLOR, hInfo[houseid][ExitCPPos][0], hInfo[houseid][ExitCPPos][1], hInfo[houseid][ExitCPPos][2], 0, -1, -1, 8000);
  488.         }
  489.         else if(listitem == 12)
  490.             ShowPlayerDialog(playerid, HOUSE_DIAG+9, DIALOG_STYLE_LIST, "{"#B>"}House Edit - {"#G>"}Teleport", "Pickup\nInformation Label\nEnter Checkpoint\nExit Checkpoint", "Go", "Cancel");
  491.         else if(listitem == 13)
  492.         {
  493.             new houseid = BUILDID(playerid);
  494.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  495.  
  496.             new Float:coords[4], key[80];
  497.             if(!IsPlayerInAnyVehicle(playerid))
  498.             {
  499.                 GetPlayerPos(playerid, coords[0], coords[1], coords[2]);
  500.                 GetPlayerFacingAngle(playerid, coords[3]);
  501.                 format(key, sizeof(key), "%f,%f,%f,%f", coords[0], coords[1], coords[2], coords[3]);
  502.                 NotifyDialog(playerid, "{"#B>"}House Edit - {"#G>"}Vehicle Spawn Position", "{"#G>"}NOTE: It's preferable you set this position while in a vehicle!\n\n{"#W>"}Vehicle spawn position successfully set!");
  503.             }
  504.             else
  505.             {
  506.                 new vehid = GetPlayerVehicleID(playerid);
  507.                 GetVehiclePos(vehid, coords[0], coords[1], coords[2]);
  508.                 GetVehicleZAngle(vehid, coords[3]);
  509.                 format(key, sizeof(key), "%f,%f,%f,%f", coords[0], coords[1], coords[2], coords[3]);
  510.                 NotifyDialog(playerid, "{"#B>"}House Edit - {"#G>"}Vehicle Spawn Position", "Vehicle spawn position successfully set!");
  511.             }
  512.             dini_Set(hfile, "VehPos", key);
  513.             hInfo[houseid][VehPos][0] = coords[0];
  514.             hInfo[houseid][VehPos][1] = coords[1];
  515.             hInfo[houseid][VehPos][2] = coords[2];
  516.             hInfo[houseid][VehPos][3] = coords[3];
  517.             CreateHouseNotice3DLabel(houseid, "{"#W>"}House {"#R>"}vehicle\n{"#W>"}position set here!", MSG_COLOR, coords[0], coords[1], coords[2], 0, -1, -1, 8000);
  518.         }
  519.     }
  520.     else if(dialogid == HOUSE_DIAG+5)
  521.     {
  522.         if(response)
  523.         {
  524.             if(!strlen(inputtext) || strlen(inputtext) > MAX_HOUSE_NAME) return ShowPlayerDialog(playerid, HOUSE_DIAG+5, DIALOG_STYLE_INPUT, "House Edit - House Name", "ERROR: You must enter a house name under 40 characters!\n\nEnter a house name under 40 characters long in the field below", "Continue", "Cancel");
  525.             new houseid = BUILDID(playerid);
  526.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  527.             dini_Set(hfile, "Name", inputtext);
  528.             format(hInfo[houseid][Name], MAX_HOUSE_NAME, "%s", inputtext);
  529.             NotifyDialog(playerid, "{"#B>"}House Edit - {"#G>"}House Name", "House name was successfully set!");
  530.         }
  531.         else ShowEditDialog(playerid);
  532.     }
  533.     else if(dialogid == HOUSE_DIAG+6)
  534.     {
  535.         if(response)
  536.         {
  537.             if(!strlen(inputtext)) return ShowPlayerDialog(playerid, HOUSE_DIAG+6, DIALOG_STYLE_INPUT, "{"#B>"}House Edit - {"#G>"}House Price", "ERROR: You must enter a price value!\n\nSet the price of the house in the field below", "Set", "Cancel");
  538.             new houseid = BUILDID(playerid);
  539.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  540.             dini_IntSet(hfile, "Price", strval(inputtext));
  541.             hInfo[houseid][Price] = strval(inputtext);
  542.             NotifyDialog(playerid, "{"#B>"}House Edit - {"#G>"}House Price", "House price was successfully set!");
  543.         }
  544.     }
  545.     else if(dialogid == HOUSE_DIAG+7)
  546.     {
  547.         if(response)
  548.         {
  549.             if(!strlen(inputtext)) return ShowPlayerDialog(playerid, HOUSE_DIAG+7, DIALOG_STYLE_INPUT, "{"#B>"}House Edit - {"#G>"}Interior", "ERROR: You must enter an interior!\n\nSet the Interior ID of the house in the field below", "Set", "Cancel");
  550.             new houseid = BUILDID(playerid);
  551.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  552.             dini_IntSet(hfile, "Interior", strval(inputtext));
  553.             hInfo[houseid][Interior] = strval(inputtext);
  554.             NotifyDialog(playerid, "{"#B>"}House Edit - {"#G>"}Interior", "Interior was successfully set!");
  555.         }
  556.     }
  557.     else if(dialogid == HOUSE_DIAG+8)
  558.     {
  559.         if(response)
  560.         {
  561.             if(!strlen(inputtext)) return ShowPlayerDialog(playerid, HOUSE_DIAG+7, DIALOG_STYLE_INPUT, "{"#B>"}House Edit - {"#G>"}Virtual World", "ERROR: You must enter a virtual world!\n\nSet the Virtual World ID of the house in the field below", "Set", "Cancel");
  562.             new houseid = BUILDID(playerid);
  563.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  564.             dini_IntSet(hfile, "World", strval(inputtext));
  565.             hInfo[houseid][World] = strval(inputtext);
  566.             NotifyDialog(playerid, "{"#B>"}House Edit - {"#G>"}Virtual World", "Virtual world was successfully set!");
  567.         }
  568.     }
  569.     else if(dialogid == HOUSE_DIAG+9)
  570.     {
  571.         if(!response) return 1;
  572.         new houseid = BUILDID(playerid);
  573.         if(listitem == 0)
  574.             SetPlayerPosEx(playerid, hInfo[houseid][PickupPos][0], hInfo[houseid][PickupPos][1], hInfo[houseid][PickupPos][2], 0.0, 0, 0);
  575.         else if(listitem == 1)
  576.             SetPlayerPosEx(playerid, hInfo[houseid][LabelPos][0], hInfo[houseid][LabelPos][1], hInfo[houseid][LabelPos][2], 0.0, 0, 0);
  577.         else if(listitem == 2)
  578.             SetPlayerPosEx(playerid, hInfo[houseid][EnterCPPos][0], hInfo[houseid][EnterCPPos][1], hInfo[houseid][EnterCPPos][2], 0.0, 0, 0);
  579.         else if(listitem == 3)
  580.             SetPlayerPosEx(playerid, hInfo[houseid][ExitCPPos][0], hInfo[houseid][ExitCPPos][1], hInfo[houseid][ExitCPPos][2], 0.0, hInfo[houseid][Interior], hInfo[houseid][World]);
  581.     }
  582.     else if(dialogid == HOUSE_DIAG+10)
  583.     {
  584.         if(!response) return 1;
  585.  
  586.         new houseid = HOUSEID(playerid);
  587.         if(listitem == 0)
  588.         {
  589.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  590.             if(hInfo[houseid][Locked] == 1 && dini_Isset(hfile, "Password")) return ShowPlayerDialog(playerid, HOUSE_DIAG+11, DIALOG_STYLE_INPUT, "{"#B>"}House Enter - {"#G>"}Password", "{"#W>"}Enter the house password below to enter!", "Enter", "Cancel");
  591.             SetPlayerPosEx(playerid, hInfo[houseid][EnterPos][0], hInfo[houseid][EnterPos][1], hInfo[houseid][EnterPos][2], hInfo[houseid][EnterPos][3], hInfo[houseid][Interior], hInfo[houseid][World]);
  592.         }
  593.         else if(listitem == 1)
  594.         {
  595.             if(!IsHouseOwner(playerid, houseid)) return NotifyDialog(playerid, "{"#B>"}House Settings - {"#G>"}Lock House", "You are not the owner of this house!");
  596.             if(hInfo[houseid][Locked])
  597.             {
  598.                 hInfo[houseid][Locked] = 0;
  599.                 NotifyDialog(playerid, "{"#B>"}House Settings - {"#G>"}Lock House", "You have unlocked your house!");
  600.             }
  601.             else
  602.             {
  603.                 hInfo[houseid][Locked] = 1;
  604.                 NotifyDialog(playerid, "{"#B>"}House Settings - {"#G>"}Lock House", "You have locked your house!");
  605.             }
  606.         }
  607.         else if(listitem == 2)
  608.         {
  609.             if(hInfo[houseid][ForSale] == 0) return NotifyDialog(playerid, "{"#B>"}House Enter - {"#G>"}Purchase", "{"#R>"}ERROR: This house is not for sale!");
  610.             if(IsHouseOwner(playerid, houseid)) return NotifyDialog(playerid, "{"#B>"}House Enter - {"#G>"}Purchase", "{"#R>"}ERROR: You already own this house!");
  611.             if(GetPlayerMoney(playerid) < hInfo[houseid][Price]) return NotifyDialog(playerid, "{"#B>"}House Enter - {"#G>"}Purchase", "{"#R>"}ERROR: You do not have enough money!");
  612.  
  613.             format(hfile, sizeof(hfile), HOUSE_FILE, HOUSEID(playerid));
  614.             format(hInfo[houseid][Owner], MAX_PLAYER_NAME, "%s", pName(playerid));
  615.             dini_Set(hfile, "Owner", pName(playerid));
  616.             GivePlayerMoney(playerid, -hInfo[houseid][Price]);
  617.             PlayerPlaySound(playerid, 1149, 0, 0, 0);
  618.  
  619.             new str[120];
  620.             format(str, sizeof(str), "%s has purchased the house \"%s\" for {"#G>"}$%d!", pName(playerid), hInfo[houseid][Name], hInfo[houseid][Price]);
  621.             SendClientMessageToAll(MSG_COLOR, str);
  622.  
  623.             format(str, sizeof(str), "{"#G>"}%s\n{"#B>"}Owner {"#W>"}%s\n{"#R>"}Price {"#W>"}$%d", hInfo[houseid][Name], hInfo[houseid][Owner], hInfo[houseid][Price]);
  624.             DestroyDynamic3DTextLabel(hInfo[houseid][InfoLabel]);
  625.             hInfo[houseid][InfoLabel] = CreateDynamic3DTextLabel(str, LABEL_COLOR, hInfo[houseid][LabelPos][0], hInfo[houseid][LabelPos][1], hInfo[houseid][LabelPos][2], LABEL_DRAW, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, LABEL_LOS, 0, 0, -1, LABEL_DRAW);
  626.         }
  627.     }
  628.     else if(dialogid == HOUSE_DIAG+11)
  629.     {
  630.         if(response)
  631.         {
  632.             new houseid = HOUSEID(playerid);
  633.             if(!strlen(inputtext)) return ShowPlayerDialog(playerid, HOUSE_DIAG+11, DIALOG_STYLE_INPUT, "{"#B>"}House Enter - {"#G>"}Password", "{"#R>"}ERROR: You must enter the password to enter!\n\n{"#W>"}Enter the house password below to enter!", "Enter", "Cancel");
  634.             if(!PasswordMatch(inputtext, houseid)) return ShowPlayerDialog(playerid, HOUSE_DIAG+11, DIALOG_STYLE_INPUT, "{"#B>"}House Enter - {"#G>"}Password", "{"#R>"}ERROR: Incorrect password\n\n{"#W>"}Enter the house password below to enter!", "Enter", "Cancel");
  635.             SetPlayerPosEx(playerid, hInfo[houseid][EnterPos][0], hInfo[houseid][EnterPos][1], hInfo[houseid][EnterPos][2], hInfo[houseid][EnterPos][3], hInfo[houseid][Interior], hInfo[houseid][World]);
  636.         }
  637.     }
  638.     else if(dialogid == HOUSE_DIAG+12)
  639.     {
  640.         if(!response) return 1;
  641.  
  642.         new houseid = HOUSEID(playerid);
  643.         if(listitem == 0)
  644.         {
  645.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  646.             format(hstr, sizeof(hstr), "House Name\t\t%s (ID %d)\nOwner\t\t\t%s\nBuilder\t\t\t%s\nPrice\t\t\t$%d\nFor Sale\t\t%d\nInterior\t\t%d\nWorld\t\t\t%d", hInfo[houseid][Name],
  647.             houseid, hInfo[houseid][Owner], dini_Get(hfile, "Builder"), hInfo[houseid][Price], hInfo[houseid][ForSale], hInfo[houseid][Interior], hInfo[houseid][World]);
  648.             ShowPlayerDialog(playerid, HOUSE_DIAG-1, DIALOG_STYLE_MSGBOX, "House Information", hstr, "Ok", "Exit");
  649.         }
  650.         else if(listitem == 1)
  651.         {
  652.             ShowPlayerDialog(playerid, HOUSE_DIAG+13, DIALOG_STYLE_INPUT, "{"#B>"}House Settings - {"#G>"}Set Password", "Enter a password for your house in the field below!", "Set", "Cancel");
  653.         }
  654.         else if(listitem == 2)
  655.         {
  656.             ShowPlayerDialog(playerid, HOUSE_DIAG+14, DIALOG_STYLE_INPUT, "{"#B>"}House Settings - {"#G>"}Set House Name", "Enter a house name in the field below!", "Set", "Cancel");
  657.         }
  658.         else if(listitem == 3)
  659.         {
  660.             ShowPlayerDialog(playerid, HOUSE_DIAG+15, DIALOG_STYLE_INPUT, "{"#B>"}House Settings - {"#G>"}Set House Price", "Enter a house price in the field below!", "Set", "Cancel");
  661.         }
  662.         else if(listitem == 4)
  663.         {
  664.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  665.             if(hInfo[houseid][ForSale])
  666.             {
  667.                 SetHouseForSale(houseid, 0);
  668.                 NotifyDialog(playerid, "{"#B>"}House Settings - {"#G>"}For Sale", "Your house is no longer for sale!");
  669.             }
  670.             else
  671.             {
  672.                 SetHouseForSale(houseid, 1);
  673.                 NotifyDialog(playerid, "{"#B>"}House Settings - {"#G>"}For Sale", "Your house is now for sale!");
  674.             }
  675.         }
  676.         else if(listitem == 5)
  677.         {
  678.             if(dini_Int(HUSER_FILE, pName(playerid)) == -1)
  679.             {
  680.                 dini_IntSet(HUSER_FILE, pName(playerid), houseid);
  681.                 NotifyDialog(playerid, "{"#B>"}House Settings - {"#G>"}House Spawn", "You will now spawn at this house on spawn!");
  682.             }
  683.             else
  684.             {
  685.                 dini_IntSet(HUSER_FILE, pName(playerid), -1);
  686.                 NotifyDialog(playerid, "{"#B>"}House Settings - {"#G>"}House Spawn", "You will no longer spawn at this house!");
  687.             }
  688.         }
  689.         else if(listitem == 6)
  690.         {
  691.             new str[MAX_VEHICLE_SLOTS * 70];
  692.             for(new x=0; x<MAX_VEHICLE_SLOTS; x++)
  693.             {
  694.                 new vehid = hVeh[houseid][x][ModelID];
  695.                 format(str, sizeof(str), "%s{"#B>"}Slot %d\t{"#G>"}%s\n", str, x, VehicleNames[vehid-400]);
  696.             }
  697.             ShowPlayerDialog(playerid, HOUSE_DIAG+16, DIALOG_STYLE_LIST, "{"#B>"}House Settings - {"#G>"}House Vehicles", str, "Edit", "Cancel");
  698.         }
  699.         else if(listitem == 7)
  700.         {
  701.             new str[MAX_VEHICLE_SLOTS * 70];
  702.             for(new x=0; x<MAX_VEHICLE_SLOTS; x++)
  703.             {
  704.                 new vehid = hVeh[houseid][x][ModelID];
  705.                 format(str, sizeof(str), "%s{"#B>"}Slot %d\t{"#G>"}%s\n", str, x, VehicleNames[vehid-400]);
  706.             }
  707.             ShowPlayerDialog(playerid, HOUSE_DIAG+19, DIALOG_STYLE_LIST, "{"#B>"}House Settings - {"#G>"}Spawn House Vehicle", str, "Select", "Cancel");
  708.         }
  709.         else if(listitem == 8) //Show dialog with player's money  (Store money/ take money)
  710.         {
  711.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  712.             new str[80];
  713.             format(str, sizeof(str), "{"#G>"}[Current Money: $%d]\n{"#W>"}Store Money\nTake Money", hInfo[houseid][MoneyStash]);
  714.             ShowPlayerDialog(playerid, HOUSE_DIAG+20, DIALOG_STYLE_LIST, "{"#B>"}House Storage - {"#G>"}Money Stash", str, "Select", "Cancel");
  715.         }
  716.     }
  717.     else if(dialogid == HOUSE_DIAG+13)
  718.     {
  719.         if(response)
  720.         {
  721.             new houseid = HOUSEID(playerid);
  722.             if(!strlen(inputtext)) return ShowPlayerDialog(playerid, HOUSE_DIAG+13, DIALOG_STYLE_INPUT, "{"#B>"}House Settings - {"#G>"}Set Password", "{"#<R"}ERROR: You must enter a password!\n\n{"#<W"}Enter a password for your house in the field below!", "Set", "Cancel");
  723.             if(strlen(inputtext) < MIN_PASS || strlen(inputtext) > MAX_PASS) return ShowPlayerDialog(playerid, HOUSE_DIAG+13, DIALOG_STYLE_INPUT, "{"#B>"}House Settings - {"#G>"}Set Password", "{"#<R"}ERROR: Password length must be between "#MIN_PASS"-"#MAX_PASS" characters!\n\n{"#<W"}Enter a password for your house in the field below!", "Set", "Cancel");
  724.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  725.             dini_IntSet(hfile, "Password", udb_hash(inputtext));
  726.             NotifyDialog(playerid, "{"#B>"}House Settings - {"#G>"}Set Password", "Password was set successfully!");
  727.         }
  728.         else ShowOptionsDialog(playerid);
  729.     }
  730.     else if(dialogid == HOUSE_DIAG+14)
  731.     {
  732.         if(response)
  733.         {
  734.             new houseid = HOUSEID(playerid);
  735.             if(!strlen(inputtext)) return ShowPlayerDialog(playerid, HOUSE_DIAG+14, DIALOG_STYLE_INPUT, "{"#B>"}House Settings - ""{"#B>"}House Settings - {"#G>"}Set House Name", "{"#<R"}ERROR: You must enter a house name!\n\n{"#<W"}Enter a house name in the field below!", "Set", "Cancel");
  736.             if(strlen(inputtext) > MAX_HOUSE_NAME) return ShowPlayerDialog(playerid, HOUSE_DIAG+14, DIALOG_STYLE_INPUT, "{"#B>"}House Settings - ""{"#B>"}House Settings - {"#G>"}Set House Name", "{"#<R"}ERROR: Maximum house name is "#MAX_HOUSE_NAME" characters!\n\n{"#<W"}Enter a house name in the field below!", "Set", "Cancel");
  737.  
  738.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  739.             format(hInfo[houseid][Name], MAX_PLAYER_NAME, "%s", inputtext);
  740.             dini_Set(hfile, "Name", inputtext);
  741.  
  742.             if(IsHousePropSet(houseid, "LabelPos"))
  743.             {
  744.                 DestroyDynamic3DTextLabel(hInfo[houseid][InfoLabel]);
  745.                 format(hfile, sizeof(hfile), "{"#G>"}%s\n{"#B>"}Owner {"#W>"}%s\n{"#R>"}Price {"#W>"}$%d", hInfo[houseid][Name], hInfo[houseid][Owner], hInfo[houseid][Price]);
  746.                 hInfo[houseid][InfoLabel] = CreateDynamic3DTextLabel(hfile, LABEL_COLOR, hInfo[houseid][LabelPos][0], hInfo[houseid][LabelPos][1], hInfo[houseid][LabelPos][2], LABEL_DRAW, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, LABEL_LOS, 0, 0, -1, LABEL_DRAW);
  747.             }
  748.             NotifyDialog(playerid, "{"#B>"}House Settings - {"#G>"}Set House Name", "House name was successfully set!");
  749.         }
  750.         else ShowOptionsDialog(playerid);
  751.     }
  752.     else if(dialogid == HOUSE_DIAG+15)
  753.     {
  754.         if(response)
  755.         {
  756.             new houseid = HOUSEID(playerid);
  757.             new price = strval(inputtext);
  758.             if(!IsNumeric(inputtext)) return ShowPlayerDialog(playerid, HOUSE_DIAG+15, DIALOG_STYLE_INPUT, "{"#B>"}House Settings - ""{"#B>"}House Settings - {"#G>"}Set House Price", "{"#<R"}ERROR: You must enter a house price!\n\n{"#<W"}Enter a house price in the field below!", "Set", "Cancel");
  759.             if(price < 0) return ShowPlayerDialog(playerid, HOUSE_DIAG+15, DIALOG_STYLE_INPUT, "{"#B>"}House Settings - ""{"#B>"}House Settings - {"#G>"}Set House Price", "{"#<R"}ERROR: Please enter a valid price!\n\n{"#<W"}Enter a house price in the field below!", "Set", "Cancel");
  760.  
  761.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  762.             dini_IntSet(hfile, "Price", price);
  763.             hInfo[houseid][Price] = price;
  764.  
  765.             if(IsHousePropSet(houseid, "LabelPos"))
  766.             {
  767.                 DestroyDynamic3DTextLabel(hInfo[houseid][InfoLabel]);
  768.                 format(hfile, sizeof(hfile), "{"#G>"}%s\n{"#B>"}Owner {"#W>"}%s\n{"#R>"}Price {"#W>"}$%d", hInfo[houseid][Name], hInfo[houseid][Owner], price);
  769.                 hInfo[houseid][InfoLabel] = CreateDynamic3DTextLabel(hfile, LABEL_COLOR, hInfo[houseid][LabelPos][0], hInfo[houseid][LabelPos][1], hInfo[houseid][LabelPos][2], LABEL_DRAW, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, LABEL_LOS, 0, 0, -1, LABEL_DRAW);
  770.             }
  771.  
  772.             NotifyDialog(playerid, "{"#B>"}House Settings - {"#G>"}Set House Price", "House price was successfully set!");
  773.         }
  774.         else ShowOptionsDialog(playerid);
  775.     }
  776.     else if(dialogid == HOUSE_DIAG+16)
  777.     {
  778.         if(response)
  779.         {
  780.             new houseid = HOUSEID(playerid);
  781.             new str[100], cvehid = hVeh[houseid][listitem][ModelID];
  782.             SetPVarInt(playerid, "HVehSlot", listitem);
  783.             format(str, sizeof(str), "{"#B>"}Set Vehicle Model\t{"#G>"}%s [ID %d]", VehicleNames[cvehid-400], cvehid);
  784.             ShowPlayerDialog(playerid, HOUSE_DIAG+17, DIALOG_STYLE_LIST, "{"#B>"}House Vehicles - {"#G>"}Editing Slot", str, "Select", "Cancel");
  785.         }
  786.         else ShowOptionsDialog(playerid);
  787.     }
  788.     else if(dialogid == HOUSE_DIAG+17)
  789.     {
  790.         if(response && listitem == 0)
  791.         ShowPlayerDialog(playerid, HOUSE_DIAG+18, DIALOG_STYLE_INPUT, "{"#B>"}House Settings - {"#G>"}House Vehicles", "Enter a vehicle name or model id to continue", "Set", "Cancel");
  792.     }
  793.     else if(dialogid == HOUSE_DIAG+18)
  794.     {
  795.         if(!response) return 1;
  796.  
  797.         if(!strlen(inputtext)) return ShowPlayerDialog(playerid, HOUSE_DIAG+18, DIALOG_STYLE_INPUT, "{"#B>"}House Settings - {"#G>"}House Vehicles", "{"#R>"}ERROR: You must enter a vehicle name or model id!\n\n{"#W>"}Enter a vehicle name or model id to continue", "Set", "Cancel");
  798.         new vehid = GetVehicleModel2(inputtext);
  799.         if(!IsValidVehicle(vehid) || !IsAllowedVehicle(vehid)) return ShowPlayerDialog(playerid, HOUSE_DIAG+18, DIALOG_STYLE_INPUT, "{"#B>"}House Settings - {"#G>"}House Vehicles", "{"#R>"}ERROR: This vehicle is either not allowed or does not exist!\n\n{"#W>"}Enter a vehicle name or model id to continue", "Set", "Cancel");
  800.  
  801.         new key[20];
  802.         new houseid = HOUSEID(playerid);
  803.         new vehslot = GetPVarInt(playerid, "HVehSlot");
  804.         format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  805.         format(key, sizeof(key), "VSlot%dModel", vehslot);
  806.         dini_IntSet(hfile, key, vehid);
  807.         hVeh[houseid][vehslot][ModelID] = vehid;
  808.         NotifyDialog(playerid, "{"#B>"}House Settings - {"#G>"}House Vehicles", "House vehicle model was successfully changed!");
  809.     }
  810.     else if(dialogid == HOUSE_DIAG+19)
  811.     {
  812.         new houseid = HOUSEID(playerid);
  813.         if(response)
  814.         {
  815.             new key[20];
  816.             format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  817.             format(key, sizeof(key), "VSlot%dModel", listitem);
  818.             if(!dini_Isset(hfile, key)) return NotifyDialog(playerid, "{"#B>"}House Settings - {"#G>"}Spawn House Vehicle", "{"#R>"}ERROR: This vehicle slot is not yet set, make sure to edit it first!");
  819.             for(new x=0; x<MAX_VEHICLE_SLOTS; x++) DestroyVehicle(hVeh[houseid][x][Vehicle]);
  820.  
  821.             new vehid = dini_Int(hfile, key);
  822.             hVeh[houseid][listitem][Vehicle] = CreateVehicle(vehid, hInfo[houseid][VehPos][0], hInfo[houseid][VehPos][1], hInfo[houseid][VehPos][2], hInfo[houseid][VehPos][3], random(120), random(120), 0);
  823.  
  824.             new str[115];
  825.             format(str, sizeof(str), "Vehicle '%s' (Slot %d) was successfully spawned at your house location!", VehicleNames[vehid-400], listitem);
  826.             SendClientMessage(playerid, MSG_COLOR, str);
  827.  
  828.             format(str, sizeof(str), "{"#B>"}Vehicle {"#G>"}'%s'\n{"#B>"}of {"#G>"}'Slot %d' {"#B>"}spawned!", VehicleNames[vehid-400], listitem);
  829.             CreateHouseNotice3DLabel(houseid, str, MSG_COLOR, hInfo[houseid][VehPos][0], hInfo[houseid][VehPos][1], hInfo[houseid][VehPos][2], 0, -1, -1, 8000);
  830.             PlayerPlaySound(playerid, 1054, 0.0, 0.0, 0.0);
  831.         }
  832.         else ShowOptionsDialog(playerid);
  833.     }
  834.     else if(dialogid == HOUSE_DIAG+20)
  835.     {
  836.         if(!response) return 1;
  837.         if(listitem == 0) return 1;
  838.         if(listitem == 1) ShowPlayerDialog(playerid, HOUSE_DIAG+21, DIALOG_STYLE_INPUT, "{"#B>"}House Cash - {"#G>"}Store Cash", "{"#W>"}TIP: Enter an amount of cash over {"#G>"}$500\n{"#W>"}store in the house!", "Store", "Cancel");
  839.         else if(listitem == 2) ShowPlayerDialog(playerid, HOUSE_DIAG+22, DIALOG_STYLE_INPUT, "{"#B>"}House Cash - {"#G>"}Take Cash", "{"#W>"}TIP: Enter an amount of cash to take from house!", "Take", "Cancel");
  840.     }
  841.     else if(dialogid == HOUSE_DIAG+21)
  842.     {
  843.         if(!response) return OnDialogResponse(playerid, HOUSE_DIAG+12, 1, 8, "");
  844.         if(!strlen(inputtext) || !IsNumeric(inputtext)) return ShowPlayerDialog(playerid, HOUSE_DIAG+21, DIALOG_STYLE_INPUT, "{"#B>"}House Cash - {"#G>"}Store Cash", "{"#R>"}ERROR: You must enter an amount!\n\n{"#W>"}Enter an amount of cash to store in the house!", "Store", "Cancel");
  845.  
  846.         new houseid = HOUSEID(playerid);
  847.         format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  848.  
  849.         new cash = strval(inputtext);
  850.         if(cash < 500) return ShowPlayerDialog(playerid, HOUSE_DIAG+22, DIALOG_STYLE_INPUT, "{"#B>"}House Cash - {"#G>"}Take Cash", "{"#R>"}ERROR: You must enter an amount!\n\n{"#W>"}Enter an amount of cash to take from the house!", "Store", "Cancel");
  851.         if(GetPlayerMoney(playerid) < cash) return ShowPlayerDialog(playerid, HOUSE_DIAG+21, DIALOG_STYLE_INPUT, "{"#B>"}House Cash - {"#G>"}Store Cash", "{"#R>"}ERROR: You do not have that much money!\n\n{"#W>"}Enter an amount of cash to store in the house!", "Store", "Cancel");
  852.  
  853.         hInfo[houseid][MoneyStash] += cash;
  854.         GivePlayerMoney(playerid, -cash);
  855.         dini_IntSet(hfile, "MoneyStash", hInfo[houseid][MoneyStash]);
  856.  
  857.         new str[100];
  858.         format(str, sizeof(str), "{"#W>"}You stored {"#G>"}'$%d' {"#W>"}in your house!\n\n{"#G>"}[Current Money: $%d]", cash, hInfo[houseid][MoneyStash]);
  859.         NotifyDialog(playerid, "{"#B>"}House Cash - {"#G>"}Store Cash", str);
  860.     }
  861.     else if(dialogid == HOUSE_DIAG+22)
  862.     {
  863.         if(!response) return OnDialogResponse(playerid, HOUSE_DIAG+12, 1, 8, "");
  864.         if(!strlen(inputtext) || !IsNumeric(inputtext)) return ShowPlayerDialog(playerid, HOUSE_DIAG+22, DIALOG_STYLE_INPUT, "{"#B>"}House Cash - {"#G>"}Take Cash", "{"#R>"}ERROR: You must enter an amount over $500!\n\n{"#W>"}Enter an amount of cash to take from the house!", "Take", "Cancel");
  865.  
  866.         new houseid = HOUSEID(playerid);
  867.         format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  868.  
  869.         new cash = strval(inputtext);
  870.         if(hInfo[houseid][MoneyStash] < cash) return ShowPlayerDialog(playerid, HOUSE_DIAG+22, DIALOG_STYLE_INPUT, "{"#B>"}House Cash - {"#G>"}Take Cash", "{"#R>"}ERROR: You do not have that much money stored!\n\n{"#W>"}Enter an amount of cash to take from the house!", "Take", "Cancel");
  871.  
  872.         hInfo[houseid][MoneyStash] -= cash;
  873.         GivePlayerMoney(playerid, cash);
  874.         dini_IntSet(hfile, "MoneyStash", hInfo[houseid][MoneyStash]);
  875.        
  876.         new str[100];
  877.         format(str, sizeof(str), "{"#W>"}You took {"#G>"}'$%d' {"#W>"}from your house!\n\n{"#G>"}[Current Money: $%d]", cash, hInfo[houseid][MoneyStash]);
  878.         NotifyDialog(playerid, "{"#B>"}House Cash - {"#G>"}Take Cash", str);
  879.     }
  880.     return 0;
  881. }
  882.  
  883. public OnPlayerUpdate(playerid)
  884. {
  885.     if(inmenu[playerid] == 1 && !BUILDINGHOUSE(playerid))
  886.     {
  887.         new Float:crd[3];
  888.         new houseid = HOUSEID(playerid);
  889.         crd[0] = hInfo[houseid][PickupPos][0];
  890.         crd[1] = hInfo[houseid][PickupPos][1];
  891.         crd[2] = hInfo[houseid][PickupPos][2];
  892.  
  893.         if(!IsPlayerInRangeOfPoint(playerid, 1.1, crd[0], crd[1], crd[2])) inmenu[playerid] = 0;
  894.     }
  895.     return 1;
  896. }
  897.  
  898. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  899. {
  900.     if(GetPVarInt(playerid, "InIntView"))
  901.     {
  902.         new intid = GetPVarInt(playerid, "IntViewID");
  903.         if(newkeys == KEY_JUMP) //Left
  904.         {
  905.             if(intid == 0) SetPVarInt(playerid, "IntViewID", 36);
  906.             else SetPVarInt(playerid, "IntViewID", intid-1);
  907.             UpdateIntScrollTextdraw(playerid);
  908.         }
  909.         else if(newkeys == KEY_SPRINT) //Right
  910.         {
  911.             if(intid == 36) SetPVarInt(playerid, "IntViewID", 0);
  912.             else SetPVarInt(playerid, "IntViewID", intid+1);
  913.             UpdateIntScrollTextdraw(playerid);
  914.         }
  915.         else if(newkeys == KEY_LOOK_BEHIND) //Spawn
  916.         {
  917.             SetPlayerPos(playerid, IntPos[intid][0], IntPos[intid][1], IntPos[intid][2]);
  918.             SetPlayerInterior(playerid, IntID[intid]);
  919.             TextDrawHideForPlayer(playerid, IntScrollTD);
  920.             SetPVarInt(playerid, "InIntView", 0);
  921.             SetCameraBehindPlayer(playerid);
  922.         }
  923.     }
  924.     return 1;
  925. }
  926.  
  927. public OnPlayerEnterDynamicCP(playerid, checkpointid)
  928. {
  929.     for(new x=0; x<MAX_HOUSES; x++)
  930.     {
  931.         if(BUILDINGHOUSE(playerid)) break;
  932.         if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) break;
  933.         if(checkpointid == hInfo[x][EnterCP])
  934.         {
  935.             SetPVarInt(playerid, "HouseID", x);
  936.             ShowPlayerDialog(playerid, HOUSE_DIAG+10, DIALOG_STYLE_LIST, "{"#G>"}House Entrance", "Enter House\nLock House\nPurchase House", "Select", "Cancel");
  937.             break;
  938.         }
  939.         else if(checkpointid == hInfo[x][ExitCP])
  940.         {
  941.             SetPVarInt(playerid, "HouseID", x);
  942.             SetPlayerPosEx(playerid, hInfo[x][ExitPos][0], hInfo[x][ExitPos][1], hInfo[x][ExitPos][2], hInfo[x][ExitPos][3], 0, 0);
  943.             break;
  944.         }
  945.     }
  946.     return 1;
  947. }
  948.  
  949. public OnPlayerPickUpDynamicPickup(playerid, pickupid)
  950. {
  951.     for(new x=0; x<MAX_HOUSES; x++)
  952.     {
  953.         if(BUILDINGHOUSE(playerid)) break;
  954.         if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) break;
  955.         if(pickupid == hInfo[x][Pickup] && IsHouseOwner(playerid, x) && inmenu[playerid] == 0)
  956.         {
  957.             inmenu[playerid] = 1;
  958.             SetPVarInt(playerid, "HouseID", x);
  959.             ShowOptionsDialog(playerid);
  960.             break;
  961.         }
  962.     }
  963.     return 1;
  964. }
  965.  
  966. //=========[Functions]============
  967. stock ShowBuilderDialog(playerid)
  968. {
  969.     ShowPlayerDialog(playerid, HOUSE_DIAG, DIALOG_STYLE_LIST, "{"#B>"}House Builder", "Build House\nEdit House\nDestroy House\nView House Info", "Select", "Exit");
  970. }
  971.  
  972. stock ShowEditDialog(playerid)
  973. {
  974.     #define EDITSTR "House Name\nPrice\nFor Sale\nInterior\nVirtual World\nEnter Position\nExit Position\nSpawn Position\nPickup Position\nLabel Position\nEnter Checkpoint\nExit Checkpoint\nTeleport\nVehicle Spawn Position"
  975.     ShowPlayerDialog(playerid, HOUSE_DIAG+4, DIALOG_STYLE_LIST, "{"#B>"}House Builder - {"#G>"}Edit", EDITSTR, "Select", "Exit");
  976. }
  977.  
  978. stock ShowOptionsDialog(playerid)
  979. {
  980.     if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
  981.     ShowPlayerDialog(playerid, HOUSE_DIAG+12, DIALOG_STYLE_LIST, "{"#G>"}House Settings", "House Information\nSet Password\nSet House Name\nSet House Price\nSet For Sale\nSpawn Here\nSet House Vehicles\nSpawn House Vehicle\nMoney Stash", "Select", "Cancel");
  982.     return 1;
  983. }
  984.  
  985. stock GetLowestOpenSlot()
  986. {
  987.     new num;
  988.     for(new x=0; x<MAX_HOUSES; x++)
  989.     {
  990.         format(hfile, sizeof(hfile), HOUSE_FILE, x);
  991.         if(!dini_Exists(hfile))
  992.         {
  993.             num = x;
  994.             break;
  995.         }
  996.     }
  997.     return num;
  998. }
  999.  
  1000. stock PasswordMatch(password[], houseid)
  1001. {
  1002.     format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  1003.     if(dini_Int(hfile, "Password") != udb_hash(password)) return 0;
  1004.     return 1;
  1005. }
  1006.  
  1007. stock IsHouseOwner(playerid, houseid)
  1008. {
  1009.     format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  1010.     if(!dini_Exists(hfile) || !strlen(hInfo[houseid][Owner])) return 0;
  1011.     if(!strcmp(hInfo[houseid][Owner], pName(playerid), true, strlen(pName(playerid)))) return 1;
  1012.     return 0;
  1013. }
  1014.  
  1015. public SpawnPlayerAtHouse(playerid)
  1016. {
  1017.     if(!IsPlayerToSpawnAtHouse(playerid)) return 1;
  1018.     new houseid = dini_Int(HUSER_FILE, pName(playerid));
  1019.     if(!IsHouseOwner(playerid, houseid)) return 1;
  1020.     SetPlayerPosEx(playerid, hInfo[houseid][SpawnPos][0], hInfo[houseid][SpawnPos][1], hInfo[houseid][SpawnPos][2], 0.0, hInfo[houseid][Interior], hInfo[houseid][World]);
  1021.     return 1;
  1022. }
  1023.  
  1024. stock IsPlayerToSpawnAtHouse(playerid)
  1025. {
  1026.     if(!dini_Exists(HUSER_FILE)) return 0;
  1027.     if(dini_Int(HUSER_FILE, pName(playerid)) == -1) return 0;
  1028.     if(!IsHouseOwner(playerid, dini_Int(HUSER_FILE, pName(playerid)))) return 0;
  1029.     return 1;
  1030. }
  1031.  
  1032. stock LoadIntScrollTextdraw()
  1033. {
  1034.     IntScrollTD = TextDrawCreate(250.000000, 342.000000, "noob");
  1035.     TextDrawBackgroundColor(IntScrollTD, 255);
  1036.     TextDrawFont(IntScrollTD, 3);
  1037.     TextDrawLetterSize(IntScrollTD, 0.500000, 1.000000);
  1038.     TextDrawColor(IntScrollTD, -1);
  1039.     TextDrawSetOutline(IntScrollTD, 0);
  1040.     TextDrawSetProportional(IntScrollTD, 1);
  1041.     TextDrawSetShadow(IntScrollTD, 1);
  1042.     TextDrawHideForAll(IntScrollTD);
  1043. }
  1044.  
  1045. stock UpdateIntScrollTextdraw(playerid)
  1046. {
  1047.     TextDrawHideForPlayer(playerid, IntScrollTD);
  1048.     new str[140];
  1049.     new intid = GetPVarInt(playerid, "IntViewID");
  1050.     format(str, sizeof(str), "Scroll with~n~~<~ ~p~~k~~PED_JUMPING~ - ~g~~k~~PED_SPRINT~ ~>~~n~~r~Interior ID ~y~%d~n~~w~Press ~k~~PED_LOOKBEHIND~ to spawn", intid);
  1051.     TextDrawSetString(IntScrollTD, str);
  1052.     TextDrawShowForPlayer(playerid, IntScrollTD);
  1053.     SetPlayerInterior(playerid, IntID[intid]);
  1054.     SetPlayerCameraPos(playerid, IntPos[intid][0], IntPos[intid][1], IntPos[intid][2]);
  1055.     SetPlayerCameraLookAt(playerid, IntPos[intid][0], IntPos[intid][1], IntPos[intid][2]);
  1056. }
  1057.  
  1058. stock DeleteHouse(houseid)
  1059. {
  1060.     format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  1061.     dini_Remove(hfile);
  1062.     format(hInfo[houseid][Name], MAX_HOUSE_NAME, "_");
  1063.     format(hInfo[houseid][Owner], MAX_PLAYER_NAME, "_");
  1064.     hInfo[houseid][Price] = 0;
  1065.     hInfo[houseid][ForSale] = 0;
  1066.     hInfo[houseid][Interior] = 0;
  1067.     hInfo[houseid][World] = 0;
  1068.     hInfo[houseid][Locked] = 0;
  1069.     for(new x=0; x<3; x++)
  1070.     {
  1071.         hInfo[houseid][EnterPos][x] = 0.0;
  1072.         hInfo[houseid][ExitPos][x] = 0.0;
  1073.         hInfo[houseid][SpawnPos][x] = 0.0;
  1074.         hInfo[houseid][PickupPos][x] = 0.0;
  1075.         hInfo[houseid][LabelPos][x] = 0.0;
  1076.         hInfo[houseid][EnterCPPos][x] = 0.0;
  1077.         hInfo[houseid][ExitCPPos][x] = 0.0;
  1078.     }
  1079.     DestroyDynamicCP(hInfo[houseid][EnterCP]);
  1080.     DestroyDynamicCP(hInfo[houseid][ExitCP]);
  1081.     DestroyDynamicPickup(hInfo[houseid][Pickup]);
  1082.     DestroyDynamicMapIcon(hInfo[houseid][MapIcon]);
  1083.     DestroyDynamic3DTextLabel(hInfo[houseid][InfoLabel]);
  1084.     return 1;
  1085. }
  1086.  
  1087. stock SetHouseForSale(houseid, value)
  1088. {
  1089.     format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  1090.     if(value == 0)
  1091.     {
  1092.         dini_IntSet(hfile, "ForSale", 0);
  1093.         hInfo[houseid][ForSale] = 0;
  1094.         DestroyDynamicPickup(hInfo[houseid][Pickup]);
  1095.         DestroyDynamicMapIcon(hInfo[houseid][MapIcon]);
  1096.         hInfo[houseid][Pickup] = CreateDynamicPickup(NOTFORSALE_PICKUP, 1, hInfo[houseid][PickupPos][0], hInfo[houseid][PickupPos][1], hInfo[houseid][PickupPos][2], 0, 0, -1, PICKUP_DRAW);
  1097.         hInfo[houseid][MapIcon] = CreateDynamicMapIcon(hInfo[houseid][PickupPos][0], hInfo[houseid][PickupPos][1], hInfo[houseid][PickupPos][2], NOTFORSALE_ICON, 0, 0, 0, -1, ICON_DRAW);
  1098.     }
  1099.     if(value == 1)
  1100.     {
  1101.         dini_IntSet(hfile, "ForSale", 1);
  1102.         hInfo[houseid][ForSale] = 1;
  1103.         DestroyDynamicPickup(hInfo[houseid][Pickup]);
  1104.         DestroyDynamicMapIcon(hInfo[houseid][MapIcon]);
  1105.         hInfo[houseid][Pickup] = CreateDynamicPickup(FORSALE_PICKUP, 1, hInfo[houseid][PickupPos][0], hInfo[houseid][PickupPos][1], hInfo[houseid][PickupPos][2], 0, 0, -1, PICKUP_DRAW);
  1106.         hInfo[houseid][MapIcon] = CreateDynamicMapIcon(hInfo[houseid][PickupPos][0], hInfo[houseid][PickupPos][1], hInfo[houseid][PickupPos][2], FORSALE_ICON, 0, 0, 0, -1, ICON_DRAW);
  1107.     }
  1108.     return 0;
  1109. }
  1110.  
  1111. LoadHouses()
  1112. {
  1113.     for(new x=0; x<MAX_HOUSES; x++)
  1114.     {
  1115.         format(hfile, sizeof(hfile), HOUSE_FILE, x);
  1116.         if(!fexist(hfile)) continue;
  1117.  
  1118.         format(hInfo[x][Name], MAX_HOUSE_NAME, "%s", dini_Get(hfile, "Name"));
  1119.         format(hInfo[x][Owner], MAX_PLAYER_NAME, "%s", dini_Get(hfile, "Owner"));
  1120.         hInfo[x][Price] = dini_Int(hfile, "Price");
  1121.         hInfo[x][ForSale] = dini_Int(hfile, "ForSale");
  1122.         hInfo[x][Interior] = dini_Int(hfile, "Interior");
  1123.         hInfo[x][World] = dini_Int(hfile, "World");
  1124.         hInfo[x][Locked] = dini_Int(hfile, "Locked");
  1125.         hInfo[x][MoneyStash] = dini_Int(hfile, "MoneyStash");
  1126.  
  1127.         for(new z=0; z<MAX_VEHICLE_SLOTS; z++)
  1128.         {
  1129.             new key[20];
  1130.             format(key, sizeof(key), "VSlot%dModel", z);
  1131.             if(!dini_Isset(hfile, key)) dini_IntSet(hfile, key, 429); //Prevent spawn vehicle dialog bug
  1132.             hVeh[x][z][ModelID] = dini_Int(hfile, key);
  1133.         }
  1134.  
  1135.         if(IsHousePropSet(x, "EnterPos")) sscanf(dini_Get(hfile, "EnterPos"), "p<,>ffff", hInfo[x][EnterPos][0], hInfo[x][EnterPos][1], hInfo[x][EnterPos][2], hInfo[x][EnterPos][3]);
  1136.         if(IsHousePropSet(x, "ExitPos")) sscanf(dini_Get(hfile, "ExitPos"), "p<,>ffff", hInfo[x][ExitPos][0], hInfo[x][ExitPos][1], hInfo[x][ExitPos][2], hInfo[x][ExitPos][3]);
  1137.         if(IsHousePropSet(x, "SpawnPos")) sscanf(dini_Get(hfile, "SpawnPos"), "p<,>ffff", hInfo[x][SpawnPos][0], hInfo[x][SpawnPos][1], hInfo[x][SpawnPos][2], hInfo[x][SpawnPos][3]);
  1138.         if(IsHousePropSet(x, "PickupPos")) sscanf(dini_Get(hfile, "PickupPos"), "p<,>fff", hInfo[x][PickupPos][0], hInfo[x][PickupPos][1], hInfo[x][PickupPos][2]);
  1139.         if(IsHousePropSet(x, "LabelPos")) sscanf(dini_Get(hfile, "LabelPos"), "p<,>fff", hInfo[x][LabelPos][0], hInfo[x][LabelPos][1], hInfo[x][LabelPos][2]);
  1140.         if(IsHousePropSet(x, "EnterCPPos")) sscanf(dini_Get(hfile, "EnterCPPos"), "p<,>fff", hInfo[x][EnterCPPos][0], hInfo[x][EnterCPPos][1], hInfo[x][EnterCPPos][2]);
  1141.         if(IsHousePropSet(x, "ExitCPPos")) sscanf(dini_Get(hfile, "ExitCPPos"), "p<,>fff", hInfo[x][ExitCPPos][0], hInfo[x][ExitCPPos][1], hInfo[x][ExitCPPos][2]);
  1142.         if(IsHousePropSet(x, "VehPos")) sscanf(dini_Get(hfile, "VehPos"), "p<,>ffff", hInfo[x][VehPos][0], hInfo[x][VehPos][1], hInfo[x][VehPos][2], hInfo[x][VehPos][3]);
  1143.  
  1144.         if(IsHousePropSet(x, "ForSale"))
  1145.         {
  1146.             if(dini_Int(hfile, "ForSale"))
  1147.             {
  1148.                 hInfo[x][Pickup] = CreateDynamicPickup(FORSALE_PICKUP, 1, hInfo[x][PickupPos][0], hInfo[x][PickupPos][1], hInfo[x][PickupPos][2], 0, 0, -1, PICKUP_DRAW);
  1149.                 hInfo[x][MapIcon] = CreateDynamicMapIcon(hInfo[x][PickupPos][0], hInfo[x][PickupPos][1], hInfo[x][PickupPos][2], FORSALE_ICON, 0, 0, 0, -1, ICON_DRAW);
  1150.             }
  1151.             else
  1152.             {
  1153.                 hInfo[x][Pickup] = CreateDynamicPickup(NOTFORSALE_PICKUP, 1, hInfo[x][PickupPos][0], hInfo[x][PickupPos][1], hInfo[x][PickupPos][2], 0, 0, -1, PICKUP_DRAW);
  1154.                 hInfo[x][MapIcon] = CreateDynamicMapIcon(hInfo[x][PickupPos][0], hInfo[x][PickupPos][1], hInfo[x][PickupPos][2], NOTFORSALE_ICON, 0, 0, 0, -1, ICON_DRAW);
  1155.             }
  1156.         }
  1157.  
  1158.         if(IsHousePropSet(x, "EnterCPPos")) hInfo[x][EnterCP] = CreateDynamicCP(hInfo[x][EnterCPPos][0], hInfo[x][EnterCPPos][1], hInfo[x][EnterCPPos][2], ENTERCP_SIZE, -1, 0, -1, ENTERCP_DRAW);
  1159.         if(IsHousePropSet(x, "ExitCPPos")) hInfo[x][ExitCP] = CreateDynamicCP(hInfo[x][ExitCPPos][0], hInfo[x][ExitCPPos][1], hInfo[x][ExitCPPos][2], EXITCP_SIZE, hInfo[x][World], hInfo[x][Interior], -1, ENTERCP_DRAW);
  1160.  
  1161.         if(IsHousePropSet(x, "LabelPos"))
  1162.         {
  1163.             new str[125];
  1164.             format(str, sizeof(str), "{"#G>"}%s\n{"#B>"}Owner {"#W>"}%s\n{"#R>"}Price {"#W>"}$%d", hInfo[x][Name], hInfo[x][Owner], hInfo[x][Price]);
  1165.             hInfo[x][InfoLabel] = CreateDynamic3DTextLabel(str, LABEL_COLOR, hInfo[x][LabelPos][0], hInfo[x][LabelPos][1], hInfo[x][LabelPos][2], LABEL_DRAW, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, LABEL_LOS, 0, 0, -1, LABEL_DRAW);
  1166.         }
  1167.     }
  1168.     return 1;
  1169. }
  1170.  
  1171. stock IsHousePropSet(houseid, key[])
  1172. {
  1173.     format(hfile, sizeof(hfile), HOUSE_FILE, houseid);
  1174.     return dini_Isset(hfile, key);
  1175. }
  1176.  
  1177. //=====[Internal Functions]=====
  1178. stock IsValidVehicle(modelid)
  1179. {
  1180.     switch(modelid)
  1181.     {
  1182.         case 581, 523, 462, 521, 463, 522, 461, 448, 468, 586, 509, 481, 510, 472, 473, 493, 595, 484, 430, 453,
  1183.         452, 446, 454, 445, 602, 416, 485, 568, 429, 433, 499, 424, 536, 496, 504, 422, 609, 498, 401, 575, 518,
  1184.         402, 541, 482, 431, 438, 457, 527, 483, 524, 415, 542, 589, 437, 532, 480, 596, 599, 597, 598, 578, 486,
  1185.         507, 562, 585, 427, 419, 587, 490, 528, 533, 544, 407, 565, 455, 530, 526, 466, 604, 492, 474, 588, 434,
  1186.         502, 503, 494, 579, 545, 411, 546, 559, 508, 571, 400, 403, 517, 410, 551, 500, 418, 572, 423, 414, 516,
  1187.         582, 467, 443, 470, 404, 514, 603, 600, 413, 426, 436, 547, 489, 441, 594, 564, 515, 479, 534, 432, 505,
  1188.         442, 440, 475, 543, 605, 495, 567, 428, 405, 535, 458, 580, 439, 561, 409, 560, 506, 601, 574, 566, 549,
  1189.         420, 459, 576, 525, 531, 408, 583, 451, 558, 552, 540, 491, 412, 478, 421, 529, 456, 554, 477, 548, 425,
  1190.         417, 487, 497, 563, 501, 465, 447, 469, 488, 406, 573, 444, 556, 557, 592, 577, 511, 512, 593, 520, 553,
  1191.         464, 476, 519, 460, 513, 539, 471, 435, 450, 591, 606, 607, 610, 584, 608, 611, 590, 449: return 1;
  1192.         default: return 0;
  1193.     }
  1194.     return 0;
  1195. }
  1196.  
  1197. stock IsAllowedVehicle(vehicleid)
  1198. {
  1199.     switch(vehicleid)
  1200.     {
  1201.         case 520, 407, 425, 427, 432, 441, 447, 449, 464, 465, 476, 501, 537, 538, 564, 569, 570, 590, 592, 601, 577: return 0;
  1202.         default: return 1;
  1203.     }
  1204.     return 1;
  1205. }
  1206.  
  1207. stock GetVehicleModel2(vname[])
  1208. {
  1209.     if(IsNumeric(vname)) return strval(vname);
  1210.     for(new i = 0; i < 211; i++)
  1211.     {
  1212.         if(strfind(VehicleNames[i], vname, true) != -1)
  1213.         return i + 400;
  1214.     }
  1215.     return -1;
  1216. }
  1217.  
  1218. stock udb_hash(buf[])
  1219. {
  1220.     new length = strlen(buf);
  1221.     new s1 = 1;
  1222.     new s2 = 0;
  1223.     new n;
  1224.     for (n=0; n<length; n++) {
  1225.         s1 = (s1 + buf[n]) % 65521;
  1226.         s2 = (s2 + s1)   % 65521;
  1227.     }
  1228.     return (s2 << 16) + s1;
  1229. }
  1230.  
  1231. IsNumeric(const string[])
  1232. {
  1233.     for (new i = 0, j = strlen(string); i < j; i++)
  1234.     {
  1235.         if (string[i] > '9' || string[i] < '0') return 0;
  1236.     }
  1237.     return 1;
  1238. }
  1239.  
  1240. stock pName(playerid)
  1241. {
  1242.     new aname[MAX_PLAYER_NAME];
  1243.     GetPlayerName(playerid, aname, sizeof(aname));
  1244.     return aname;
  1245. }
  1246.  
  1247. stock NotifyDialog(playerid, title[], content[])
  1248. {
  1249.     return ShowPlayerDialog(playerid, HOUSE_DIAG-1, DIALOG_STYLE_MSGBOX, title, content, "Exit", "");
  1250. }
  1251.  
  1252. stock SetPlayerPosEx(playerid, Float:x, Float:y, Float:z, Float:angle, interior, world)
  1253. {
  1254.     SetPlayerPos(playerid, x, y, z);
  1255.     SetPlayerFacingAngle(playerid, angle);
  1256.     SetPlayerInterior(playerid, interior);
  1257.     SetPlayerVirtualWorld(playerid, world);
  1258. }
  1259.  
  1260. CreateHouseNotice3DLabel(houseid, str[], labelcolor, Float:X, Float:Y, Float:Z, labellos, virtualworld, interior, ms)
  1261. {
  1262.     DestroyDynamic3DTextLabel(hInfo[houseid][NoticeLabel]);
  1263.     hInfo[houseid][NoticeLabel] = CreateDynamic3DTextLabel(str, labelcolor, X, Y, Z, LABEL_DRAW, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, labellos, virtualworld, interior, -1, LABEL_DRAW);
  1264.     SetTimerEx("HideHouseNotice3DLabel", ms, 0, "d", houseid);
  1265. }
  1266.  
  1267. forward HideHouseNotice3DLabel(houseid);
  1268. public HideHouseNotice3DLabel(houseid)
  1269. {
  1270.     DestroyDynamic3DTextLabel(hInfo[houseid][NoticeLabel]);
  1271.     return 1;
  1272. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement