KrisnaPradnya

awada

Jul 11th, 2013
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 136.79 KB | None | 0 0
  1. // Make sure you don't get warnings about tabsize
  2. #pragma tabsize 0
  3.  
  4. // Include default files
  5. #include <a_samp>
  6. #include <zcmd>
  7. #include <sscanf2>
  8. #include <streamer>
  9.  
  10. //if you see this, you are gay
  11. #define TEXTLABEL_DISTANCE          25.0 // 3D text visible range (drawdistance)
  12. #define TEXTLABEL_TESTLOS           1 // 1 makes the 3D text label visible trough walls.
  13.  
  14. new bool:SpawnAtHouse = false;
  15. new ExitHouseTimer = 1000;
  16. new bool:ShowBoughtHouses = true;
  17. new bool:LoadCarsDuringFSInit = false;
  18. new bool:AutomaticInsurance = true;
  19.  
  20. // Default max number of players is set to 500, re-define it to 50
  21. #undef MAX_PLAYERS
  22. #define MAX_PLAYERS 50
  23.  
  24. // Define housing parameters
  25. #define MAX_HOUSES                  2000 // Defines the maximum number of houses that can be created
  26. #define MAX_HOUSESPERPLAYER         8 // Defines the maximum number of houses that any player can own (useable values: 1 to 20)
  27. #define HouseUpgradePercent         100 // Defines the percentage for upgrading a house (house of 10m can be upgraded for 5m when set to 50)
  28. #define ParkRange                   20 // Defines the range for parking the vehicle around the house to which it belongs (default = 150m)
  29.  
  30. // Define path to house-files
  31. #define HouseFile "PPC_Housing/House%i.ini"
  32.  
  33. // Define Dialogs
  34. #define DialogHouseMenu             5001
  35. #define DialogUpgradeHouse          5002
  36. #define DialogGoHome                5003
  37. #define DialogHouseNameChange       5004
  38. #define DialogSellHouse             5005
  39. #define DialogBuyCarClass           5006
  40. #define DialogBuyCar                5007
  41. #define DialogSellCar               5008
  42. #define DialogBuyInsurance          5009
  43. #define DialogGetCarSelectHouse     5010
  44. #define DialogGetCarSelectCar       5011
  45.  
  46. // Define vehicle-classes
  47. #define VClassBike          1
  48. #define VClassBoat          2
  49. #define VClassConvertible   3
  50. #define VClassHelicopter    4
  51. #define VClassIndustrial    5
  52. #define VClassLowRider      6
  53. #define VClassOffRoad       7
  54. #define VClassPlane         8
  55. #define VClassPublic        9
  56. #define VClassRCVehicle     10
  57. #define VClassSaloons       11
  58. #define VClassSportCar      12
  59. #define VClassStationCar    13
  60. #define VClassTrailer       14
  61. #define VClassUnique        15
  62.  
  63.  
  64.  
  65. // ******************************************************************************************************************************
  66. // Enums and the array-setups that use them
  67. // ******************************************************************************************************************************
  68.  
  69. // Setup a custom type that holds all data for houses
  70. enum THouseData
  71. {
  72.     PickupID, // Holds the pickup-id that is linked to this house
  73.     Text3D:DoorText, // Holds the reference to the 3DText above the house's pickup
  74.     MapIconID, // Holds the ID of the mapicon for the house
  75.  
  76.     bool:Owned, // Holds true if the house is owned by somebody
  77.     Owner[24], // Holds the name of the owner of the house
  78.  
  79.     HouseName[100], // Holds the name of the house (this will be displayed above the pickup near the house when it's owned)
  80.     Float:HouseX, // Holds the X-coordinate of the pickup for the house
  81.     Float:HouseY, // Holds the Y-coordinate of the pickup for the house
  82.     Float:HouseZ, // Holds the Z-coordinate of the pickup for the house
  83.     HouseLevel, // Holds the level of upgrades the house has, and defines which interior to use when you enter the house
  84.     HouseMaxLevel, // Holds the maximum level this house can be upgraded to
  85.     HousePrice, // Holds the price for buying the house, the same price applies when upgrading a house per level (multiplied by HouseUpgradePercent/100)
  86.     bool:HouseOpened, // Holds true if the house is open to the public (anyone can enter), false means: only the owner can enter it
  87.     bool:Insurance, // Holds "true" if the house has an insurance for the vehicles belonging to this house
  88.     VehicleIDs[10], // Holds the vehicle-id's of the vehicles linked to this house (max 10 vehicles per house)
  89.  
  90.     bool:StaticHouse, // Holds "true" if the house is static (cannot be upgraded and has a fixed interior)
  91.     CarSlots // Holds the amount of carslots available
  92. }
  93. // Holds the data for all houses
  94. new AHouseData[MAX_HOUSES][THouseData];
  95.  
  96.  
  97.  
  98. // Setup a custom type to hold all data about a vehicle
  99. enum TVehicleData
  100. {
  101.     BelongsToHouse, // Holds the HouseID to which this vehicle belongs
  102.  
  103.     bool:Owned, // Holds true if the vehicle is owned by somebody
  104.     Owner[24], // Holds the name of the owner of the vehicle
  105.  
  106.     Model, // Holds the vehicle-model of this vehicle
  107.     PaintJob, // Holds the ID of the paintjob applied to the vehicle
  108.     Components[14], // Holds all Component-ID's for all components on the vehicle
  109.     Color1, // Holds the primary color for this vehicle
  110.     Color2, // Holds the secundairy color for this vehicle
  111.  
  112.     Float:SpawnX, // Holds the X-coordinate of the parking spot for this vehicle
  113.     Float:SpawnY, // Holds the Y-coordinate of the parking spot for this vehicle
  114.     Float:SpawnZ, // Holds the Z-coordinate of the parking spot for this vehicle
  115.     Float:SpawnRot // Holds the rotation of the parking spot for this vehicle
  116. }
  117. // Setup an array which holds all data for every vehicle, max 2000 vehicles (server limit)
  118. new AVehicleData[2000][TVehicleData];
  119.  
  120.  
  121.  
  122. // Setup all the fields required for the player data (Speedometer TextDraw, current job, ...)
  123. enum TPlayerData
  124. {
  125.     Houses[20], // Holds the HouseID's of the houses that the player owns (index of the AHouseData array), maximum 20 houses per player
  126.     CurrentHouse, // Holds the HouseID to track in which house the player currently is (used when accessing the housemenu)
  127.     DialogBuyVClass,
  128.     DialogGetCarHouseID
  129. }
  130. // Create an array to hold the playerdata for every player
  131. new APlayerData[MAX_PLAYERS][TPlayerData];
  132.  
  133.  
  134.  
  135. // Setup a custom type that holds all data about a house-interior (selected when entering a house, based on the house-level)
  136. enum THouseInterior
  137. {
  138.     InteriorName[50], // Holds the name of the interior
  139.     InteriorID, // Holds the interior-id
  140.     Float:IntX, // Holds the X-coordinate of the spawn-location where you enter the house
  141.     Float:IntY, // Holds the Y-coordinate of the spawn-location where you enter the house
  142.     Float:IntZ // Holds the Z-coordinate of the spawn-location where you enter the house
  143. }
  144. // Holds the data for all interiors for houses (each house-level has it's own interior)
  145. new AHouseInteriors[][THouseInterior] =
  146. {
  147.     {"Dummy",               0,      0.0,        0.0,        0.0}, // Dummy interior (Level 0), as the house-level starts at 1
  148.     {"Small motel room",    10,     2262.83,    -1137.71,   1050.63}, // Level 1
  149.     {"Small house",         2,      2467.36,    -1698.38,   1013.51}, // Level 2
  150.     {"Small house 2",       1,      223.00,     1289.26,    1082.20}, // Level 3
  151.     {"Medium house",        10,     2260.76,    -1210.45,   1049.02}, // Level 4
  152.     {"Medium house 2",      8,      2365.42,    -1131.85,   1050.88}, // Level 5
  153.     {"Duplex house",        12,     2324.33,    -1144.79,   1050.71}, // Level 6
  154.     {"Big house",           15,     295.14,     1474.47,    1080.52}, // Level 7
  155.     {"Big duplex house",    3,      235.50,     1189.17,    1080.34}, // Level 8
  156.     {"Huge house",          7,      225.63,     1022.48,    1084.07}, // Level 9
  157.     {"Mansion",             5,      1299.14,    -794.77,    1084.00} // Level 10
  158. };
  159.  
  160.  
  161.  
  162. // Setup a custom type that holds all data about a buyable vehicle
  163. enum TBuyableVehicle
  164. {
  165.     CarName[50], // Holds the name of the vehicle
  166.     VehicleClass, // Holds the ID of the vehicleclass
  167.     CarModel, // Holds the model-ID of the vehicle
  168.     Price // Holds the price for the vehicle (renting it will be 10% of this price)
  169. }
  170. new ABuyableVehicles[][TBuyableVehicle] =
  171. {
  172.     {"Admiral", VClassSaloons, 445, 50000},
  173.     {"Alpha", VClassSportCar, 602, 50000},
  174.     {"Ambulance", VClassPublic, 416, 50000},
  175.     {"Andromada", VClassPlane, 592, 50000},
  176.     {"Article Trailer", VClassTrailer, 591, 50000},
  177. //  {"AT400", VClassPlane, 577, 50000},
  178.     {"Baggage", VClassUnique, 485, 50000},
  179.     {"Baggage Trailer A", VClassTrailer, 606, 50000},
  180.     {"Baggage Trailer B", VClassTrailer, 607, 50000},
  181.     {"Bandito", VClassOffRoad, 568, 50000},
  182.     {"Banshee", VClassSportCar, 429, 50000},
  183.     {"Barracks", VClassPublic, 433, 50000},
  184.     {"Beagle", VClassPlane, 511, 50000},
  185.     {"Benson", VClassIndustrial, 499, 50000},
  186.     {"Berkley's RC Van", VClassIndustrial, 459, 50000},
  187.     {"BF Injection", VClassOffRoad, 424, 50000},
  188.     {"BF-400", VClassBike, 581, 50000},
  189.     {"Bike", VClassBike, 509, 50000},
  190.     {"Blade", VClassLowRider, 536, 50000},
  191.     {"Blista Compact", VClassSportCar, 496, 50000},
  192.     {"Bloodring Banger", VClassSaloons, 504, 50000},
  193.     {"BMX", VClassBike, 481, 50000},
  194.     {"Bobcat", VClassIndustrial, 422, 50000},
  195.     {"Boxville 1", VClassIndustrial, 498, 50000},
  196.     {"Boxville 2", VClassIndustrial, 609, 50000},
  197.     {"Bravura", VClassSaloons, 401, 50000},
  198.     {"Broadway", VClassLowRider, 575, 50000},
  199. //  {"Brownstreak (train)", VClassUnique, 538, 50000},
  200.     {"Buccaneer", VClassSaloons, 518, 50000},
  201.     {"Buffalo", VClassSportCar, 402, 50000},
  202.     {"Bullet", VClassSportCar, 541, 50000},
  203.     {"Burrito", VClassIndustrial, 482, 50000},
  204.     {"Bus", VClassPublic, 431, 50000},
  205.     {"Cabbie", VClassPublic, 438, 50000},
  206.     {"Caddy", VClassUnique, 457, 50000},
  207.     {"Cadrona", VClassSaloons, 527, 50000},
  208.     {"Camper", VClassUnique, 483, 50000},
  209.     {"Cargo Trailer", VClassTrailer, 435, 50000},
  210.     {"Cargobob", VClassHelicopter, 548, 50000},
  211.     {"Cement Truck", VClassIndustrial, 524, 50000},
  212.     {"Cheetah", VClassSportCar, 415, 50000},
  213.     {"Clover", VClassSaloons, 542, 50000},
  214.     {"Club", VClassSportCar, 589, 50000},
  215.     {"Coach", VClassPublic, 437, 50000},
  216.     {"Coastguard", VClassBoat, 472, 50000},
  217.     {"Combine Harvester", VClassUnique, 532, 50000},
  218.     {"Comet", VClassConvertible, 480, 50000},
  219.     {"Cropduster", VClassPlane, 512, 50000},
  220.     {"DFT-30", VClassIndustrial, 578, 50000},
  221.     {"Dinghy", VClassBoat, 473, 50000},
  222.     {"Dodo", VClassPlane, 593, 50000},
  223.     {"Dozer", VClassUnique, 486, 50000},
  224.     {"Dumper", VClassUnique, 406, 50000},
  225.     {"Dune", VClassOffRoad, 573, 50000},
  226.     {"Elegant", VClassSaloons, 507, 50000},
  227.     {"Elegy", VClassSaloons, 562, 50000},
  228.     {"Emperor", VClassSaloons, 585, 50000},
  229.     {"Enforcer", VClassPublic, 427, 50000},
  230.     {"Esperanto", VClassSaloons, 419, 50000},
  231.     {"Euros", VClassSportCar, 587, 50000},
  232.     {"Faggio", VClassBike, 462, 50000},
  233.     {"Farm Trailer", VClassTrailer, 610, 50000},
  234.     {"FBI Rancher", VClassPublic, 490, 50000},
  235.     {"FBI Truck", VClassPublic, 528, 50000},
  236.     {"FCR-900", VClassBike, 521, 50000},
  237.     {"Feltzer", VClassConvertible, 533, 50000},
  238.     {"Firetruck", VClassPublic, 407, 50000},
  239.     {"Firetruck LA", VClassPublic, 544, 50000},
  240.     {"Flash", VClassSportCar, 565, 50000},
  241.     {"Flatbed", VClassIndustrial, 455, 50000},
  242.     {"Fluids Trailer", VClassTrailer, 584, 50000},
  243.     {"Forklift", VClassUnique, 530, 50000},
  244.     {"Fortune", VClassSaloons, 526, 50000},
  245.     {"Freeway", VClassBike, 463, 50000},
  246. //  {"Freight (train)", VClassUnique, 537, 50000},
  247. //  {"Freight Box Trailer (train)", VClassTrailer, 590, 50000},
  248. //  {"Freight Flat Trailer (train)", VClassTrailer, 569, 50000},
  249.     {"Glendale", VClassSaloons, 466, 50000},
  250.     {"Glendale Shit", VClassSaloons, 604, 50000},
  251.     {"Greenwood", VClassSaloons, 492, 50000},
  252.     {"Hermes", VClassSaloons, 474, 50000},
  253.     {"Hotdog", VClassUnique, 588, 50000},
  254.     {"Hotknife", VClassUnique, 434, 50000},
  255.     {"Hotring Racer 1", VClassSportCar, 494, 50000},
  256.     {"Hotring Racer 2", VClassSportCar, 502, 50000},
  257.     {"Hotring Racer 3", VClassSportCar, 503, 50000},
  258.     {"HPV1000", VClassPublic, 523, 50000},
  259.     {"Hunter", VClassHelicopter, 425, 50000},
  260.     {"Huntley", VClassOffRoad, 579, 50000},
  261.     {"Hustler", VClassUnique, 545, 50000},
  262.     {"Hydra", VClassPlane, 520, 50000},
  263.     {"Infernus", VClassSportCar, 411, 50000},
  264.     {"Intruder", VClassSaloons, 546, 50000},
  265.     {"Jester", VClassSportCar, 559, 50000},
  266.     {"Jetmax", VClassBoat, 493, 50000},
  267.     {"Journey", VClassUnique, 508, 50000},
  268.     {"Kart", VClassUnique, 571, 50000},
  269.     {"Landstalker", VClassOffRoad, 400, 50000},
  270.     {"Launch", VClassBoat, 595, 50000},
  271.     {"Leviathan", VClassHelicopter, 417, 50000},
  272.     {"Linerunner", VClassIndustrial, 403, 50000},
  273.     {"Majestic", VClassSaloons, 517, 50000},
  274.     {"Manana", VClassSaloons, 410, 50000},
  275.     {"Marquis", VClassBoat, 484, 50000},
  276.     {"Maverick", VClassHelicopter, 487, 50000},
  277.     {"Merit", VClassSaloons, 551, 50000},
  278.     {"Mesa", VClassOffRoad, 500, 50000},
  279.     {"Monster", VClassOffRoad, 444, 50000},
  280.     {"Monster A", VClassOffRoad, 556, 50000},
  281.     {"Monster B", VClassOffRoad, 557, 50000},
  282.     {"Moonbeam", VClassStationCar, 418, 50000},
  283.     {"Mountain Bike", VClassBike, 510, 50000},
  284.     {"Mower", VClassUnique, 572, 50000},
  285.     {"Mr Whoopee", VClassUnique, 423, 50000},
  286.     {"Mule", VClassIndustrial, 414, 50000},
  287.     {"Nebula", VClassSaloons, 516, 50000},
  288.     {"Nevada", VClassPlane, 553, 50000},
  289.     {"Newsvan", VClassIndustrial, 582, 50000},
  290.     {"NRG-500", VClassBike, 522, 50000},
  291.     {"Oceanic", VClassSaloons, 467, 50000},
  292.     {"Ore Trailer", VClassTrailer, 450, 50000},
  293.     {"Packer", VClassIndustrial, 443, 50000},
  294.     {"Patriot", VClassOffRoad, 470, 50000},
  295.     {"PCJ-600", VClassBike, 461, 50000},
  296.     {"Perenniel", VClassStationCar, 404, 50000},
  297.     {"Phoenix", VClassSportCar, 603, 50000},
  298.     {"Picador", VClassIndustrial, 600, 50000},
  299.     {"Pizzaboy", VClassBike, 448, 50000},
  300.     {"Police Car (LSPD)", VClassPublic, 596, 50000},
  301.     {"Police Car (LVPD)", VClassPublic, 598, 50000},
  302.     {"Police Car (SFPD)", VClassPublic, 597, 50000},
  303.     {"Police Maverick", VClassHelicopter, 497, 50000},
  304.     {"Police Ranger", VClassPublic, 599, 50000},
  305.     {"Pony", VClassIndustrial, 413, 50000},
  306.     {"Predator", VClassBoat, 430, 50000},
  307.     {"Premier", VClassSaloons, 426, 50000},
  308.     {"Previon", VClassSaloons, 436, 50000},
  309.     {"Primo", VClassSaloons, 547, 50000},
  310.     {"Quad", VClassBike, 471, 50000},
  311.     {"Raindance", VClassHelicopter, 563, 50000},
  312.     {"Rancher 1", VClassOffRoad, 489, 50000},
  313.     {"Rancher 2", VClassOffRoad, 505, 50000},
  314. //  {"RC Bandit", VClassRCVehicle, 441, 50000},
  315. //  {"RC Baron", VClassRCVehicle, 464, 50000},
  316. //  {"RC Cam", VClassRCVehicle, 594, 50000},
  317. //  {"RC Goblin", VClassRCVehicle, 501, 50000},
  318. //  {"RC Raider", VClassRCVehicle, 465, 50000},
  319. //  {"RC Tiger", VClassRCVehicle, 564, 50000},
  320.     {"Reefer", VClassBoat, 453, 50000},
  321.     {"Regina", VClassStationCar, 479, 50000},
  322.     {"Remington", VClassLowRider, 534, 50000},
  323.     {"Rhino", VClassPublic, 432, 50000},
  324.     {"Roadtrain", VClassIndustrial, 515, 50000},
  325.     {"Romero", VClassUnique, 442, 50000},
  326.     {"Rumpo", VClassIndustrial, 440, 50000},
  327.     {"Rustler", VClassPlane, 476, 50000},
  328.     {"Sabre", VClassSportCar, 475, 50000},
  329.     {"Sadler", VClassIndustrial, 543, 50000},
  330.     {"Sadler Shit", VClassIndustrial, 605, 50000},
  331.     {"SAN News Maverick", VClassHelicopter, 488, 50000},
  332.     {"Sanchez", VClassBike, 468, 50000},
  333.     {"Sandking", VClassOffRoad, 495, 50000},
  334.     {"Savanna", VClassLowRider, 567, 50000},
  335.     {"Seasparrow", VClassHelicopter, 447, 50000},
  336.     {"Securicar", VClassUnique, 428, 50000},
  337.     {"Sentinel", VClassSaloons, 405, 50000},
  338.     {"Shamal", VClassPlane, 519, 50000},
  339.     {"Skimmer", VClassPlane, 460, 50000},
  340.     {"Slamvan", VClassLowRider, 535, 50000},
  341.     {"Solair", VClassStationCar, 458, 50000},
  342.     {"Sparrow", VClassHelicopter, 469, 50000},
  343.     {"Speeder", VClassBoat, 452, 50000},
  344.     {"Squallo", VClassBoat, 446, 50000},
  345.     {"Stafford", VClassSaloons, 580, 50000},
  346.     {"Stallion", VClassConvertible, 439, 50000},
  347.     {"Stratum", VClassStationCar, 561, 50000},
  348. //  {"Streak Trailer (train)", VClassTrailer, 570, 50000},
  349.     {"Stretch", VClassUnique, 409, 50000},
  350.     {"Stuntplane", VClassPlane, 513, 50000},
  351.     {"Sultan", VClassSaloons, 560, 50000},
  352.     {"Sunrise", VClassSaloons, 550, 50000},
  353.     {"Super GT", VClassSportCar, 506, 50000},
  354.     {"S.W.A.T.", VClassPublic, 601, 50000},
  355.     {"Sweeper", VClassUnique, 574, 50000},
  356.     {"Tahoma", VClassLowRider, 566, 50000},
  357.     {"Tampa", VClassSaloons, 549, 50000},
  358.     {"Tanker", VClassIndustrial, 514, 50000},
  359.     {"Taxi", VClassPublic, 420, 50000},
  360.     {"Tornado", VClassLowRider, 576, 50000},
  361.     {"Towtruck", VClassUnique, 525, 50000},
  362.     {"Tractor", VClassIndustrial, 531, 50000},
  363. //  {"Tram", VClassUnique, 449, 50000},
  364.     {"Trashmaster", VClassIndustrial, 408, 50000},
  365.     {"Tropic", VClassBoat, 454, 50000},
  366.     {"Tug", VClassUnique, 583, 50000},
  367.     {"Tug Stairs Trailer", VClassTrailer, 608, 50000},
  368.     {"Turismo", VClassSportCar, 451, 50000},
  369.     {"Uranus", VClassSportCar, 558, 50000},
  370.     {"Utility Trailer", VClassTrailer, 611, 50000},
  371.     {"Utility Van", VClassIndustrial, 552, 50000},
  372.     {"Vincent", VClassSaloons, 540, 50000},
  373.     {"Virgo", VClassSaloons, 491, 50000},
  374.     {"Voodoo", VClassLowRider, 412, 50000},
  375.     {"Vortex", VClassUnique, 539, 50000},
  376.     {"Walton", VClassIndustrial, 478, 50000},
  377.     {"Washington", VClassSaloons, 421, 50000},
  378.     {"Wayfarer", VClassBike, 586, 50000},
  379.     {"Willard", VClassSaloons, 529, 50000},
  380.     {"Windsor", VClassConvertible, 555, 50000},
  381.     {"Yankee", VClassIndustrial, 456, 50000},
  382.     {"Yosemite", VClassIndustrial, 554, 50000},
  383.     {"ZR-350", VClassSportCar, 477, 50000}
  384. };
  385.  
  386.  
  387.  
  388. // Setup an array that holds all prices for vehicle-components
  389. new AVehicleModPrices[] =
  390. {
  391.     400, // ID 1000, Spoiler Pro                                Certain Transfender cars
  392.     550, // ID 1001, Spoiler Win                                Certain Transfender cars
  393.     200, // ID 1002, Spoiler Drag                               Certain Transfender cars
  394.     250, // ID 1003, Spoiler Alpha                              Certain Transfender cars
  395.     100, // ID 1004, Hood Champ Scoop                           Certain Transfender cars
  396.     150, // ID 1005, Hood Fury Scoop                            Certain Transfender cars
  397.     80, // ID 1006, Roof Roof Scoop                             Certain Transfender cars
  398.     500, // ID 1007, Sideskirt Right Sideskirt                  Certain Transfender cars
  399.     500, // ID 1008, Nitro 5 times                              Most cars, Most planes and Most Helicopters
  400.     200, // ID 1009, Nitro 2 times                              Most cars, Most planes and Most Helicopters
  401.     1000, // ID 1010, Nitro 10 times                            Most cars, Most planes and Most Helicopters
  402.     220, // ID 1011, Hood Race Scoop                            Certain Transfender cars
  403.     250, // ID 1012, Hood Worx Scoop                            Certain Transfender cars
  404.     100, // ID 1013, Lamps Round Fog                            Certain Transfender cars
  405.     400, // ID 1014, Spoiler Champ                              Certain Transfender cars
  406.     500, // ID 1015, Spoiler Race                               Certain Transfender cars
  407.     200, // ID 1016, Spoiler Worx                               Certain Transfender cars
  408.     500, // ID 1017, Sideskirt Left Sideskirt                   Certain Transfender cars
  409.     350, // ID 1018, Exhaust Upswept                            Most cars
  410.     300, // ID 1019, Exhaust Twin                               Most cars
  411.     250, // ID 1020, Exhaust Large                              Most cars
  412.     200, // ID 1021, Exhaust Medium                             Most cars
  413.     150, // ID 1022, Exhaust Small                              Most cars
  414.     350, // ID 1023, Spoiler Fury                               Certain Transfender cars
  415.     50, // ID 1024, Lamps Square Fog                            Certain Transfender cars
  416.     1000, // ID 1025, Wheels Offroad                            Certain Transfender cars
  417.     480, // ID 1026, Sideskirt Right Alien Sideskirt            Sultan
  418.     480, // ID 1027, Sideskirt Left Alien Sideskirt             Sultan
  419.     770, // ID 1028, Exhaust Alien                              Sultan
  420.     680, // ID 1029, Exhaust X-Flow                             Sultan
  421.     370, // ID 1030, Sideskirt Left X-Flow Sideskirt            Sultan
  422.     370, // ID 1031, Sideskirt Right X-Flow Sideskirt           Sultan
  423.     170, // ID 1032, Roof Alien Roof Vent                       Sultan
  424.     120, // ID 1033, Roof X-Flow Roof Vent                      Sultan
  425.     790, // ID 1034, Exhaust Alien                              Elegy
  426.     150, // ID 1035, Roof X-Flow Roof Vent                      Elegy
  427.     500, // ID 1036, SideSkirt Right Alien Sideskirt            Elegy
  428.     690, // ID 1037, Exhaust X-Flow                             Elegy
  429.     190, // ID 1038, Roof Alien Roof Vent                       Elegy
  430.     390, // ID 1039, SideSkirt Right X-Flow Sideskirt           Elegy
  431.     500, // ID 1040, SideSkirt Left Alien Sideskirt             Elegy
  432.     390, // ID 1041, SideSkirt Right X-Flow Sideskirt           Elegy
  433.     1000, // ID 1042, SideSkirt Right Chrome Sideskirt          Broadway
  434.     500, // ID 1043, Exhaust Slamin                             Broadway
  435.     500, // ID 1044, Exhaust Chrome                             Broadway
  436.     510, // ID 1045, Exhaust X-Flow                             Flash
  437.     710, // ID 1046, Exhaust Alien                              Flash
  438.     670, // ID 1047, SideSkirt Right Alien Sideskirt            Flash
  439.     530, // ID 1048, SideSkirt Right X-Flow Sideskirt           Flash
  440.     810, // ID 1049, Spoiler Alien                              Flash
  441.     620, // ID 1050, Spoiler X-Flow                             Flash
  442.     670, // ID 1051, SideSkirt Left Alien Sideskirt             Flash
  443.     530, // ID 1052, SideSkirt Left X-Flow Sideskirt            Flash
  444.     130, // ID 1053, Roof X-Flow                                Flash
  445.     210, // ID 1054, Roof Alien                                 Flash
  446.     230, // ID 1055, Roof Alien                                 Stratum
  447.     520, // ID 1056, Sideskirt Right Alien Sideskirt            Stratum
  448.     430, // ID 1057, Sideskirt Right X-Flow Sideskirt           Stratum
  449.     620, // ID 1058, Spoiler Alien                              Stratum
  450.     720, // ID 1059, Exhaust X-Flow                             Stratum
  451.     530, // ID 1060, Spoiler X-Flow                             Stratum
  452.     180, // ID 1061, Roof X-Flow                                Stratum
  453.     520, // ID 1062, Sideskirt Left Alien Sideskirt             Stratum
  454.     430, // ID 1063, Sideskirt Left X-Flow Sideskirt            Stratum
  455.     830, // ID 1064, Exhaust Alien                              Stratum
  456.     850, // ID 1065, Exhaust Alien                              Jester
  457.     750, // ID 1066, Exhaust X-Flow                             Jester
  458.     250, // ID 1067, Roof Alien                                 Jester
  459.     200, // ID 1068, Roof X-Flow                                Jester
  460.     550, // ID 1069, Sideskirt Right Alien Sideskirt            Jester
  461.     450, // ID 1070, Sideskirt Right X-Flow Sideskirt           Jester
  462.     550, // ID 1071, Sideskirt Left Alien Sideskirt             Jester
  463.     450, // ID 1072, Sideskirt Left X-Flow Sideskirt            Jester
  464.     1100, // ID 1073, Wheels Shadow                             Most cars
  465.     1030, // ID 1074, Wheels Mega                               Most cars
  466.     980, // ID 1075, Wheels Rimshine                            Most cars
  467.     1560, // ID 1076, Wheels Wires                              Most cars
  468.     1620, // ID 1077, Wheels Classic                            Most cars
  469.     1200, // ID 1078, Wheels Twist                              Most cars
  470.     1030, // ID 1079, Wheels Cutter                             Most cars
  471.     900, // ID 1080, Wheels Switch                              Most cars
  472.     1230, // ID 1081, Wheels Grove                              Most cars
  473.     820, // ID 1082, Wheels Import                              Most cars
  474.     1560, // ID 1083, Wheels Dollar                             Most cars
  475.     1350, // ID 1084, Wheels Trance                             Most cars
  476.     770, // ID 1085, Wheels Atomic                              Most cars
  477.     100, // ID 1086, Stereo Stereo                              Most cars
  478.     1500, // ID 1087, Hydraulics Hydraulics                     Most cars
  479.     150, // ID 1088, Roof Alien                                 Uranus
  480.     650, // ID 1089, Exhaust X-Flow                             Uranus
  481.     450, // ID 1090, Sideskirt Right Alien Sideskirt            Uranus
  482.     100, // ID 1091, Roof X-Flow                                Uranus
  483.     750, // ID 1092, Exhaust Alien                              Uranus
  484.     350, // ID 1093, Sideskirt Right X-Flow Sideskirt           Uranus
  485.     450, // ID 1094, Sideskirt Left Alien Sideskirt             Uranus
  486.     350, // ID 1095, Sideskirt Right X-Flow Sideskirt           Uranus
  487.     1000, // ID 1096, Wheels Ahab                               Most cars
  488.     620, // ID 1097, Wheels Virtual                             Most cars
  489.     1140, // ID 1098, Wheels Access                             Most cars
  490.     1000, // ID 1099, Sideskirt Left Chrome Sideskirt           Broadway
  491.     940, // ID 1100, Bullbar Chrome Grill                       Remington
  492.     780, // ID 1101, Sideskirt Left `Chrome Flames` Sideskirt   Remington
  493.     830, // ID 1102, Sideskirt Left `Chrome Strip` Sideskirt    Savanna
  494.     3250, // ID 1103, Roof Convertible                          Blade
  495.     1610, // ID 1104, Exhaust Chrome                            Blade
  496.     1540, // ID 1105, Exhaust Slamin                            Blade
  497.     780, // ID 1106, Sideskirt Right `Chrome Arches`            Remington
  498.     780, // ID 1107, Sideskirt Left `Chrome Strip` Sideskirt    Blade
  499.     780, // ID 1108, Sideskirt Right `Chrome Strip` Sideskirt   Blade
  500.     1610, // ID 1109, Rear Bullbars Chrome                      Slamvan
  501.     1540, // ID 1110, Rear Bullbars Slamin                      Slamvan
  502.     55, // ID 1111, Front Sign? Little Sign?                    Slamvan         ???
  503.     55, // ID 1112, Front Sign? Little Sign?                    Slamvan         ???
  504.     3340, // ID 1113, Exhaust Chrome                            Slamvan
  505.     3250, // ID 1114, Exhaust Slamin                            Slamvan
  506.     2130, // ID 1115, Front Bullbars Chrome                     Slamvan
  507.     2050, // ID 1116, Front Bullbars Slamin                     Slamvan
  508.     2040, // ID 1117, Front Bumper Chrome                       Slamvan
  509.     780, // ID 1118, Sideskirt Right `Chrome Trim` Sideskirt    Slamvan
  510.     940, // ID 1119, Sideskirt Right `Wheelcovers` Sideskirt    Slamvan
  511.     780, // ID 1120, Sideskirt Left `Chrome Trim` Sideskirt     Slamvan
  512.     940, // ID 1121, Sideskirt Left `Wheelcovers` Sideskirt     Slamvan
  513.     780, // ID 1122, Sideskirt Right `Chrome Flames` Sideskirt  Remington
  514.     860, // ID 1123, Bullbars Bullbar Chrome Bars               Remington
  515.     780, // ID 1124, Sideskirt Left `Chrome Arches` Sideskirt   Remington
  516.     1120, // ID 1125, Bullbars Bullbar Chrome Lights            Remington
  517.     3340, // ID 1126, Exhaust Chrome Exhaust                    Remington
  518.     3250, // ID 1127, Exhaust Slamin Exhaust                    Remington
  519.     3340, // ID 1128, Roof Vinyl Hardtop                        Blade
  520.     1650, // ID 1129, Exhaust Chrome                            Savanna
  521.     3380, // ID 1130, Roof Hardtop                              Savanna
  522.     3290, // ID 1131, Roof Softtop                              Savanna
  523.     1590, // ID 1132, Exhaust Slamin                            Savanna
  524.     830, // ID 1133, Sideskirt Right `Chrome Strip` Sideskirt   Savanna
  525.     800, // ID 1134, SideSkirt Right `Chrome Strip` Sideskirt   Tornado
  526.     1500, // ID 1135, Exhaust Slamin                            Tornado
  527.     1000, // ID 1136, Exhaust Chrome                            Tornado
  528.     800, // ID 1137, Sideskirt Left `Chrome Strip` Sideskirt    Tornado
  529.     580, // ID 1138, Spoiler Alien                              Sultan
  530.     470, // ID 1139, Spoiler X-Flow                             Sultan
  531.     870, // ID 1140, Rear Bumper X-Flow                         Sultan
  532.     980, // ID 1141, Rear Bumper Alien                          Sultan
  533.     150, // ID 1142, Vents Left Oval Vents                      Certain Transfender Cars
  534.     150, // ID 1143, Vents Right Oval Vents                     Certain Transfender Cars
  535.     100, // ID 1144, Vents Left Square Vents                    Certain Transfender Cars
  536.     100, // ID 1145, Vents Right Square Vents                   Certain Transfender Cars
  537.     490, // ID 1146, Spoiler X-Flow                             Elegy
  538.     600, // ID 1147, Spoiler Alien                              Elegy
  539.     890, // ID 1148, Rear Bumper X-Flow                         Elegy
  540.     1000, // ID 1149, Rear Bumper Alien                         Elegy
  541.     1090, // ID 1150, Rear Bumper Alien                         Flash
  542.     840, // ID 1151, Rear Bumper X-Flow                         Flash
  543.     910, // ID 1152, Front Bumper X-Flow                        Flash
  544.     1200, // ID 1153, Front Bumper Alien                        Flash
  545.     1030, // ID 1154, Rear Bumper Alien                         Stratum
  546.     1030, // ID 1155, Front Bumper Alien                        Stratum
  547.     920, // ID 1156, Rear Bumper X-Flow                         Stratum
  548.     930, // ID 1157, Front Bumper X-Flow                        Stratum
  549.     550, // ID 1158, Spoiler X-Flow                             Jester
  550.     1050, // ID 1159, Rear Bumper Alien                         Jester
  551.     1050, // ID 1160, Front Bumper Alien                        Jester
  552.     950, // ID 1161, Rear Bumper X-Flow                         Jester
  553.     650, // ID 1162, Spoiler Alien                              Jester
  554.     450, // ID 1163, Spoiler X-Flow                             Uranus
  555.     550, // ID 1164, Spoiler Alien                              Uranus
  556.     850, // ID 1165, Front Bumper X-Flow                        Uranus
  557.     950, // ID 1166, Front Bumper Alien                         Uranus
  558.     850, // ID 1167, Rear Bumper X-Flow                         Uranus
  559.     950, // ID 1168, Rear Bumper Alien                          Uranus
  560.     970, // ID 1169, Front Bumper Alien                         Sultan
  561.     880, // ID 1170, Front Bumper X-Flow                        Sultan
  562.     990, // ID 1171, Front Bumper Alien                         Elegy
  563.     900, // ID 1172, Front Bumper X-Flow                        Elegy
  564.     950, // ID 1173, Front Bumper X-Flow                        Jester
  565.     1000, // ID 1174, Front Bumper Chrome                       Broadway
  566.     900, // ID 1175, Front Bumper Slamin                        Broadway
  567.     1000, // ID 1176, Rear Bumper Chrome                        Broadway
  568.     900, // ID 1177, Rear Bumper Slamin                         Broadway
  569.     2050, // ID 1178, Rear Bumper Slamin                        Remington
  570.     2150, // ID 1179, Front Bumper Chrome                       Remington
  571.     2130, // ID 1180, Rear Bumper Chrome                        Remington
  572.     2050, // ID 1181, Front Bumper Slamin                       Blade
  573.     2130, // ID 1182, Front Bumper Chrome                       Blade
  574.     2040, // ID 1183, Rear Bumper Slamin                        Blade
  575.     2150, // ID 1184, Rear Bumper Chrome                        Blade
  576.     2040, // ID 1185, Front Bumper Slamin                       Remington
  577.     2095, // ID 1186, Rear Bumper Slamin                        Savanna
  578.     2175, // ID 1187, Rear Bumper Chrome                        Savanna
  579.     2080, // ID 1188, Front Bumper Slamin                       Savanna
  580.     2200, // ID 1189, Front Bumper Chrome                       Savanna
  581.     1200, // ID 1190, Front Bumper Slamin                       Tornado
  582.     1040, // ID 1191, Front Bumper Chrome                       Tornado
  583.     940, // ID 1192, Rear Bumper Chrome                         Tornado
  584.     1100, // ID 1193 Rear Bumper Slamin                         Tornado
  585. };
  586.  
  587.  
  588.  
  589. // These variables are used when starting the script and debugging purposes
  590. new TotalHouses;
  591.  
  592.  
  593.  
  594. // ******************************************************************************************************************************
  595. // Callbacks
  596. // ******************************************************************************************************************************
  597.  
  598. // The main function (used only once when the server loads)
  599. main()
  600. {
  601. }
  602.  
  603. // This callback gets called when the server initializes the filterscript
  604. public OnFilterScriptInit()
  605. {
  606.     // Loop through all houses and try to load them (HouseID 0 isn't used)
  607.     for (new HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
  608.     {
  609.         // Try to load the house-file
  610.         HouseFile_Load(HouseID);
  611.  
  612.         // Load housecars too if chosen to do so
  613.         if (LoadCarsDuringFSInit == true)
  614.             HouseFile_LoadCars(HouseID);
  615.     }
  616.  
  617.     // Add some icons to the map (modding garages), they will only appear when the player discovers them
  618.     CreateDynamicMapIcon(1039, -1032, 32, 27, 0, 0, 0, -1, 150.0); // Transfender, Los Santos
  619.     CreateDynamicMapIcon(-1936, 235, 34, 27, 0, 0, 0, -1, 150.0); // Transfender, San Fierro
  620.     CreateDynamicMapIcon(2385, 1034, 11, 27, 0, 0, 0, -1, 150.0); // Transfender, Las Venturas
  621.     CreateDynamicMapIcon(2646, -2025, 14, 27, 0, 0, 0, -1, 150.0); // Loco Low Co, Los Santos
  622.     CreateDynamicMapIcon(-2712, 218, 4, 27, 0, 0, 0, -1, 150.0); // Wheel Arch Angels, San Fierro
  623.  
  624.     // Print information about the filterscript on the server-console
  625.     printf("----------------------------------------");
  626.     printf("House filterscript initialized");
  627.     printf("Houses loaded: %i", TotalHouses);
  628.     printf("----------------------------------------");
  629.  
  630.     return 1;
  631. }
  632.  
  633. // This callback gets called when a player connects to the server
  634. public OnPlayerConnect(playerid)
  635. {
  636.     // Setup local variables
  637.     new HouseID, HouseSlot, Name[24];
  638.  
  639.     // Get the player's name
  640.     GetPlayerName(playerid, Name, sizeof(Name));
  641.  
  642.     // Loop through all houses to find the ones which belong to this player
  643.     for (HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
  644.     {
  645.         // Check if the house exists
  646.         if (IsValidDynamicPickup(AHouseData[HouseID][PickupID]))
  647.         {
  648.             // Check if the house is owned
  649.             if (AHouseData[HouseID][Owned] == true)
  650.             {
  651.                 // Check if the player is the owner of the house
  652.                 if (strcmp(AHouseData[HouseID][Owner], Name, false) == 0)
  653.                 {
  654.                     // Add the HouseID to the player's account for faster reference later on
  655.                     APlayerData[playerid][Houses][HouseSlot] = HouseID;
  656.  
  657.                     // Load housecars if they weren't loaded at FilterscriptInit
  658.                     if (LoadCarsDuringFSInit == false)
  659.                         HouseFile_LoadCars(HouseID);
  660.  
  661.                     // Select the next HouseSlot
  662.                     HouseSlot++;
  663.                 }
  664.             }
  665.         }
  666.     }
  667.  
  668.     return 1;
  669. }
  670.  
  671. // This callback gets called when a player disconnects from the server
  672. public OnPlayerDisconnect(playerid, reason)
  673. {
  674.     // Setup local variables
  675.     new HouseSlot;
  676.  
  677.     // Loop through all Houses the player owns
  678.     for (HouseSlot = 0; HouseSlot < MAX_HOUSESPERPLAYER; HouseSlot++)
  679.     {
  680.         // Check if the player has a house in this houseslot
  681.         if (APlayerData[playerid][Houses][HouseSlot] != 0)
  682.         {
  683.             // Save the housefile
  684.             HouseFile_Save(APlayerData[playerid][Houses][HouseSlot]);
  685.  
  686.             // Unload housecars if they were loaded when the owner logged in
  687.             if (LoadCarsDuringFSInit == false)
  688.             {
  689.                 // Unload all vehicles assigned to this house
  690.                 House_RemoveVehicles(APlayerData[playerid][Houses][HouseSlot]);
  691.             }
  692.  
  693.             // Clear the HouseID stored in this houseslot
  694.             APlayerData[playerid][Houses][HouseSlot] = 0;
  695.         }
  696.     }
  697.  
  698.     // Clear all data for this player
  699.     APlayerData[playerid][CurrentHouse] = 0;
  700.     APlayerData[playerid][DialogBuyVClass] = 0;
  701.     APlayerData[playerid][DialogGetCarHouseID] = 0;
  702.  
  703.     return 1;
  704. }
  705.  
  706. // This callback gets called when a player interacts with a dialog
  707. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  708. {
  709.     // Select the proper dialog to process
  710.     switch (dialogid)
  711.     {
  712.         case DialogHouseMenu: Dialog_HouseMenu(playerid, response, listitem); // Process the main housemenu
  713.         case DialogUpgradeHouse: Dialog_UpgradeHouse(playerid, response, listitem); // Process the house-upgrade menu
  714.         case DialogGoHome: Dialog_GoHome(playerid, response, listitem); // Port to one of your houses
  715.         case DialogHouseNameChange: Dialog_ChangeHouseName(playerid, response, inputtext); // Change the name of your house
  716.         case DialogSellHouse: Dialog_SellHouse(playerid, response); // Sell the house
  717.         case DialogBuyCarClass: Dialog_BuyCarClass(playerid, response, listitem); // The player chose a vehicleclass from where he can buy a vehicle
  718.         case DialogBuyCar: Dialog_BuyCar(playerid, response, listitem); // The player chose a vehicle from the list of vehicles from the vehicleclass he chose before
  719.         case DialogSellCar: Dialog_SellCar(playerid, response, listitem);
  720.         case DialogBuyInsurance: Dialog_BuyInsurance(playerid, response);
  721.         case DialogGetCarSelectHouse: Dialog_GetCarSelectHouse(playerid, response, listitem);
  722.         case DialogGetCarSelectCar: Dialog_GetCarSelectCar(playerid, response, listitem);
  723.     }
  724.  
  725.     return 0;
  726. }
  727.  
  728. // This callback gets called when a player spawns somewhere
  729. public OnPlayerSpawn(playerid)
  730. {
  731.     // Setup local variables
  732.     new HouseID;
  733.  
  734.     // Reset the HouseID where the player is located
  735.     APlayerData[playerid][CurrentHouse] = 0;
  736.  
  737.     // If SpawnAtHouse is set to "true", re-position the player at the first house in his list of owned houses
  738.     if (SpawnAtHouse == true)
  739.     {
  740.         // Get the first HouseID in your list of owned houses
  741.         HouseID = APlayerData[playerid][Houses][0];
  742.         // Check if the player has a house in this first slot
  743.         if (HouseID != 0)
  744.         {
  745.             // Re-position the player at the house's coordinates
  746.             SetPlayerPos(playerid, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]);
  747.         }
  748.     }
  749.  
  750.     return 1;
  751. }
  752.  
  753. // This callback gets called whenever a player dies
  754. public OnPlayerDeath(playerid, killerid, reason)
  755. {
  756.     // Reset the HouseID where the player is located
  757.     APlayerData[playerid][CurrentHouse] = 0;
  758.  
  759.     return 1;
  760. }
  761.  
  762. // This callback gets called when the player is selecting a class (but hasn't clicked "Spawn" yet)
  763. public OnPlayerRequestClass(playerid, classid)
  764. {
  765.     // Reset the HouseID where the player is located
  766.     APlayerData[playerid][CurrentHouse] = 0;
  767.  
  768.     return 1;
  769. }
  770.  
  771. // This callback is called when the player attempts to spawn via class-selection
  772. public OnPlayerRequestSpawn(playerid)
  773. {
  774.     // Reset the HouseID where the player is located
  775.     APlayerData[playerid][CurrentHouse] = 0;
  776.  
  777.     return 1;
  778. }
  779.  
  780. // This callback gets called when a vehicle respawns at it's spawn-location (where it was created)
  781. public OnVehicleSpawn(vehicleid)
  782. {
  783.     // Only use this for house-vehicles
  784.     if (AVehicleData[vehicleid][Owned] == true)
  785.     {
  786.         // Re-apply the paintjob (if any was applied)
  787.         if (AVehicleData[vehicleid][PaintJob] != 0)
  788.         {
  789.             // Re-apply the paintjob
  790.             ChangeVehiclePaintjob(vehicleid, AVehicleData[vehicleid][PaintJob] - 1);
  791.         }
  792.  
  793.         // Also update the car-color
  794.         ChangeVehicleColor(vehicleid, AVehicleData[vehicleid][Color1], AVehicleData[vehicleid][Color2]);
  795.  
  796.         // Re-add all components that were installed (if they were there)
  797.         for (new i; i < 14; i++)
  798.         {
  799.             // Remove all mods from the vehicle (all added mods applied by hackers will hopefully be removed this way when the vehicle respawns)
  800.             RemoveVehicleComponent(vehicleid, GetVehicleComponentInSlot(vehicleid, i));
  801.  
  802.             // Check if the componentslot has a valid component-id
  803.             if (AVehicleData[vehicleid][Components][i] != 0)
  804.                 AddVehicleComponent(vehicleid, AVehicleData[vehicleid][Components][i]); // Add the component to the vehicle
  805.         }
  806.     }
  807.  
  808.     return 1;
  809. }
  810.  
  811. // This callback is called when the vehicle leaves a mod shop
  812. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  813. {
  814.     // Only use this for house-vehicles
  815.     if (AVehicleData[vehicleid][Owned] == true)
  816.     {
  817.         // Let the player pay $150 for changing the color (if they have been changed)
  818.         if ((AVehicleData[vehicleid][Color1] != color1) || (AVehicleData[vehicleid][Color2] != color2))
  819.             INT_GivePlayerMoney(playerid, -150);
  820.  
  821.         // Save the colors
  822.         AVehicleData[vehicleid][Color1] = color1;
  823.         AVehicleData[vehicleid][Color2] = color2;
  824.  
  825.         // If the primary color is black, remove the paintjob
  826.         if (color1 == 0)
  827.             AVehicleData[vehicleid][PaintJob] = 0;
  828.     }
  829.  
  830.     return 1;
  831. }
  832.  
  833. // This callback gets called whenever a player mods his vehicle
  834. public OnVehicleMod(playerid, vehicleid, componentid)
  835. {
  836.     // Only use this for house-vehicles
  837.     if (AVehicleData[vehicleid][Owned] == true)
  838.     {
  839.         // When the player changes a component of his vehicle, reduce the price of the component from the player's money
  840.         INT_GivePlayerMoney(playerid, -AVehicleModPrices[componentid - 1000]);
  841.  
  842.         // Store the component in the AVehicleData array
  843.         AVehicleData[vehicleid][Components][GetVehicleComponentType(componentid)] = componentid;
  844.     }
  845.  
  846.     return 1;
  847. }
  848.  
  849. // This callback gets called whenever a player VIEWS at a paintjob in a mod garage (viewing automatically applies it)
  850. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  851. {
  852.     // Only use this for house-vehicles
  853.     if (AVehicleData[vehicleid][Owned] == true)
  854.     {
  855.         // Store the paintjobid for the vehicle (add 1 to the value, otherwise checking for an applied paintjob is difficult)
  856.         AVehicleData[vehicleid][PaintJob] = paintjobid + 1;
  857.     }
  858.  
  859.     return 1;
  860. }
  861.  
  862. // This callback gets called whenever a vehicle enters the water or is destroyed (explodes)
  863. public OnVehicleDeath(vehicleid)
  864. {
  865.     // Setup local variables
  866.     new HouseID, CarSlot;
  867.  
  868.     // Only use this for house-vehicles
  869.     if (AVehicleData[vehicleid][Owned] == true)
  870.     {
  871.         // Get the houseid to which this vehicle belongs
  872.         HouseID = AVehicleData[vehicleid][BelongsToHouse];
  873.  
  874.         // If automatic insurance has been turned off, check if the vehicle's house has insurance for the vehicle
  875.         if (AutomaticInsurance == false)
  876.         {
  877.             // Check if this vehicle belongs to a house
  878.             if (HouseID != 0)
  879.             {
  880.                 // If the house doesn't have insurance for it's vehicles
  881.                 if (AHouseData[HouseID][Insurance] == false)
  882.                 {
  883.                     // Find the CarSlot where this vehicle is stored
  884.                     for (CarSlot = 0; CarSlot < 10; CarSlot++)
  885.                     {
  886.                         // Check if the vehicle is stored in this carslot
  887.                         if (AHouseData[HouseID][VehicleIDs][CarSlot] == vehicleid)
  888.                             break; // Stop searching, because CarSlot now hold the carslot of the vehicle where it's stored
  889.                     }
  890.  
  891.                     // Delete the vehicle, clear the data and remove it from the house it belongs to
  892.                     Vehicle_Delete(vehicleid, HouseID, CarSlot);
  893.  
  894.                     // Save the house (and linked vehicles)
  895.                     HouseFile_Save(HouseID);
  896.                 }
  897.             }
  898.         }
  899.     }
  900.  
  901.     return 1;
  902. }
  903.  
  904. // This callback gets called when the player changes state
  905. public OnPlayerStateChange(playerid,newstate,oldstate)
  906. {
  907.     // Setup local variables
  908.     new vid, Name[24], Msg[250], engine, lights, alarm, doors, bonnet, boot, objective;
  909.  
  910.     // Check if the player became the driver of a vehicle
  911.     if (newstate == PLAYER_STATE_DRIVER)
  912.     {
  913.         // Get the ID of the player's vehicle
  914.         vid = GetPlayerVehicleID(playerid);
  915.         // Get the player's name
  916.         GetPlayerName(playerid, Name, sizeof(Name));
  917.  
  918.         // Check if the vehicle is owned
  919.         if (AVehicleData[vid][Owned] == true)
  920.         {
  921.             // Check if the vehicle is owned by somebody else (strcmp will not be 0)
  922.             if (strcmp(AVehicleData[vid][Owner], Name, false) != 0)
  923.             {
  924.                 // Force the player out of the vehicle
  925.                 RemovePlayerFromVehicle(playerid);
  926.                 // Turn off the lights and engine
  927.                 GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
  928.                 SetVehicleParamsEx(vid, 0, 0, alarm, doors, bonnet, boot, objective);
  929.                 // Let the player know he cannot use somebody else's vehicle
  930.                 format(Msg, 250, "{FF0000}You cannot use this vehicle, it's owned by \"{FFFF00}%s{FF0000}\"", AVehicleData[vid][Owner]);
  931.                 SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  932.             }
  933.         }
  934.     }
  935.  
  936.     return 1;
  937. }
  938.  
  939.  
  940.  
  941. // ******************************************************************************************************************************
  942. // Commands
  943. // ******************************************************************************************************************************
  944.  
  945. // Lets the player add new houses (a house that can be upgraded and where the houselevel determines the amount of carslots)
  946. COMMAND:createstatichouse(playerid, params[])
  947. {
  948.     // If a player hasn't logged in properly, he cannot use this command
  949.     if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
  950.     // If the player has an insufficient admin-level (he needs level 5 or RCON admin), exit the command
  951.     // returning "SERVER: Unknown command" to the player
  952.     if (INT_CheckPlayerAdminLevel(playerid, 5) == 0) return 0;
  953.  
  954.     // Setup local variables
  955.     new HPrice, MaxLevel, HouseID;
  956.  
  957.     // Check if the player isn't inside a vehicle (the admin-player must be on foot to use this command)
  958.     if (GetPlayerVehicleSeat(playerid) == -1)
  959.     {
  960.         if (sscanf(params, "ii", HPrice, MaxLevel)) SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Usage: \"/createhouse <price> <maxlevel (1-10)>\"");
  961.         else
  962.         {
  963.             // Check if the player entered a proper maxlevel
  964.             if ((MaxLevel >= 1) && (MaxLevel <= 10))
  965.             {
  966.                 // Find the first free HouseID
  967.                 for (HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
  968.                     if (!IsValidDynamicPickup(AHouseData[HouseID][PickupID])) // Check if an empty house-index has been found (PickupID is 0)
  969.                         break; // Stop searching, the first free HouseID has been found now
  970.  
  971.                 // Check if the house-limit hasn't been reached yet
  972.                 // This would seem to double-check the pickup-id, but in case there was no free houseslot found (HouseID points
  973.                 // to the last index, the last index would hold a house, so be sure to not overwrite it
  974.                 if (!IsValidDynamicPickup(AHouseData[HouseID][PickupID]))
  975.                 {
  976.                     // Setup some local variables
  977.                     new Float:x, Float:y, Float:z, Msg[128];
  978.                     // Get the player's position
  979.                     GetPlayerPos(playerid, x, y, z);
  980.                     // Set some default data
  981.                     AHouseData[HouseID][Owned] = false;
  982.                     AHouseData[HouseID][Owner] = 0;
  983.                     AHouseData[HouseID][HouseX] = x;
  984.                     AHouseData[HouseID][HouseY] = y;
  985.                     AHouseData[HouseID][HouseZ] = z;
  986.                     AHouseData[HouseID][HouseLevel] = 1;
  987.                     AHouseData[HouseID][HouseMaxLevel] = MaxLevel;
  988.                     AHouseData[HouseID][HousePrice] = HPrice;
  989.                     AHouseData[HouseID][HouseOpened] = false;
  990.                     AHouseData[HouseID][Insurance] = false;
  991.                     AHouseData[HouseID][StaticHouse] = false;
  992.                     AHouseData[HouseID][CarSlots] = 1; // This must be equal to the house-level for a normal house
  993.  
  994.                     // Add the pickup and 3DText at the location of the house-entrance (where the player is standing when he creates the house)
  995.                     House_UpdateEntrance(HouseID);
  996.  
  997.                     // Save the house
  998.                     HouseFile_Save(HouseID);
  999.  
  1000.                     // Inform the player that he created a new house
  1001.                     format(Msg, 128, "{00FF00}You've succesfully created a house with ID: {FFFF00}%i", HouseID);
  1002.                     SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  1003.                 }
  1004.                 else
  1005.                     SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}The maximum amount of houses has been reached");
  1006.             }
  1007.             else
  1008.                 SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You have to use a max-level from 1 to 10");
  1009.         }
  1010.     }
  1011.     else
  1012.         SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You must be on foot to create a house");
  1013.  
  1014.     // Let the server know that this was a valid command
  1015.     return 1;
  1016. }
  1017.  
  1018. // Lets the player add new houses (a house that cannot be upgraded, has a fixed interior and a fixed amount of carslots)
  1019. COMMAND:createhouse(playerid, params[])
  1020. {
  1021.     // Setup local variables
  1022.     new HPrice, Carslots, HouseID, Interior;
  1023.  
  1024.     // If a player hasn't logged in properly, he cannot use this command
  1025.     if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
  1026.     // If the player has an insufficient admin-level (he needs level 5 or RCON admin), exit the command
  1027.     // returning "SERVER: Unknown command" to the player
  1028.     if (INT_CheckPlayerAdminLevel(playerid, 5) == 0) return 0;
  1029.  
  1030.     // Check if the player isn't inside a vehicle (the admin-player must be on foot to use this command)
  1031.     if (GetPlayerVehicleSeat(playerid) == -1)
  1032.     {
  1033.         if (sscanf(params, "iii", HPrice, Interior)) SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Usage: \"/createhouse <price> <Interior (1-10)>\"");
  1034.         else
  1035.         {
  1036.             if ((Interior >= 1) && (Interior <= 10))
  1037.             {
  1038.                 for (HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
  1039.                 if (!IsValidDynamicPickup(AHouseData[HouseID][PickupID])) // Check if an empty house-index has been found (PickupID is 0)
  1040.                 break;
  1041.                
  1042.                 if (!IsValidDynamicPickup(AHouseData[HouseID][PickupID]))
  1043.                 {
  1044.                     new Float:x, Float:y, Float:z, Msg[128];
  1045.                     GetPlayerPos(playerid, x, y, z);
  1046.                     AHouseData[HouseID][Owned] = false;
  1047.                     AHouseData[HouseID][HouseX] = x;
  1048.                     AHouseData[HouseID][HouseY] = y;
  1049.                     AHouseData[HouseID][HouseZ] = z;
  1050.                     AHouseData[HouseID][HouseLevel] = Interior; // The house-level indicates the static interior
  1051.                     AHouseData[HouseID][HouseMaxLevel] = Interior;
  1052.                     AHouseData[HouseID][HousePrice] = HPrice;
  1053.                     AHouseData[HouseID][HouseOpened] = false;
  1054.                     AHouseData[HouseID][Insurance] = false;
  1055.                     AHouseData[HouseID][StaticHouse] = true;
  1056.                     AHouseData[HouseID][CarSlots] = Carslots;
  1057.  
  1058.                         // Add the pickup and 3DText at the location of the house-entrance (where the player is standing when he creates the house)
  1059.                     House_UpdateEntrance(HouseID);
  1060.  
  1061.                         // Save the house
  1062.                     HouseFile_Save(HouseID);
  1063.  
  1064.                         // Inform the player that he created a new house
  1065.                     format(Msg, 128, "{00FF00}You've succesfully created a static house with ID: {FFFF00}%i", HouseID);
  1066.                     SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  1067.                 }
  1068.                 else
  1069.                     SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}The maximum amount of houses has been reached");
  1070.             }
  1071.             else
  1072.                 SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You have to use an interior-id from 1 to 10");
  1073.         }
  1074.     }
  1075.     else
  1076.         SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You must be on foot to create a house");
  1077.     return 1;
  1078. }
  1079.  
  1080. // This command lets the player delete a house
  1081. COMMAND:delhouse(playerid, params[])
  1082. {
  1083.     // If a player hasn't logged in properly, he cannot use this command
  1084.     if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
  1085.     // If the player has an insufficient admin-level (he needs level 5 or RCON admin), exit the command
  1086.     // returning "SERVER: Unknown command" to the player
  1087.     if (INT_CheckPlayerAdminLevel(playerid, 5) == 0) return 0;
  1088.  
  1089.     // Setup local variables
  1090.     new file[100], Msg[128], Name[24];
  1091.  
  1092.     // Check if the player isn't inside a vehicle (the admin-player must be on foot to use this command)
  1093.     if (GetPlayerVehicleSeat(playerid) == -1)
  1094.     {
  1095.         // Loop through all houses
  1096.         for (new HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
  1097.         {
  1098.             // Check if the house exists
  1099.             if (IsValidDynamicPickup(AHouseData[HouseID][PickupID]))
  1100.             {
  1101.                 // Check if the player is in range of the house-pickup
  1102.                 if (IsPlayerInRangeOfPoint(playerid, 2.5, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]))
  1103.                 {
  1104.                     // Get the name of the owner (if the house is owned)
  1105.                     if (AHouseData[HouseID][Owned] == true)
  1106.                     {
  1107.                         // Loop through all players to find the owner (if he's online)
  1108.                         for (new pid; pid < MAX_PLAYERS; pid++)
  1109.                         {
  1110.                             // Check if this player is online
  1111.                             if (INT_IsPlayerLoggedIn(playerid) == 1)
  1112.                             {
  1113.                                 // Get that player's name
  1114.                                 GetPlayerName(pid, Name, sizeof(Name));
  1115.                                 // Compare if this player has the same name as the owner of the house
  1116.                                 if (strcmp(AHouseData[HouseID][Owner], Name, false) == 0)
  1117.                                 {
  1118.                                     // Inform the player that his house is being deleted
  1119.                                     format(Msg, 128, "{FF0000}Your house {FFFF00}\"%s\"{FF0000} is being deleted", AHouseData[HouseID][HouseName]);
  1120.                                     SendClientMessage(pid, 0xFFFFFFFF, Msg);
  1121.  
  1122.                                     // Also remove the HouseID from his list of houses
  1123.                                     for (new HouseSlot; HouseSlot < MAX_HOUSESPERPLAYER; HouseSlot++)
  1124.                                         // Check if the house is stored in this houseslot
  1125.                                         if (APlayerData[pid][Houses][HouseSlot] == HouseID)
  1126.                                             // If the house is stored in this slot, clear the slot
  1127.                                             APlayerData[pid][Houses][HouseSlot] = 0;
  1128.  
  1129.                                     // Stop this For-loop, as the owner was already found and informed
  1130.                                     break;
  1131.                                 }
  1132.                             }
  1133.                         }
  1134.                     }
  1135.  
  1136.                     // First remove all vehicles from the house
  1137.                     House_RemoveVehicles(HouseID);
  1138.  
  1139.                     // Clear all data of the house
  1140.                     AHouseData[HouseID][Owned] = false;
  1141.                     AHouseData[HouseID][Owner] = 0;
  1142.                     AHouseData[HouseID][HouseName] = 0;
  1143.                     AHouseData[HouseID][Insurance] = false;
  1144.                     AHouseData[HouseID][HouseX] = 0.0;
  1145.                     AHouseData[HouseID][HouseY] = 0.0;
  1146.                     AHouseData[HouseID][HouseZ] = 0.0;
  1147.                     AHouseData[HouseID][HouseLevel] = 0;
  1148.                     AHouseData[HouseID][HouseMaxLevel] = 0;
  1149.                     AHouseData[HouseID][HousePrice] = 0;
  1150.                     AHouseData[HouseID][HouseOpened] = false;
  1151.                     AHouseData[HouseID][StaticHouse] = false;
  1152.                     AHouseData[HouseID][CarSlots] = 0;
  1153.                     // Destroy the mapicon, 3DText and pickup for the house
  1154.                     DestroyDynamicPickup(AHouseData[HouseID][PickupID]);
  1155.                     DestroyDynamicMapIcon(AHouseData[HouseID][MapIconID]);
  1156.                     DestroyDynamic3DTextLabel(AHouseData[HouseID][DoorText]);
  1157.                     AHouseData[HouseID][PickupID] = 0;
  1158.                     AHouseData[HouseID][MapIconID] = 0;
  1159.  
  1160.                     // Delete the house-file
  1161.                     format(file, sizeof(file), HouseFile, HouseID); // Construct the complete filename for this house-file
  1162.                     if (fexist(file)) // Make sure the file exists
  1163.                         fremove(file); // Delete the file
  1164.  
  1165.                     // Also let the player know he deleted the house
  1166.                     format(Msg, 128, "{00FF00}You have deleted the house with ID: {FFFF00}%i", HouseID);
  1167.                     SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  1168.  
  1169.                     // Exit the function
  1170.                     return 1;
  1171.                 }
  1172.             }
  1173.         }
  1174.  
  1175.         // There was no house in range, so let the player know about it
  1176.         SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}No house in range to delete");
  1177.     }
  1178.     else
  1179.         SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You must be on foot to delete a house");
  1180.  
  1181.     // Let the server know that this was a valid command
  1182.     return 1;
  1183. }
  1184.  
  1185. // This command lets the player buy a house when he's standing in range of a house that isn't owned yet
  1186. COMMAND:buyhouse(playerid, params[])
  1187. {
  1188.     // Setup local variables
  1189.     new Msg[128];
  1190.  
  1191.     // If a player hasn't logged in properly, he cannot use this command
  1192.     if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
  1193.  
  1194.     // Check if the player isn't inside a vehicle (the player must be on foot to use this command)
  1195.     if (GetPlayerVehicleSeat(playerid) == -1)
  1196.     {
  1197.         // Check if the player is near a house-pickup
  1198.         for (new HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
  1199.         {
  1200.             // Check if the house exists
  1201.             if (IsValidDynamicPickup(AHouseData[HouseID][PickupID]))
  1202.             {
  1203.                 // Check if the player is in range of the house-pickup
  1204.                 if (IsPlayerInRangeOfPoint(playerid, 2.5, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]))
  1205.                 {
  1206.                     // Check if the house isn't owned yet
  1207.                     if (AHouseData[HouseID][Owned] == false)
  1208.                     {
  1209.                         // Check if the player can afford this house
  1210.                         if (INT_GetPlayerMoney(playerid) >= AHouseData[HouseID][HousePrice])
  1211.                             House_SetOwner(playerid, HouseID); // Give ownership of the house to the player (if he has a spare houseslot)
  1212.                         else
  1213.                             SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot afford this house"); // The player cannot afford this house
  1214.                     }
  1215.                     else
  1216.                     {
  1217.                         // Let the player know that this house is already owned by a player
  1218.                         format(Msg, 128, "{FF0000}This house is already owned by {FFFF00}%s", AHouseData[HouseID][Owner]);
  1219.                         SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  1220.                     }
  1221.  
  1222.                     // The player was in range of a house-pickup, so stop searching for the other house pickups
  1223.                     return 1;
  1224.                 }
  1225.             }
  1226.         }
  1227.  
  1228.         // All houses have been processed, but the player wasn't in range of any house-pickup, let him know about it
  1229.         SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}To buy a house, you have to be near a house-pickup");
  1230.     }
  1231.     else
  1232.         SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You can't buy a house when you're inside a vehicle");
  1233.  
  1234.     // Let the server know that this was a valid command
  1235.     return 1;
  1236. }
  1237.  
  1238. // This command lets the player enter the house/business if he's the owner
  1239. COMMAND:enter(playerid, params[])
  1240. {
  1241.     // Setup local variables
  1242.     new HouseID, IntID;
  1243.  
  1244.     // If a player hasn't logged in properly, he cannot use this command
  1245.     if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
  1246.  
  1247.     // Check if the player isn't inside a vehicle (the player must be on foot to use this command)
  1248.     if (GetPlayerVehicleSeat(playerid) == -1)
  1249.     {
  1250.         // Loop through all houses
  1251.         for (HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
  1252.         {
  1253.             // Check if the house exists
  1254.             if (IsValidDynamicPickup(AHouseData[HouseID][PickupID]))
  1255.             {
  1256.                 // Check if the player is in range of the house-pickup
  1257.                 if (IsPlayerInRangeOfPoint(playerid, 2.5, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]))
  1258.                 {
  1259.                     // Check if the house is closed to the public
  1260.                     if (AHouseData[HouseID][HouseOpened] == false)
  1261.                     {
  1262.                         // The house isn't open to the public, so keep anyone out who isn't the owner of the house
  1263.                         if (House_PlayerIsOwner(playerid, HouseID) == 0)
  1264.                         {
  1265.                             // Let the player know that this house isn't open to the public and he can't enter it
  1266.                             SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}This house isn't open to the public, you can't enter it");
  1267.                             return 1;
  1268.                         }
  1269.                     }
  1270.  
  1271.                     // The house is open to the public, or the player trying to enter is the owner, so let the player inside the house
  1272.  
  1273.                     // Get the interior to put the player in
  1274.                     IntID = AHouseData[HouseID][HouseLevel]; // Get the level of the house
  1275.  
  1276.                     // Set the worldid so other players cannot see him anymore (but allow all players in the same house to see eachother)
  1277.                     SetPlayerVirtualWorld(playerid, 5000 + HouseID);
  1278.                     // Set the player inside the interior of the house
  1279.                     SetPlayerInterior(playerid, AHouseInteriors[IntID][InteriorID]);
  1280.                     // Set the position of the player at the spawn-location of the house's interior
  1281.                     SetPlayerPos(playerid, AHouseInteriors[IntID][IntX], AHouseInteriors[IntID][IntY], AHouseInteriors[IntID][IntZ]);
  1282.                     // Also set a tracking-variable to enable /housemenu to track in which house the player is
  1283.                     APlayerData[playerid][CurrentHouse] = HouseID;
  1284.                     // Also let the player know he can use /housemenu to upgrade/exit his house
  1285.                     SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Use {FFFF00}/housemenu{00FF00} to change options for your house");
  1286.  
  1287.                     // Exit the function
  1288.                     return 1;
  1289.                 }
  1290.             }
  1291.         }
  1292.     }
  1293.  
  1294.     // If no house was in range, allow other script to use this command too (business-script for example)
  1295.     return 0;
  1296. }
  1297. COMMAND:exit(playerid, params[])
  1298. {
  1299.     new HouseID = APlayerData[playerid][CurrentHouse];
  1300.  
  1301.     // All players must exit the house
  1302.     for (new OtherPlayer; OtherPlayer < MAX_PLAYERS; OtherPlayer++)
  1303.     {
  1304.         // If this player is inside the house
  1305.         if (APlayerData[OtherPlayer][CurrentHouse] == HouseID)
  1306.         {
  1307.             // Let the player exit the house
  1308.             House_Exit(OtherPlayer, HouseID);
  1309.         }
  1310.     }
  1311.     return 1;
  1312. }
  1313. // This command opens a menu when you're inside your house to allow to access the options of your house
  1314. COMMAND:housemenu(playerid, params[])
  1315. {
  1316.     // Setup local variables
  1317.     new OptionsList[200], DialogTitle[200], HouseID;
  1318.  
  1319.     // If a player hasn't logged in properly, he cannot use this command
  1320.     if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
  1321.  
  1322.     // Get the HouseID where the player has entered
  1323.     HouseID = APlayerData[playerid][CurrentHouse];
  1324.  
  1325.     // Check if the player is inside a house
  1326.     if (HouseID != 0)
  1327.     {
  1328.         format(DialogTitle, sizeof(DialogTitle), "Select option for %s", AHouseData[HouseID][HouseName]);
  1329.  
  1330.         // Create 2 different option-lists, based on StaticHouse
  1331.         if (AHouseData[HouseID][StaticHouse] == true)
  1332.         {
  1333.             // Create the dialog for a static house (has the same options as a normal house, except for upgrading the house)
  1334.             format(OptionsList, sizeof(OptionsList), "%sChange house-name\n", OptionsList);
  1335.             //format(OptionsList, sizeof(OptionsList), "%sBuy house-car\n", OptionsList);
  1336.             //format(OptionsList, sizeof(OptionsList), "%sBuy house-car insurance\n", OptionsList);
  1337.             //format(OptionsList, sizeof(OptionsList), "%sSell house-car\n", OptionsList);
  1338.             format(OptionsList, sizeof(OptionsList), "%sSell house\n", OptionsList);
  1339.             format(OptionsList, sizeof(OptionsList), "%sOpen house to the public\n", OptionsList);
  1340.             format(OptionsList, sizeof(OptionsList), "%sClose house to the public\n", OptionsList);
  1341.             //format(OptionsList, sizeof(OptionsList), "%sExit house\n", OptionsList);
  1342.         }
  1343.         else
  1344.         {
  1345.             // Create the dialog for a normal house
  1346.             format(OptionsList, sizeof(OptionsList), "%sChange house-name\n", OptionsList);
  1347.             format(OptionsList, sizeof(OptionsList), "%sUpgrade house\n", OptionsList);
  1348.             //format(OptionsList, sizeof(OptionsList), "%sBuy house-car\n", OptionsList);
  1349.             //format(OptionsList, sizeof(OptionsList), "%sBuy house-car insurance\n", OptionsList);
  1350.             //format(OptionsList, sizeof(OptionsList), "%sSell house-car\n", OptionsList);
  1351.             format(OptionsList, sizeof(OptionsList), "%sSell house\n", OptionsList);
  1352.             format(OptionsList, sizeof(OptionsList), "%sOpen house to the public\n", OptionsList);
  1353.             format(OptionsList, sizeof(OptionsList), "%sClose house to the public\n", OptionsList);
  1354.             //format(OptionsList, sizeof(OptionsList), "%sExit house\n", OptionsList);
  1355.         }
  1356.         // Show the housemenu
  1357.         ShowPlayerDialog(playerid, DialogHouseMenu, DIALOG_STYLE_LIST, DialogTitle, OptionsList, "Select", "Cancel");
  1358.     }
  1359.     else
  1360.         SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You're not inside a house");
  1361.  
  1362.     // Let the server know that this was a valid command
  1363.     return 1;
  1364. }
  1365.  
  1366. // This command teleports you to your selected house
  1367. COMMAND:myhouses(playerid, params[])
  1368. {
  1369.     // Setup local variables
  1370.     new HouseList[1000], HouseID;
  1371.  
  1372.     // If a player hasn't logged in properly, he cannot use this command
  1373.     if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
  1374.  
  1375.     // Check if the player isn't jailed
  1376.     if (INT_IsPlayerJailed(playerid) == 0)
  1377.     {
  1378.         // Check if the player isn't inside a vehicle (the player must be on foot to use this command)
  1379.         if (GetPlayerVehicleSeat(playerid) == -1)
  1380.         {
  1381.             // Ask to which house the player wants to port
  1382.             for (new HouseSlot; HouseSlot < MAX_HOUSESPERPLAYER; HouseSlot++)
  1383.             {
  1384.                 // Get the HouseID in this slot
  1385.                 HouseID = APlayerData[playerid][Houses][HouseSlot];
  1386.  
  1387.                 // Check if this houseindex is occupied
  1388.                 if (HouseID != 0)
  1389.                     format(HouseList, 1000, "%s{00FF00}%s{FFFFFF}\n", HouseList, AHouseData[HouseID][HouseName]);
  1390.                 else
  1391.                     format(HouseList, 1000, "%s{FFFFFF}%s{FFFFFF}\n", HouseList, "Empty house-slot");
  1392.             }
  1393.             ShowPlayerDialog(playerid, DialogGoHome, DIALOG_STYLE_LIST, "Choose the house to go to:", HouseList, "Select", "Cancel");
  1394.         }
  1395.         else
  1396.             SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You must be on foot to port to your house");
  1397.     }
  1398.     else
  1399.         SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot use /myhouses when you're in jail");
  1400.  
  1401.     // Let the server know that this was a valid command
  1402.     return 1;
  1403. }
  1404.  
  1405. // This command allows you to port a vehicle from your house to your location
  1406. COMMAND:getcar(playerid, params[])
  1407. {
  1408.     // Setup local variables
  1409.     new HouseList[1000], HouseID;
  1410.  
  1411.     // If a player hasn't logged in properly, he cannot use this command
  1412.     if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
  1413.  
  1414.     // Check if the player isn't inside a vehicle (the player must be on foot to use this command)
  1415.     if (GetPlayerVehicleSeat(playerid) == -1)
  1416.     {
  1417.         // Ask to which house the player wants to port
  1418.         for (new HouseSlot; HouseSlot < MAX_HOUSESPERPLAYER; HouseSlot++)
  1419.         {
  1420.             // Get the HouseID in this slot
  1421.             HouseID = APlayerData[playerid][Houses][HouseSlot];
  1422.  
  1423.             // Check if this houseindex is occupied
  1424.             if (HouseID != 0)
  1425.                 format(HouseList, 1000, "%s{00FF00}%s{FFFFFF}\n", HouseList, AHouseData[HouseID][HouseName]);
  1426.             else
  1427.                 format(HouseList, 1000, "%s{FFFFFF}%s{FFFFFF}\n", HouseList, "Empty house-slot");
  1428.         }
  1429.         ShowPlayerDialog(playerid, DialogGetCarSelectHouse, DIALOG_STYLE_LIST, "Choose the house to get a car from:", HouseList, "Select", "Cancel");
  1430.     }
  1431.     else
  1432.         SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You need to be on foot to port a vehicle to your location");
  1433.  
  1434.     // Let the server know that this was a valid command
  1435.     return 1;
  1436. }
  1437.  
  1438. // This command checks if the player is inside a vehicle that he owns and if he's in range of the house where the vehicle is assigned to
  1439. COMMAND:park(playerid, params[])
  1440. {
  1441.     // Setup local variables
  1442.     new Float:x, Float:y, Float:z, Float:rot, vid, HouseID, Msg[128];
  1443.     new engine,lights,alarm,doors,bonnet,boot,objective;
  1444.  
  1445.     // If a player hasn't logged in properly, he cannot use this command
  1446.     if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
  1447.  
  1448.     // Check if the player is inside a vehicle (he must be the driver)
  1449.     if (GetPlayerVehicleSeat(playerid) == 0)
  1450.     {
  1451.         // Get the vehicle-id
  1452.         vid = GetPlayerVehicleID(playerid);
  1453.         // Get the HouseID to which this vehicle belongs
  1454.         HouseID = AVehicleData[vid][BelongsToHouse];
  1455.  
  1456.         // Check if this vehicle belongs to a house (if not, the vehicle cannot be parked, as it's not a house-vehicle)
  1457.         if (HouseID != 0)
  1458.         {
  1459.             // Check if the vehicle is in range of the house-entrance (you cannot park a vehicle further away from your house than 150m)
  1460.             if (IsPlayerInRangeOfPoint(playerid, ParkRange, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]))
  1461.             {
  1462.                 // Get the player's position and angle
  1463.                 GetVehiclePos(vid, x, y, z);
  1464.                 GetVehicleZAngle(vid, rot);
  1465.                 // Save those values for the vehicle
  1466.                 AVehicleData[vid][SpawnX] = x;
  1467.                 AVehicleData[vid][SpawnY] = y;
  1468.                 AVehicleData[vid][SpawnZ] = z;
  1469.                 AVehicleData[vid][SpawnRot] = rot;
  1470.  
  1471.                 // Loop through all carslots of this house to find the vehicle-id
  1472.                 for (new CarSlot; CarSlot < 10; CarSlot++)
  1473.                 {
  1474.                     // Check if this carslot holds the same vehicle-id
  1475.                     if (AHouseData[HouseID][VehicleIDs][CarSlot] == vid)
  1476.                     {
  1477.                         House_ReplaceVehicle(HouseID, CarSlot); // Re-create the vehicle at the same spot the player wants to park his vehicle
  1478.                         PutPlayerInVehicle(playerid, AHouseData[HouseID][VehicleIDs][CarSlot], 0);
  1479.                         // Turn on the engine and lights
  1480.                         GetVehicleParamsEx(AHouseData[HouseID][VehicleIDs][CarSlot], engine, lights, alarm, doors, bonnet, boot, objective);
  1481.                         SetVehicleParamsEx(AHouseData[HouseID][VehicleIDs][CarSlot], 1, 1, alarm, doors, bonnet, boot, objective);
  1482.                         break; // Stop the for-loop
  1483.                     }
  1484.                 }
  1485.  
  1486.                 // Let the player know he parked his vehicle
  1487.                 SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}You've parked your vehicle");
  1488.  
  1489.                 // Save the housefile
  1490.                 HouseFile_Save(HouseID);
  1491.             }
  1492.             else
  1493.             {
  1494.                 format(Msg, 128, "{FF0000}You need to be within {FFFF00}%im{FF0000} of your house to park this vehicle", ParkRange);
  1495.                 SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  1496.             }
  1497.         }
  1498.         else
  1499.             SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot park a vehicle that's not owned by you");
  1500.     }
  1501.     else
  1502.         SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You must be driving a vehicle you own to park it");
  1503.  
  1504.     // Let the server know that this was a valid command
  1505.     return 1;
  1506. }
  1507.  
  1508. // This command lets the player evict a house (this clears the ownership of the house so it can be bought again by other players)
  1509. COMMAND:evict(playerid, params[])
  1510. {
  1511.     // If a player hasn't logged in properly, he cannot use this command
  1512.     if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
  1513.     // If the player has an insufficient admin-level (he needs level 5 or RCON admin), exit the command
  1514.     // returning "SERVER: Unknown command" to the player
  1515.     if (INT_CheckPlayerAdminLevel(playerid, 5) == 0) return 0;
  1516.  
  1517.     // Setup local variables
  1518.     new Msg[128], Name[24];
  1519.  
  1520.     // Check if the player isn't inside a vehicle (the admin-player must be on foot to use this command)
  1521.     if (GetPlayerVehicleSeat(playerid) == -1)
  1522.     {
  1523.         // Loop through all houses
  1524.         for (new HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
  1525.         {
  1526.             // Check if the house exists
  1527.             if (IsValidDynamicPickup(AHouseData[HouseID][PickupID]))
  1528.             {
  1529.                 // Check if the player is in range of the house-pickup
  1530.                 if (IsPlayerInRangeOfPoint(playerid, 2.5, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]))
  1531.                 {
  1532.                     // Get the name of the owner (if the house is owned)
  1533.                     if (AHouseData[HouseID][Owned] == true)
  1534.                     {
  1535.                         // Loop through all players to find the owner (if he's online)
  1536.                         for (new pid; pid < MAX_PLAYERS; pid++)
  1537.                         {
  1538.                             // Check if this player is online
  1539.                             if (INT_IsPlayerLoggedIn(playerid) == 1)
  1540.                             {
  1541.                                 // Get that player's name
  1542.                                 GetPlayerName(pid, Name, sizeof(Name));
  1543.                                 // Compare if this player has the same name as the owner of the house
  1544.                                 if (strcmp(AHouseData[HouseID][Owner], Name, false) == 0)
  1545.                                 {
  1546.                                     // Inform the player that his house is being deleted
  1547.                                     format(Msg, 128, "{FF0000}You lost your house {FFFF00}\"%s\"{FF0000}, as it was evicted", AHouseData[HouseID][HouseName]);
  1548.                                     SendClientMessage(pid, 0xFFFFFFFF, Msg);
  1549.  
  1550.                                     // Also remove the HouseID from his list of houses
  1551.                                     for (new HouseSlot; HouseSlot < MAX_HOUSESPERPLAYER; HouseSlot++)
  1552.                                         // Check if the house is stored in this houseslot
  1553.                                         if (APlayerData[pid][Houses][HouseSlot] == HouseID)
  1554.                                             // If the house is stored in this slot, clear the slot
  1555.                                             APlayerData[pid][Houses][HouseSlot] = 0;
  1556.  
  1557.                                     // Stop this For-loop, as the owner was already found and informed
  1558.                                     break;
  1559.                                 }
  1560.                             }
  1561.                         }
  1562.                     }
  1563.  
  1564.                     // First remove all vehicles from the house
  1565.                     House_RemoveVehicles(HouseID);
  1566.  
  1567.                     // Clear the ownership of the house
  1568.                     AHouseData[HouseID][Owned] = false;
  1569.                     AHouseData[HouseID][Owner] = 0;
  1570.  
  1571.                     // Update the entrance of the house so other players know it's available for purchase again
  1572.                     House_UpdateEntrance(HouseID);
  1573.                     // Save the house
  1574.                     HouseFile_Save(HouseID);
  1575.  
  1576.                     // Also let the player know he evicted the house
  1577.                     format(Msg, 128, "{00FF00}You have evicted the house with ID: {FFFF00}%i", HouseID);
  1578.                     SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  1579.  
  1580.                     // Exit the function
  1581.                     return 1;
  1582.                 }
  1583.             }
  1584.         }
  1585.  
  1586.         // There was no house in range, so let the player know about it
  1587.         SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}No house in range to delete");
  1588.     }
  1589.     else
  1590.         SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You must be on foot to delete a house");
  1591.  
  1592.     // Let the server know that this was a valid command
  1593.     return 1;
  1594. }
  1595.  
  1596.  
  1597.  
  1598. // ******************************************************************************************************************************
  1599. // Dialog-responses
  1600. // ******************************************************************************************************************************
  1601.  
  1602. // This function processes the housemenu dialog
  1603. Dialog_HouseMenu(playerid, response, listitem)
  1604. {
  1605.     // Just close the dialog if the player clicked "Cancel"
  1606.     if(!response) return 1;
  1607.  
  1608.     // Setup local variables
  1609.     new UpgradeList[2000], HouseID, DialogTitle[200], Counter, UpgradePrice, Msg[128], CarSlot;
  1610.     //new MsgInsurance[128], BuyableCarIndex,
  1611.     new bool:HouseHasCars = false;
  1612.  
  1613.     // Get the HouseID of the house where the player is
  1614.     HouseID = APlayerData[playerid][CurrentHouse];
  1615.  
  1616.     // Skip listitem 1 if this house is a static house (listitem 1 = buy house-car => item 2, ...)
  1617.     if (AHouseData[HouseID][StaticHouse] == true)
  1618.     {
  1619.         // If listitem is 1 or higher, increase the listitem by 1, skipping the "upgrade house" option
  1620.         // but still keep the "change housename" option (listitem 0)
  1621.         if (listitem >= 1)
  1622.             listitem++;
  1623.     }
  1624.  
  1625.     // Select an option based on the selection in the list
  1626.     switch(listitem)
  1627.     {
  1628.         case 0: // Change house name
  1629.         {
  1630.             // Only the house-owner can use this option
  1631.             if (House_PlayerIsOwner(playerid, HouseID) == 1)
  1632.             {
  1633.                 format(DialogTitle, 200, "Old house-name: %s", AHouseData[HouseID][HouseName]);
  1634.                 ShowPlayerDialog(playerid, DialogHouseNameChange, DIALOG_STYLE_INPUT, DialogTitle, "Give a new name to your house", "Select", "Cancel");
  1635.             }
  1636.             else
  1637.                 SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Only the house-owner can use this option");
  1638.         }
  1639.         case 1: // Upgrade the house
  1640.         {
  1641.             // Only the house-owner can use this option
  1642.             if (House_PlayerIsOwner(playerid, HouseID) == 1)
  1643.             {
  1644.                 // Check if it's possible to upgrade further
  1645.                 if (AHouseData[HouseID][HouseLevel] < AHouseData[HouseID][HouseMaxLevel])
  1646.                 {
  1647.                     // Add only the upgrades above the current house-level to the upgradelist
  1648.                     for (new i = AHouseData[HouseID][HouseLevel] + 1; i <= AHouseData[HouseID][HouseMaxLevel]; i++)
  1649.                     {
  1650.                         Counter++; // Add 1 to the counter each time an upgrade is added to the upgradelist
  1651.                         UpgradePrice = ((AHouseData[HouseID][HousePrice] * Counter) / 100) * HouseUpgradePercent;
  1652.                         // Add the upgrade-info in green if the player can afford it, and in red if he cannot afford it
  1653.                         if (INT_GetPlayerMoney(playerid) >= UpgradePrice)
  1654.                             format(UpgradeList, 2000, "%s{00FF00}%s (level %i)\t\t$%i\n", UpgradeList, AHouseInteriors[i][InteriorName], i, UpgradePrice);
  1655.                         else
  1656.                             format(UpgradeList, 2000, "%s{FF0000}%s (level %i)\t\t$%i\n", UpgradeList, AHouseInteriors[i][InteriorName], i, UpgradePrice);
  1657.                     }
  1658.  
  1659.                     // Show another dialog to let the player select which upgrade he wants for his house
  1660.                     ShowPlayerDialog(playerid, DialogUpgradeHouse, DIALOG_STYLE_LIST, "Select upgrade:", UpgradeList, "Select", "Cancel");
  1661.                 }
  1662.                 else
  1663.                     SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Your house has reached the maximum level, you cannot upgrade it further");
  1664.             }
  1665.             else
  1666.                 SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Only the house-owner can use this option");
  1667.         }
  1668.         /*case 2: // Buy house-car
  1669.         {
  1670.             // Only the house-owner can use this option
  1671.             if (House_PlayerIsOwner(playerid, HouseID) == 1)
  1672.             {
  1673.                 // Find a free carslot
  1674.                 CarSlot = House_GetFreeCarSlot(HouseID);
  1675.                 // Check if the carslot is valid
  1676.                 if (CarSlot != -1)
  1677.                 {
  1678.                     // Let the player choose a vehicle-class
  1679.                     format(VehicleClassList, 1000, "%s{00FF00}%s{FFFFFF}\n", VehicleClassList, "Bikes");
  1680.                     format(VehicleClassList, 1000, "%s{40FF00}%s{FFFFFF}\n", VehicleClassList, "Boats");
  1681.                     format(VehicleClassList, 1000, "%s{80FF00}%s{FFFFFF}\n", VehicleClassList, "Convertibles");
  1682.                     format(VehicleClassList, 1000, "%s{B0FF00}%s{FFFFFF}\n", VehicleClassList, "Helicopters");
  1683.                     format(VehicleClassList, 1000, "%s{FFFF00}%s{FFFFFF}\n", VehicleClassList, "Industrial vehicles");
  1684.                     format(VehicleClassList, 1000, "%s{B0FF40}%s{FFFFFF}\n", VehicleClassList, "Low-riders");
  1685.                     format(VehicleClassList, 1000, "%s{80FF80}%s{FFFFFF}\n", VehicleClassList, "Off-Road vehicles");
  1686.                     format(VehicleClassList, 1000, "%s{40FFB0}%s{FFFFFF}\n", VehicleClassList, "Planes");
  1687.                     format(VehicleClassList, 1000, "%s{00FFFF}%s{FFFFFF}\n", VehicleClassList, "Public Service vehicles");
  1688.                     format(VehicleClassList, 1000, "%s{00B0FF}%s{FFFFFF}\n", VehicleClassList, "RC vehicles");
  1689.                     format(VehicleClassList, 1000, "%s{0080FF}%s{FFFFFF}\n", VehicleClassList, "Saloon vehicles");
  1690.                     format(VehicleClassList, 1000, "%s{0040FF}%s{FFFFFF}\n", VehicleClassList, "Sport vehicles");
  1691.                     format(VehicleClassList, 1000, "%s{0000FF}%s{FFFFFF}\n", VehicleClassList, "Station wagons");
  1692.                     format(VehicleClassList, 1000, "%s{4000FF}%s{FFFFFF}\n", VehicleClassList, "Trailers");
  1693.                     format(VehicleClassList, 1000, "%s{8000FF}%s{FFFFFF}\n", VehicleClassList, "Unique vehicles");
  1694.                     // Ask which vehicle class the player wants to see to buy a vehicle
  1695.                     ShowPlayerDialog(playerid, DialogBuyCarClass, DIALOG_STYLE_LIST, "Select vehicle class:", VehicleClassList, "Select", "Cancel");
  1696.                 }
  1697.                 else
  1698.                     SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}This house has the maximum amount of house-cars already");
  1699.             }
  1700.             else
  1701.                 SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Only the house-owner can use this option");
  1702.         }
  1703.         case 3: // Buy house-car insurance
  1704.         {
  1705.             // Only the house-owner can use this option
  1706.             if (House_PlayerIsOwner(playerid, HouseID) == 1)
  1707.             {
  1708.                 // Check if this house doesn't have insurance yet
  1709.                 if (AHouseData[HouseID][Insurance] == false)
  1710.                 {
  1711.                     // Check if the player can afford the insurance
  1712.                     if (INT_GetPlayerMoney(playerid) >= (AHouseData[HouseID][HousePrice] / 10))
  1713.                     {
  1714.                         // Construct the message for the dialog, this includes the price for the insurance
  1715.                         format(MsgInsurance, 128, "Are you sure you want to buy an insurance for your house's vehicles for $%i?", AHouseData[HouseID][HousePrice] / 10);
  1716.                         // Ask the player if the wants to buy an insurance for this house's vehicles
  1717.                         if (AutomaticInsurance == true)
  1718.                             ShowPlayerDialog(playerid, DialogBuyInsurance, DIALOG_STYLE_MSGBOX, "The admin enabled insurance for everyone. Buy insurance anyway?", MsgInsurance, "Yes", "No");
  1719.                         else
  1720.                             ShowPlayerDialog(playerid, DialogBuyInsurance, DIALOG_STYLE_MSGBOX, "Buy insurance?", MsgInsurance, "Yes", "No");
  1721.                     }
  1722.                     else
  1723.                         SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot afford the vehicle-insurance");
  1724.                 }
  1725.                 else
  1726.                     SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}This house already has an insurance for it's vehicles");
  1727.             }
  1728.             else
  1729.                 SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Only the house-owner can use this option");
  1730.         }
  1731.         case 4: // Sell house-car
  1732.         {
  1733.             // Only the house-owner can use this option
  1734.             if (House_PlayerIsOwner(playerid, HouseID) == 1)
  1735.             {
  1736.                 // Check if the house has any cars assigned to it
  1737.                 for (CarSlot = 0; CarSlot < AHouseData[HouseID][CarSlots]; CarSlot++)
  1738.                     if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
  1739.                         HouseHasCars = true;
  1740.  
  1741.                 // Check if the house has any cars assigned to it
  1742.                 if (HouseHasCars == true)
  1743.                 {
  1744.                     // Add all vehicles to the list
  1745.                     for (CarSlot = 0; CarSlot < AHouseData[HouseID][CarSlots]; CarSlot++)
  1746.                     {
  1747.                         if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
  1748.                         {
  1749.                             // Get the index where the first vehicle is found in the ABuyableVehicles array
  1750.                             BuyableCarIndex = VehicleBuyable_GetIndex(GetVehicleModel(AHouseData[HouseID][VehicleIDs][CarSlot]));
  1751.                             // Add the name of the vehicle to the list
  1752.                             format(VehicleList, 500, "%s{00FF00}%s: $%i{FFFFFF}\n", VehicleList, ABuyableVehicles[BuyableCarIndex][CarName], ABuyableVehicles[BuyableCarIndex][Price] / 2);
  1753.                         }
  1754.                         else
  1755.                             format(VehicleList, 500, "%s{FFFFFF}Empty car-slot{FFFFFF}\n", VehicleList);
  1756.                     }
  1757.  
  1758.                     // Ask which vehicle class the player wants to see to buy a vehicle
  1759.                     ShowPlayerDialog(playerid, DialogSellCar, DIALOG_STYLE_LIST, "Select vehicle to sell:", VehicleList, "Select", "Cancel");
  1760.                 }
  1761.                 else
  1762.                     SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}This house has no vehicles assigned to it");
  1763.             }
  1764.             else
  1765.                 SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Only the house-owner can use this option");
  1766.         }*/
  1767.         case 2: // Sell house
  1768.         {
  1769.             // Only the house-owner can use this option
  1770.             if (House_PlayerIsOwner(playerid, HouseID) == 1)
  1771.             {
  1772.                 // Check if the house has any cars assigned to it
  1773.                 for (CarSlot = 0; CarSlot < AHouseData[HouseID][CarSlots]; CarSlot++)
  1774.                     if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
  1775.                         HouseHasCars = true;
  1776.  
  1777.                 // Check if all house-cars have been sold (all slots are empty)
  1778.                 if (HouseHasCars == false)
  1779.                 {
  1780.                     format(Msg, 128, "Are you sure you want to sell your house for $%i?", House_CalcSellPrice(HouseID));
  1781.                     ShowPlayerDialog(playerid, DialogSellHouse, DIALOG_STYLE_MSGBOX, "Are you sure?", Msg, "Yes", "No");
  1782.                 }
  1783.                 else
  1784.                     SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You can't sell a house which still has house-cars assigned to it");
  1785.             }
  1786.             else
  1787.                 SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Only the house-owner can use this option");
  1788.         }
  1789.         case 3: // Open the house to the public (everyone can enter it)
  1790.         {
  1791.             // Only the house-owner can use this option
  1792.             if (House_PlayerIsOwner(playerid, HouseID) == 1)
  1793.             {
  1794.                 // Open the house to the public
  1795.                 AHouseData[HouseID][HouseOpened] = true;
  1796.                 // Let the player know he opened the house to the public
  1797.                 SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}You've opened the house to the public, anyone can enter it");
  1798.             }
  1799.             else
  1800.                 SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Only the house-owner can use this option");
  1801.         }
  1802.         case 4: // Close the house to the public (only the owner can enter it)
  1803.         {
  1804.             // Only the house-owner can use this option
  1805.             if (House_PlayerIsOwner(playerid, HouseID) == 1)
  1806.             {
  1807.                 // Close the house to the public
  1808.                 AHouseData[HouseID][HouseOpened] = false;
  1809.                 // Let the player know he closed the house to the public
  1810.                 SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}You've closed the house to the public, only you can enter it");
  1811.             }
  1812.             else
  1813.                 SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Only the house-owner can use this option");
  1814.         }
  1815.         /*case 5: // Exit the house
  1816.         {
  1817.             House_Exit(playerid, HouseID);
  1818.         }*/
  1819.     }
  1820.  
  1821.     return 1;
  1822. }
  1823.  
  1824. // This function processes the house-upgrade menu
  1825. Dialog_UpgradeHouse(playerid, response, listitem)
  1826. {
  1827.     // Just close the dialog if the player clicked "Cancel"
  1828.     if(!response) return 1;
  1829.  
  1830.     // Setup local variables
  1831.     new Msg[128], HouseID, hLevel, Payment;
  1832.  
  1833.     // Get the HouseID of the house where the player is
  1834.     HouseID = APlayerData[playerid][CurrentHouse];
  1835.     // Calculate the new house-level based on the selection in the list (the first entry is 1 level higher than the current house-level)
  1836.     hLevel = listitem + 1 + AHouseData[HouseID][HouseLevel];
  1837.     // Calculate the price for upgrading
  1838.     Payment = ((AHouseData[HouseID][HousePrice] * (listitem + 1)) / 100) * HouseUpgradePercent;
  1839.  
  1840.     // Check if the player can afford it
  1841.     if (INT_GetPlayerMoney(playerid) >= Payment)
  1842.     {
  1843.         // Upgrade the house
  1844.         AHouseData[HouseID][HouseLevel] = hLevel;
  1845.         // Also set the amount of carslots equal to the house-level
  1846.         AHouseData[HouseID][CarSlots] = hLevel;
  1847.  
  1848.         // Also re-position all players who are in your house (including yourself), otherwise they stay in the same interior
  1849.         for (new OtherPlayer; OtherPlayer < MAX_PLAYERS; OtherPlayer++)
  1850.         {
  1851.             // Check if the other player is in the house too
  1852.             if (APlayerData[OtherPlayer][CurrentHouse] == HouseID)
  1853.             {
  1854.                 // Set the worldid so other players cannot see him anymore (but allow all players in the same house to see eachother)
  1855.                 SetPlayerVirtualWorld(OtherPlayer, 5000 + HouseID);
  1856.                 // Set the player inside the new interior of the house
  1857.                 SetPlayerInterior(OtherPlayer, AHouseInteriors[hLevel][InteriorID]);
  1858.                 // Set the position of the player at the spawn-location of the house's interior
  1859.                 SetPlayerPos(OtherPlayer, AHouseInteriors[hLevel][IntX], AHouseInteriors[hLevel][IntY], AHouseInteriors[hLevel][IntZ]);
  1860.             }
  1861.         }
  1862.  
  1863.         // Let the player pay for the upgrade
  1864.         INT_GivePlayerMoney(playerid, -Payment);
  1865.         format(Msg, 128, "{00FF00}You've upgraded your house to level {FFFF00}%i{00FF00} for {FFFF00}$%i", AHouseData[HouseID][HouseLevel], Payment);
  1866.         SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  1867.  
  1868.         // Also update the 3DText at the entrance of the house
  1869.         House_UpdateEntrance(HouseID);
  1870.  
  1871.         // Save the house-file
  1872.         HouseFile_Save(HouseID);
  1873.     }
  1874.     else
  1875.         SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot afford this upgrade");
  1876.  
  1877.     return 1;
  1878. }
  1879.  
  1880. // Check which house the player chose, and port him to it
  1881. Dialog_GoHome(playerid, response, listitem)
  1882. {
  1883.     // Just close the dialog if the player clicked "Cancel"
  1884.     if(!response) return 1;
  1885.  
  1886.     // Setup local variables
  1887.     new HouseIndex, HouseID;
  1888.  
  1889.     // The listitem directly indicates the house-index
  1890.     HouseIndex = listitem;
  1891.     // Get the HouseID
  1892.     HouseID = APlayerData[playerid][Houses][HouseIndex];
  1893.  
  1894.     // Check if this is a valid house (HouseID != 0)
  1895.     if (HouseID != 0)
  1896.     {
  1897.         // Get the coordinates of the house's entrance
  1898.         SetPlayerPos(playerid, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]);
  1899.     }
  1900.     else
  1901.         SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You don't have a house in this house-slot");
  1902.  
  1903.     return 1;
  1904. }
  1905.  
  1906. // Let the player change the name of his house
  1907. Dialog_ChangeHouseName(playerid, response, inputtext[])
  1908. {
  1909.     // Just close the dialog if the player clicked "Cancel" or if the player didn't input any text
  1910.     if ((!response) || (strlen(inputtext) == 0)) return 1;
  1911.  
  1912.     // Change the name of the house
  1913.     format(AHouseData[APlayerData[playerid][CurrentHouse]][HouseName], 100, inputtext);
  1914.     // Also update the 3DText at the entrance of the house
  1915.     House_UpdateEntrance(APlayerData[playerid][CurrentHouse]);
  1916.     // Let the player know that the name of his house has been changed
  1917.     SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}You've changed the name of your house");
  1918.  
  1919.     // Save the house-file
  1920.     HouseFile_Save(APlayerData[playerid][CurrentHouse]);
  1921.  
  1922.     return 1;
  1923. }
  1924.  
  1925. // Choose a vehicle class from which to buy a vehicle
  1926. Dialog_BuyCarClass(playerid, response, listitem)
  1927. {
  1928.     // Just close the dialog if the player clicked "Cancel"
  1929.     if(!response) return 1;
  1930.  
  1931.     // Setup local variables
  1932.     new CarList[1000], DialogTitle[128];
  1933.  
  1934.     // Set the player's chosen vehicle-class based on the listitem he chose (add 1 as the vehicleclass starts at 1)
  1935.     APlayerData[playerid][DialogBuyVClass] = listitem + 1;
  1936.  
  1937.     // Add all vehicles of the same class to the list
  1938.     for (new i; i < sizeof(ABuyableVehicles); i++)
  1939.     {
  1940.         // Check if the vehicle in the list has the same class as requested
  1941.         if (ABuyableVehicles[i][VehicleClass] == APlayerData[playerid][DialogBuyVClass])
  1942.         {
  1943.             // Add the carname to the list and it's price
  1944.             format(CarList, 1000, "%s%s%s ($%i)", CarList, "\n", ABuyableVehicles[i][CarName], ABuyableVehicles[i][Price]); // Add the name of the next car to the list on the next line
  1945.         }
  1946.     }
  1947.  
  1948.     // Check if the list is empty
  1949.     if (strlen(CarList) == 0)
  1950.     {
  1951.         // Send the player a message that all vehicles have been disabled of the chosen class (no vehicles in the array of this class)
  1952.         SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}This is an empty list, the administrator may have disabled all vehicles of this class");
  1953.         // Exit the function (don't ask to choose a vehicle)
  1954.         return 1;
  1955.     }
  1956.  
  1957.     // Set a title for the dialog based on the requested vehicleclass
  1958.     switch (APlayerData[playerid][DialogBuyVClass])
  1959.     {
  1960.         case VClassBike: format(DialogTitle, 128, "Buy a bike:");
  1961.         case VClassBoat: format(DialogTitle, 128, "Buy a boat:");
  1962.         case VClassConvertible: format(DialogTitle, 128, "Buy a convertible:");
  1963.         case VClassHelicopter: format(DialogTitle, 128, "Buy a helicopter:");
  1964.         case VClassIndustrial: format(DialogTitle, 128, "Buy a industrial vehicle:");
  1965.         case VClassLowRider: format(DialogTitle, 128, "Buy a low-rider:");
  1966.         case VClassOffRoad: format(DialogTitle, 128, "Buy an off-road vehicle:");
  1967.         case VClassPlane: format(DialogTitle, 128, "Buy a plane:");
  1968.         case VClassPublic: format(DialogTitle, 128, "Buy a public service vehicle:");
  1969.         case VClassRCVehicle: format(DialogTitle, 128, "Buy a RC vehicle:");
  1970.         case VClassSaloons: format(DialogTitle, 128, "Buy a saloon vehicle:");
  1971.         case VClassSportCar: format(DialogTitle, 128, "Buy a sport vehicle:");
  1972.         case VClassStationCar: format(DialogTitle, 128, "Buy a stationwagon:");
  1973.         case VClassTrailer: format(DialogTitle, 128, "Buy a trailer:");
  1974.         case VClassUnique: format(DialogTitle, 128, "Buy a unique vehicle:");
  1975.     }
  1976.  
  1977.     // Ask which car the player wants to have by showing the dialog
  1978.     ShowPlayerDialog(playerid, DialogBuyCar, DIALOG_STYLE_LIST, DialogTitle, CarList, "Select", "Cancel");
  1979.  
  1980.     return 1;
  1981. }
  1982.  
  1983. // Buy a vehicle and assign it to the house
  1984. Dialog_BuyCar(playerid, response, listitem)
  1985. {
  1986.     // Just close the dialog if the player clicked "Cancel"
  1987.     if(!response) return 1;
  1988.  
  1989.     // Setup local variables
  1990.     new Counter, Msg[128], cComponents[14], vid;
  1991.  
  1992.     // Get the HouseID
  1993.     new HouseID = APlayerData[playerid][CurrentHouse];
  1994.  
  1995.     // Loop through the entire list of buyable vehicles
  1996.     for (new i; i < sizeof(ABuyableVehicles); i++)
  1997.     {
  1998.         // Check if the vehicle in the list has the same class as requested
  1999.         if (ABuyableVehicles[i][VehicleClass] == APlayerData[playerid][DialogBuyVClass])
  2000.         {
  2001.             // Check if this is the vehicle that the player chose
  2002.             if (Counter == listitem)
  2003.             {
  2004.                 // Check if the player has enough money to afford buying this vehicle
  2005.                 if (INT_GetPlayerMoney(playerid) >= (ABuyableVehicles[i][Price]))
  2006.                 {
  2007.                     // Add the vehicle to the house (this sets ownership and other data that's needed)
  2008.                     // The vehicles are by default created inside the hangar of KACC Military Fuels instead of near the EasterBoard Farm
  2009.                     vid = House_AddVehicle(HouseID, ABuyableVehicles[i][CarModel], 0, cComponents, 2585.0, 2829.0, 10.9, 0.0, random(126), random(126));
  2010.                     // Also set the vehicle's fuel to maximum (when the PPC_Speedometer script is used)
  2011.                     INT_SetVehicleFuel(vid, -1);
  2012.  
  2013.                     // Let the player pay for buying the vehicle
  2014.                     INT_GivePlayerMoney(playerid, -ABuyableVehicles[i][Price]);
  2015.                     // Let the player know he bought a vehicle
  2016.                     format(Msg, 128, "{00FF00}You have bought a {FFFF00}%s{00FF00} for {FFFF00}$%i", ABuyableVehicles[i][CarName], ABuyableVehicles[i][Price]);
  2017.                     SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  2018.                     // Let the player know he can go outside and use /getcar and /park to park his vehicle
  2019.                     SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Now get outside and use \"{FFFF00}/getcar{00FF00}\" to spawn it, then use \"{FFFF00}/park{00FF00}\" to park it near your house");
  2020.  
  2021.                     // Save the house-file
  2022.                     HouseFile_Save(HouseID);
  2023.                 }
  2024.                 else // The player has not enough money to buy this vehicle
  2025.                     SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You can't afford to buy this vehicle");
  2026.  
  2027.                 // Stop looking for the vehicle, as it's found and given to the player already
  2028.                 return 1;
  2029.             }
  2030.             else // The player chose another vehicle from the same class, keep looking for another one
  2031.                 Counter++;
  2032.         }
  2033.     }
  2034.  
  2035.     return 1;
  2036. }
  2037.  
  2038. // Buy insurance for the house's vehicles
  2039. Dialog_BuyInsurance(playerid, response)
  2040. {
  2041.     // Just close the dialog if the player clicked "No"
  2042.     if(!response) return 1;
  2043.  
  2044.     // Setup local variables
  2045.     new Msg[128];
  2046.  
  2047.     // Get the HouseID where the player is right now
  2048.     new HouseID = APlayerData[playerid][CurrentHouse];
  2049.  
  2050.     // Buy an insurance for this house's vehicles (insurance costs 10% of the house's baseprice)
  2051.     AHouseData[HouseID][Insurance] = true;
  2052.     INT_GivePlayerMoney(playerid, -(AHouseData[HouseID][HousePrice] / 10));
  2053.  
  2054.     // Let the player know he has bought a vehicle-insurance for this house
  2055.     format(Msg, 128, "{00FF00}You've bought a vehicle-insurance for all vehicles in this house for {FFFF00}$%i", AHouseData[HouseID][HousePrice] / 10);
  2056.     SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  2057.  
  2058.     // Save the house-file
  2059.     HouseFile_Save(HouseID);
  2060.  
  2061.     return 1;
  2062. }
  2063.  
  2064. // Sell the house
  2065. Dialog_SellHouse(playerid, response)
  2066. {
  2067.     // Just close the dialog if the player clicked "Cancel"
  2068.     if(!response) return 1;
  2069.  
  2070.     // Get the HouseID where the player is right now
  2071.     new HouseID = APlayerData[playerid][CurrentHouse];
  2072.  
  2073.     // All players must exit the house
  2074.     for (new OtherPlayer; OtherPlayer < MAX_PLAYERS; OtherPlayer++)
  2075.     {
  2076.         // If this player is inside the house
  2077.         if (APlayerData[OtherPlayer][CurrentHouse] == HouseID)
  2078.         {
  2079.             // Let the player exit the house
  2080.             House_Exit(OtherPlayer, HouseID);
  2081.         }
  2082.     }
  2083.  
  2084.     // Refund the player 50% of the worth of the house
  2085.     INT_GivePlayerMoney(playerid, House_CalcSellPrice(HouseID));
  2086.     SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}You've sold your house");
  2087.  
  2088.     // Clear the owner of the house
  2089.     AHouseData[HouseID][Owned] = false;
  2090.     AHouseData[HouseID][Owner] = 0;
  2091.     // Clear the house-name and house-level
  2092.     AHouseData[HouseID][HouseName] = 0;
  2093.     if (AHouseData[HouseID][StaticHouse] == false)
  2094.     {
  2095.         AHouseData[HouseID][HouseLevel] = 1;
  2096.         AHouseData[HouseID][CarSlots] = 1;
  2097.     }
  2098.     AHouseData[HouseID][Insurance] = false;
  2099.     AHouseData[HouseID][HouseOpened] = false;
  2100.  
  2101.     // Clear the house-id from the player
  2102.     for (new HouseSlot; HouseSlot < MAX_HOUSESPERPLAYER; HouseSlot++)
  2103.     {
  2104.         // If the house-slot if found where the house was added to the player
  2105.         if (APlayerData[playerid][Houses][HouseSlot] == HouseID)
  2106.         {
  2107.             // Clear the house-id
  2108.             APlayerData[playerid][Houses][HouseSlot] = 0;
  2109.             // Stop searching
  2110.             break;
  2111.         }
  2112.     }
  2113.  
  2114.     // Update the 3DText near the house's entrance to show other players that it's for sale again
  2115.     House_UpdateEntrance(HouseID);
  2116.  
  2117.     // Save the sold house, otherwise the old ownership-data is still there
  2118.     HouseFile_Save(HouseID);
  2119.  
  2120.     return 1;
  2121. }
  2122.  
  2123. // Sell the selected car
  2124. Dialog_SellCar(playerid, response, listitem)
  2125. {
  2126.     // Just close the dialog if the player clicked "Cancel"
  2127.     if(!response) return 1;
  2128.  
  2129.     // Setup local variables
  2130.     new HouseID = APlayerData[playerid][CurrentHouse];
  2131.     new vid = AHouseData[HouseID][VehicleIDs][listitem];
  2132.     new CarSlot = listitem;
  2133.  
  2134.     // Check if there is a vehicle stored in this carslot
  2135.     if (vid != 0)
  2136.     {
  2137.         new BuyableCarIndex = VehicleBuyable_GetIndex(GetVehicleModel(vid));
  2138.         new Msg[128];
  2139.  
  2140.         // Destroy the vehicle and remove it from the house
  2141.         Vehicle_Delete(vid, HouseID, CarSlot);
  2142.  
  2143.         // Refund the player with 50% of the vehicle's buying price
  2144.         INT_GivePlayerMoney(playerid, (ABuyableVehicles[BuyableCarIndex][Price] / 2));
  2145.         // Let the player know about it
  2146.         format(Msg, 128, "{00FF00}You've sold your {FFFF00}%s{00FF00} for {FFFF00}$%i", ABuyableVehicles[BuyableCarIndex][CarName], ABuyableVehicles[BuyableCarIndex][Price] / 2);
  2147.         SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  2148.  
  2149.         // Save the house-file
  2150.         HouseFile_Save(HouseID);
  2151.     }
  2152.     else
  2153.         SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}No vehicle exists in this vehicle-slot");
  2154.  
  2155.     return 1;
  2156. }
  2157.  
  2158. // This dialog processes the selected house from which to get a vehicle using /getcar
  2159. Dialog_GetCarSelectHouse(playerid, response, listitem)
  2160. {
  2161.     // Just close the dialog if the player clicked "Cancel"
  2162.     if(!response) return 1;
  2163.  
  2164.     // Get the houseid based on the chosen listitem
  2165.     new HouseID = APlayerData[playerid][Houses][listitem];
  2166.  
  2167.     // Check if it was a valid house
  2168.     if (HouseID != 0)
  2169.     {
  2170.         // Setup local variables
  2171.         new BuyableCarIndex, VehicleList[500], bool:HouseHasCars = false, CarSlot;
  2172.  
  2173.         // Store the HouseID, otherwise the next dialog won't be able to get a car from the chosen house
  2174.         APlayerData[playerid][DialogGetCarHouseID] = HouseID;
  2175.  
  2176.         // Check if the house has any cars assigned to it
  2177.         for (CarSlot = 0; CarSlot < AHouseData[HouseID][CarSlots]; CarSlot++)
  2178.             if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
  2179.                 HouseHasCars = true;
  2180.  
  2181.         // Check if the house has any cars assigned to it
  2182.         if (HouseHasCars == true)
  2183.         {
  2184.             // Add all vehicles to the list
  2185.             for (CarSlot = 0; CarSlot < AHouseData[HouseID][CarSlots]; CarSlot++)
  2186.             {
  2187.                 // Check if the carslot has a vehicle in it
  2188.                 if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
  2189.                 {
  2190.                     // Get the index where the first vehicle is found in the ABuyableVehicles array
  2191.                     BuyableCarIndex = VehicleBuyable_GetIndex(GetVehicleModel(AHouseData[HouseID][VehicleIDs][CarSlot]));
  2192.                     // Add the name of the vehicle to the list
  2193.                     format(VehicleList, 500, "%s{00FF00}%s\n", VehicleList, ABuyableVehicles[BuyableCarIndex][CarName]);
  2194.                 }
  2195.                 else
  2196.                     format(VehicleList, 500, "%s{FFFFFF}Empty car-slot{FFFFFF}\n", VehicleList);
  2197.             }
  2198.  
  2199.             // Ask which vehicle the player wants to teleport to his location
  2200.             ShowPlayerDialog(playerid, DialogGetCarSelectCar, DIALOG_STYLE_LIST, "Select vehicle to port to your location:", VehicleList, "Select", "Cancel");
  2201.         }
  2202.         else
  2203.             SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}This house has no vehicles assigned to it");
  2204.     }
  2205.     else
  2206.         SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You don't have a house in this house-slot");
  2207.  
  2208.     return 1;
  2209. }
  2210.  
  2211. // This dialog processes the chosen car and spawns it at the player's location
  2212. Dialog_GetCarSelectCar(playerid, response, listitem)
  2213. {
  2214.     // Just close the dialog if the player clicked "Cancel"
  2215.     if(!response) return 1;
  2216.  
  2217.     // Get the HouseID from which to get the car
  2218.     new HouseID = APlayerData[playerid][DialogGetCarHouseID];
  2219.  
  2220.     // Get the vehicleid from the chosen listitem
  2221.     new vid = AHouseData[HouseID][VehicleIDs][listitem];
  2222.  
  2223.     // Check if it was a valid vehicleid
  2224.     if (vid != 0)
  2225.     {
  2226.         // Setup local variables
  2227.         new Float:x, Float:y, Float:z, Float:Angle;
  2228.         // Get the player's position
  2229.         GetPlayerPos(playerid, x, y, z);
  2230.         GetPlayerFacingAngle(playerid, Angle);
  2231.         // Port the vehicle to the player
  2232.         SetVehiclePos(vid, x, y, z);
  2233.         // Put the player inside the vehicle and rotate the vehicle to face where the player was facing
  2234.         PutPlayerInVehicle(playerid, vid, 0);
  2235.         SetVehicleZAngle(vid, Angle);
  2236.         // Turn on the engine and lights
  2237.         new engine,lights,alarm,doors,bonnet,boot,objective;
  2238.         GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
  2239.         SetVehicleParamsEx(vid, 1, 1, alarm, doors, bonnet, boot, objective);
  2240.         // Let the player know he should park the vehicle
  2241.         SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}You've spawned your vehicle, now use \"{FFFF00}/park{00FF00}\" to park it near your house");
  2242.     }
  2243.     else
  2244.         SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}No vehicle exists in this vehicle-slot");
  2245.  
  2246.     return 1;
  2247. }
  2248.  
  2249.  
  2250.  
  2251. // ******************************************************************************************************************************
  2252. // File functions
  2253. // ******************************************************************************************************************************
  2254.  
  2255. // This function will load the house's datafile (used when the server is started to load all houses)
  2256. // It only reads the data about the house, vehicle-data is skipped
  2257. HouseFile_Load(HouseID)
  2258. {
  2259.     // Setup local variables
  2260.     new file[100], File:HFile, LineFromFile[100], ParameterName[50], ParameterValue[50];
  2261.  
  2262.     // Construct the complete filename for this house-file
  2263.     format(file, sizeof(file), HouseFile, HouseID);
  2264.  
  2265.     // Check if the HouseFile exists
  2266.     if (fexist(file))
  2267.     {
  2268.         // Open the housefile for reading
  2269.         HFile = fopen(file, io_read);
  2270.         // Read the first line of the file
  2271.         fread(HFile, LineFromFile);
  2272.  
  2273.         // Keep reading until the end of the file is found (no more data)
  2274.         // An empty line between data-segments still has the NewLine characters (\r\n) so it's not completely empty
  2275.         // Reading past the last line will read a completely empty line, therefore indicating the end of the file
  2276.         while (strlen(LineFromFile) > 0)
  2277.         {
  2278.             StripNewLine(LineFromFile); // Strip any newline characters from the LineFromFile
  2279.             sscanf(LineFromFile, "s[50]s[50]", ParameterName, ParameterValue); // Extract parametername and parametervalue
  2280.  
  2281.             // Check if there is anything in the LineFromFile (skipping empty lines)
  2282.             if (strlen(LineFromFile) > 0)
  2283.             {
  2284.                 // Store the proper value in the proper place
  2285.                 if (strcmp(ParameterName, "Owned", false) == 0) // If the parametername is correct ("Owned")
  2286.                 {
  2287.                     if (strcmp(ParameterValue, "Yes", false) == 0) // If the value "Yes" was read
  2288.                         AHouseData[HouseID][Owned] = true; // House is owned
  2289.                     else
  2290.                         AHouseData[HouseID][Owned] = false; // House is not owned
  2291.                 }
  2292.                 if (strcmp(ParameterName, "Owner", false) == 0) // If the parametername is correct ("Owner")
  2293.                     // Store the Owner (Owner will hold "1" if there is no owner (empty string), done by "sscanf" I guess)
  2294.                     // But this doesn't matter, as the owner will never be displayed when the house is not owned by someone
  2295.                     format(AHouseData[HouseID][Owner], 24, ParameterValue);
  2296.  
  2297.                 if (strcmp(ParameterName, "HouseName", false) == 0) // If the parametername is correct ("HouseName")
  2298.                     format(AHouseData[HouseID][HouseName], 24, ParameterValue); // Store the HouseName
  2299.                 if (strcmp(ParameterName, "HouseX", false) == 0) // If the parametername is correct ("HouseX")
  2300.                     AHouseData[HouseID][HouseX] = floatstr(ParameterValue); // Store the HouseX
  2301.                 if (strcmp(ParameterName, "HouseY", false) == 0) // If the parametername is correct ("HouseY")
  2302.                     AHouseData[HouseID][HouseY] = floatstr(ParameterValue); // Store the HouseY
  2303.                 if (strcmp(ParameterName, "HouseZ", false) == 0) // If the parametername is correct ("HouseZ")
  2304.                     AHouseData[HouseID][HouseZ] = floatstr(ParameterValue); // Store the HouseZ
  2305.                 if (strcmp(ParameterName, "HouseLevel", false) == 0) // If the parametername is correct ("HouseLevel")
  2306.                     AHouseData[HouseID][HouseLevel] = strval(ParameterValue); // Store the HouseLevel
  2307.                 if (strcmp(ParameterName, "HouseMaxLevel", false) == 0) // If the parametername is correct ("HouseMaxLevel")
  2308.                     AHouseData[HouseID][HouseMaxLevel] = strval(ParameterValue); // Store the HouseMaxLevel
  2309.                 if (strcmp(ParameterName, "HousePrice", false) == 0) // If the parametername is correct ("HousePrice")
  2310.                     AHouseData[HouseID][HousePrice] = strval(ParameterValue); // Store the HousePrice
  2311.                 if (strcmp(ParameterName, "HouseOpened", false) == 0) // If the parametername is correct ("HouseOpened")
  2312.                 {
  2313.                     if (strcmp(ParameterValue, "Yes", false) == 0) // If the value "Yes" was read
  2314.                         AHouseData[HouseID][HouseOpened] = true; // House is open to the public (anyone can enter)
  2315.                     else
  2316.                         AHouseData[HouseID][HouseOpened] = false; // House is closed to the public, only house-owner can enter
  2317.                 }
  2318.                 if (strcmp(ParameterName, "Insurance", false) == 0) // If the parametername is correct ("Insurance")
  2319.                 {
  2320.                     if (strcmp(ParameterValue, "Yes", false) == 0) // If the value "Yes" was read
  2321.                         AHouseData[HouseID][Insurance] = true; // House has insurance for it's vehicles
  2322.                     else
  2323.                         AHouseData[HouseID][Insurance] = false; // House doesn't have insurance
  2324.                 }
  2325.  
  2326.                 if (strcmp(ParameterName, "StaticHouse", false) == 0) // If the parametername is correct ("StaticHouse")
  2327.                 {
  2328.                     if (strcmp(ParameterValue, "Yes", false) == 0) // If the value "Yes" was read
  2329.                         AHouseData[HouseID][StaticHouse] = true; // House is static (not upgradable, fixed interior and carslots)
  2330.                     else
  2331.                         AHouseData[HouseID][StaticHouse] = false; // House isn't static (upgradable, interior and carslots based on HouseLevel)
  2332.                 }
  2333.                 if (strcmp(ParameterName, "CarSlots", false) == 0) // If the parametername is correct ("CarSlots")
  2334.                     AHouseData[HouseID][CarSlots] = strval(ParameterValue); // Store the CarSlots
  2335.             }
  2336.  
  2337.             // Read the next line of the file
  2338.             fread(HFile, LineFromFile);
  2339.         }
  2340.  
  2341.         // Close the file
  2342.         fclose(HFile);
  2343.  
  2344.         // Add a pickup and 3DText for this house
  2345.         House_UpdateEntrance(HouseID);
  2346.         // Count the amount of houses that are loaded
  2347.         TotalHouses++;
  2348.  
  2349.         // Return if the file was read correctly
  2350.         return 1;
  2351.     }
  2352.     else
  2353.         return 0; // Return 0 if the file couldn't be read (doesn't exist)
  2354. }
  2355.  
  2356. // This function will load the house's datafile (used when the server is started to load all houses)
  2357. // It only reads the data about the vehicles, house-data is skipped
  2358. HouseFile_LoadCars(HouseID)
  2359. {
  2360.     // Setup local variables
  2361.     new file[100], File:HFile, LineFromFile[100], ParameterName[50], ParameterValue[50];
  2362.     new vid, cModel, cPaint, cComponents[14], Float:cx, Float:cy, Float:cz, Float:crot, Col1, Col2, cFuel;
  2363.  
  2364.     // Construct the complete filename for this house-file
  2365.     format(file, sizeof(file), HouseFile, HouseID);
  2366.  
  2367.     // Check if the HouseFile exists
  2368.     if (fexist(file))
  2369.     {
  2370.         // Open the housefile for reading
  2371.         HFile = fopen(file, io_read);
  2372.         // Read the first line of the file
  2373.         fread(HFile, LineFromFile);
  2374.  
  2375.         // Keep reading until the end of the file is found (no more data)
  2376.         // An empty line between data-segments still has the NewLine characters (\r\n) so it's not completely empty
  2377.         // Reading past the last line will read a completely empty line, therefore indicating the end of the file
  2378.         while (strlen(LineFromFile) > 0)
  2379.         {
  2380.             StripNewLine(LineFromFile); // Strip any newline characters from the LineFromFile
  2381.             sscanf(LineFromFile, "s[50]s[50]", ParameterName, ParameterValue); // Extract parametername and parametervalue
  2382.  
  2383.             // Check if there is anything in the LineFromFile (skipping empty lines)
  2384.             if (strlen(LineFromFile) > 0)
  2385.             {
  2386.                 if (strcmp(ParameterName, "[Vehicle]", false) == 0) // If the parametername is correct ("[Vehicle]")
  2387.                 {
  2388.                     // Clear all data to start a new vehicle
  2389.                     for (new i; i < 14; i++)
  2390.                         cComponents[i] = 0;
  2391.                 }
  2392.                 if (strcmp(ParameterName, "VehicleModel", false) == 0) // If the parametername is correct ("VehicleModel")
  2393.                     cModel = strval(ParameterValue); // Store the VehicleModel
  2394.                 if (strcmp(ParameterName, "VehiclePaintJob", false) == 0) // If the parametername is correct ("VehiclePaintJob")
  2395.                     cPaint = strval(ParameterValue); // Store the VehiclePaintJob
  2396.                 if (strcmp(ParameterName, "VehicleSpoiler", false) == 0) // If the parametername is correct ("VehicleSpoiler")
  2397.                     cComponents[0] = strval(ParameterValue); // Store the VehicleSpoiler
  2398.                 if (strcmp(ParameterName, "VehicleHood", false) == 0) // If the parametername is correct ("VehicleHood")
  2399.                     cComponents[1] = strval(ParameterValue); // Store the VehicleHood
  2400.                 if (strcmp(ParameterName, "VehicleRoof", false) == 0) // If the parametername is correct ("VehicleRoof")
  2401.                     cComponents[2] = strval(ParameterValue); // Store the VehicleRoof
  2402.                 if (strcmp(ParameterName, "VehicleSideSkirt", false) == 0) // If the parametername is correct ("VehicleSideSkirt")
  2403.                     cComponents[3] = strval(ParameterValue); // Store the VehicleSideSkirt
  2404.                 if (strcmp(ParameterName, "VehicleLamps", false) == 0) // If the parametername is correct ("VehicleLamps")
  2405.                     cComponents[4] = strval(ParameterValue); // Store the VehicleLamps
  2406.                 if (strcmp(ParameterName, "VehicleNitro", false) == 0) // If the parametername is correct ("VehicleNitro")
  2407.                     cComponents[5] = strval(ParameterValue); // Store the VehicleNitro
  2408.                 if (strcmp(ParameterName, "VehicleExhaust", false) == 0) // If the parametername is correct ("VehicleExhaust")
  2409.                     cComponents[6] = strval(ParameterValue); // Store the VehicleExhaust
  2410.                 if (strcmp(ParameterName, "VehicleWheels", false) == 0) // If the parametername is correct ("VehicleWheels")
  2411.                     cComponents[7] = strval(ParameterValue); // Store the VehicleWheels
  2412.                 if (strcmp(ParameterName, "VehicleStereo", false) == 0) // If the parametername is correct ("VehicleStereo")
  2413.                     cComponents[8] = strval(ParameterValue); // Store the VehicleStereo
  2414.                 if (strcmp(ParameterName, "VehicleHydraulics", false) == 0) // If the parametername is correct ("VehicleHydraulics")
  2415.                     cComponents[9] = strval(ParameterValue); // Store the VehicleHydraulics
  2416.                 if (strcmp(ParameterName, "VehicleFrontBumper", false) == 0) // If the parametername is correct ("VehicleFrontBumper")
  2417.                     cComponents[10] = strval(ParameterValue); // Store the VehicleFrontBumper
  2418.                 if (strcmp(ParameterName, "VehicleRearBumper", false) == 0) // If the parametername is correct ("VehicleRearBumper")
  2419.                     cComponents[11] = strval(ParameterValue); // Store the VehicleRearBumper
  2420.                 if (strcmp(ParameterName, "VehicleVentRight", false) == 0) // If the parametername is correct ("VehicleVentRight")
  2421.                     cComponents[12] = strval(ParameterValue); // Store the VehicleVentRight
  2422.                 if (strcmp(ParameterName, "VehicleVentLeft", false) == 0) // If the parametername is correct ("VehicleVentLeft")
  2423.                     cComponents[13] = strval(ParameterValue); // Store the VehicleVentLeft
  2424.  
  2425.                 if (strcmp(ParameterName, "Color1", false) == 0) // If the parametername is correct ("Color1")
  2426.                     Col1 = strval(ParameterValue); // Store the Color1
  2427.                 if (strcmp(ParameterName, "Color2", false) == 0) // If the parametername is correct ("Color2")
  2428.                     Col2 = strval(ParameterValue); // Store the Color2
  2429.  
  2430.                 if (strcmp(ParameterName, "VehicleX", false) == 0) // If the parametername is correct ("VehicleX")
  2431.                     cx = floatstr(ParameterValue); // Store the VehicleX
  2432.                 if (strcmp(ParameterName, "VehicleY", false) == 0) // If the parametername is correct ("VehicleY")
  2433.                     cy = floatstr(ParameterValue); // Store the VehicleY
  2434.                 if (strcmp(ParameterName, "VehicleZ", false) == 0) // If the parametername is correct ("VehicleZ")
  2435.                     cz = floatstr(ParameterValue); // Store the VehicleZ
  2436.                 if (strcmp(ParameterName, "VehicleAngle", false) == 0) // If the parametername is correct ("VehicleAngle")
  2437.                     crot = floatstr(ParameterValue); // Store the VehicleAngle
  2438.  
  2439.                 if (strcmp(ParameterName, "Fuel", false) == 0) // If the parametername is correct ("Fuel")
  2440.                     cFuel = strval(ParameterValue); // Store the Fuel
  2441.  
  2442.                 if (strcmp(ParameterName, "[/Vehicle]", false) == 0) // If the parametername is correct ("[/Vehicle]")
  2443.                 {
  2444.                     // Set both colors to 1 if they are 0 AND if there is a paintjob applied
  2445.                     if ((Col1 == 0) && (cPaint != 0))
  2446.                         Col1 = 1;
  2447.                     if ((Col2 == 0) && (cPaint != 0))
  2448.                         Col2 = 1;
  2449.  
  2450.                     // The "[/Vehicle]" is found, this means that all data about this vehicle is now stored in the variables
  2451.                     // Now add the vehicle to the house and set it's data
  2452.                     vid = House_AddVehicle(HouseID, cModel, cPaint, cComponents, cx, cy, cz, crot, Col1, Col2);
  2453.  
  2454.                     // Also set the vehicle's fuel
  2455.                     INT_SetVehicleFuel(vid, cFuel);
  2456.                 }
  2457.             }
  2458.  
  2459.             // Read the next line of the file
  2460.             fread(HFile, LineFromFile);
  2461.         }
  2462.  
  2463.         // Close the file
  2464.         fclose(HFile);
  2465.  
  2466.         // Return if the file was read correctly
  2467.         return 1;
  2468.     }
  2469.     else
  2470.         return 0; // Return 0 if the file couldn't be read (doesn't exist)
  2471. }
  2472.  
  2473. // This function will save the given house
  2474. HouseFile_Save(HouseID)
  2475. {
  2476.     new file[100], File:HFile, LineForFile[100], vid;
  2477.  
  2478.     // Construct the complete filename for this house
  2479.     format(file, sizeof(file), HouseFile, HouseID);
  2480.  
  2481.     // Open the housefile for writing
  2482.     HFile = fopen(file, io_write);
  2483.  
  2484.     if (AHouseData[HouseID][Owned] == true) // Check if the house is owned
  2485.         format(LineForFile, 100, "Owned Yes\r\n"); // Construct the line: "Owned Yes"
  2486.     else
  2487.         format(LineForFile, 100, "Owned No\r\n"); // Construct the line: "Owned No"
  2488.     fwrite(HFile, LineForFile); // And save it to the file
  2489.  
  2490.     format(LineForFile, 100, "Owner %s\r\n", AHouseData[HouseID][Owner]); // Construct the line: "Owner <Owner>"
  2491.     fwrite(HFile, LineForFile); // And save it to the file
  2492.  
  2493.     format(LineForFile, 100, "HouseName %s\r\n", AHouseData[HouseID][HouseName]); // Construct the line: "HouseName <HouseName>"
  2494.     fwrite(HFile, LineForFile); // And save it to the file
  2495.     format(LineForFile, 100, "HouseX %f\r\n", AHouseData[HouseID][HouseX]); // Construct the line: "HouseX <HouseX>"
  2496.     fwrite(HFile, LineForFile); // And save it to the file
  2497.     format(LineForFile, 100, "HouseY %f\r\n", AHouseData[HouseID][HouseY]); // Construct the line: "HouseY <HouseY>"
  2498.     fwrite(HFile, LineForFile); // And save it to the file
  2499.     format(LineForFile, 100, "HouseZ %f\r\n", AHouseData[HouseID][HouseZ]); // Construct the line: "HouseZ <HouseZ>"
  2500.     fwrite(HFile, LineForFile); // And save it to the file
  2501.     format(LineForFile, 100, "HouseLevel %i\r\n", AHouseData[HouseID][HouseLevel]); // Construct the line: "HouseLevel <HouseLevel>"
  2502.     fwrite(HFile, LineForFile); // And save it to the file
  2503.     format(LineForFile, 100, "HouseMaxLevel %i\r\n", AHouseData[HouseID][HouseMaxLevel]); // Construct the line: "HouseMaxLevel <HouseMaxLevel>"
  2504.     fwrite(HFile, LineForFile); // And save it to the file
  2505.     format(LineForFile, 100, "HousePrice %i\r\n", AHouseData[HouseID][HousePrice]); // Construct the line: "HousePrice <HousePrice>"
  2506.     fwrite(HFile, LineForFile); // And save it to the file
  2507.  
  2508.     if (AHouseData[HouseID][HouseOpened] == true) // Check if the house is open to the public
  2509.         format(LineForFile, 100, "HouseOpened Yes\r\n"); // Construct the line: "HouseOpened Yes"
  2510.     else
  2511.         format(LineForFile, 100, "HouseOpened No\r\n"); // Construct the line: "HouseOpened No"
  2512.     fwrite(HFile, LineForFile); // And save it to the file
  2513.  
  2514.     if (AHouseData[HouseID][Insurance] == true) // Check if the house has insurance for it's vehicles
  2515.         format(LineForFile, 100, "Insurance Yes\r\n"); // Construct the line: "Insurance Yes"
  2516.     else
  2517.         format(LineForFile, 100, "Insurance No\r\n"); // Construct the line: "Insurance No"
  2518.     fwrite(HFile, LineForFile); // And save it to the file
  2519.  
  2520.     if (AHouseData[HouseID][StaticHouse] == true) // Check if the house is a static house
  2521.         format(LineForFile, 100, "StaticHouse Yes\r\n"); // Construct the line: "StaticHouse Yes"
  2522.     else
  2523.         format(LineForFile, 100, "StaticHouse No\r\n"); // Construct the line: "StaticHouse No"
  2524.     fwrite(HFile, LineForFile); // And save it to the file
  2525.  
  2526.     format(LineForFile, 100, "CarSlots %i\r\n", AHouseData[HouseID][CarSlots]); // Construct the line: "CarSlots <CarSlots>"
  2527.     fwrite(HFile, LineForFile); // And save it to the file
  2528.     fwrite(HFile, "\r\n"); // Add an empty line, just for readability
  2529.  
  2530.  
  2531.     // Save the vehicle-data for every vehicle added to the house
  2532.     for (new CarSlot; CarSlot < AHouseData[HouseID][CarSlots]; CarSlot++)
  2533.     {
  2534.         // If a valid vehicle-id has been found
  2535.         if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
  2536.         {
  2537.             // Get the vehicle id
  2538.             vid = AHouseData[HouseID][VehicleIDs][CarSlot];
  2539.  
  2540.             format(LineForFile, 100, "[Vehicle]\r\n"); // Construct the line: "[Vehicle]"
  2541.             fwrite(HFile, LineForFile); // And save it to the file
  2542.  
  2543.             format(LineForFile, 100, "VehicleModel %i\r\n", AVehicleData[vid][Model]); // Construct the line: "VehicleModel <VehicleModel>"
  2544.             fwrite(HFile, LineForFile); // And save it to the file
  2545.             format(LineForFile, 100, "VehiclePaintJob %i\r\n", AVehicleData[vid][PaintJob]); // Construct the line: "VehiclePaintJob <VehiclePaintJob>"
  2546.             fwrite(HFile, LineForFile); // And save it to the file
  2547.  
  2548.             format(LineForFile, 100, "VehicleSpoiler %i\r\n", AVehicleData[vid][Components][0]); // Construct the line: "VehicleSpoiler <VehicleSpoiler>"
  2549.             fwrite(HFile, LineForFile); // And save it to the file
  2550.             format(LineForFile, 100, "VehicleHood %i\r\n", AVehicleData[vid][Components][1]); // Construct the line: "VehicleHood <VehicleHood>"
  2551.             fwrite(HFile, LineForFile); // And save it to the file
  2552.             format(LineForFile, 100, "VehicleRoof %i\r\n", AVehicleData[vid][Components][2]); // Construct the line: "VehicleRoof <VehicleRoof>"
  2553.             fwrite(HFile, LineForFile); // And save it to the file
  2554.             format(LineForFile, 100, "VehicleSideSkirt %i\r\n", AVehicleData[vid][Components][3]); // Construct the line: "VehicleSideSkirt <VehicleSideSkirt>"
  2555.             fwrite(HFile, LineForFile); // And save it to the file
  2556.             format(LineForFile, 100, "VehicleLamps %i\r\n", AVehicleData[vid][Components][4]); // Construct the line: "VehicleLamps <VehicleLamps>"
  2557.             fwrite(HFile, LineForFile); // And save it to the file
  2558.             format(LineForFile, 100, "VehicleNitro %i\r\n", AVehicleData[vid][Components][5]); // Construct the line: "VehicleNitro <VehicleNitro>"
  2559.             fwrite(HFile, LineForFile); // And save it to the file
  2560.             format(LineForFile, 100, "VehicleExhaust %i\r\n", AVehicleData[vid][Components][6]); // Construct the line: "VehicleSpoiler <VehicleSpoiler>"
  2561.             fwrite(HFile, LineForFile); // And save it to the file
  2562.             format(LineForFile, 100, "VehicleWheels %i\r\n", AVehicleData[vid][Components][7]); // Construct the line: "VehicleWheels <VehicleWheels>"
  2563.             fwrite(HFile, LineForFile); // And save it to the file
  2564.             format(LineForFile, 100, "VehicleStereo %i\r\n", AVehicleData[vid][Components][8]); // Construct the line: "VehicleStereo <VehicleStereo>"
  2565.             fwrite(HFile, LineForFile); // And save it to the file
  2566.             format(LineForFile, 100, "VehicleHydraulics %i\r\n", AVehicleData[vid][Components][9]); // Construct the line: "VehicleHydraulics <VehicleHydraulics>"
  2567.             fwrite(HFile, LineForFile); // And save it to the file
  2568.             format(LineForFile, 100, "VehicleFrontBumper %i\r\n", AVehicleData[vid][Components][10]); // Construct the line: "VehicleFrontBumper <VehicleFrontBumper>"
  2569.             fwrite(HFile, LineForFile); // And save it to the file
  2570.             format(LineForFile, 100, "VehicleRearBumper %i\r\n", AVehicleData[vid][Components][11]); // Construct the line: "VehicleRearBumper <VehicleRearBumper>"
  2571.             fwrite(HFile, LineForFile); // And save it to the file
  2572.             format(LineForFile, 100, "VehicleVentRight %i\r\n", AVehicleData[vid][Components][12]); // Construct the line: "VehicleVentRight <VehicleVentRight>"
  2573.             fwrite(HFile, LineForFile); // And save it to the file
  2574.             format(LineForFile, 100, "VehicleVentLeft %i\r\n", AVehicleData[vid][Components][13]); // Construct the line: "VehicleVentLeft <VehicleVentLeft>"
  2575.             fwrite(HFile, LineForFile); // And save it to the file
  2576.  
  2577.             format(LineForFile, 100, "Color1 %i\r\n", AVehicleData[vid][Color1]); // Construct the line: "Color1 <Color1>"
  2578.             fwrite(HFile, LineForFile); // And save it to the file
  2579.             format(LineForFile, 100, "Color2 %i\r\n", AVehicleData[vid][Color2]); // Construct the line: "Color2 <Color2>"
  2580.             fwrite(HFile, LineForFile); // And save it to the file
  2581.  
  2582.             format(LineForFile, 100, "VehicleX %f\r\n", AVehicleData[vid][SpawnX]); // Construct the line: "VehicleVentLeft <VehicleVentLeft>"
  2583.             fwrite(HFile, LineForFile); // And save it to the file
  2584.             format(LineForFile, 100, "VehicleY %f\r\n", AVehicleData[vid][SpawnY]); // Construct the line: "VehicleVentLeft <VehicleVentLeft>"
  2585.             fwrite(HFile, LineForFile); // And save it to the file
  2586.             format(LineForFile, 100, "VehicleZ %f\r\n", AVehicleData[vid][SpawnZ]); // Construct the line: "VehicleVentLeft <VehicleVentLeft>"
  2587.             fwrite(HFile, LineForFile); // And save it to the file
  2588.             format(LineForFile, 100, "VehicleAngle %f\r\n", AVehicleData[vid][SpawnRot]); // Construct the line: "VehicleVentLeft <VehicleVentLeft>"
  2589.             fwrite(HFile, LineForFile); // And save it to the file
  2590.  
  2591.             format(LineForFile, 100, "Fuel %i\r\n", INT_GetVehicleFuel(vid)); // Construct the line: "Fuel <Fuel>"
  2592.             fwrite(HFile, LineForFile); // And save it to the file
  2593.  
  2594.             format(LineForFile, 100, "[/Vehicle]\r\n"); // Construct the line: "[/Vehicle]"
  2595.             fwrite(HFile, LineForFile); // And save it to the file
  2596.             fwrite(HFile, "\r\n"); // Add an empty line, just for readability
  2597.         }
  2598.     }
  2599.  
  2600.     fclose(HFile); // Close the file
  2601.  
  2602.     return 1;
  2603. }
  2604.  
  2605.  
  2606.  
  2607. // ******************************************************************************************************************************
  2608. // Housing functions
  2609. // ******************************************************************************************************************************
  2610.  
  2611. // This function updates (destroys and re-creates) the pickup, map-icon and 3DText label near the house's entrance
  2612. House_UpdateEntrance(HouseID)
  2613. {
  2614.     // Setup local variables
  2615.     new Msg[250], Float:x, Float:y, Float:z;
  2616.  
  2617.     // Get the coordinates of the house's pickup (usually near the door)
  2618.     x = AHouseData[HouseID][HouseX];
  2619.     y = AHouseData[HouseID][HouseY];
  2620.     z = AHouseData[HouseID][HouseZ];
  2621.  
  2622.     // Destroy the pickup, map-icon and 3DText near the house's entrance (if they exist)
  2623.     if (IsValidDynamicPickup(AHouseData[HouseID][PickupID]))
  2624.         DestroyDynamicPickup(AHouseData[HouseID][PickupID]);
  2625.     if (IsValidDynamicMapIcon(AHouseData[HouseID][MapIconID]))
  2626.         DestroyDynamicMapIcon(AHouseData[HouseID][MapIconID]);
  2627.     if (IsValidDynamic3DTextLabel(AHouseData[HouseID][DoorText]))
  2628.         DestroyDynamic3DTextLabel(AHouseData[HouseID][DoorText]);
  2629.  
  2630.     // Add a new pickup at the house's location (usually near the door), green = free, blue = owned
  2631.     if (AHouseData[HouseID][Owned] == true)
  2632.     {
  2633.         // Create a blue house-pickup (house is owned)
  2634.         AHouseData[HouseID][PickupID] = CreateDynamicPickup(1272, 1, x, y, z, 0);
  2635.         // Create the 3DText that appears above the house-pickup (displays the housename and the name of the owner)
  2636.         if (AHouseData[HouseID][StaticHouse] == true)
  2637.             format(Msg, 250, "{00BC00}Name: {F6F6F6}%s\n{00BC00}Owner: {F6F6F6}%s\n{00BC00}Interior: {F6F6F6}%i\n{F6F6F6}/enter", AHouseData[HouseID][HouseName], AHouseData[HouseID][Owner], AHouseData[HouseID][HouseLevel]);
  2638.         else
  2639.             format(Msg, 250, "%s\nOwned by: %s\nHouse-level: %i\n/enter", AHouseData[HouseID][HouseName], AHouseData[HouseID][Owner], AHouseData[HouseID][HouseLevel]);
  2640.         AHouseData[HouseID][DoorText] = CreateDynamic3DTextLabel(Msg, 0x008080FF, x, y, z + 0.9, 15);
  2641.         if (ShowBoughtHouses == true)
  2642.             AHouseData[HouseID][MapIconID] = CreateDynamicMapIcon(x, y, z, 32, 0, 0, 0, -1, 150.0);
  2643.     }
  2644.     else
  2645.     {
  2646.         // Create a green house-pickup (house is free)
  2647.         AHouseData[HouseID][PickupID] = CreateDynamicPickup(1273, 1, x, y, z, 0);
  2648.         // Create the 3DText that appears above the house-pickup (displays the price of the house)
  2649.         if (AHouseData[HouseID][StaticHouse] == true)
  2650.             format(Msg, 128, "{00BC00}House Available: {F6F6F6}$%i\n{00BC00} Interior: {F6F6F6}%i\n{F6F6F6}/buyhouse", AHouseData[HouseID][HousePrice], AHouseData[HouseID][HouseLevel]);
  2651.         else
  2652.             format(Msg, 128, "House available for\n$%i\nMax-level: %i\n/buyhouse", AHouseData[HouseID][HousePrice], AHouseData[HouseID][HouseMaxLevel]);
  2653.         AHouseData[HouseID][DoorText] = CreateDynamic3DTextLabel(Msg, 0x008080FF, x, y, z + 1.0, 50.0);
  2654.         // Add a streamed icon to the map (green house), type = 31, color = 0, world = 0, interior = 0, playerid = -1, drawdist = 150.0
  2655.         AHouseData[HouseID][MapIconID] = CreateDynamicMapIcon(x, y, z, 31, 0, 0, 0, -1, 150.0);
  2656.     }
  2657. }
  2658.  
  2659. // This function is used to spawn back at the entrance of your house
  2660. House_Exit(playerid, HouseID)
  2661. {
  2662.     // Set the player in the normal world again
  2663.     SetPlayerVirtualWorld(playerid, 0);
  2664.     SetPlayerInterior(playerid, 0);
  2665.     // Set the position of the player at the entrance of his house
  2666.     SetPlayerPos(playerid, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]);
  2667.     // Also clear the tracking-variable to track in which house the player is
  2668.     APlayerData[playerid][CurrentHouse] = 0;
  2669.  
  2670.     // Check if there is a timer-value set for exiting the house (this timer freezes the player while the environment is being loaded)
  2671.     if (ExitHouseTimer > 0)
  2672.     {
  2673.         // Don't allow the player to fall
  2674.         TogglePlayerControllable(playerid, 0);
  2675.         // Let the player know he's frozen for 5 seconds
  2676.         // Start a timer that will allow the player to fall again when the environment has loaded
  2677.         SetTimerEx("House_ExitTimer", ExitHouseTimer, false, "ii", playerid, HouseID);
  2678.     }
  2679.  
  2680.     return 1;
  2681. }
  2682.  
  2683. forward House_ExitTimer(playerid, HouseID);
  2684. public House_ExitTimer(playerid, HouseID)
  2685. {
  2686.     // Allow the player to move again (environment should have been loaded now)
  2687.     TogglePlayerControllable(playerid, 1);
  2688.  
  2689.     // Respawn the player's vehicles near the house (only the vehicles that belong to this house)
  2690.     for (new CarSlot; CarSlot < AHouseData[HouseID][CarSlots]; CarSlot++)
  2691.         if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
  2692.             SetVehicleToRespawn(AHouseData[HouseID][VehicleIDs][CarSlot]);
  2693.  
  2694.     return 1;
  2695. }
  2696.  
  2697. // This function sets ownership to the given player (if he has a free houseslot)
  2698. House_SetOwner(playerid, HouseID)
  2699. {
  2700.     // Setup local variables
  2701.     new FreeHouseSlot, Name[24], Msg[128];
  2702.  
  2703.     // Get the first free house-slot from this player
  2704.     FreeHouseSlot = Player_GetFreeHouseSlot(playerid);
  2705.  
  2706.     // Check if the player has a free house-slot
  2707.     if (FreeHouseSlot != -1)
  2708.     {
  2709.         // Get the player's name
  2710.         GetPlayerName(playerid, Name, sizeof(Name));
  2711.  
  2712.         // Store the house-id for the player
  2713.         APlayerData[playerid][Houses][FreeHouseSlot] = HouseID;
  2714.         // Let the player pay for the house
  2715.         INT_GivePlayerMoney(playerid, -AHouseData[HouseID][HousePrice]);
  2716.  
  2717.         // Set the house as owned
  2718.         AHouseData[HouseID][Owned] = true;
  2719.         // Store the owner-name for the house
  2720.         format(AHouseData[HouseID][Owner], 24, Name);
  2721.         // Set the level and amount of carslots to 1 for a normal house (keep existing data for a static house)
  2722.         if (AHouseData[HouseID][StaticHouse] == false)
  2723.         {
  2724.             AHouseData[HouseID][HouseLevel] = 1;
  2725.             AHouseData[HouseID][CarSlots] = 1;
  2726.         }
  2727.         // Set the default house-name ("<playername>'s house")
  2728.         format(AHouseData[HouseID][HouseName], 100, "%s's house", Name);
  2729.  
  2730.         // Also, update the pickup and map-icon for this house
  2731.         House_UpdateEntrance(HouseID);
  2732.  
  2733.         // Save the house-file
  2734.         HouseFile_Save(HouseID);
  2735.  
  2736.         // Let the player know he bought the house
  2737.         format(Msg, 128, "{00FF00}You've bought the house for {FFFF00}$%i", AHouseData[HouseID][HousePrice]);
  2738.         SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  2739.     }
  2740.     else
  2741.         SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You already own the maximum amount of allowed houses per player");
  2742.  
  2743.     return 1;
  2744. }
  2745.  
  2746. // This function adds a vehicle to the house (if possible)
  2747. House_AddVehicle(HouseID, cModel, cPaint, cComponents[], Float:cx, Float:cy, Float:cz, Float:crot, Col1, Col2)
  2748. {
  2749.     // Setup local variables
  2750.     new vid, CarSlot;
  2751.  
  2752.     // Get a free carslot from the house
  2753.     CarSlot = House_GetFreeCarSlot(HouseID);
  2754.  
  2755.     // Check if there is a free carslot
  2756.     if (CarSlot != -1)
  2757.     {
  2758.         // Create a new vehicle and get the vehicle-id
  2759.         vid = CreateVehicle(cModel, cx, cy, cz, crot, Col1, Col2, 600);
  2760.         // Store the vehicle-id in the house's free carslot
  2761.         AHouseData[HouseID][VehicleIDs][CarSlot] = vid;
  2762.  
  2763.         // Save the model of the vehicle
  2764.         AVehicleData[vid][Model] = cModel;
  2765.         // Save the paintjob of the vehicle and apply it
  2766.         AVehicleData[vid][PaintJob] = cPaint;
  2767.         if (cPaint != 0)
  2768.             ChangeVehiclePaintjob(vid, cPaint - 1);
  2769.  
  2770.         // Also update the car-color
  2771.         ChangeVehicleColor(vid, Col1, Col2);
  2772.         // Save the colors of the vehicle
  2773.         AVehicleData[vid][Color1] = Col1;
  2774.         AVehicleData[vid][Color2] = Col2;
  2775.  
  2776.         // Save the components of the vehicle and apply them
  2777.         for (new i; i < 14; i++)
  2778.         {
  2779.             AVehicleData[vid][Components][i] = cComponents[i];
  2780.             // Check if the componentslot has a valid component-id
  2781.             if (AVehicleData[vid][Components][i] != 0)
  2782.                 AddVehicleComponent(vid, AVehicleData[vid][Components][i]); // Add the component to the vehicle
  2783.         }
  2784.  
  2785.         // Save the spawn-data of the vehicle
  2786.         AVehicleData[vid][SpawnX] = cx;
  2787.         AVehicleData[vid][SpawnY] = cy;
  2788.         AVehicleData[vid][SpawnZ] = cz;
  2789.         AVehicleData[vid][SpawnRot] = crot;
  2790.         // Also set the owner
  2791.         AVehicleData[vid][Owned] = true;
  2792.         format(AVehicleData[vid][Owner], 24, AHouseData[HouseID][Owner]);
  2793.         // Save the HouseID for the vehicle
  2794.         AVehicleData[vid][BelongsToHouse] = HouseID;
  2795.     }
  2796.     else // No free carslot was found, return 0
  2797.         return 0;
  2798.  
  2799.     // Exit the function and return the vehicle-id
  2800.     return vid;
  2801. }
  2802.  
  2803. // This function is used only when you park a car
  2804. House_ReplaceVehicle(HouseID, CarSlot)
  2805. {
  2806.     // Setup local variables
  2807.     new vid, cModel, cPaint, cComponents[14], Float:cx, Float:cy, Float:cz, Float:crot, Col1, Col2, cFuel;
  2808.  
  2809.     // Get the data from the already existing vehicle that was parked before
  2810.     vid = AHouseData[HouseID][VehicleIDs][CarSlot];
  2811.     cModel = AVehicleData[vid][Model];
  2812.     cPaint = AVehicleData[vid][PaintJob];
  2813.     for (new i; i < 14; i++)
  2814.         cComponents[i] = AVehicleData[vid][Components][i];
  2815.     Col1 = AVehicleData[vid][Color1];
  2816.     Col2 = AVehicleData[vid][Color2];
  2817.     cx = AVehicleData[vid][SpawnX];
  2818.     cy = AVehicleData[vid][SpawnY];
  2819.     cz = AVehicleData[vid][SpawnZ];
  2820.     crot = AVehicleData[vid][SpawnRot];
  2821.     cFuel = INT_GetVehicleFuel(vid);
  2822.  
  2823.     // Delete the vehicle and clear the data
  2824.     Vehicle_Delete(vid, HouseID, CarSlot);
  2825.  
  2826.     // Create a new vehicle in the same carslot
  2827.     vid = House_AddVehicle(HouseID, cModel, cPaint, cComponents, Float:cx, Float:cy, Float:cz, Float:crot, Col1, Col2);
  2828.     // Restore the previous fuel-setting for the new vehicle
  2829.     INT_SetVehicleFuel(vid, cFuel);
  2830.  
  2831.     // Return the new vehicle-id of the replaced vehicle
  2832.     return vid;
  2833. }
  2834.  
  2835. // This function deletes the vehicle and clears all the data
  2836. Vehicle_Delete(vid, HouseID, CarSlot)
  2837. {
  2838.     // Remove the vehicle from the house
  2839.     AHouseData[HouseID][VehicleIDs][CarSlot] = 0;
  2840.  
  2841.     // Delete the vehicle
  2842.     DestroyVehicle(vid);
  2843.     // Clear the data
  2844.     AVehicleData[vid][Owned] = false;
  2845.     AVehicleData[vid][Owner] = 0;
  2846.     AVehicleData[vid][Model] = 0;
  2847.     AVehicleData[vid][PaintJob] = 0;
  2848.     for (new i; i < 14; i++)
  2849.         AVehicleData[vid][Components][i] = 0;
  2850.     AVehicleData[vid][Color1] = 0;
  2851.     AVehicleData[vid][Color2] = 0;
  2852.     AVehicleData[vid][SpawnX] = 0.0;
  2853.     AVehicleData[vid][SpawnY] = 0.0;
  2854.     AVehicleData[vid][SpawnZ] = 0.0;
  2855.     AVehicleData[vid][SpawnRot] = 0.0;
  2856.     AVehicleData[vid][BelongsToHouse] = 0;
  2857.  
  2858.     // After deleting the vehicle, the vehicle's id has become available, so restore the fuel to maximum for this id
  2859.     // Otherwise newly created vehicles that use this id would have an unpredictable fuel-setting
  2860.     INT_SetVehicleFuel(vid, -1);
  2861. }
  2862.  
  2863. // This function is used only when a player logs out (the vehicles are unloaded)
  2864. House_RemoveVehicles(HouseID)
  2865. {
  2866.     // Setup local variables
  2867.     new vid;
  2868.  
  2869.     // Loop through all carslots of this house
  2870.     for (new CarSlot; CarSlot < AHouseData[HouseID][CarSlots]; CarSlot++)
  2871.     {
  2872.         // Get the vehicle-id
  2873.         vid = AHouseData[HouseID][VehicleIDs][CarSlot];
  2874.  
  2875.         // Check if there was a vehicle in this carslot
  2876.         if (vid != 0)
  2877.         {
  2878.             // Delete the vehicle and clear the data
  2879.             Vehicle_Delete(vid, HouseID, CarSlot);
  2880.         }
  2881.     }
  2882. }
  2883.  
  2884. // This function returns the first free house-slot for the given player
  2885. Player_GetFreeHouseSlot(playerid)
  2886. {
  2887.     // Check if the player has room for another house (he hasn't bought the maximum amount of houses per player yet)
  2888.     // and get the slot-id
  2889.     for (new HouseSlot; HouseSlot < MAX_HOUSESPERPLAYER; HouseSlot++) // Loop through all house-slots of the player
  2890.         if (APlayerData[playerid][Houses][HouseSlot] == 0) // Check if this house slot is free
  2891.             return HouseSlot; // Return the free HouseSlot for this player
  2892.  
  2893.     // If there were no free house-slots, return "-1"
  2894.     return -1;
  2895. }
  2896.  
  2897. // This function returns "1" if the given player is the owner of the given house
  2898. House_PlayerIsOwner(playerid, HouseID)
  2899. {
  2900.     // Loop through all houses owner by this player
  2901.     for (new HouseSlot; HouseSlot < MAX_HOUSESPERPLAYER; HouseSlot++)
  2902.     {
  2903.         // Check if the player owns the house in any of his house-slots
  2904.         if (APlayerData[playerid][Houses][HouseSlot] == HouseID)
  2905.             return 1;
  2906.     }
  2907.  
  2908.     // If the player doesn't own the house, return 0
  2909.     return 0;
  2910. }
  2911.  
  2912. // This function returns the first free carslot in the given house (or -1 if no free slot is found)
  2913. House_GetFreeCarSlot(HouseID)
  2914. {
  2915.     // Get the maximum number of carslots for this house and make a loop through all carslots for this house
  2916.     for (new CarSlot; CarSlot < AHouseData[HouseID][CarSlots]; CarSlot++)
  2917.     {
  2918.         // Check if the carslot is empty
  2919.         if (AHouseData[HouseID][VehicleIDs][CarSlot] == 0)
  2920.             return CarSlot; // Return the carslot-id
  2921.     }
  2922.  
  2923.     // If no carslots are free, return -1
  2924.     return -1;
  2925. }
  2926.  
  2927. // This function calculates the sell-price for the given house
  2928. House_CalcSellPrice(HouseID)
  2929. {
  2930.     // Setup local variables
  2931.     new SellPrice, NumUpgrades, UpgradePrice;
  2932.  
  2933.     // Calculate 50% of the original buying price (base-price for selling)
  2934.     SellPrice = AHouseData[HouseID][HousePrice] / 2;
  2935.     // Calculate the number of upgrades applied to the house
  2936.     NumUpgrades = AHouseData[HouseID][HouseLevel] - 1;
  2937.     // Also calculate 50% for each upgrade, based on the percentage for upgrading the house
  2938.     UpgradePrice = ((AHouseData[HouseID][HousePrice] / 100) * HouseUpgradePercent) * NumUpgrades;
  2939.  
  2940.     // Add 50% of the upgrade-price to the sell-price
  2941.     SellPrice = SellPrice + UpgradePrice;
  2942.  
  2943.     // Return the total sell-price to the calling function
  2944.     return SellPrice;
  2945. }
  2946.  
  2947. // This function searches the ABuyableVehicles array to search for the model and returns the index in the array
  2948. VehicleBuyable_GetIndex(vModel)
  2949. {
  2950.     // Loop through all vehicles in the ABuyableVehicles array
  2951.     for (new i; i < sizeof(ABuyableVehicles); i++)
  2952.     {
  2953.         // Check if the model of the current vehicle is the same as the given model
  2954.         if (ABuyableVehicles[i][CarModel] == vModel)
  2955.             return i; // Return the index of the array where the carmodel was found
  2956.     }
  2957.  
  2958.     return -1;
  2959. }
  2960.  
  2961.  
  2962.  
  2963. // ******************************************************************************************************************************
  2964. // Support functions
  2965. // ******************************************************************************************************************************
  2966.  
  2967. // This function is copied from the include-file "dutils.inc"
  2968. stock StripNewLine(string[])
  2969. {
  2970.     new len = strlen(string); // Get the length of the given string
  2971.  
  2972.     if (string[0] == 0) return ; // If the given string is empty, exit the function
  2973.     if ((string[len - 1] == '\n') || (string[len - 1] == '\r')) // If the string ends with \n or \r
  2974.     {
  2975.         string[len - 1] = 0; // Replace the \n or \r with a 0 character
  2976.         if (string[0]==0) return ; // If the string became empty, exit the function
  2977.         if ((string[len - 2] == '\n') || (string[len - 2] == '\r')) // Check again if the string ends with \n or \r
  2978.             string[len - 2] = 0; // Replace the \n or \r again with a 0 character
  2979.     }
  2980. }
  2981.  
  2982.  
  2983.  
  2984. // ******************************************************************************************************************************
  2985. // Special functions that try to access external public functions to retreive or set data from another script
  2986. // ******************************************************************************************************************************
  2987.  
  2988. // This function is used to get the player's money
  2989. INT_GetPlayerMoney(playerid)
  2990. {
  2991.     // Setup local variables
  2992.     new Money;
  2993.  
  2994.     // Try to call the external function to get the player's money (used to get the serversided money for this player)
  2995.     Money = CallRemoteFunction("Admin_GetPlayerMoney", "i", playerid);
  2996.  
  2997.     // The external function returned "0" (as the player doesn't have any money yet), or the function is not used in another script
  2998.     if (Money == 0)
  2999.         return GetPlayerMoney(playerid); // Return the normal money of the player
  3000.     else
  3001.         return Money; // Return the money that was returned by the external function
  3002. }
  3003.  
  3004. // This function is used to set the player's money
  3005. INT_GivePlayerMoney(playerid, Money)
  3006. {
  3007.     // Setup local variables
  3008.     new Success;
  3009.  
  3010.     // Try to call the external function to get the player's money (used to get the serversided money for this player)
  3011.     Success = CallRemoteFunction("Admin_GivePlayerMoney", "ii", playerid, Money);
  3012.  
  3013.     // The external function returned "0" as the function is not used in another script
  3014.     if (Success == 0)
  3015.         GivePlayerMoney(playerid, Money); // Use the normal money (client-sided money)
  3016. }
  3017.  
  3018. // This function checks if the admin-level of a player is sufficient
  3019. INT_CheckPlayerAdminLevel(playerid, AdminLevel)
  3020. {
  3021.     // Setup local variables
  3022.     new Level;
  3023.  
  3024.     // Check if the player is an RCON admin
  3025.     if (IsPlayerAdmin(playerid))
  3026.         return 1; // Return 1 to indicate this player has a sufficient admin-level to use a command
  3027.  
  3028.     // If the player is not an RCON admin, try to get his admin-level from an external script using a remote function
  3029.     Level = CallRemoteFunction("Admin_GetPlayerAdminLevel", "i", playerid);
  3030.     // Check if the player has a sufficient admin-level
  3031.     if (Level >= AdminLevel)
  3032.         return 1; // Return 1 to indicate this player has a sufficient admin-level
  3033.     else
  3034.         return 0; // Return 0 to indicate this player has an insufficient admin-level
  3035. }
  3036.  
  3037. // This function checks if the player has logged in properly by entering his password
  3038. INT_IsPlayerLoggedIn(playerid)
  3039. {
  3040.     // Setup local variables
  3041.     new LoggedIn;
  3042.  
  3043.     // Try to determine if the player logged in properly by entering his password in another script
  3044.     LoggedIn = CallRemoteFunction("Admin_IsPlayerLoggedIn", "i", playerid);
  3045.  
  3046.     // Check if the player has logged in properly
  3047.     switch (LoggedIn)
  3048.     {
  3049.         case 0: return 1; // No admin script present that holds the LoggedIn status of a player, so allow a command to be used
  3050.         case 1: return 1; // The player logged in properly by entering his password, allow commands to be used
  3051.         case -1: return 0; // There is an admin script present, but the player hasn't entered his password yet, so block all commands
  3052.                             // This prevents executing the commands using F6 during login with an admin-account before entering a password
  3053.     }
  3054.  
  3055.     // In any other case, block all commands
  3056.     return 0;
  3057. }
  3058.  
  3059. // This function sets the fuel of the given vehicle to the given value (calls the PPC_Speedometer script)
  3060. INT_SetVehicleFuel(vehicleid, Fuel)
  3061. {
  3062.     // Call the remote function in the PPC_Speedometer script to set the given vehicle's fuel
  3063.     CallRemoteFunction("Speedo_SetVehicleFuel", "ii", vehicleid, Fuel);
  3064. }
  3065.  
  3066. // This function tries to get the vehicle's fuel from the PPC_Speedometer script
  3067. INT_GetVehicleFuel(vehicleid)
  3068. {
  3069.     // Call the remote function in the PPC_Speedometer script to get the vehicle's fuel
  3070.     return CallRemoteFunction("Speedo_GetVehicleFuel", "i", vehicleid);
  3071. }
  3072.  
  3073. // This function tries to cetermine if the player is in jail
  3074. INT_IsPlayerJailed(playerid)
  3075. {
  3076.     // Setup local variables
  3077.     new Jailed;
  3078.  
  3079.     // Try to determine if the player is jailed
  3080.     Jailed = CallRemoteFunction("Admin_IsPlayerJailed", "i", playerid);
  3081.  
  3082.     // Check if the player is jailed
  3083.     switch (Jailed)
  3084.     {
  3085.         case 0: return 0; // No admin script present, so there is no jail either
  3086.         case 1: return 1; // The player is jailed, so return "1"
  3087.         case -1: return 0; // There is an admin script present, but the player isn't jailed
  3088.     }
  3089.  
  3090.     // In any other case, return "0" (player not jailed)
  3091.     return 0;
  3092. }
  3093.  
  3094.  
  3095.  
  3096. // ******************************************************************************************************************************
  3097. // External functions to be used from within other filterscripts or gamemode (these aren't called anywhere inside this script)
  3098. // These functions can be called from other filterscripts or the gamemode to get data from the housing filterscript
  3099. // ******************************************************************************************************************************
  3100.  
  3101. // This function returns "1" if the given vehicle is owned by a player (a vehicle belonging to this script, as this script
  3102. // only holds owned vehicles
  3103. forward Housing_IsVehicleOwned(vehicleid);
  3104. public Housing_IsVehicleOwned(vehicleid)
  3105. {
  3106.     // Check if the vehicle is owned by a player
  3107.     if (AVehicleData[vehicleid][Owned] == true)
  3108.         return 1; // The vehicle is owned, return 1
  3109.     else
  3110.         return -1; // The vehicle is not owned, return -1
  3111. }
  3112.  
  3113.  
  3114.  
  3115. // ******************************************************************************************************************************
  3116. // Functions that need to be placed in the gamemode or filterscript which holds the playerdata
  3117. // Only needed when the server uses server-sided money, otherwise the normal money is used
  3118. // ******************************************************************************************************************************
  3119.  
  3120. /*
  3121. // This function is used to get the player's money
  3122. forward Admin_GetPlayerMoney(playerid);
  3123. public Admin_GetPlayerMoney(playerid)
  3124. {
  3125.     return APlayerData[playerid][PlayerMoney];
  3126. }
  3127.  
  3128. // This function is used to get the player's money
  3129. forward Admin_GivePlayerMoney(playerid, Money);
  3130. public Admin_GivePlayerMoney(playerid, Money)
  3131. {
  3132.     // Add the given money to the player's account
  3133.     APlayerData[playerid][PlayerMoney] = APlayerData[playerid][PlayerMoney] + Money;
  3134.  
  3135.     // Return that the function had success
  3136.     return 1;
  3137. }
  3138.  
  3139. // This function is used to get the player's admin-level
  3140. forward Admin_GetPlayerAdminLevel(playerid);
  3141. public Admin_GetPlayerAdminLevel(playerid)
  3142. {
  3143.     return APlayerData[playerid][AdminLevel];
  3144. }
  3145.  
  3146. // This function is used to determine if the player has logged in (he succesfully entered his password)
  3147. forward Admin_IsPlayerLoggedIn(playerid);
  3148. public Admin_IsPlayerLoggedIn(playerid)
  3149. {
  3150.     if (APlayerData[playerid][LoggedIn] == true)
  3151.         return 1; // The player has logged in succesfully
  3152.     else
  3153.         return -1; // The player hasn't logged in (yet)
  3154. }
  3155. // This function is used to determine if a player is jailed
  3156. forward Admin_IsPlayerJailed(playerid);
  3157. public Admin_IsPlayerJailed(playerid)
  3158. {
  3159.     // Check if a player has jaimtime left
  3160.     if (APlayerData[playerid][PlayerJailed] == true)
  3161.         return 1; // The player is still jailed
  3162.     else
  3163.         return -1; // The player is not jailed
  3164. }
  3165.  
  3166. // This function can be used to get the fuel-status from the given vehicle
  3167. forward Speedo_GetVehicleFuel(vehicleid);
  3168. public Speedo_GetVehicleFuel(vehicleid)
  3169. {
  3170.     return AVehicleData[vehicleid][Fuel];
  3171. }
  3172.  
  3173. // This function can be used to set the fuel-status for the given vehicle
  3174. forward Speedo_SetVehicleFuel(vehicleid, fuel);
  3175. public Speedo_SetVehicleFuel(vehicleid, fuel)
  3176. {
  3177.     // If a fuel-value of -1 is used, this will refuel the vehicle to maximum fuel
  3178.     if (fuel == -1)
  3179.     {
  3180.         AVehicleData[vehicleid][Fuel] = MaxFuel; // Set fuel to maximum
  3181.         return 1; // Return 1 (this can be used in the other script to check if the function was called successfully)
  3182.     }
  3183.  
  3184.     // Fuel cannot be negative (other negative values are ignored)
  3185.     if (fuel >= 0)
  3186.     {
  3187.         // Check if the fuel is within normal limits
  3188.         if (fuel > MaxFuel)
  3189.             AVehicleData[vehicleid][Fuel] = MaxFuel; // If a higher value was given than allowed (higher than MaxFuel), set fuel to maximum
  3190.         else
  3191.             AVehicleData[vehicleid][Fuel] = fuel; // Set the fuel to the given value
  3192.     }
  3193.     else
  3194.         return -1; // Return -1 (this can be used in the other script to check if the function was called successfully,
  3195.                     // but the fuel-value was not acceptable)
  3196.  
  3197.     // Return 1 (this can be used in the other script to check if the function was called successfully)
  3198.     return 1;
  3199. }
  3200. */
Advertisement
Add Comment
Please, Sign In to add comment