Advertisement
Guest User

Untitled

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