Advertisement
Guest User

Untitled

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