Advertisement
Guest User

sadadadasdasdasd

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