muHamad-asYraf-aKmal

Ak's Dynamic House /system

Nov 14th, 2016
1,252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.38 KB | None | 0 0
  1. //==============================================================================
  2. #include <a_samp>
  3. #include <dini>
  4. #include <streamer>
  5. #include <zcmd>
  6. #include <sscanf>
  7. //==============================================================================
  8. #define MAX_HOUSES 500
  9. #define PRESSED(%0) \
  10. (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  11. #define loop(%0,%1,%2) for(new %0 = %2; %0 < %1; %0++)
  12. //==============================================================================
  13. enum Info {
  14. Target,
  15. Owner[MAX_PLAYERS],
  16. Price,
  17. Pickup,
  18. Text3D:Label,
  19. Mapicon
  20. }
  21. //------------------------------------------------------------------------------
  22. new House[MAX_HOUSES][Info];
  23. new Float:Entrance[MAX_HOUSES][3],
  24. Float:Extrance[MAX_PLAYERS][3],
  25. Inside[MAX_HOUSES][2],
  26. Outside[MAX_HOUSES][2],
  27. Home[MAX_PLAYERS];
  28. new HouseCount[MAX_PLAYERS];
  29. //==============================================================================
  30. public OnFilterScriptInit()
  31. {
  32. //--------------------------------------------------------------------------
  33. CreateDynamicPickup(1318, 1, 2282.9744, -1140.2855, 1050.8984, -1, -1, -1);
  34. CreateDynamicPickup(1318, 1, 2196.8511, -1204.3903, 1049.0234, -1, -1, -1);
  35. CreateDynamicPickup(1318, 1, 2233.6482, -1115.2621, 1050.8828, -1, -1, -1);
  36. CreateDynamicPickup(1318, 1, 2218.4036, -1076.2433, 1050.4844, -1, -1, -1);
  37. CreateDynamicPickup(1318, 1, 2496.0659, -1692.0844, 1014.7422, -1, -1, -1);
  38. CreateDynamicPickup(1318, 1, 2365.2371, -1135.5989, 1050.8826, -1, -1, -1);
  39. CreateDynamicPickup(1318, 1, 2317.7810, -1026.7635, 1050.2178, -1, -1, -1);
  40. CreateDynamicPickup(1318, 1, 2324.41, -1149.54, 1050.71, -1, -1, -1);
  41. CreateDynamicPickup(1318, 1, 140.28, 1365.92, 1083.85, -1, -1, -1);
  42. CreateDynamicPickup(1318, 1, 1260.6603, -785.4005, 1091.9063, -1, -1, -1);
  43. //--------------------------------------------------------------------------
  44. new file[MAX_PLAYERS], string[MAX_PLAYERS];
  45. for(new i = 0; i < MAX_HOUSES; i++)
  46. {
  47. format(file, sizeof(file), "Houses/%d.ini", i);
  48. if(!fexist(file)) return 0;
  49. Entrance[i][0] = dini_Float(file, "Enter_House_One");
  50. Entrance[i][1] = dini_Float(file, "Enter_House_Two");
  51. Entrance[i][2] = dini_Float(file, "Enter_House_Three");
  52. Inside[i][0] = dini_Int(file, "Inside_House_One");
  53. Inside[i][1] = dini_Int(file, "Inside_House_Two");
  54. Outside[i][0] = dini_Int(file, "Outside_House_One");
  55. Outside[i][1] = dini_Int(file, "Outside_House_Two");
  56. House[i][Target] = dini_Int(file, "Target_Of_House");
  57. // strcat(House[i][Owner], dini_Get(file, "Owner_Of_House"));
  58. format(House[i][Owner], MAX_PLAYER_NAME, "%s", dini_Get(file, "Owner_Of_House"));
  59. House[i][Price] = dini_Int(file, "Price_Of_House");
  60. if(House[i][Target] >= 1)
  61. {
  62. House[i][Pickup] = CreateDynamicPickup(19522, 1, Entrance[i][0], Entrance[i][1], Entrance[i][2], -1, -1, -1, 50.0);
  63. format(string, sizeof(string), "{FFFFFF}Owner: %s\nPrice: $%d\nLevel: %d\nHouse: %d", House[i][Owner], House[i][Price], Inside[i][0], i);
  64. House[i][Label] = CreateDynamic3DTextLabel(string, 0xFFFFFFAA, Entrance[i][0], Entrance[i][1], Entrance[i][2], 50.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1, 10.0);
  65. House[i][Mapicon] = CreateDynamicMapIcon(Entrance[i][0], Entrance[i][1], Entrance[i][2], 32, -1, -1, -1, -1, 100.0);
  66. } else {
  67. House[i][Pickup] = CreateDynamicPickup(1273, 1, Entrance[i][0], Entrance[i][1], Entrance[i][2], -1, -1, -1, 50.0);
  68. format(string, sizeof(string), "{FFFFFF}Owner: Unknown\nPrice: $%d\nLevel: %d\nHouse: %d", House[i][Price], Inside[i][0], i);
  69. House[i][Label] = CreateDynamic3DTextLabel(string, 0xFFFFFFAA, Entrance[i][0], Entrance[i][1], Entrance[i][2], 50.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1, 10.0);
  70. House[i][Mapicon] = CreateDynamicMapIcon(Entrance[i][0], Entrance[i][1], Entrance[i][2], 31, -1, -1, -1, -1, 100.0);
  71. }
  72. //
  73. }
  74. //--------------------------------------------------------------------------
  75. return 1;
  76. }
  77. //==============================================================================
  78. public OnFilterScriptExit()
  79. {
  80. return 1;
  81. }
  82. //==============================================================================
  83. public OnPlayerConnect(playerid)
  84. {
  85. new file[MAX_PLAYERS];
  86. //==========================================================================
  87. Extrance[playerid][0] = 0;
  88. Extrance[playerid][1] = 0;
  89. Extrance[playerid][2] = 0;
  90. //==========================================================================
  91. Home[playerid] = 0;
  92. //==========================================================================
  93. format(file, sizeof(file), "Houses/Owners/%s.ini", IsPlayerName(playerid));
  94. if(!fexist(file))
  95. {
  96. dini_IntSet(file, "Count_House_You_Have", 0);
  97. HouseCount[playerid] = dini_Int(file, "Count_House_You_Have");
  98. } else {
  99. HouseCount[playerid] = dini_Int(file, "Count_House_You_Have");
  100. }
  101. return 1;
  102. }
  103. //==============================================================================
  104. public OnPlayerDisconnect(playerid, reason)
  105. {
  106. //==========================================================================
  107. Extrance[playerid][0] = 0;
  108. Extrance[playerid][1] = 0;
  109. Extrance[playerid][2] = 0;
  110. //==========================================================================
  111. Home[playerid] = 0;
  112. //
  113. new file[MAX_PLAYERS];
  114. format(file, sizeof(file), "Houses/Owners/%s.ini", IsPlayerName(playerid));
  115. dini_IntSet(file, "Count_House_You_Have", HouseCount[playerid]);
  116. //==========================================================================
  117. return 1;
  118. }
  119. //==============================================================================
  120. public OnPlayerSpawn(playerid)
  121. {
  122. return 1;
  123. }
  124. //==============================================================================
  125. stock IsPlayerName(playerid)
  126. {
  127. new name[MAX_PLAYERS];
  128. GetPlayerName(playerid, name, sizeof(name));
  129. return name;
  130. }
  131. //------------------------------------------------------------------------------
  132. cmd(createhouse, playerid, params[])
  133. {
  134. //--------------------------------------------------------------------------
  135. new discount, level, Float:x, Float:y, Float:z, string[MAX_PLAYERS], i = GetFreeHouseModel(), file[MAX_PLAYERS];
  136. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "{FF0000}Error: You are not a rcon administrator");
  137. if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "{FF0000}Error: You're in a vehicle?");
  138. if(sscanf(params, "dd", discount, level)) return SendClientMessage(playerid, -1, "{FF0000}Error: /createhouse [price] [level]");
  139. if(discount < 100 || discount > 10000) return SendClientMessage(playerid, -1, "{FF0000}Error: Invalid house discount price [100 - 100000]");
  140. if(level < 0 || level > 10) return SendClientMessage(playerid, -1, "{FF0000}Error: Invalid house interior level [1 - 10]");
  141. GetPlayerPos(playerid, x, y, z);
  142. //
  143. Entrance[i][0] = x;
  144. Entrance[i][1] = y;
  145. Entrance[i][2] = z;
  146. Inside[i][0] = level;
  147. Inside[i][1] = i;
  148. Outside[i][0] = GetPlayerInterior(playerid);
  149. Outside[i][1] = GetPlayerVirtualWorld(playerid);
  150. House[i][Target] = 0;
  151. format(House[i][Owner], MAX_PLAYER_NAME, "%s", "Unknown");
  152. House[i][Price] = discount;
  153. //
  154. format(file, sizeof(file), "Houses/%d.ini", i);
  155. dini_Create(file);
  156. dini_FloatSet(file, "Enter_House_One", Entrance[i][0]);
  157. dini_FloatSet(file, "Enter_House_Two", Entrance[i][1]);
  158. dini_FloatSet(file, "Enter_House_Three", Entrance[i][2]);
  159. dini_IntSet(file, "Inside_House_One", Inside[i][0]);
  160. dini_IntSet(file, "Inside_House_Two", Inside[i][1]);
  161. dini_IntSet(file, "Outside_House_One", Outside[i][0]);
  162. dini_IntSet(file, "Outside_House_Two", Outside[i][0]);
  163. dini_IntSet(file, "Target_Of_House", House[i][Target]);
  164. dini_Set(file, "Owner_Of_House", House[i][Owner]);
  165. dini_IntSet(file, "Price_Of_House", House[i][Price]);
  166. //
  167. House[i][Pickup] = CreateDynamicPickup(1273, 1, Entrance[i][0], Entrance[i][1], Entrance[i][2], -1, -1, -1, 50.0);
  168. format(string, sizeof(string), "{FFFFFF}Owner: %s\nPrice: $%d\nLevel: %d\nHouse: %d", House[i][Owner], House[i][Price], Inside[i][0], i);
  169. House[i][Label] = CreateDynamic3DTextLabel(string, 0xFFFFFFAA, Entrance[i][0], Entrance[i][1], Entrance[i][2], 50.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1, 10.0);
  170. House[i][Mapicon] = CreateDynamicMapIcon(Entrance[i][0], Entrance[i][1], Entrance[i][2], 31, -1, -1, -1, -1, 100.0);
  171. format(string, sizeof(string), "{FFFFFF}|» You have been created this house [Model: %d - Level: %d - Price: $%d] «|", i, Inside[i][0], House[i][Price]);
  172. SendClientMessage(playerid, -1, string);
  173. //--------------------------------------------------------------------------
  174. return 1;
  175. }
  176. //==============================================================================
  177. stock GetFreeHouseModel()
  178. {
  179. //--------------------------------------------------------------------------
  180. new file[MAX_PLAYERS];
  181. loop(h, MAX_HOUSES, 0)
  182. {
  183. format(file, sizeof(file), "Houses/%d.ini", h);
  184. if(!fexist(file))
  185. {
  186. return h;
  187. }
  188. }
  189. //--------------------------------------------------------------------------
  190. return -1;
  191. }
  192. //==============================================================================
  193. cmd(removehouse, playerid, params[])
  194. {
  195. //--------------------------------------------------------------------------
  196. new string[MAX_PLAYERS], file[MAX_PLAYERS];
  197. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "{FF0000}Error: You are not a rcon administrator");
  198. for(new i = 0; i < MAX_HOUSES; i++)
  199. {
  200. if(IsPlayerInRangeOfPoint(playerid, 0.5, Entrance[i][0], Entrance[i][1], Entrance[i][2]))
  201. {
  202. format(string, sizeof(string), "{FFFFFF}|» You have been removed this house [Model: %d] «|", i);
  203. SendClientMessage(playerid, -1, string);
  204. DestroyDynamicMapIcon(House[i][Mapicon]);
  205. DestroyDynamicPickup(House[i][Pickup]);
  206. DestroyDynamic3DTextLabel(House[i][Label]);
  207. //
  208. Entrance[i][0] = 0;
  209. Entrance[i][1] = 0;
  210. Entrance[i][2] = 0;
  211. Inside[i][0] = 0;
  212. Inside[i][1] = 0;
  213. Outside[i][0] = 0;
  214. Outside[i][1] = 0;
  215. House[i][Target] = 0;
  216. House[i][Owner] = 0;
  217. House[i][Price] = 0;
  218. format(file, sizeof(file), "Houses/%d.ini", i);
  219. dini_Remove(file);
  220. }
  221. }
  222. //--------------------------------------------------------------------------
  223. return 1;
  224. }
  225. //==============================================================================
  226. public OnPlayerUpdate(playerid)
  227. {
  228. //--------------------------------------------------------------------------
  229. for(new i = 0; i < MAX_HOUSES; i++)
  230. {
  231. if(IsPlayerInRangeOfPoint(playerid, 0.5, Entrance[i][0], Entrance[i][1], Entrance[i][2]))
  232. {
  233. if(House[i][Target] == 1)
  234. {
  235. GameTextForPlayer(playerid, "~w~press ~k~~CONVERSATION_YES~ to enter this house", 3000, 3);
  236. } else {
  237. GameTextForPlayer(playerid, "~w~press ~k~~SNEAK_ABOUT~ to buy this house", 3000, 3);
  238. }
  239. }
  240.  
  241. }
  242. //--------------------------------------------------------------------------
  243. if(IsPlayerInRangeOfPoint(playerid, 0.5, 2282.9744, -1140.2855, 1050.8984))
  244. {
  245. GameTextForPlayer(playerid, "~w~press ~k~~CONVERSATION_NO~ to exit this house", 3000, 3);
  246. }
  247. //
  248. if(IsPlayerInRangeOfPoint(playerid, 0.5, 2196.8511, -1204.3903, 1049.0234))
  249. {
  250. GameTextForPlayer(playerid, "~w~press ~k~~CONVERSATION_NO~ to exit this house", 3000, 3);
  251. }
  252. //
  253. if(IsPlayerInRangeOfPoint(playerid, 0.5, 2233.6482, -1115.2621, 1050.8828))
  254. {
  255. GameTextForPlayer(playerid, "~w~press ~k~~CONVERSATION_NO~ to exit this house", 3000, 3);
  256. }
  257. //
  258. if(IsPlayerInRangeOfPoint(playerid, 0.5, 2218.4036, -1076.2433, 1050.4844))
  259. {
  260. GameTextForPlayer(playerid, "~w~press ~k~~CONVERSATION_NO~ to exit this house", 3000, 3);
  261. }
  262. //
  263. if(IsPlayerInRangeOfPoint(playerid, 0.5, 2496.0659, -1692.0844, 1014.7422))
  264. {
  265. GameTextForPlayer(playerid, "~w~press ~k~~CONVERSATION_NO~ to exit this house", 3000, 3);
  266. }
  267. //
  268. if(IsPlayerInRangeOfPoint(playerid, 0.5, 2365.2371, -1135.5989, 1050.8826))
  269. {
  270. GameTextForPlayer(playerid, "~w~press ~k~~CONVERSATION_NO~ to exit this house", 3000, 3);
  271. }
  272. //
  273. if(IsPlayerInRangeOfPoint(playerid, 0.5, 2317.7810, -1026.7635, 1050.2178))
  274. {
  275. GameTextForPlayer(playerid, "~w~press ~k~~CONVERSATION_NO~ to exit this house", 3000, 3);
  276. }
  277. //
  278. if(IsPlayerInRangeOfPoint(playerid, 0.5, 2324.41, -1149.54, 1050.71))
  279. {
  280. GameTextForPlayer(playerid, "~w~press ~k~~CONVERSATION_NO~ to exit this house", 3000, 3);
  281. }
  282. //
  283. if(IsPlayerInRangeOfPoint(playerid, 0.5, 140.28, 1365.92, 1083.85))
  284. {
  285. GameTextForPlayer(playerid, "~w~press ~k~~CONVERSATION_NO~ to exit this house", 3000, 3);
  286. }
  287. //
  288. if(IsPlayerInRangeOfPoint(playerid, 0.5, 1260.6603, -785.4005, 1091.9063))
  289. {
  290. GameTextForPlayer(playerid, "~w~press ~k~~CONVERSATION_NO~ to exit this house", 3000, 3);
  291. }
  292. //--------------------------------------------------------------------------
  293. return 1;
  294. }
  295. //==============================================================================
  296. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  297. {
  298. if(PRESSED(KEY_YES))
  299. {
  300. if(!IsPlayerInAnyVehicle(playerid))
  301. {
  302. //------------------------------------------------------------------
  303. new Float:x, Float:y, Float:z;
  304. GetPlayerPos(playerid, x, y, z);
  305. Extrance[playerid][0] = x, Extrance[playerid][1] = y, Extrance[playerid][2] = z;
  306. for(new i = 0; i < MAX_HOUSES; i++)
  307. {
  308. if(Home[playerid] == 0)
  309. {
  310. if(IsPlayerInRangeOfPoint(playerid, 0.5, Entrance[i][0], Entrance[i][1], Entrance[i][2]))
  311. {
  312. if(House[i][Target] == 1)
  313. {
  314. // if(strcmp(IsPlayerName(playerid), House[i][Owner]) != 0)
  315. if(!strcmp(House[i][Owner], IsPlayerName(playerid), true))
  316. {
  317. if(Inside[i][0] == 1)
  318. {
  319. SetPlayerPos(playerid, 2283.0632, -1136.9760, 1050.8984);
  320. SetPlayerFacingAngle(playerid, 358.7963);
  321. SetPlayerInterior(playerid, 11);
  322. SetPlayerVirtualWorld(playerid, Inside[i][1]);
  323. Home[playerid] = 1;
  324. }
  325. //
  326. if(Inside[i][0] == 2)
  327. {
  328. SetPlayerPos(playerid, 2193.9001, -1202.4185, 1049.0234);
  329. SetPlayerFacingAngle(playerid, 91.9386);
  330. SetPlayerInterior(playerid, 6);
  331. SetPlayerVirtualWorld(playerid, Inside[i][1]);
  332. Home[playerid] = 1;
  333. }
  334. //
  335. if(Inside[i][0] == 3)
  336. {
  337. SetPlayerPos(playerid, 2233.6057, -1111.7039, 1050.8828);
  338. SetPlayerFacingAngle(playerid, 2.9124);
  339. SetPlayerInterior(playerid, 5);
  340. SetPlayerVirtualWorld(playerid, Inside[i][1]);
  341. Home[playerid] = 1;
  342. }
  343. //
  344. if(Inside[i][0] == 4)
  345. {
  346. SetPlayerPos(playerid, 2214.8909, -1076.0967, 1050.4844);
  347. SetPlayerFacingAngle(playerid, 88.8910);
  348. SetPlayerInterior(playerid, 1);
  349. SetPlayerVirtualWorld(playerid, Inside[i][1]);
  350. Home[playerid] = 1;
  351. }
  352. //
  353. if(Inside[i][0] == 5)
  354. {
  355. SetPlayerPos(playerid, 2495.8035, -1695.0997, 1014.7422);
  356. SetPlayerFacingAngle(playerid, 181.9661);
  357. SetPlayerInterior(playerid, 3);
  358. SetPlayerVirtualWorld(playerid, Inside[i][1]);
  359. Home[playerid] = 1;
  360. }
  361. //
  362. if(Inside[i][0] == 6)
  363. {
  364. SetPlayerPos(playerid, 2365.2883, -1132.5228, 1050.8750);
  365. SetPlayerFacingAngle(playerid, 358.0393);
  366. SetPlayerInterior(playerid, 8);
  367. SetPlayerVirtualWorld(playerid, Inside[i][1]);
  368. Home[playerid] = 1;
  369. }
  370. //
  371. if(Inside[i][0] == 7)
  372. {
  373. SetPlayerPos(playerid, 2320.0730, -1023.9533, 1050.2109);
  374. SetPlayerFacingAngle(playerid, 358.4915);
  375. SetPlayerInterior(playerid, 9);
  376. SetPlayerVirtualWorld(playerid, Inside[i][1]);
  377. Home[playerid] = 1;
  378. }
  379. //
  380. if(Inside[i][0] == 8)
  381. {
  382. SetPlayerPos(playerid, 2324.4490, -1145.2841, 1050.7101);
  383. SetPlayerFacingAngle(playerid, 357.5873);
  384. SetPlayerInterior(playerid, 12);
  385. SetPlayerVirtualWorld(playerid, Inside[i][1]);
  386. Home[playerid] = 1;
  387. }
  388. //
  389. if(Inside[i][0] == 9)
  390. {
  391. SetPlayerPos(playerid, 140.1788, 1369.1936, 1083.8641);
  392. SetPlayerFacingAngle(playerid, 359.2263);
  393. SetPlayerInterior(playerid, 5);
  394. SetPlayerVirtualWorld(playerid, Inside[i][1]);
  395. Home[playerid] = 1;
  396. }
  397. //
  398. if(Inside[i][0] == 10)
  399. {
  400. SetPlayerPos(playerid, 1264.7765, -781.2485, 1091.9063);
  401. SetPlayerFacingAngle(playerid, 270.6992);
  402. SetPlayerInterior(playerid, 5);
  403. SetPlayerVirtualWorld(playerid, Inside[i][1]);
  404. Home[playerid] = 1;
  405. }
  406. }
  407. }
  408. }
  409. }
  410. }
  411. }
  412. }
  413. if(PRESSED(KEY_NO))
  414. {
  415. if(!IsPlayerInAnyVehicle(playerid))
  416. {
  417. if(Home[playerid] == 1)
  418. {
  419. if(IsPlayerInRangeOfPoint(playerid, 0.5, 2282.9744, -1140.2855, 1050.8984))
  420. {
  421. Home[playerid] = 0;
  422. SetPlayerPos(playerid, Extrance[playerid][0], Extrance[playerid][1], Extrance[playerid][2]);
  423. SetPlayerInterior(playerid, 0);
  424. SetPlayerVirtualWorld(playerid, 0);
  425. }
  426. //
  427. if(IsPlayerInRangeOfPoint(playerid, 0.5, 2196.8511, -1204.3903, 1049.0234))
  428. {
  429. Home[playerid] = 0;
  430. SetPlayerPos(playerid, Extrance[playerid][0], Extrance[playerid][1], Extrance[playerid][2]);
  431. SetPlayerInterior(playerid, 0);
  432. SetPlayerVirtualWorld(playerid, 0);
  433. }
  434. //
  435. if(IsPlayerInRangeOfPoint(playerid, 0.5, 2233.6482, -1115.2621, 1050.8828))
  436. {
  437. Home[playerid] = 0;
  438. SetPlayerPos(playerid, Extrance[playerid][0], Extrance[playerid][1], Extrance[playerid][2]);
  439. SetPlayerInterior(playerid, 0);
  440. SetPlayerVirtualWorld(playerid, 0);
  441. }
  442. //
  443. if(IsPlayerInRangeOfPoint(playerid, 0.5, 2218.4036, -1076.2433, 1050.4844))
  444. {
  445. Home[playerid] = 0;
  446. SetPlayerPos(playerid, Extrance[playerid][0], Extrance[playerid][1], Extrance[playerid][2]);
  447. SetPlayerInterior(playerid, 0);
  448. SetPlayerVirtualWorld(playerid, 0);
  449. }
  450. //
  451. if(IsPlayerInRangeOfPoint(playerid, 0.5, 2496.0659, -1692.0844, 1014.7422))
  452. {
  453. Home[playerid] = 0;
  454. SetPlayerPos(playerid, Extrance[playerid][0], Extrance[playerid][1], Extrance[playerid][2]);
  455. SetPlayerInterior(playerid, 0);
  456. SetPlayerVirtualWorld(playerid, 0);
  457. }
  458. //
  459. if(IsPlayerInRangeOfPoint(playerid, 0.5, 2365.2371, -1135.5989, 1050.8826))
  460. {
  461. Home[playerid] = 0;
  462. SetPlayerPos(playerid, Extrance[playerid][0], Extrance[playerid][1], Extrance[playerid][2]);
  463. SetPlayerInterior(playerid, 0);
  464. SetPlayerVirtualWorld(playerid, 0);
  465. }
  466. //
  467. if(IsPlayerInRangeOfPoint(playerid, 0.5, 2317.7810, -1026.7635, 1050.2178))
  468. {
  469. Home[playerid] = 0;
  470. SetPlayerPos(playerid, Extrance[playerid][0], Extrance[playerid][1], Extrance[playerid][2]);
  471. SetPlayerInterior(playerid, 0);
  472. SetPlayerVirtualWorld(playerid, 0);
  473. }
  474. //
  475. if(IsPlayerInRangeOfPoint(playerid, 0.5, 2324.41, -1149.54, 1050.71))
  476. {
  477. Home[playerid] = 0;
  478. SetPlayerPos(playerid, Extrance[playerid][0], Extrance[playerid][1], Extrance[playerid][2]);
  479. SetPlayerInterior(playerid, 0);
  480. SetPlayerVirtualWorld(playerid, 0);
  481. }
  482. //
  483. if(IsPlayerInRangeOfPoint(playerid, 0.5, 140.28, 1365.92, 1083.85))
  484. {
  485. Home[playerid] = 0;
  486. SetPlayerPos(playerid, Extrance[playerid][0], Extrance[playerid][1], Extrance[playerid][2]);
  487. SetPlayerInterior(playerid, 0);
  488. SetPlayerVirtualWorld(playerid, 0);
  489. }
  490. //
  491. if(IsPlayerInRangeOfPoint(playerid, 0.5, 1260.6603, -785.4005, 1091.9063))
  492. {
  493. Home[playerid] = 0;
  494. SetPlayerPos(playerid, Extrance[playerid][0], Extrance[playerid][1], Extrance[playerid][2]);
  495. SetPlayerInterior(playerid, 0);
  496. SetPlayerVirtualWorld(playerid, 0);
  497. }
  498. }
  499. }
  500. }
  501. //==========================================================================
  502. if(PRESSED(KEY_WALK))
  503. {
  504. new string[MAX_PLAYERS], file[MAX_PLAYERS];
  505. for(new i = 0; i < MAX_HOUSES; i++) {
  506. if(IsPlayerInRangeOfPoint(playerid, 1.0, Entrance[i][0], Entrance[i][1], Entrance[i][2]))
  507. {
  508. if(House[i][Target] == 0)
  509. {
  510. if(HouseCount[playerid] > 7 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "{FF0000}Wait, you want to buy any house for this time?");
  511. if(GetPlayerMoney(playerid) < House[i][Price]) return SendClientMessage(playerid, -1, "{FF0000}Error: You don't have enough money to buy this house.");
  512. GivePlayerMoney(playerid, -House[i][Price]);
  513. format(House[i][Owner], MAX_PLAYER_NAME, "%s", IsPlayerName(playerid));
  514. House[i][Target] = 1;
  515. //
  516. format(file, sizeof(file), "Houses/%d.ini", i);
  517. dini_IntSet(file, "Target_Of_House", House[i][Target]);
  518. dini_Set(file, "Owner_Of_House", House[i][Owner]);
  519. format(string, sizeof(string), "{FFFFFF}|» You have been buyed this house [Model: %d - Level: %d - Price: $%d] «|", i, Inside[i][0], House[i][Price]);
  520. SendClientMessage(playerid, -1, string);
  521. //
  522. HouseCount[playerid] += 1;
  523. DestroyDynamicPickup(House[i][Pickup]);
  524. House[i][Pickup] = CreateDynamicPickup(19522, 1, Entrance[i][0], Entrance[i][1], Entrance[i][2], -1, -1, -1, 50.0);
  525. format(string, sizeof(string), "{FFFFFF}Owner: %s\nPrice: $%d\nLevel: %d\nHouse: %d", House[i][Owner], House[i][Price], Inside[i][0], i);
  526. UpdateDynamic3DTextLabelText(House[i][Label], -1, string);
  527. DestroyDynamicMapIcon(House[i][Mapicon]);
  528. House[i][Mapicon] = CreateDynamicMapIcon(Entrance[i][0], Entrance[i][1], Entrance[i][2], 32, -1, -1, -1, -1, 100.0);
  529. } else {
  530. }
  531. } else {
  532. } }
  533. }
  534. //==========================================================================
  535. return 1;
  536. }
Advertisement
Add Comment
Please, Sign In to add comment