Advertisement
Guest User

JaKe's House System v1 - Official by _JaKe_

a guest
Dec 14th, 2014
4,097
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 60.13 KB | None | 0 0
  1. //
  2. // JakHouse (Jake's House System) v1.0
  3. // Simple, Efficient, and Easy to use!
  4. // Housing System, You can also add your own custom interior.
  5. // Refer to SA-MP forums for more information regarding to JakHouse.
  6. // Credits: DracoBlue, Jake, Zeex, Incognito, Y_Less
  7. //
  8.  
  9. //Changelog for JakHouse: None
  10.  
  11. //
  12. //============================================================================//
  13. // Includes
  14.  
  15. #include < a_samp > //SAMP Team
  16. #include < zcmd > //Zeex
  17. #include < streamer > //Incognito
  18. #include < sscanf2 > //Y_Less
  19. #include < dini > //DracoBlue
  20. #include < foreach > //Y_Less
  21.  
  22. //
  23. //============================================================================//
  24. // File Path
  25.  
  26. #define HOUSE_PATH "JakHouse/Houses/house_%d.ini"
  27. #define USER_PATH "JakHouse/User/%s.ini"
  28.  
  29. //
  30. //============================================================================//
  31. // Configuartions
  32.  
  33. #define MAX_HOUSE_NAME 256
  34. #define MAX_HOUSES 350
  35.  
  36. #define FREEZE_LOAD true
  37. //If enable, Freezes you once entered the house, freezes you aswell once exited the house
  38. //The freeze lifts off in 5 seconds, depends on FREEZE_TIME
  39.  
  40. #define FREEZE_TIME 5 //In seconds
  41.  
  42. #define FORCE_SPAWNHOME true
  43. //Once the FORCE_SPAWNHOME is set to true, a timer will be run for 2.5 seconds when you spawn.
  44. //Once that timer is called, Player will be forced spawn in his home if he has the spawn settings on.
  45. //This define is created as the spawnhome feature we had doesn't work, as instead of spawning at home, it spawns at the gamemode's spawnpoint.
  46.  
  47. //You can change this [Just make sure you know what you are doing].
  48.  
  49. #define SALE_PICKUP 1273
  50. #define NOTSALE_PICKUP 1272
  51. #define NOTSALE_ICON 32
  52. #define SALE_ICON 31
  53.  
  54. #define STREAM_DISTANCES 35.0
  55. //Do not make it higher, or else it will conflict with the other stream objects etc.
  56.  
  57. //
  58. //============================================================================//
  59. // Colors
  60.  
  61. #define white "{FFFFFF}"
  62. #define red "{FF0000}"
  63. #define green "{33CC33}"
  64. #define yellow "{FFFF00}"
  65.  
  66. #define COLOR_RED 0xFF0000C8
  67. #define COLOR_YELLOW 0xFFFF00AA
  68. #define COLOR_GREEN 0x33CC33C8
  69. #define COLOR_WHITE 0xFFFFFFFF
  70.  
  71. //
  72. //============================================================================//
  73. // Dialogs
  74.  
  75. #define DIALOG_HMENU 6000
  76. #define DIALOG_NULL DIALOG_HMENU-1
  77. #define DIALOG_HNAME DIALOG_HMENU+1
  78. #define DIALOG_HPRICE DIALOG_HMENU+2
  79. #define DIALOG_HSTOREC DIALOG_HMENU+3
  80. #define DIALOG_WCASH DIALOG_HMENU+4
  81. #define DIALOG_HSTORE DIALOG_HMENU+5
  82. #define DIALOG_HWORLD DIALOG_HMENU+6
  83. #define DIALOG_HINTERIOR DIALOG_HMENU+7
  84. #define DIALOG_HSPAWN DIALOG_HMENU+8
  85. //Making the dialog id changing easier by just adding it.
  86.  
  87. //
  88. //============================================================================//
  89. // Enums
  90.  
  91. enum HouseInfo
  92. {
  93. hName[MAX_HOUSE_NAME],
  94. hOwner[256],
  95. hIName[256],
  96. hPrice,
  97. hSale,
  98. hInterior,
  99. hWorld,
  100. hLocked,
  101. Float:hEnterPos[4],
  102. Float:hPickupP[3],
  103. Float:ExitCPPos[3],
  104. hMapIcon,
  105. hPickup,
  106. hCP,
  107. hLevel,
  108. Text3D:hLabel,
  109. MoneyStore,
  110. hNotes[256]
  111. };
  112.  
  113. enum InteriorInfo
  114. {
  115. Name[128],
  116. Float:SpawnPointX,
  117. Float:SpawnPointY,
  118. Float:SpawnPointZ,
  119. Float:SpawnPointA,
  120. Float:ExitPointX,
  121. Float:ExitPointY,
  122. Float:ExitPointZ,
  123. i_Int,
  124. i_Price,
  125. Notes[128]
  126. };
  127.  
  128. enum HousePInfo
  129. {
  130. OwnedHouses,
  131. Float:p_SpawnPoint[4],
  132. p_Interior,
  133. p_Spawn
  134. };
  135.  
  136. //
  137. //============================================================================//
  138. // Arrays, Variables.
  139.  
  140. //Interior Lists
  141. new intInfo[][InteriorInfo] =
  142. {
  143. {"Unused House", 2324.3469, -1145.8812, 1050.7101, 359.6399, 2324.4570, -1148.8044, 1050.7101, 12, 1500000, "No bugs/glitches found"},
  144. {"House #1", 235.3069, 1190.0491, 1080.2578, 359.9533, 235.3969, 1187.6935, 1080.2578, 3, 1000000, "No bugs/glitches found"},
  145. {"House #2", 222.9837, 1239.8391, 1082.1406, 92.7009, 225.8877, 1240.0209, 1082.1406, 2, 1000000, "No bugs/glitches found"},
  146. {"House #3", 223.3313, 1290.3979, 1082.1328, 0.2667, 223.3452, 1287.8087, 1082.1406, 1, 950000, "No bugs/glitches found"},
  147. {"House #4", 225.7910, 1025.7743, 1084.0078, 0.2900, 225.6310, 1022.4800, 1084.0146, 7, 2950000, "No bugs/glitches found"},
  148. {"House #5", 295.1922, 1475.5353, 1080.2578, 3.4232, 295.2854, 1473.0117, 1080.2578, 15, 980000, "No bugs/glitches found"},
  149. {"House #6", 2265.8953, -1210.4926, 1049.0234, 88.7521, 2269.4565, -1210.4597, 1047.5625, 10, 1000000, "No bugs/glitches found"},
  150. {"Ryder's House", 2463.5032, -1698.1881, 1013.5078, 89.8337, 2466.9146, -1698.2842, 1013.5078, 2, 3000000, "Some floors of the interior are bugged."},
  151. {"Sweet's House", 2530.1094, -1679.2772, 1015.4986, 359.6395, 2525.2393, -1679.3699, 1015.4986, 1, 3500000, "Some floors/walls of the interior are bugged."},
  152. {"Crack Den", 317.9371, 1118.0695, 1083.8828, 1.3314, 318.5647, 1115.5923, 1083.8828, 5, 3200000, "No bugs/glitches found"},
  153. {"Carl Johnson's House", 2496.0076, -1695.8928, 1014.7422, 181.1864, 2495.9934, -1692.9742, 1014.7422, 3, 4500000, "No bugs/glitches found"},
  154. {"Maddog's Crib (HUGE)", 1298.9324, -793.3831, 1084.0078, 0.4147, 1298.9706, -795.9689, 1084.0078, 5, 5500000, "No bugs/glitches found"},
  155. {"Santa Maria Beach House", 2365.0667, -1131.3645, 1050.8750, 0.1014, 2365.3577, -1134.2891, 1050.8750, 8, 1200000, "No bugs/glitches found"}
  156. //{House Name[], Float:sX, Float:sY, Float:sZ, Float:sA, Float:eX, Float:eY, Float:eZ, interior, price, notes[]}
  157. };
  158.  
  159. new hInfo[MAX_HOUSES][HouseInfo];
  160. new jpInfo[MAX_PLAYERS][HousePInfo];
  161.  
  162. new h_Loaded = 0;
  163. new h_ID[MAX_PLAYERS];
  164. new h_Inside[MAX_PLAYERS];
  165. new h_Selection[MAX_PLAYERS];
  166. new h_Selected[MAX_PLAYERS];
  167.  
  168. //
  169. //============================================================================//
  170. // Public functions and others.
  171.  
  172. public OnFilterScriptInit()
  173. {
  174. for(new i=0; i<MAX_HOUSES; i++)
  175. {
  176. if(fexist(HousePath(i)))
  177. {
  178. LoadHouse(i);
  179. h_Loaded ++;
  180. }
  181. }
  182.  
  183. printf("... Houses loaded by JakHouse [%d houses out of %d]", h_Loaded, MAX_HOUSES);
  184. return 1;
  185. }
  186.  
  187. public OnFilterScriptExit()
  188. {
  189. for(new a=0; a<MAX_HOUSES; a++)
  190. {
  191. DestroyDynamicCP(hInfo[a][hCP]);
  192. DestroyDynamicPickup(hInfo[a][hPickup]);
  193. DestroyDynamicMapIcon(hInfo[a][hMapIcon]);
  194. DestroyDynamic3DTextLabel(hInfo[a][hLabel]);
  195. }
  196. return 1;
  197. }
  198.  
  199.  
  200. public OnPlayerConnect(playerid)
  201. {
  202. h_ID[playerid] = -1;
  203. h_Inside[playerid] = -1;
  204. h_Selection[playerid] = 0;
  205. h_Selected[playerid] = -1;
  206.  
  207. if(!fexist(PlayerPath(playerid)))
  208. {
  209. jpInfo[playerid][OwnedHouses] = 0;
  210. jpInfo[playerid][p_SpawnPoint][0] = 0.0;
  211. jpInfo[playerid][p_SpawnPoint][1] = 0.0;
  212. jpInfo[playerid][p_SpawnPoint][2] = 0.0;
  213. jpInfo[playerid][p_SpawnPoint][3] = 0.0;
  214. jpInfo[playerid][p_Interior] = 0;
  215. jpInfo[playerid][p_Spawn] = 0;
  216.  
  217. dini_Create(PlayerPath(playerid));
  218.  
  219. Player_Save(playerid);
  220. Player_Load(playerid);
  221. }
  222. else
  223. {
  224. Player_Load(playerid);
  225. }
  226. return 1;
  227. }
  228.  
  229. public OnPlayerDisconnect(playerid, reason)
  230. {
  231. h_ID[playerid] = -1;
  232. h_Inside[playerid] = -1;
  233. h_Selection[playerid] = 0;
  234. h_Selected[playerid] = -1;
  235.  
  236. if(fexist(PlayerPath(playerid))) Player_Save(playerid);
  237. return 1;
  238. }
  239.  
  240. public OnPlayerSpawn(playerid)
  241. {
  242. if(jpInfo[playerid][p_Spawn] == 1)
  243. {
  244. #if FREEZE_LOAD == true
  245. House_Load(playerid);
  246. #endif
  247.  
  248. SendClientMessage(playerid, COLOR_GREEN, "<!> Spawned at your house.");
  249.  
  250. #if FORCE_SPAWNHOME == true
  251. SetTimerEx("JakSpawnHome", 2500, false, "d", playerid);
  252. SendClientMessage(playerid, -1, "Force respawning to your house...");
  253. #else
  254. SetPlayerInterior(playerid, jpInfo[playerid][p_Interior]);
  255. SetPlayerPos(playerid, jpInfo[playerid][p_SpawnPoint][0], jpInfo[playerid][p_SpawnPoint][1], jpInfo[playerid][p_SpawnPoint][2]);
  256. SetPlayerFacingAngle(playerid, jpInfo[playerid][p_SpawnPoint][3]);
  257. #endif
  258. }
  259. return 1;
  260. }
  261.  
  262. forward JakSpawnHome(playerid);
  263. public JakSpawnHome(playerid)
  264. {
  265. SetPlayerInterior(playerid, jpInfo[playerid][p_Interior]);
  266. SetPlayerPos(playerid, jpInfo[playerid][p_SpawnPoint][0], jpInfo[playerid][p_SpawnPoint][1], jpInfo[playerid][p_SpawnPoint][2]);
  267. SetPlayerFacingAngle(playerid, jpInfo[playerid][p_SpawnPoint][3]);
  268. return SendClientMessage(playerid, COLOR_YELLOW, "<!> Finally spawned at your house.");
  269. }
  270.  
  271. public OnPlayerEnterDynamicCP(playerid, checkpointid)
  272. {
  273. for(new x=0; x<MAX_HOUSES; x++)
  274. {
  275. if(checkpointid == hInfo[x][hCP])
  276. {
  277. #if FREEZE_LOAD == true
  278. House_Load(playerid);
  279.  
  280. SetPlayerPos(playerid, hInfo[x][hPickupP][0], hInfo[x][hPickupP][1], hInfo[x][hPickupP][2]);
  281. SetPlayerInterior(playerid, 0);
  282. SetPlayerVirtualWorld(playerid, 0);
  283.  
  284. #else
  285. SetPlayerPos(playerid, hInfo[x][hPickupP][0], hInfo[x][hPickupP][1], hInfo[x][hPickupP][2]);
  286. SetPlayerInterior(playerid, 0);
  287. SetPlayerVirtualWorld(playerid, 0);
  288.  
  289. #endif
  290.  
  291. h_Inside[playerid] = -1;
  292. }
  293. }
  294. return 1;
  295. }
  296.  
  297. public OnPlayerPickUpDynamicPickup(playerid, pickupid)
  298. {
  299. for(new x=0; x<MAX_HOUSES; x++)
  300. {
  301. if(pickupid == hInfo[x][hPickup])
  302. {
  303. h_ID[playerid] = x;
  304. }
  305. }
  306. return 1;
  307. }
  308.  
  309. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  310. {
  311. new hid = h_ID[playerid];
  312.  
  313. if(dialogid == DIALOG_HMENU)
  314. {
  315. if(response)
  316. {
  317. switch(listitem)
  318. {
  319. case 0:
  320. {
  321. ShowPlayerDialog(playerid, DIALOG_HNAME, DIALOG_STYLE_INPUT, ""green"House Name",\
  322. ""white"You are now editing the name of your house.\nPut the name of your house below (E.G. Jake's House)\n\nMaximum Length for the house name: 100", "Configure", "Back");
  323. }
  324. case 1:
  325. {
  326. ShowPlayerDialog(playerid, DIALOG_HPRICE, DIALOG_STYLE_INPUT, ""green"House Price ($)",\
  327. ""white"You are now editing the price of your house.\nPut the price of your house below (E.G. 500)", "Configure", "Back");
  328. }
  329. case 2:
  330. {
  331. ShowPlayerDialog(playerid, DIALOG_HSTOREC, DIALOG_STYLE_INPUT, ""green"Store Cash ($)",\
  332. ""white"You are now storing your money into your house safe.\nPut the amount of cash you want to store into your house. (E.G. 500)", "Configure", "Back");
  333. }
  334. case 3:
  335. {
  336. ShowPlayerDialog(playerid, DIALOG_WCASH, DIALOG_STYLE_INPUT, ""green"Withdraw Cash ($)",\
  337. ""white"You are now withdrawing a money from your house safe.\nPut the amount of cash you want to withdraw from your house safe. (E.G. 500)", "Configure", "Back");
  338. }
  339. case 4:
  340. {
  341. new string[1000];
  342. format(string, sizeof(string), ""white"Your house safe status:\n\nCash Stored: "green"$%d\n"white"Notes:\n"red"%s", hInfo[hid][MoneyStore], hInfo[hid][hNotes]);
  343. ShowPlayerDialog(playerid, DIALOG_HSTORE, DIALOG_STYLE_MSGBOX, ""green"Storage Info",\
  344. string, "Back", "");
  345. }
  346. case 5:
  347. {
  348. ShowPlayerDialog(playerid, DIALOG_HWORLD, DIALOG_STYLE_INPUT, ""green"Virtual World",\
  349. ""white"You are now editing the virtual world of your house (inside).\nPut the virtual world you want to set to your house. (E.G. 1)", "Configure", "Back");
  350. }
  351. case 6:
  352. {
  353. new string[1200];
  354.  
  355. for(new a=0; a<sizeof(intInfo); a++)
  356. {
  357. format(string, sizeof(string), "%s%s - $%d\n", string, intInfo[a][Name], intInfo[a][i_Price]);
  358. }
  359. ShowPlayerDialog(playerid, DIALOG_HINTERIOR, DIALOG_STYLE_LIST, ""green"Interior", string, "Preview", "Back");
  360. }
  361. case 7:
  362. {
  363. if(jpInfo[playerid][p_Spawn] == 0)
  364. {
  365. ShowPlayerDialog(playerid, DIALOG_HSPAWN, DIALOG_STYLE_MSGBOX, ""yellow"Spawn at Home, Are you sure?",\
  366. ""white"Are you sure you want to spawn at your house everytime you die?", "Yes", "No");
  367. }
  368. else
  369. {
  370. ShowPlayerDialog(playerid, DIALOG_HSPAWN, DIALOG_STYLE_MSGBOX, ""yellow"Are you sure?",\
  371. ""white"Are you sure you will no longer spawn at your house everytime you die?", "Yes", "No");
  372. }
  373. }
  374. }
  375. }
  376. }
  377. if(dialogid == DIALOG_HSPAWN)
  378. {
  379. if(response)
  380. {
  381. if(jpInfo[playerid][p_Spawn] == 0)
  382. {
  383. jpInfo[playerid][p_Spawn] = 1;
  384. SendClientMessage(playerid, -1, "<!> You will now spawn at your house, everytime you die.");
  385. }
  386. else if(jpInfo[playerid][p_Spawn] == 1)
  387. {
  388. jpInfo[playerid][p_Spawn] = 0;
  389. SendClientMessage(playerid, -1, "<!> You will no longer spawn at your house, everytime you die.");
  390. }
  391. }
  392. else
  393. {
  394. cmd_hmenu(playerid, "");
  395. }
  396. }
  397. if(dialogid == DIALOG_HINTERIOR)
  398. {
  399. if(response)
  400. {
  401. new hi = listitem;
  402. h_Selected[playerid] = hi;
  403.  
  404. TogglePlayerControllable(playerid, 0);
  405. SetCameraBehindPlayer(playerid);
  406.  
  407. h_Selection[playerid] = 1;
  408.  
  409. new Float:x_Pos[3];
  410. GetPlayerPos(playerid, x_Pos[0], x_Pos[1], x_Pos[2]);
  411. SetPVarInt(playerid, "h_Interior", GetPlayerInterior(playerid));
  412. SetPVarInt(playerid, "h_World", GetPlayerVirtualWorld(playerid));
  413. SetPVarFloat(playerid, "h_X", x_Pos[0]);
  414. SetPVarFloat(playerid, "h_Y", x_Pos[1]);
  415. SetPVarFloat(playerid, "h_Z", x_Pos[2]);
  416.  
  417. SetPlayerPos(playerid, intInfo[hi][SpawnPointX], intInfo[hi][SpawnPointY], intInfo[hi][SpawnPointZ]);
  418. SetPlayerInterior(playerid, intInfo[hi][i_Int]);
  419. SetPlayerFacingAngle(playerid, intInfo[hi][SpawnPointA]);
  420. SetPlayerVirtualWorld(playerid, 271569); //So in that way, no one can see you during the preview.
  421.  
  422. new string[250];
  423. format(string, sizeof(string), "~w~You are now viewing: ~g~%s~n~/buyint to buy the interior~n~~r~/cancelint to cancel buying it.", intInfo[hi][Name]);
  424. GameTextForPlayer(playerid, string, 15000, 3);
  425.  
  426. format(string, sizeof(string), "You are now viewing the house '%s' - /buyint to buy the interior, /cancelint to cancel buying it.", intInfo[hi][Name]);
  427. SendClientMessage(playerid, COLOR_YELLOW, string);
  428. format(string, sizeof(string), "The house interior costs "green"$%d, "white"Notes left in the interior: "red"'%s'", intInfo[hi][i_Price], intInfo[hi][Notes]);
  429. SendClientMessage(playerid, -1, string);
  430. }
  431. else
  432. {
  433. cmd_hmenu(playerid, "");
  434. }
  435. }
  436. if(dialogid == DIALOG_HSTORE)
  437. {
  438. if(response || !response)
  439. {
  440. cmd_hmenu(playerid, "");
  441. }
  442. }
  443. if(dialogid == DIALOG_HNAME)
  444. {
  445. if(response)
  446. {
  447. if(!strlen(inputtext))
  448. {
  449. ShowPlayerDialog(playerid, DIALOG_HNAME, DIALOG_STYLE_INPUT, ""green"House Name",\
  450. ""white"You are now editing the name of your house.\nPut the name of your house below (E.G. Jake's House)\n\nMaximum Length for the house name: 100\n"red"Invalid House Name Length.", "Configure", "Back");
  451. return 1;
  452. }
  453.  
  454. new string[128];
  455. format(string, 128, "You have changed the name of your house to '%s'", inputtext);
  456. SendClientMessage(playerid, -1, string);
  457.  
  458. format(hInfo[hid][hName], 256, "%s", inputtext);
  459.  
  460. SaveHouse(hid);
  461.  
  462. DestroyDynamicCP(hInfo[hid][hCP]);
  463. DestroyDynamicPickup(hInfo[hid][hPickup]);
  464. DestroyDynamicMapIcon(hInfo[hid][hMapIcon]);
  465. DestroyDynamic3DTextLabel(hInfo[hid][hLabel]);
  466.  
  467. LoadHouse(hid);
  468.  
  469. cmd_hmenu(playerid, "");
  470. }
  471. else
  472. {
  473. cmd_hmenu(playerid, "");
  474. }
  475. }
  476. if(dialogid == DIALOG_HPRICE)
  477. {
  478. if(response)
  479. {
  480. if(!strlen(inputtext))
  481. {
  482. ShowPlayerDialog(playerid, DIALOG_HPRICE, DIALOG_STYLE_INPUT, ""green"House Price ($)",\
  483. ""white"You are now editing the price of your house.\nPut the price of your house below (E.G. 500)", "Configure", "Back");
  484. return 1;
  485. }
  486. if(!isnumeric(inputtext))
  487. {
  488. ShowPlayerDialog(playerid, DIALOG_HPRICE, DIALOG_STYLE_INPUT, ""green"House Price ($)",\
  489. ""white"You are now editing the price of your house.\nPut the price of your house below (E.G. 500)\n\n"red"Invalid Integer.", "Configure", "Back");
  490. return 1;
  491. }
  492.  
  493. new string[128];
  494. format(string, 128, "You have changed the price of your house to $%d.", strval(inputtext));
  495. SendClientMessage(playerid, -1, string);
  496.  
  497. hInfo[hid][hPrice] = strval(inputtext);
  498.  
  499. SaveHouse(hid);
  500.  
  501. DestroyDynamicCP(hInfo[hid][hCP]);
  502. DestroyDynamicPickup(hInfo[hid][hPickup]);
  503. DestroyDynamicMapIcon(hInfo[hid][hMapIcon]);
  504. DestroyDynamic3DTextLabel(hInfo[hid][hLabel]);
  505.  
  506. LoadHouse(hid);
  507.  
  508. cmd_hmenu(playerid, "");
  509. }
  510. else
  511. {
  512. cmd_hmenu(playerid, "");
  513. }
  514. }
  515. if(dialogid == DIALOG_HSTOREC)
  516. {
  517. if(response)
  518. {
  519. if(!strlen(inputtext))
  520. {
  521. ShowPlayerDialog(playerid, DIALOG_HSTOREC, DIALOG_STYLE_INPUT, ""green"Store Cash ($)",\
  522. ""white"You are now storing your money into your house safe.\nPut the amount of cash you want to store into your house. (E.G. 500)", "Configure", "Back");
  523. return 1;
  524. }
  525. if(!isnumeric(inputtext))
  526. {
  527. ShowPlayerDialog(playerid, DIALOG_HSTOREC, DIALOG_STYLE_INPUT, ""green"Store Cash ($)",\
  528. ""white"You are now storing your money into your house safe.\nPut the amount of cash you want to store into your house. (E.G. 500)\n\n"red"Invalid Integer", "Configure", "Back");
  529. return 1;
  530. }
  531.  
  532. GivePlayerMoney(playerid, -strval(inputtext));
  533. hInfo[hid][MoneyStore] = hInfo[hid][MoneyStore] + strval(inputtext);
  534.  
  535. new string[128];
  536. format(string, 128, "You have store your $%d into your house safe. ($%d over all in your safe)", strval(inputtext), hInfo[hid][MoneyStore]);
  537. SendClientMessage(playerid, -1, string);
  538.  
  539. SaveHouse(hid);
  540.  
  541. DestroyDynamicCP(hInfo[hid][hCP]);
  542. DestroyDynamicPickup(hInfo[hid][hPickup]);
  543. DestroyDynamicMapIcon(hInfo[hid][hMapIcon]);
  544. DestroyDynamic3DTextLabel(hInfo[hid][hLabel]);
  545.  
  546. LoadHouse(hid);
  547.  
  548. cmd_hmenu(playerid, "");
  549. }
  550. else
  551. {
  552. cmd_hmenu(playerid, "");
  553. }
  554. }
  555. if(dialogid == DIALOG_HWORLD)
  556. {
  557. if(response)
  558. {
  559. if(!strlen(inputtext))
  560. {
  561. ShowPlayerDialog(playerid, DIALOG_HWORLD, DIALOG_STYLE_INPUT, ""green"Virtual World",\
  562. ""white"You are now editing the virtual world of your house (inside).\nPut the virtual world you want to set to your house. (E.G. 1)", "Configure", "Back");
  563. return 1;
  564. }
  565. if(!isnumeric(inputtext))
  566. {
  567. ShowPlayerDialog(playerid, DIALOG_HWORLD, DIALOG_STYLE_INPUT, ""green"Virtual World",\
  568. ""white"You are now editing the virtual world of your house (inside).\nPut the virtual world you want to set to your house. (E.G. 1)\n\n"red"Invalid Integer.", "Configure", "Back");
  569. return 1;
  570. }
  571.  
  572. hInfo[hid][hWorld] = strval(inputtext);
  573.  
  574. new string[128];
  575. format(string, 128, "You have change your inside house virtual world to %d.", strval(inputtext));
  576. SendClientMessage(playerid, -1, string);
  577.  
  578. SaveHouse(hid);
  579.  
  580. DestroyDynamicCP(hInfo[hid][hCP]);
  581. DestroyDynamicPickup(hInfo[hid][hPickup]);
  582. DestroyDynamicMapIcon(hInfo[hid][hMapIcon]);
  583. DestroyDynamic3DTextLabel(hInfo[hid][hLabel]);
  584.  
  585. LoadHouse(hid);
  586.  
  587. cmd_hmenu(playerid, "");
  588. }
  589. else
  590. {
  591. cmd_hmenu(playerid, "");
  592. }
  593. }
  594. if(dialogid == DIALOG_WCASH)
  595. {
  596. if(response)
  597. {
  598. if(!strlen(inputtext))
  599. {
  600. ShowPlayerDialog(playerid, DIALOG_WCASH, DIALOG_STYLE_INPUT, ""green"Withdraw Cash ($)",\
  601. ""white"You are now withdrawing a money from your house safe.\nPut the amount of cash you want to withdraw from your house safe. (E.G. 500)", "Configure", "Back");
  602. return 1;
  603. }
  604. if(!isnumeric(inputtext))
  605. {
  606. ShowPlayerDialog(playerid, DIALOG_WCASH, DIALOG_STYLE_INPUT, ""green"Withdraw Cash ($)",\
  607. ""white"You are now withdrawing a money from your house safe.\nPut the amount of cash you want to withdraw from your house safe. (E.G. 500)\n\n"red"Invalid Integer.", "Configure", "Back");
  608. return 1;
  609. }
  610. if(strval(inputtext) > hInfo[hid][MoneyStore])
  611. {
  612. ShowPlayerDialog(playerid, DIALOG_WCASH, DIALOG_STYLE_INPUT, ""green"Withdraw Cash ($)",\
  613. ""white"You are now withdrawing a money from your house safe.\nPut the amount of cash you want to withdraw from your house safe. (E.G. 500)\n\n"red"You do not have that amount of cash on your safe.", "Configure", "Back");
  614. return 1;
  615. }
  616.  
  617. GivePlayerMoney(playerid, strval(inputtext));
  618. hInfo[hid][MoneyStore] = hInfo[hid][MoneyStore] - strval(inputtext);
  619.  
  620. new string[128];
  621. format(string, 128, "You have withdrawn a $%d from your house safe. ($%d over all in your safe)", strval(inputtext), hInfo[hid][MoneyStore]);
  622. SendClientMessage(playerid, -1, string);
  623.  
  624. SaveHouse(hid);
  625.  
  626. DestroyDynamicCP(hInfo[hid][hCP]);
  627. DestroyDynamicPickup(hInfo[hid][hPickup]);
  628. DestroyDynamicMapIcon(hInfo[hid][hMapIcon]);
  629. DestroyDynamic3DTextLabel(hInfo[hid][hLabel]);
  630.  
  631. LoadHouse(hid);
  632.  
  633. cmd_hmenu(playerid, "");
  634. }
  635. else
  636. {
  637. cmd_hmenu(playerid, "");
  638. }
  639. }
  640. return 1;
  641. }
  642.  
  643. // Commands [ZCMD] //
  644.  
  645. // Version 1.0 Commands
  646.  
  647. CMD:hcmds(playerid, params[])
  648. {
  649. SendClientMessage(playerid, -1, "Jake's House System (v1.0)");
  650. SendClientMessage(playerid, COLOR_YELLOW, "/buyint - To buy interior (Works only when you choose interior on /hmenu)");
  651. SendClientMessage(playerid, COLOR_YELLOW, "/cancelint - To cancel the preview interior (Same like /buyint)");
  652. SendClientMessage(playerid, COLOR_YELLOW, "/buyhouse - /sellhouse (Buys/Sells house, Works only when in-range of the pickup)");
  653. SendClientMessage(playerid, COLOR_YELLOW, "/hlock - To lock the house (Works only when in-range of pickup/Inside)");
  654. SendClientMessage(playerid, COLOR_YELLOW, "/hmenu - Player's House Configuration Menu");
  655. SendClientMessage(playerid, COLOR_YELLOW, "/henter - Enters inside the house (If not locked).");
  656. SendClientMessage(playerid, COLOR_YELLOW, "/hnote - Adds a note to your house.");
  657. SendClientMessage(playerid, COLOR_YELLOW, "/hcnote - Checks a note on someones house");
  658. SendClientMessage(playerid, -1, "For RCONs, /ahcmds for RCON House commands.");
  659. return 1;
  660. }
  661.  
  662. CMD:buyint(playerid, params[])
  663. {
  664. if(h_Selection[playerid] == 0)
  665. {
  666. SendClientMessage(playerid, COLOR_RED, "<!> You are not on Interior Selection.");
  667. return 1;
  668. }
  669.  
  670. new id = h_Selected[playerid], string[128], hid = h_ID[playerid];
  671.  
  672. if(GetPlayerMoney(playerid) < intInfo[id][i_Price])
  673. {
  674. SendClientMessage(playerid, COLOR_RED, "<!> You do not have enough money to purchase this interior!");
  675. SendClientMessage(playerid, -1, "JakHouse_Bot: I suggest you to /cancelint now.");
  676. return 1;
  677. }
  678.  
  679. GivePlayerMoney(playerid, -intInfo[id][i_Price]);
  680. GameTextForPlayer(playerid, "~g~Interior Purchased!", 4500, 3);
  681.  
  682. hInfo[hid][hEnterPos][0] = intInfo[id][SpawnPointX];
  683. hInfo[hid][hEnterPos][1] = intInfo[id][SpawnPointY];
  684. hInfo[hid][hEnterPos][2] = intInfo[id][SpawnPointZ];
  685. hInfo[hid][hEnterPos][3] = intInfo[id][SpawnPointA];
  686. hInfo[hid][ExitCPPos][0] = intInfo[id][ExitPointX];
  687. hInfo[hid][ExitCPPos][1] = intInfo[id][ExitPointY];
  688. hInfo[hid][ExitCPPos][2] = intInfo[id][ExitPointZ];
  689. hInfo[hid][hInterior] = intInfo[id][i_Int];
  690. format(hInfo[hid][hIName], 256, "%s", intInfo[id][Name]);
  691.  
  692. jpInfo[playerid][p_SpawnPoint][0] = intInfo[id][SpawnPointX];
  693. jpInfo[playerid][p_SpawnPoint][1] = intInfo[id][SpawnPointY];
  694. jpInfo[playerid][p_SpawnPoint][2] = intInfo[id][SpawnPointZ];
  695. jpInfo[playerid][p_SpawnPoint][3] = intInfo[id][SpawnPointA];
  696. jpInfo[playerid][p_Interior] = hInfo[hid][hInterior];
  697.  
  698. format(string, sizeof(string), "House Interior '%s' has been purchased for $%d, Your house has now had this interior.", intInfo[id][Name], intInfo[id][i_Price]);
  699. SendClientMessage(playerid, COLOR_GREEN, string);
  700. format(string, sizeof(string), "Notes left at the house for you: '%s'", intInfo[id][Notes]);
  701. SendClientMessage(playerid, COLOR_RED, string);
  702. SendClientMessage(playerid, -1, "House updated.");
  703.  
  704. SendClientMessage(playerid, COLOR_YELLOW, "<!> Your spawnpoint has been changed.");
  705.  
  706. format(hInfo[hid][hNotes], 256, "%s", intInfo[id][Notes]);
  707.  
  708. h_Selected[playerid] = -1;
  709. h_Selection[playerid] = 0;
  710. TogglePlayerControllable(playerid, 1);
  711. SetPlayerInterior(playerid, GetPVarInt(playerid, "h_Interior"));
  712. SetPlayerVirtualWorld(playerid, GetPVarInt(playerid, "h_World"));
  713. SetPlayerPos(playerid, GetPVarFloat(playerid, "h_X"), GetPVarFloat(playerid, "h_Y"), GetPVarFloat(playerid, "h_Z"));
  714.  
  715. SaveHouse(hid);
  716.  
  717. DestroyDynamicCP(hInfo[hid][hCP]);
  718. DestroyDynamicPickup(hInfo[hid][hPickup]);
  719. DestroyDynamicMapIcon(hInfo[hid][hMapIcon]);
  720. DestroyDynamic3DTextLabel(hInfo[hid][hLabel]);
  721.  
  722. LoadHouse(hid);
  723. return 1;
  724. }
  725. CMD:cancelint(playerid, params[])
  726. {
  727. if(h_Selection[playerid] == 0)
  728. {
  729. SendClientMessage(playerid, COLOR_RED, "<!> You are not on Interior Selection.");
  730. return 1;
  731. }
  732.  
  733. h_Selection[playerid] = 0;
  734. h_Selected[playerid] = -1;
  735.  
  736. SetPlayerInterior(playerid, GetPVarInt(playerid, "h_Interior"));
  737. SetPlayerVirtualWorld(playerid, GetPVarInt(playerid, "h_World"));
  738. SetPlayerPos(playerid, GetPVarFloat(playerid, "h_X"), GetPVarFloat(playerid, "h_Y"), GetPVarFloat(playerid, "h_Z"));
  739.  
  740. SendClientMessage(playerid, -1, "You have decided not to buy the interior.");
  741. SendClientMessage(playerid, -1, "You've been teleported back to your position.");
  742.  
  743. #if FREEZE_LOAD == true
  744. House_Load(playerid);
  745. #endif
  746. return 1;
  747. }
  748.  
  749. CMD:ahcmds(playerid, params[])
  750. {
  751. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "<!> You are not a RCON Admin to use this command!");
  752.  
  753. SendClientMessage(playerid, -1, "Jake's House System (v1.0) - RCON Commands");
  754. SendClientMessage(playerid, COLOR_YELLOW, "/addhouse - Adds a house");
  755. SendClientMessage(playerid, COLOR_YELLOW, "/removehouse - Removes a house");
  756. SendClientMessage(playerid, COLOR_YELLOW, "/gotohouse - Teleports to the house");
  757. SendClientMessage(playerid, COLOR_YELLOW, "/hinteriors - Lists all the available interior");
  758. SendClientMessage(playerid, COLOR_YELLOW, "/hmove - Moves the specific houseid to your current location.");
  759. SendClientMessage(playerid, COLOR_YELLOW, "/asellhouse - Sells the house without doing the actual command.");
  760. SendClientMessage(playerid, COLOR_YELLOW, "/hnear - Lists all nearby houses within 35 meters.");
  761. return 1;
  762. }
  763.  
  764. CMD:gotohouse(playerid, params[])
  765. {
  766. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "<!> You are not a RCON Admin to use this command!");
  767.  
  768. new string[128], id;
  769. if(sscanf(params, "i", id)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /gotohouse <houseid>");
  770. if(!fexist(HousePath(id))) return SendClientMessage(playerid, COLOR_RED, "<!> House Slot do not exists.");
  771.  
  772. #if FREEZE_LOAD == true
  773. House_Load(playerid);
  774. #endif
  775.  
  776. SetPlayerInterior(playerid, 0);
  777. SetPlayerVirtualWorld(playerid, 0);
  778. SetPlayerPos(playerid, hInfo[id][hPickupP][0], hInfo[id][hPickupP][1], hInfo[id][hPickupP][2]);
  779.  
  780. format(string, sizeof(string), "You have been successfully teleported to houseID %d (Owned by %s)", id, hInfo[id][hOwner]);
  781. SendClientMessage(playerid, -1, string);
  782. return 1;
  783. }
  784.  
  785. CMD:hinteriors(playerid, params[])
  786. {
  787. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "<!> You are not a RCON Admin to use this command!");
  788.  
  789. new string[1200];
  790.  
  791. for(new a=0; a<sizeof(intInfo); a++)
  792. {
  793. format(string, sizeof(string), "%s%s - ID: %d\n", string, intInfo[a][Name], a);
  794. }
  795. ShowPlayerDialog(playerid, DIALOG_NULL, DIALOG_STYLE_LIST, ""green"Interior List", string, "Close", "");
  796. return 1;
  797. }
  798.  
  799. CMD:hmove(playerid, params[])
  800. {
  801. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "<!> You are not a RCON Admin to use this command!");
  802.  
  803. new
  804. string[128],
  805. hid,
  806. Float:p_Pos[3]
  807. ;
  808.  
  809. if(sscanf(params, "i", hid)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /hmove <houseid>");
  810. if(!fexist(HousePath(hid))) return SendClientMessage(playerid, COLOR_RED, "<!> House does not exists.");
  811.  
  812. GetPlayerPos(playerid, p_Pos[0], p_Pos[1], p_Pos[2]);
  813.  
  814. hInfo[hid][hPickupP][0] = p_Pos[0];
  815. hInfo[hid][hPickupP][1] = p_Pos[1];
  816. hInfo[hid][hPickupP][2] = p_Pos[2];
  817.  
  818. SaveHouse(hid);
  819.  
  820. DestroyDynamicCP(hInfo[hid][hCP]);
  821. DestroyDynamicPickup(hInfo[hid][hPickup]);
  822. DestroyDynamicMapIcon(hInfo[hid][hMapIcon]);
  823. DestroyDynamic3DTextLabel(hInfo[hid][hLabel]);
  824.  
  825. LoadHouse(hid);
  826.  
  827. format(string, sizeof(string), "<!> HouseID %d moved at your location.", hid);
  828. SendClientMessage(playerid, COLOR_GREEN, string);
  829. format(string, sizeof(string), "Location: %f, %f, %f", p_Pos[0], p_Pos[1], p_Pos[2]);
  830. SendClientMessage(playerid, -1, string);
  831.  
  832. printf("...HouseID %d moved to %f, %f, %f - JakHouse log", hid, p_Pos[0], p_Pos[1], p_Pos[2]);
  833. return 1;
  834. }
  835.  
  836. CMD:addhouse(playerid, params[])
  837. {
  838. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "<!> You are not a RCON Admin to use this command!");
  839.  
  840. new
  841. string[128],
  842. hid,
  843. price,
  844. world,
  845. level,
  846. interior,
  847. Float:p_Pos[3]
  848. ;
  849.  
  850. if(sscanf(params, "iiiii", hid, level, price, world, interior)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /addhouse <houseid> <level> <price> <world> <interiorid(0-12)>");
  851. if(hid < 0 || hid > MAX_HOUSES) return SendClientMessage(playerid, COLOR_RED, "<!> Do not exceed the house limitations of JakHouse.");
  852. if(interior < 0 || interior > 12) return SendClientMessage(playerid, COLOR_RED, "<!> Do not exceed the interior limitations of JakHouse.");
  853. if(level < 0) return SendClientMessage(playerid, COLOR_RED, "<!> Level Requirements shouldn't go below under 0.");
  854. if(fexist(HousePath(hid))) return SendClientMessage(playerid, COLOR_RED, "<!> House Slot used.");
  855.  
  856. GetPlayerPos(playerid, p_Pos[0], p_Pos[1], p_Pos[2]);
  857.  
  858. format(hInfo[hid][hName], 256, "None");
  859. format(hInfo[hid][hOwner], 256, "None");
  860. hInfo[hid][hLevel] = level;
  861. hInfo[hid][hPrice] = price;
  862. hInfo[hid][hSale] = 0;
  863. hInfo[hid][hInterior] = intInfo[interior][i_Int];
  864. hInfo[hid][hWorld] = world;
  865. hInfo[hid][hLocked] = 1;
  866. hInfo[hid][hEnterPos][0] = intInfo[interior][SpawnPointX];
  867. hInfo[hid][hEnterPos][1] = intInfo[interior][SpawnPointY];
  868. hInfo[hid][hEnterPos][2] = intInfo[interior][SpawnPointZ];
  869. hInfo[hid][hEnterPos][3] = intInfo[interior][SpawnPointA];
  870. hInfo[hid][hPickupP][0] = p_Pos[0];
  871. hInfo[hid][hPickupP][1] = p_Pos[1];
  872. hInfo[hid][hPickupP][2] = p_Pos[2];
  873. hInfo[hid][ExitCPPos][0] = intInfo[interior][ExitPointX];
  874. hInfo[hid][ExitCPPos][1] = intInfo[interior][ExitPointY];
  875. hInfo[hid][ExitCPPos][2] = intInfo[interior][ExitPointZ];
  876. format(hInfo[hid][hIName], 256, "%s", intInfo[interior][Name]);
  877. format(hInfo[hid][hNotes], 256, "None");
  878. hInfo[hid][MoneyStore] = 0;
  879.  
  880. dini_Create(HousePath(hid));
  881. SaveHouse(hid);
  882.  
  883. DestroyDynamicCP(hInfo[hid][hCP]);
  884. DestroyDynamicPickup(hInfo[hid][hPickup]);
  885. DestroyDynamicMapIcon(hInfo[hid][hMapIcon]);
  886. DestroyDynamic3DTextLabel(hInfo[hid][hLabel]);
  887.  
  888. LoadHouse(hid);
  889.  
  890. format(string, sizeof(string), "<!> HouseID %d created, Price $%d, Level %d, Virtaul World %d", hid, price, level, world);
  891. SendClientMessage(playerid, COLOR_GREEN, string);
  892. format(string, sizeof(string), "House created under the interior %s (Int %d)", intInfo[interior][Name], interior);
  893. SendClientMessage(playerid, -1, string);
  894.  
  895. printf("...HouseID %d created - JakHouse log", hid);
  896. return 1;
  897. }
  898. CMD:removehouse(playerid, params[])
  899. {
  900. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "<!> You are not a RCON Admin to use this command!");
  901.  
  902. new
  903. string[128],
  904. hid
  905. ;
  906.  
  907. if(sscanf(params, "i", hid)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /removehouse <houseid>");
  908. if(!fexist(HousePath(hid))) return SendClientMessage(playerid, COLOR_RED, "<!> House Slot not used.");
  909.  
  910. foreach(new i : Player)
  911. {
  912. if(strcmp(p_Name(playerid), hInfo[hid][hOwner], true) == 0)
  913. {
  914. jpInfo[i][OwnedHouses] = 0;
  915. jpInfo[i][OwnedHouses] = 0;
  916. jpInfo[i][p_SpawnPoint][0] = 0.0;
  917. jpInfo[i][p_SpawnPoint][1] = 0.0;
  918. jpInfo[i][p_SpawnPoint][2] = 0.0;
  919. jpInfo[i][p_SpawnPoint][3] = 0.0;
  920. jpInfo[i][p_Interior] = 0;
  921. jpInfo[i][p_Spawn] = 0;
  922.  
  923. SendClientMessage(i, COLOR_YELLOW, "Your house has been removed by RCON Admin.");
  924. }
  925. }
  926.  
  927. new file[128];
  928. format(file, sizeof(file), USER_PATH, hInfo[hid][hOwner]);
  929. dini_IntSet(file, "Houses", jpInfo[playerid][OwnedHouses]=0);
  930. dini_FloatSet(file, "X", jpInfo[playerid][p_SpawnPoint][0]=0.0);
  931. dini_FloatSet(file, "Y", jpInfo[playerid][p_SpawnPoint][1]=0.0);
  932. dini_FloatSet(file, "Z", jpInfo[playerid][p_SpawnPoint][2]=0.0);
  933. dini_FloatSet(file, "A", jpInfo[playerid][p_SpawnPoint][3]=0.0);
  934. dini_IntSet(file, "Interior", jpInfo[playerid][p_Interior]=0);
  935. dini_IntSet(file, "Spawn", jpInfo[playerid][p_Spawn]=0);
  936.  
  937. format(hInfo[hid][hName], 256, "None");
  938. format(hInfo[hid][hOwner], 256, "None");
  939. hInfo[hid][hLevel] = 0;
  940. hInfo[hid][hPrice] = 0;
  941. hInfo[hid][hSale] = 0;
  942. hInfo[hid][hInterior] = 2;
  943. hInfo[hid][hWorld] = 0;
  944. hInfo[hid][hLocked] = 1;
  945. hInfo[hid][hEnterPos][0] = 2461.4714;
  946. hInfo[hid][hEnterPos][1] = -1698.2998;
  947. hInfo[hid][hEnterPos][2] = 1013.5078;
  948. hInfo[hid][hEnterPos][3] = 89.5674;
  949. hInfo[hid][hPickupP][0] = 0.0;
  950. hInfo[hid][hPickupP][1] = 0.0;
  951. hInfo[hid][hPickupP][2] = 0.0;
  952. hInfo[hid][ExitCPPos][0] = 2465.7527;
  953. hInfo[hid][ExitCPPos][1] = -1697.9935;
  954. hInfo[hid][ExitCPPos][2] = 1013.5078;
  955. hInfo[hid][MoneyStore] = 0;
  956. format(hInfo[hid][hNotes], 256, "None");
  957.  
  958. fremove(HousePath(hid));
  959.  
  960. DestroyDynamicCP(hInfo[hid][hCP]);
  961. DestroyDynamicPickup(hInfo[hid][hPickup]);
  962. DestroyDynamicMapIcon(hInfo[hid][hMapIcon]);
  963. DestroyDynamic3DTextLabel(hInfo[hid][hLabel]);
  964.  
  965. format(string, sizeof(string), "<!> HouseID %d has been successfully removed.", hid);
  966. SendClientMessage(playerid, COLOR_RED, string);
  967.  
  968. printf("...HouseID %d removed - JakHouse log", hid);
  969. return 1;
  970. }
  971.  
  972. CMD:buyhouse(playerid, params[])
  973. {
  974. new
  975. string[128]
  976. ;
  977.  
  978. new i = h_ID[playerid];
  979.  
  980. if(i == -1) return SendClientMessage(playerid, COLOR_RED, "<!> You are not near any house.");
  981. if(IsPlayerInRangeOfPoint(playerid, 1.5, hInfo[i][hPickupP][0], hInfo[i][hPickupP][1], hInfo[i][hPickupP][2]))
  982. {
  983. if(hInfo[i][hSale] == 1) return SendClientMessage(playerid, COLOR_RED, "<!> This house isn't for sale.");
  984. if(GetPlayerMoney(playerid) < hInfo[i][hPrice]) return SendClientMessage(playerid, COLOR_RED, "<!> You don't have enough money to buy this house!");
  985. if(GetPlayerScore(playerid) < hInfo[i][hLevel]) return SendClientMessage(playerid, COLOR_RED, "<!> You don't have enough score to buy this house!");
  986. if(jpInfo[playerid][OwnedHouses] == 1) return SendClientMessage(playerid, COLOR_RED, "<!> You already owned a house, You can't buy another one.");
  987.  
  988. jpInfo[playerid][OwnedHouses] = 1;
  989.  
  990. jpInfo[playerid][p_SpawnPoint][0] = hInfo[i][hEnterPos][0];
  991. jpInfo[playerid][p_SpawnPoint][1] = hInfo[i][hEnterPos][1];
  992. jpInfo[playerid][p_SpawnPoint][2] = hInfo[i][hEnterPos][2];
  993. jpInfo[playerid][p_SpawnPoint][3] = hInfo[i][hEnterPos][3];
  994. jpInfo[playerid][p_Interior] = hInfo[i][hInterior];
  995.  
  996. hInfo[i][hSale] = 1;
  997. hInfo[i][hLocked] = 0;
  998. format(hInfo[i][hOwner], 256, "%s", p_Name(playerid));
  999. GivePlayerMoney(playerid, -hInfo[i][hPrice]);
  1000. format(string, 128, "You have bought this house for $%d.", hInfo[i][hPrice]);
  1001. SendClientMessage(playerid, COLOR_YELLOW, string);
  1002.  
  1003. SaveHouse(i);
  1004.  
  1005. DestroyDynamicCP(hInfo[i][hCP]);
  1006. DestroyDynamicPickup(hInfo[i][hPickup]);
  1007. DestroyDynamicMapIcon(hInfo[i][hMapIcon]);
  1008. DestroyDynamic3DTextLabel(hInfo[i][hLabel]);
  1009.  
  1010. LoadHouse(i);
  1011. }
  1012. else
  1013. {
  1014. SendClientMessage(playerid, COLOR_RED, "<!> You are not near any house.");
  1015. }
  1016. return 1;
  1017. }
  1018.  
  1019. CMD:asellhouse(playerid, params[])
  1020. {
  1021. new
  1022. string[128]
  1023. ;
  1024.  
  1025. new id;
  1026. if(sscanf(params, "i", id)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /asellhouse <houseid>");
  1027. if(!fexist(HousePath(id))) return SendClientMessage(playerid, COLOR_RED, "<!> House Slot do not exists.");
  1028.  
  1029. format(string, 128, "You have admin-sold this house for $%d, The money wasn't given to you, given to the owner instead.", hInfo[id][hPrice]);
  1030. SendClientMessage(playerid, -1, string);
  1031. format(string, 128, "The house safe also has $%d which was given to the owner.", hInfo[id][MoneyStore]);
  1032. SendClientMessage(playerid, -1, string);
  1033.  
  1034. foreach(new i : Player)
  1035. {
  1036. if(strcmp(p_Name(playerid), hInfo[id][hOwner], true) == 0)
  1037. {
  1038. jpInfo[i][OwnedHouses] = 0;
  1039. jpInfo[i][p_SpawnPoint][0] = 0.0;
  1040. jpInfo[i][p_SpawnPoint][1] = 0.0;
  1041. jpInfo[i][p_SpawnPoint][2] = 0.0;
  1042. jpInfo[i][p_SpawnPoint][3] = 0.0;
  1043. jpInfo[i][p_Interior] = 0;
  1044. jpInfo[i][p_Spawn] = 0;
  1045.  
  1046. GivePlayerMoney(i, hInfo[id][hPrice]);
  1047. GivePlayerMoney(i, hInfo[id][MoneyStore]);
  1048. format(string, sizeof(string), "You received a $%d (Including House Safe), Admin %s has sold your house.", hInfo[id][hPrice]+hInfo[id][MoneyStore], p_Name(playerid));
  1049. //Var MoneyStore plus hPrice = Total $%d, Nothing was added if MoneyStore is 0.
  1050. SendClientMessage(i, COLOR_YELLOW, string);
  1051. SendClientMessage(playerid, COLOR_GREEN, "The owner is online, the money was received.");
  1052. }
  1053. }
  1054.  
  1055. new file[128];
  1056. format(file, sizeof(file), USER_PATH, hInfo[id][hOwner]);
  1057. dini_IntSet(file, "Houses", jpInfo[playerid][OwnedHouses]=0);
  1058. dini_FloatSet(file, "X", jpInfo[playerid][p_SpawnPoint][0]=0.0);
  1059. dini_FloatSet(file, "Y", jpInfo[playerid][p_SpawnPoint][1]=0.0);
  1060. dini_FloatSet(file, "Z", jpInfo[playerid][p_SpawnPoint][2]=0.0);
  1061. dini_FloatSet(file, "A", jpInfo[playerid][p_SpawnPoint][3]=0.0);
  1062. dini_IntSet(file, "Interior", jpInfo[playerid][p_Interior]=0);
  1063. dini_IntSet(file, "Spawn", jpInfo[playerid][p_Spawn]=0);
  1064.  
  1065. hInfo[id][hSale] = 0;
  1066. hInfo[id][hLocked] = 1;
  1067. format(hInfo[id][hOwner], 256, "None");
  1068. format(hInfo[id][hName], 256, "None");
  1069. hInfo[id][MoneyStore] = 0;
  1070.  
  1071. SaveHouse(id);
  1072.  
  1073. DestroyDynamicCP(hInfo[id][hCP]);
  1074. DestroyDynamicPickup(hInfo[id][hPickup]);
  1075. DestroyDynamicMapIcon(hInfo[id][hMapIcon]);
  1076. DestroyDynamic3DTextLabel(hInfo[id][hLabel]);
  1077.  
  1078. LoadHouse(id);
  1079. return 1;
  1080. }
  1081.  
  1082. CMD:sellhouse(playerid, params[])
  1083. {
  1084. new
  1085. string[128]
  1086. ;
  1087.  
  1088. new i = h_ID[playerid];
  1089.  
  1090. if(i == -1) return SendClientMessage(playerid, COLOR_RED, "<!> You are not near any house.");
  1091. if(h_Inside[playerid] == -1)
  1092. {
  1093. if(IsPlayerInRangeOfPoint(playerid, 1.5, hInfo[i][hPickupP][0], hInfo[i][hPickupP][1], hInfo[i][hPickupP][2]))
  1094. {
  1095. if(hInfo[i][hSale] == 0) return SendClientMessage(playerid, COLOR_RED, "<!> This house is already for sale.");
  1096. if(strcmp(hInfo[i][hOwner], p_Name(playerid), true) == 0)
  1097. {
  1098. jpInfo[playerid][OwnedHouses] = 0;
  1099. jpInfo[playerid][p_SpawnPoint][0] = 0.0;
  1100. jpInfo[playerid][p_SpawnPoint][1] = 0.0;
  1101. jpInfo[playerid][p_SpawnPoint][2] = 0.0;
  1102. jpInfo[playerid][p_SpawnPoint][3] = 0.0;
  1103. jpInfo[playerid][p_Interior] = 0;
  1104. jpInfo[playerid][p_Spawn] = 0;
  1105.  
  1106. hInfo[i][hSale] = 0;
  1107. hInfo[i][hLocked] = 1;
  1108. format(hInfo[i][hOwner], 256, "None");
  1109. format(hInfo[i][hName], 256, "None");
  1110. GivePlayerMoney(playerid, hInfo[i][hPrice]);
  1111. GivePlayerMoney(playerid, hInfo[i][MoneyStore]);
  1112. format(string, 128, "You have sold this house for $%d.", hInfo[i][hPrice]);
  1113. SendClientMessage(playerid, COLOR_YELLOW, string);
  1114. format(string, 128, "You have also got $%d from your house safe.", hInfo[i][MoneyStore]);
  1115. SendClientMessage(playerid, -1, string);
  1116. hInfo[i][MoneyStore] = 0;
  1117.  
  1118. SaveHouse(i);
  1119.  
  1120. DestroyDynamicCP(hInfo[i][hCP]);
  1121. DestroyDynamicPickup(hInfo[i][hPickup]);
  1122. DestroyDynamicMapIcon(hInfo[i][hMapIcon]);
  1123. DestroyDynamic3DTextLabel(hInfo[i][hLabel]);
  1124.  
  1125. LoadHouse(i);
  1126. }
  1127. else
  1128. {
  1129. SendClientMessage(playerid, COLOR_RED, "<!> You do not own the house.");
  1130. }
  1131. }
  1132. else
  1133. {
  1134. SendClientMessage(playerid, COLOR_RED, "<!> You are not near any house.");
  1135. }
  1136. }
  1137. else
  1138. {
  1139. if(hInfo[i][hSale] == 0) return SendClientMessage(playerid, COLOR_RED, "<!> This house is already for sale.");
  1140. if(strcmp(hInfo[i][hOwner], p_Name(playerid), true) == 0)
  1141. {
  1142. jpInfo[playerid][OwnedHouses] = 0;
  1143. jpInfo[playerid][p_SpawnPoint][0] = 0.0;
  1144. jpInfo[playerid][p_SpawnPoint][1] = 0.0;
  1145. jpInfo[playerid][p_SpawnPoint][2] = 0.0;
  1146. jpInfo[playerid][p_SpawnPoint][3] = 0.0;
  1147. jpInfo[playerid][p_Interior] = 0;
  1148. jpInfo[playerid][p_Spawn] = 0;
  1149.  
  1150. hInfo[i][hSale] = 0;
  1151. hInfo[i][hLocked] = 1;
  1152. format(hInfo[i][hOwner], 256, "None");
  1153. format(hInfo[i][hName], 256, "None");
  1154. GivePlayerMoney(playerid, hInfo[i][hPrice]);
  1155. format(string, 128, "You have sold this house for $%d.", hInfo[i][hPrice]);
  1156. SendClientMessage(playerid, COLOR_YELLOW, string);
  1157. GivePlayerMoney(playerid, hInfo[i][MoneyStore]);
  1158. format(string, 128, "You have also got $%d from your house safe.", hInfo[i][MoneyStore]);
  1159. SendClientMessage(playerid, -1, string);
  1160. hInfo[i][MoneyStore] = 0;
  1161.  
  1162. SaveHouse(i);
  1163.  
  1164. DestroyDynamicCP(hInfo[i][hCP]);
  1165. DestroyDynamicPickup(hInfo[i][hPickup]);
  1166. DestroyDynamicMapIcon(hInfo[i][hMapIcon]);
  1167. DestroyDynamic3DTextLabel(hInfo[i][hLabel]);
  1168.  
  1169. LoadHouse(i);
  1170. }
  1171. else
  1172. {
  1173. SendClientMessage(playerid, COLOR_RED, "<!> You do not own the house.");
  1174. }
  1175. }
  1176. return 1;
  1177. }
  1178.  
  1179. CMD:henter(playerid, params[])
  1180. {
  1181. new i = h_ID[playerid];
  1182.  
  1183. if(i == -1) return SendClientMessage(playerid, COLOR_RED, "<!> You are not near any house.");
  1184. if(IsPlayerInRangeOfPoint(playerid, 1.5, hInfo[i][hPickupP][0], hInfo[i][hPickupP][1], hInfo[i][hPickupP][2]))
  1185. {
  1186. if(hInfo[i][hLocked] == 1) return SendClientMessage(playerid, COLOR_RED, "<!> House is locked!");
  1187. #if FREEZE_LOAD == true
  1188. House_Load(playerid);
  1189.  
  1190. SetPlayerPos(playerid, hInfo[i][hEnterPos][0], hInfo[i][hEnterPos][1], hInfo[i][hEnterPos][2]);
  1191. SetPlayerFacingAngle(playerid, hInfo[i][hEnterPos][3]);
  1192. SetPlayerInterior(playerid, hInfo[i][hInterior]);
  1193. SetPlayerVirtualWorld(playerid, hInfo[i][hWorld]);
  1194. #else
  1195. SetPlayerPos(playerid, hInfo[i][hEnterPos][0], hInfo[i][hEnterPos][1], hInfo[i][hEnterPos][2]);
  1196. SetPlayerFacingAngle(playerid, hInfo[i][hEnterPos][3]);
  1197. SetPlayerInterior(playerid, hInfo[i][hInterior]);
  1198. SetPlayerVirtualWorld(playerid, hInfo[i][hWorld]);
  1199. #endif
  1200.  
  1201. h_Inside[playerid] = i;
  1202. }
  1203. else
  1204. {
  1205. SendClientMessage(playerid, COLOR_RED, "<!> You are not near any house.");
  1206. }
  1207. return 1;
  1208. }
  1209.  
  1210. CMD:hlock(playerid, params[])
  1211. {
  1212. new i = h_ID[playerid];
  1213.  
  1214. if(i == -1) return SendClientMessage(playerid, COLOR_RED, "<!> You are not near any house.");
  1215. if(h_Inside[playerid] == -1)
  1216. {
  1217. if(IsPlayerInRangeOfPoint(playerid, 1.5, hInfo[i][hPickupP][0], hInfo[i][hPickupP][1], hInfo[i][hPickupP][2]))
  1218. {
  1219. if(strcmp(hInfo[i][hOwner], p_Name(playerid), true) == 0)
  1220. {
  1221. if(hInfo[i][hLocked] == 0)
  1222. {
  1223. hInfo[i][hLocked] = 1;
  1224. SendClientMessage(playerid, COLOR_RED, "You have locked your house.");
  1225. }
  1226. else if(hInfo[i][hLocked] == 1)
  1227. {
  1228. hInfo[i][hLocked] = 0;
  1229. SendClientMessage(playerid, COLOR_GREEN, "You have unlocked your house.");
  1230. }
  1231.  
  1232. SaveHouse(i);
  1233.  
  1234. DestroyDynamicCP(hInfo[i][hCP]);
  1235. DestroyDynamicPickup(hInfo[i][hPickup]);
  1236. DestroyDynamicMapIcon(hInfo[i][hMapIcon]);
  1237. DestroyDynamic3DTextLabel(hInfo[i][hLabel]);
  1238.  
  1239. LoadHouse(i);
  1240. }
  1241. else
  1242. {
  1243. SendClientMessage(playerid, COLOR_RED, "<!> You do not own the house.");
  1244. }
  1245. }
  1246. else
  1247. {
  1248. SendClientMessage(playerid, COLOR_RED, "<!> You are not near any house.");
  1249. }
  1250. }
  1251. else
  1252. {
  1253. if(strcmp(hInfo[i][hOwner], p_Name(playerid), true) == 0)
  1254. {
  1255. if(hInfo[i][hLocked] == 0)
  1256. {
  1257. hInfo[i][hLocked] = 1;
  1258. SendClientMessage(playerid, COLOR_RED, "You have locked your house.");
  1259. }
  1260. else if(hInfo[i][hLocked] == 1)
  1261. {
  1262. hInfo[i][hLocked] = 0;
  1263. SendClientMessage(playerid, COLOR_GREEN, "You have unlocked your house.");
  1264. }
  1265.  
  1266. SaveHouse(i);
  1267.  
  1268. DestroyDynamicCP(hInfo[i][hCP]);
  1269. DestroyDynamicPickup(hInfo[i][hPickup]);
  1270. DestroyDynamicMapIcon(hInfo[i][hMapIcon]);
  1271. DestroyDynamic3DTextLabel(hInfo[i][hLabel]);
  1272.  
  1273. LoadHouse(i);
  1274. }
  1275. else
  1276. {
  1277. SendClientMessage(playerid, COLOR_RED, "<!> You do not own the house.");
  1278. }
  1279. }
  1280. return 1;
  1281. }
  1282.  
  1283. CMD:hnote(playerid, params[])
  1284. {
  1285. new i = h_ID[playerid];
  1286. new string[128], note[128];
  1287.  
  1288. if(i == -1) return SendClientMessage(playerid, COLOR_RED, "<!> You are not near any house.");
  1289. if(h_Inside[playerid] == -1)
  1290. {
  1291. if(IsPlayerInRangeOfPoint(playerid, 1.5, hInfo[i][hPickupP][0], hInfo[i][hPickupP][1], hInfo[i][hPickupP][2]))
  1292. {
  1293. if(strcmp(hInfo[i][hOwner], p_Name(playerid), true) == 0)
  1294. {
  1295. if(sscanf(params, "s[128]", note)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /hnote <note>");
  1296.  
  1297. format(hInfo[i][hNotes], 256, "%s", note);
  1298.  
  1299. SaveHouse(i);
  1300.  
  1301. DestroyDynamicCP(hInfo[i][hCP]);
  1302. DestroyDynamicPickup(hInfo[i][hPickup]);
  1303. DestroyDynamicMapIcon(hInfo[i][hMapIcon]);
  1304. DestroyDynamic3DTextLabel(hInfo[i][hLabel]);
  1305.  
  1306. LoadHouse(i);
  1307.  
  1308. format(string, sizeof(string), "You have replaced the old notes with a new one: %s", note);
  1309. SendClientMessage(playerid, -1, string);
  1310. }
  1311. else
  1312. {
  1313. SendClientMessage(playerid, COLOR_RED, "<!> You do not own the house.");
  1314. }
  1315. }
  1316. else
  1317. {
  1318. SendClientMessage(playerid, COLOR_RED, "<!> You are not near any house.");
  1319. }
  1320. }
  1321. else
  1322. {
  1323. if(strcmp(hInfo[i][hOwner], p_Name(playerid), true) == 0)
  1324. {
  1325. if(sscanf(params, "s[128]", note)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /hnote <note>");
  1326.  
  1327. format(hInfo[i][hNotes], 256, "%s", note);
  1328.  
  1329. SaveHouse(i);
  1330.  
  1331. DestroyDynamicCP(hInfo[i][hCP]);
  1332. DestroyDynamicPickup(hInfo[i][hPickup]);
  1333. DestroyDynamicMapIcon(hInfo[i][hMapIcon]);
  1334. DestroyDynamic3DTextLabel(hInfo[i][hLabel]);
  1335.  
  1336. LoadHouse(i);
  1337.  
  1338. format(string, sizeof(string), "You have replaced the old notes with a new one: %s", note);
  1339. SendClientMessage(playerid, -1, string);
  1340. }
  1341. else
  1342. {
  1343. SendClientMessage(playerid, COLOR_RED, "<!> You do not own the house.");
  1344. }
  1345. }
  1346. return 1;
  1347. }
  1348.  
  1349. CMD:hcnote(playerid, params[])
  1350. {
  1351. new i = h_ID[playerid];
  1352. new string[150];
  1353.  
  1354. if(i == -1) return SendClientMessage(playerid, COLOR_RED, "<!> You are not near any house.");
  1355. if(h_Inside[playerid] == -1)
  1356. {
  1357. if(IsPlayerInRangeOfPoint(playerid, 1.5, hInfo[i][hPickupP][0], hInfo[i][hPickupP][1], hInfo[i][hPickupP][2]))
  1358. {
  1359. if(strcmp(hInfo[i][hOwner], p_Name(playerid), true) == 0)
  1360. {
  1361. format(string, sizeof(string), "Note: %s", hInfo[i][hNotes]);
  1362. SendClientMessage(playerid, COLOR_RED, string);
  1363. }
  1364. else
  1365. {
  1366. SendClientMessage(playerid, COLOR_RED, "<!> You do not own the house.");
  1367. }
  1368. }
  1369. else
  1370. {
  1371. SendClientMessage(playerid, COLOR_RED, "<!> You are not near any house.");
  1372. }
  1373. }
  1374. else
  1375. {
  1376. if(strcmp(hInfo[i][hOwner], p_Name(playerid), true) == 0)
  1377. {
  1378. format(string, sizeof(string), "Note: %s", hInfo[i][hNotes]);
  1379. SendClientMessage(playerid, COLOR_RED, string);
  1380. }
  1381. else
  1382. {
  1383. SendClientMessage(playerid, COLOR_RED, "<!> You do not own the house.");
  1384. }
  1385. }
  1386. return 1;
  1387. }
  1388.  
  1389. CMD:hmenu(playerid, params[])
  1390. {
  1391. new i = h_ID[playerid];
  1392.  
  1393. if(i == -1) return SendClientMessage(playerid, COLOR_RED, "<!> You are not near any house.");
  1394. if(h_Inside[playerid] == -1)
  1395. {
  1396. if(IsPlayerInRangeOfPoint(playerid, 1.5, hInfo[i][hPickupP][0], hInfo[i][hPickupP][1], hInfo[i][hPickupP][2]))
  1397. {
  1398. if(strcmp(hInfo[i][hOwner], p_Name(playerid), true) == 0)
  1399. {
  1400. ShowPlayerDialog(playerid, DIALOG_HMENU, DIALOG_STYLE_LIST, ""red"House Configuration",\
  1401. ""yellow"House Name\n"green"House Price ($)\n"yellow"Store Cash ($)\n"green"Withdraw Cash ($)\n"yellow"Storage Information\n"green"Virtual World\n"yellow"Interior\n"green"Spawn at Home", "Configure", "Cancel");
  1402. }
  1403. else
  1404. {
  1405. SendClientMessage(playerid, COLOR_RED, "<!> You do not own the house.");
  1406. }
  1407. }
  1408. else
  1409. {
  1410. SendClientMessage(playerid, COLOR_RED, "<!> You are not near any house.");
  1411. }
  1412. }
  1413. else
  1414. {
  1415. if(strcmp(hInfo[i][hOwner], p_Name(playerid), true) == 0)
  1416. {
  1417. ShowPlayerDialog(playerid, DIALOG_HMENU, DIALOG_STYLE_LIST, ""red"House Configuration",\
  1418. ""yellow"House Name\n"green"House Price ($)\n"yellow"Store Cash ($)\n"green"Withdraw Cash ($)\n"yellow"Storage Information\n"green"Virtual World\n"yellow"Interior\n"green"Spawn at Home", "Configure", "Cancel");
  1419. }
  1420. else
  1421. {
  1422. SendClientMessage(playerid, COLOR_RED, "<!> You do not own the house.");
  1423. }
  1424. }
  1425. return 1;
  1426. }
  1427.  
  1428. Float:GetDistance(Float: x1, Float: y1, Float: z1, Float: x2, Float: y2, Float: z2)
  1429. {
  1430. new Float:d;
  1431. d += floatpower(x1-x2, 2.0 );
  1432. d += floatpower(y1-y2, 2.0 );
  1433. d += floatpower(z1-z2, 2.0 );
  1434. d = floatsqroot(d);
  1435. return d;
  1436. }
  1437.  
  1438. CMD:hnear(playerid, params[])
  1439. {
  1440. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "<!> You are not a RCON Admin to use this command!");
  1441.  
  1442. new hcount=0;
  1443.  
  1444. SendClientMessage(playerid, COLOR_RED, "* Listing all JakHouses within 35 meters of you");
  1445.  
  1446. new Float:X, Float:Y, Float:Z;
  1447. new Float:X2, Float:Y2, Float:Z2;
  1448.  
  1449. GetPlayerPos(playerid, X2, Y2, Z2);
  1450.  
  1451. for(new i=0; i < MAX_HOUSES; i++)
  1452. {
  1453. X = hInfo[i][hPickupP][0];
  1454. Y = hInfo[i][hPickupP][1];
  1455. Z = hInfo[i][hPickupP][2];
  1456. if(IsPlayerInRangeOfPoint(playerid, 35, X, Y, Z))
  1457. {
  1458. hcount++;
  1459. new string[128];
  1460. format(string, sizeof(string), "(%d) Owned by %s - Price: $%d | %f from you", i, hInfo[i][hOwner], hInfo[i][hPrice], GetDistance(X, Y, Z, X2, Y2, Z2));
  1461. SendClientMessage(playerid, COLOR_WHITE, string);
  1462. }
  1463. }
  1464.  
  1465. if(hcount==0) return SendClientMessage(playerid, -1, "No houses found nearby you.");
  1466. else
  1467. {
  1468. new str[128];
  1469. format(str, sizeof(str), "There are "green"%d "white"houses founded on your position.", hcount);
  1470. SendClientMessage(playerid, -1, str);
  1471. }
  1472. return 1;
  1473. }
  1474.  
  1475. //
  1476. //============================================================================//
  1477. // Stocks
  1478.  
  1479. forward HouseUnload(playerid);
  1480. public HouseUnload(playerid)
  1481. {
  1482. SetCameraBehindPlayer(playerid);
  1483. GameTextForPlayer(playerid, "~g~Loaded!", 2500, 3);
  1484. return TogglePlayerControllable(playerid, 1);
  1485. }
  1486.  
  1487. stock House_Load(playerid)
  1488. {
  1489. TogglePlayerControllable(playerid, 0);
  1490. SetCameraBehindPlayer(playerid);
  1491. GameTextForPlayer(playerid, "~w~Loading...", 1000*FREEZE_TIME, 3);
  1492. return SetTimerEx("HouseUnload", 1000*FREEZE_TIME, false, "d", playerid);
  1493. }
  1494.  
  1495. stock Player_Save(playerid)
  1496. {
  1497. dini_IntSet(PlayerPath(playerid), "Houses", jpInfo[playerid][OwnedHouses]);
  1498. dini_FloatSet(PlayerPath(playerid), "X", jpInfo[playerid][p_SpawnPoint][0]);
  1499. dini_FloatSet(PlayerPath(playerid), "Y", jpInfo[playerid][p_SpawnPoint][1]);
  1500. dini_FloatSet(PlayerPath(playerid), "Z", jpInfo[playerid][p_SpawnPoint][2]);
  1501. dini_FloatSet(PlayerPath(playerid), "A", jpInfo[playerid][p_SpawnPoint][3]);
  1502. dini_IntSet(PlayerPath(playerid), "Interior", jpInfo[playerid][p_Interior]);
  1503. dini_IntSet(PlayerPath(playerid), "Spawn", jpInfo[playerid][p_Spawn]);
  1504. return 1;
  1505. }
  1506. stock Player_Load(playerid)
  1507. {
  1508. jpInfo[playerid][OwnedHouses] = dini_Int(PlayerPath(playerid), "Houses");
  1509. jpInfo[playerid][p_SpawnPoint][0] = dini_Float(PlayerPath(playerid), "X");
  1510. jpInfo[playerid][p_SpawnPoint][1] = dini_Float(PlayerPath(playerid), "Y");
  1511. jpInfo[playerid][p_SpawnPoint][2] = dini_Float(PlayerPath(playerid), "Z");
  1512. jpInfo[playerid][p_SpawnPoint][3] = dini_Float(PlayerPath(playerid), "A");
  1513. jpInfo[playerid][p_Interior] = dini_Int(PlayerPath(playerid), "Interior");
  1514. jpInfo[playerid][p_Spawn] = dini_Int(PlayerPath(playerid), "Spawn");
  1515. return 1;
  1516. }
  1517.  
  1518. stock isnumeric(str[])
  1519. {
  1520. new
  1521. ch,
  1522. i;
  1523. while ((ch = str[i++])) if (!('0' <= ch <= '9')) return 0;
  1524. return 1;
  1525. }
  1526.  
  1527. stock p_Name(playerid)
  1528. {
  1529. new pName[24];
  1530. GetPlayerName(playerid, pName, 24);
  1531. return pName;
  1532. }
  1533.  
  1534. stock SaveHouse(houseid)
  1535. {
  1536. dini_Set(HousePath(houseid), "Name", hInfo[houseid][hName]);
  1537. dini_Set(HousePath(houseid), "Owner", hInfo[houseid][hOwner]);
  1538. dini_Set(HousePath(houseid), "InteriorName", hInfo[houseid][hIName]);
  1539. dini_Set(HousePath(houseid), "Notes", hInfo[houseid][hNotes]);
  1540. dini_IntSet(HousePath(houseid), "Level", hInfo[houseid][hLevel]);
  1541. dini_IntSet(HousePath(houseid), "Price", hInfo[houseid][hPrice]);
  1542. dini_IntSet(HousePath(houseid), "Sale", hInfo[houseid][hSale]);
  1543. dini_IntSet(HousePath(houseid), "Interior", hInfo[houseid][hInterior]);
  1544. dini_IntSet(HousePath(houseid), "World", hInfo[houseid][hWorld]);
  1545. dini_IntSet(HousePath(houseid), "Locked", hInfo[houseid][hLocked]);
  1546. dini_FloatSet(HousePath(houseid), "xPoint", hInfo[houseid][hEnterPos][0]);
  1547. dini_FloatSet(HousePath(houseid), "yPoint", hInfo[houseid][hEnterPos][1]);
  1548. dini_FloatSet(HousePath(houseid), "zPoint", hInfo[houseid][hEnterPos][2]);
  1549. dini_FloatSet(HousePath(houseid), "aPoint", hInfo[houseid][hEnterPos][3]);
  1550. dini_FloatSet(HousePath(houseid), "enterX", hInfo[houseid][hPickupP][0]);
  1551. dini_FloatSet(HousePath(houseid), "enterY", hInfo[houseid][hPickupP][1]);
  1552. dini_FloatSet(HousePath(houseid), "enterZ", hInfo[houseid][hPickupP][2]);
  1553. dini_FloatSet(HousePath(houseid), "exitX", hInfo[houseid][ExitCPPos][0]);
  1554. dini_FloatSet(HousePath(houseid), "exitY", hInfo[houseid][ExitCPPos][1]);
  1555. dini_FloatSet(HousePath(houseid), "exitZ", hInfo[houseid][ExitCPPos][2]);
  1556. dini_IntSet(HousePath(houseid), "MoneySafe", hInfo[houseid][MoneyStore]);
  1557. printf("... House ID %d from JakHouse has been saved.", houseid);
  1558. return 1;
  1559. }
  1560.  
  1561. stock LoadHouse(houseid)
  1562. {
  1563. format(hInfo[houseid][hName], 256, "%s", dini_Get(HousePath(houseid), "Name"));
  1564. format(hInfo[houseid][hOwner], 256, "%s", dini_Get(HousePath(houseid), "Owner"));
  1565. format(hInfo[houseid][hIName], 256, "%s", dini_Get(HousePath(houseid), "InteriorName"));
  1566. format(hInfo[houseid][hNotes], 256, "%s", dini_Get(HousePath(houseid), "Notes"));
  1567. hInfo[houseid][hLevel] = dini_Int(HousePath(houseid), "Level");
  1568. hInfo[houseid][hPrice] = dini_Int(HousePath(houseid), "Price");
  1569. hInfo[houseid][hSale] = dini_Int(HousePath(houseid), "Sale");
  1570. hInfo[houseid][hInterior] = dini_Int(HousePath(houseid), "Interior");
  1571. hInfo[houseid][hWorld] = dini_Int(HousePath(houseid), "World");
  1572. hInfo[houseid][hLocked] = dini_Int(HousePath(houseid), "Locked");
  1573. hInfo[houseid][hEnterPos][0] = dini_Float(HousePath(houseid), "xPoint");
  1574. hInfo[houseid][hEnterPos][1] = dini_Float(HousePath(houseid), "yPoint");
  1575. hInfo[houseid][hEnterPos][2] = dini_Float(HousePath(houseid), "zPoint");
  1576. hInfo[houseid][hEnterPos][3] = dini_Float(HousePath(houseid), "aPoint");
  1577. hInfo[houseid][hPickupP][0] = dini_Float(HousePath(houseid), "enterX");
  1578. hInfo[houseid][hPickupP][1] = dini_Float(HousePath(houseid), "enterY");
  1579. hInfo[houseid][hPickupP][2] = dini_Float(HousePath(houseid), "enterZ");
  1580. hInfo[houseid][ExitCPPos][0] = dini_Float(HousePath(houseid), "exitX");
  1581. hInfo[houseid][ExitCPPos][1] = dini_Float(HousePath(houseid), "exitY");
  1582. hInfo[houseid][ExitCPPos][2] = dini_Float(HousePath(houseid), "exitZ");
  1583. hInfo[houseid][MoneyStore] = dini_Int(HousePath(houseid), "MoneySafe");
  1584.  
  1585. new string[256];
  1586.  
  1587. if(hInfo[houseid][hSale] == 0)
  1588. {
  1589. format(string, 256, ""white"HouseID: "red"%d\n"green"House for Sale!\n"white"Price: "red"$%d\n"white"Interior: "green"%s\n"white"Level: "red"%d\n\n"white"/buyhouse to buy the house.", houseid, hInfo[houseid][hPrice], hInfo[houseid][hIName], hInfo[houseid][hLevel]);
  1590. hInfo[houseid][hMapIcon] = CreateDynamicMapIcon(hInfo[houseid][hPickupP][0], hInfo[houseid][hPickupP][1], hInfo[houseid][hPickupP][2], SALE_ICON, -1, 0, 0, -1, STREAM_DISTANCES, MAPICON_LOCAL);
  1591. hInfo[houseid][hPickup] = CreateDynamicPickup(SALE_PICKUP, 1, hInfo[houseid][hPickupP][0], hInfo[houseid][hPickupP][1], hInfo[houseid][hPickupP][2], 0, 0, -1, STREAM_DISTANCES);
  1592. }
  1593. else
  1594. {
  1595. if(hInfo[houseid][hLocked] == 0)
  1596. {
  1597. if(strcmp(hInfo[houseid][hName], "None", true) == 0)
  1598. {
  1599. format(string, 256, ""white"HouseID: "red"%d\n"green"Unlock\n"white"House Own by: "red"%s\n"white"Interior: "green"%s\n"white"Level: "red"%d\n"white"Price: "green"$%d\n\n"white"Type /henter to enter inside.", houseid, hInfo[houseid][hOwner], hInfo[houseid][hIName], hInfo[houseid][hLevel], hInfo[houseid][hPrice]);
  1600. }
  1601. else
  1602. {
  1603. format(string, 256, ""white"HouseID: "red"%d\n"green"Unlock\n"white"House Own by: "red"%s\n"white"Name: "green"%s\n"white"Interior: "red"%s\n"white"Level: "red"%d\n"white"Price: "green"$%d\n\n"white"Type /henter to enter inside.", houseid, hInfo[houseid][hOwner], hInfo[houseid][hName], hInfo[houseid][hIName], hInfo[houseid][hLevel], hInfo[houseid][hPrice]);
  1604. }
  1605. }
  1606. else
  1607. {
  1608. if(strcmp(hInfo[houseid][hName], "None", true) == 0)
  1609. {
  1610. format(string, 256, ""white"HouseID: "red"%d\n"red"Locked\n"white"House Own by: "red"%s\n"white"Interior: "green"%s\n"white"Level: "red"%d\n"white"Price: "green"$%d\n\n"white"Type /henter to enter inside.", houseid, hInfo[houseid][hOwner], hInfo[houseid][hIName], hInfo[houseid][hLevel], hInfo[houseid][hPrice]);
  1611. }
  1612. else
  1613. {
  1614. format(string, 256, ""white"HouseID: "red"%d\n"red"Locked\n"white"House Own by: "red"%s\n"white"Name: "green"%s\n"white"Interior: "red"%s\n"white"Level: "red"%d\n"white"Price: "green"$%d\n\n"white"Type /henter to enter inside.", houseid, hInfo[houseid][hOwner], hInfo[houseid][hName], hInfo[houseid][hIName], hInfo[houseid][hLevel], hInfo[houseid][hPrice]);
  1615. }
  1616. }
  1617. hInfo[houseid][hMapIcon] = CreateDynamicMapIcon(hInfo[houseid][hPickupP][0], hInfo[houseid][hPickupP][1], hInfo[houseid][hPickupP][2], NOTSALE_ICON, -1, 0, 0, -1, STREAM_DISTANCES, MAPICON_LOCAL);
  1618. hInfo[houseid][hPickup] = CreateDynamicPickup(NOTSALE_PICKUP, 1, hInfo[houseid][hPickupP][0], hInfo[houseid][hPickupP][1], hInfo[houseid][hPickupP][2], 0, 0, -1, STREAM_DISTANCES);
  1619. }
  1620. hInfo[houseid][hLabel] = CreateDynamic3DTextLabel(string, -1, hInfo[houseid][hPickupP][0], hInfo[houseid][hPickupP][1], hInfo[houseid][hPickupP][2], STREAM_DISTANCES, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, 0, -1, STREAM_DISTANCES);
  1621. hInfo[houseid][hCP] = CreateDynamicCP(hInfo[houseid][ExitCPPos][0], hInfo[houseid][ExitCPPos][1], hInfo[houseid][ExitCPPos][2], 1.0, hInfo[houseid][hWorld], hInfo[houseid][hInterior], -1, 15.0);
  1622. return 1;
  1623. }
  1624.  
  1625. stock HousePath(houseid)
  1626. {
  1627. new hfile[128];
  1628. format(hfile, 128, HOUSE_PATH, houseid);
  1629. return hfile;
  1630. }
  1631.  
  1632. stock PlayerPath(playerid)
  1633. {
  1634. new pfile[128];
  1635. format(pfile, 128, USER_PATH, p_Name(playerid));
  1636. return pfile;
  1637. }
  1638.  
  1639. //
  1640. //============================================================================//
  1641. //
  1642.  
  1643. //EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement