Guest User

h-House [Dynamic House System] 0.3z

a guest
Feb 5th, 2015
1,751
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.43 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <sscanf2>
  4. #include <Dini>
  5.  
  6. //------------------------------------------------------------------------------
  7.  
  8. #define MAX_HOUSES 1000
  9.  
  10. //------------------------------------------------------------------------------
  11.  
  12. #define DIALOG_EDITID 300
  13. #define DIALOG_EDIT 301
  14. #define DIALOG_EDITPRICE 302
  15. #define DIALOG_EDITINTERIOR 303
  16.  
  17. //------------------------------------------------------------------------------
  18.  
  19. enum hInfo
  20. {
  21. hPrice,
  22. hInterior,
  23. hOwned,
  24. hLocked,
  25. hPick,
  26. Text3D:hLabel,
  27. hOwner[MAX_PLAYER_NAME],
  28. Float:hX,
  29. Float:hY,
  30. Float:hZ,
  31. Float:hEnterX,
  32. Float:hEnterY,
  33. Float:hEnterZ
  34. }
  35.  
  36. //------------------------------------------------------------------------------
  37.  
  38. new HouseInfo[MAX_HOUSES][hInfo];
  39. new houseid;
  40. new InHouse[MAX_PLAYERS][MAX_HOUSES];
  41. new hid;
  42.  
  43. //------------------------------------------------------------------------------
  44.  
  45. CMD:createhouse(playerid, params[])
  46. {
  47. new Price, Level, string[144], Float:X, Float:Y, Float:Z, labelstring[144], file[50];
  48. GetPlayerPos(playerid, X, Y, Z);
  49. if(sscanf(params, "ii", Price, Level)) return SendClientMessage(playerid, -1, "{FF0000}USAGE: {FFFFFF}/CreateHouse [Price] [Level]");
  50. if(Price > 1000000 || Price < 1) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}Invalid Price. [1 - 10,000,000]");
  51. if(Level > 5 || Level < 1) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}Invalid Level. [1 - 5]");
  52. if(Level == 1)
  53. {
  54. HouseInfo[houseid][hEnterX] = 2237.590087;
  55. HouseInfo[houseid][hEnterY] = -1078.869995;
  56. HouseInfo[houseid][hEnterZ] = 1049.023437;
  57. HouseInfo[houseid][hInterior] = 2;
  58. SendClientMessage(playerid, -1, "{FF0000}[HOUSE]: {FFFFFF}House Interior setted. {FF0000}#1.");
  59. }
  60. else if(Level == 2)
  61. {
  62. HouseInfo[houseid][hEnterX] = 2216.540039;
  63. HouseInfo[houseid][hEnterY] = -1076.290039;
  64. HouseInfo[houseid][hEnterZ] = 1050.484375;
  65. HouseInfo[houseid][hInterior] = 1;
  66. SendClientMessage(playerid, -1, "{FF0000}[HOUSE]: {FFFFFF}House Interior setted. {FF0000}#2.");
  67. }
  68. else if(Level == 3)
  69. {
  70. HouseInfo[houseid][hEnterX] = 2282.909912;
  71. HouseInfo[houseid][hEnterY] = -1137.971191;
  72. HouseInfo[houseid][hEnterZ] = 1050.898437;
  73. HouseInfo[houseid][hInterior] = 11;
  74. SendClientMessage(playerid, -1, "{FF0000}[HOUSE]: {FFFFFF}House Interior setted. {FF0000}#3.");
  75. }
  76. else if(Level == 4)
  77. {
  78. HouseInfo[houseid][hEnterX] = 2365.300048;
  79. HouseInfo[houseid][hEnterY] = -1132.920043;
  80. HouseInfo[houseid][hEnterZ] = 1050.875000;
  81. HouseInfo[houseid][hInterior] = 8;
  82. SendClientMessage(playerid, -1, "{FF0000}[HOUSE]: {FFFFFF}House Interior setted. {FF0000}#4.");
  83. }
  84. else if(Level == 5)
  85. {
  86. HouseInfo[houseid][hEnterX] = 1299.079956;
  87. HouseInfo[houseid][hEnterY] = -795.226989;
  88. HouseInfo[houseid][hEnterZ] = 1084.007812;
  89. HouseInfo[houseid][hInterior] = 5;
  90. SendClientMessage(playerid, -1, "{FF0000}[HOUSE]: {FFFFFF}House Interior setted. {FF0000}#5.");
  91. }
  92. format(string, sizeof(string), "{FF0000}[HOUSE]: {FFFFFF}House ID: {FF0000}%d {FFFFFF}created.", houseid);
  93. SendClientMessage(playerid, -1, string);
  94. format(labelstring, sizeof(labelstring), "{15FF00}House ID: {FFFFFF}%d\n{15FF00}Status: {FFFFFF}For Sale\n{15FF00}Price: {FFFFFF}%d", houseid, Price);
  95. HouseInfo[houseid][hOwned] = 0;
  96. HouseInfo[houseid][hX] = X;
  97. HouseInfo[houseid][hZ] = Z;
  98. HouseInfo[houseid][hY] = Y;
  99. HouseInfo[houseid][hPick] = CreatePickup(1273, 1, X, Y, Z, 0);
  100. HouseInfo[houseid][hLabel] = Create3DTextLabel(labelstring, 0xFFFFFFFF, X, Y, Z, 30.0, 0, 0);
  101. format(file, sizeof(file), "Houses/%d.ini", houseid);
  102. if(!fexist(file))
  103. {
  104. dini_Create(file);
  105. dini_IntSet(file, "Price", Price);
  106. dini_IntSet(file, "Interior", HouseInfo[houseid][hInterior]);
  107. dini_IntSet(file, "Level", Level);
  108. dini_IntSet(file, "Owned", 0);
  109. dini_FloatSet(file, "Position X", X);
  110. dini_FloatSet(file, "Position Y", Y);
  111. dini_FloatSet(file, "Position Z", Z);
  112. dini_FloatSet(file, "Enter X", HouseInfo[houseid][hEnterX]);
  113. dini_FloatSet(file, "Enter Y", HouseInfo[houseid][hEnterY]);
  114. dini_FloatSet(file, "Enter Z", HouseInfo[houseid][hEnterZ]);
  115. }
  116. houseid++;
  117. return 1;
  118. }
  119.  
  120. //------------------------------------------------------------------------------
  121.  
  122. CMD:buyhouse(playerid, params[])
  123. {
  124. new name[MAX_PLAYER_NAME], labelstring[144], string[144], file[50];
  125. GetPlayerName(playerid, name, sizeof(name));
  126. for(new i = 0; i < MAX_HOUSES; i++)
  127. {
  128. if(IsPlayerInRangeOfPoint(playerid, 5.0, HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ]))
  129. {
  130. if(HouseInfo[i][hOwned] == 1) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}This house have an Owner.");
  131. if(GetPlayerMoney(playerid) < HouseInfo[i][hPrice]) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}You don't have enough money.");
  132. DestroyPickup(HouseInfo[i][hPick]);
  133. format(labelstring, sizeof(labelstring), "{15FF00}House ID: {FFFFFF}%d\n{15FF00}Owner: {FFFFFF}%s\n{15FF00}Price: {FFFFFF}%d", i, name, HouseInfo[i][hPrice]);
  134. HouseInfo[i][hPick] = CreatePickup(1272, 1, HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ]);
  135. Update3DTextLabelText(HouseInfo[i][hLabel], 0xFFFFFFFF, labelstring);
  136. format(labelstring, sizeof(labelstring), "{FF0000}[HOUSE]: {FFFFFF}You bought house ID: {FF0000}%d {FFFFFF}for {FF0000}$ %d.", i, HouseInfo[i][hPrice]);
  137. SendClientMessage(playerid, -1, string);
  138. HouseInfo[i][hOwned] = 1;
  139. HouseInfo[i][hOwner] = name;
  140. format(file, sizeof(file), "Houses/%d.ini", i);
  141. if(fexist(file))
  142. {
  143. dini_IntSet(file, "Owned", 1);
  144. dini_Set(file, "Owner", name);
  145. }
  146. }
  147. }
  148. return 1;
  149. }
  150.  
  151. //------------------------------------------------------------------------------
  152.  
  153. CMD:sellhouse(playerid, params[])
  154. {
  155. new pname[MAX_PLAYER_NAME], labelstring[144], string[144], file[50];
  156. GetPlayerName(playerid, pname, sizeof(pname));
  157. for(new i = 0; i < MAX_HOUSES; i++)
  158. {
  159. if(IsPlayerInRangeOfPoint(playerid, 5.0, HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ]))
  160. {
  161. if(HouseInfo[i][hOwned] == 0) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}You cannot sell this house.");
  162. if(strcmp(pname, HouseInfo[i][hOwner], true)) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}You aren't Owner of this house.");
  163. format(labelstring, sizeof(labelstring), "{15FF00}House ID: {FFFFFF}%d\n{15FF00}Status: {FFFFFF}For Sale\n{15FF00}Price: {FFFFFF}%d", i, HouseInfo[i][hPrice]);
  164. DestroyPickup(HouseInfo[i][hPick]);
  165. HouseInfo[i][hPick] = CreatePickup(1273, 1, HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ], 0);
  166. Update3DTextLabelText(HouseInfo[i][hLabel], 0xFFFFFFFF, labelstring);
  167. format(string, sizeof(string), "{FF0000}[HOUSE]: {FFFFFF}You've sold your house: {FF0000}%d.", i);
  168. SendClientMessage(playerid, -1, string);
  169. HouseInfo[i][hOwned] = 0;
  170. HouseInfo[i][hOwner] = 0;
  171. format(file, sizeof(file), "Houses/%d.ini", i);
  172. if(fexist(file))
  173. {
  174. dini_IntSet(file, "Owned", 0);
  175. dini_Set(file, "Owner", " ");
  176. }
  177. }
  178. }
  179. return 1;
  180. }
  181.  
  182. //------------------------------------------------------------------------------
  183.  
  184. CMD:enterhouse(playerid, params[])
  185. {
  186. for(new i = 0; i < MAX_HOUSES; i++)
  187. {
  188. if(IsPlayerInRangeOfPoint(playerid, 5.0, HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ]))
  189. {
  190. if(HouseInfo[i][hLocked] == 1) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}This house it's locked.");
  191. if(HouseInfo[i][hOwned] == 0) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}You cannot enter in this house.");
  192. SetPlayerPos(playerid, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]);
  193. SetPlayerInterior(playerid, HouseInfo[i][hInterior]);
  194. SendClientMessage(playerid, -1, "{FF0000}[HOUSE]: {FFFFFF}You've entered in a house.");
  195. InHouse[playerid][i] = 1;
  196. }
  197. }
  198. return 1;
  199. }
  200.  
  201. //------------------------------------------------------------------------------
  202.  
  203. CMD:exithouse(playerid, params[])
  204. {
  205. for(new i = 0; i < MAX_HOUSES; i++)
  206. {
  207. if(InHouse[playerid][i] == 1)
  208. {
  209. SetPlayerPos(playerid, HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ]);
  210. SetPlayerInterior(playerid, 0);
  211. SendClientMessage(playerid, -1, "{FF0000}[HOUSE]: {FFFFFF}You've exited from a house.");
  212. InHouse[playerid][i] = 0;
  213. }
  214. }
  215. return 1;
  216. }
  217.  
  218. //------------------------------------------------------------------------------
  219.  
  220. CMD:lockhouse(playerid, params[])
  221. {
  222. new pname[MAX_PLAYER_NAME];
  223. GetPlayerName(playerid, pname, sizeof(pname));
  224. for(new i = 0; i < MAX_HOUSES; i++)
  225. {
  226. if(IsPlayerInRangeOfPoint(playerid, 5.0, HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ]))
  227. {
  228. if(HouseInfo[i][hOwned] == 0) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}You can't lock this house.");
  229. if(HouseInfo[i][hLocked] == 1) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}This house it's already locked.");
  230. if(strcmp(pname, HouseInfo[i][hOwner], true)) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}You aren't Owner of this house.");
  231. SendClientMessage(playerid, -1, "{FF0000}[HOUSE]: {FFFFFF}You've locked your house.");
  232. GameTextForPlayer(playerid, "House ~r~Locked", 5000, 3);
  233. HouseInfo[i][hLocked] = 1;
  234. }
  235. }
  236. return 1;
  237. }
  238.  
  239. //------------------------------------------------------------------------------
  240.  
  241. CMD:unlockhouse(playerid, params[])
  242. {
  243. new pname[MAX_PLAYER_NAME];
  244. GetPlayerName(playerid, pname, sizeof(pname));
  245. for(new i = 0; i < MAX_HOUSES; i++)
  246. {
  247. if(IsPlayerInRangeOfPoint(playerid, 5.0, HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ]))
  248. {
  249. if(HouseInfo[i][hOwned] == 0) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}You can't enter in this house.");
  250. if(HouseInfo[i][hLocked] == 0) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}This house it's already unlocked.");
  251. if(strcmp(pname, HouseInfo[i][hOwner], true)) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}You aren't Owner of this house.");
  252. SendClientMessage(playerid, -1, "{FF0000}[HOUSE]: {FFFFFF}You've unlocked your house.");
  253. GameTextForPlayer(playerid, "House ~g~UnLocked", 5000, 3);
  254. HouseInfo[i][hLocked] = 0;
  255. }
  256. }
  257. return 1;
  258. }
  259.  
  260. //------------------------------------------------------------------------------
  261.  
  262. CMD:edithouse(playerid, params[])
  263. {
  264. ShowPlayerDialog(playerid, DIALOG_EDITID, DIALOG_STYLE_INPUT, "House ID", "{FFFFFF}Please, input below house ID wich you want to edit:", "Continue", "Exit");
  265. return 1;
  266. }
  267.  
  268. //------------------------------------------------------------------------------
  269.  
  270. CMD:housecmds(playerid, params[])
  271. {
  272. new Dialog[512];
  273. strcat(Dialog, "{FF0000}h-House Commands.\n\n", sizeof(Dialog));
  274. strcat(Dialog, "{FFCC33}/HouseCMDS {FFFFFF}- See this list with all commands.\n", sizeof(Dialog));
  275. strcat(Dialog, "{FFCC33}/BuyHouse {FFFFFF}- Buy a house.\n", sizeof(Dialog));
  276. strcat(Dialog, "{FFCC33}/SellHouse {FFFFFF}- Sell your house.\n", sizeof(Dialog));
  277. strcat(Dialog, "{FFCC33}/EnterHouse {FFFFFF}- Enter in a house.\n", sizeof(Dialog));
  278. strcat(Dialog, "{FFCC33}/ExitHouse {FFFFFF}- Exit from a house.\n", sizeof(Dialog));
  279. strcat(Dialog, "{FFCC33}/LockHouse {FFFFFF}- Locks your house.\n", sizeof(Dialog));
  280. strcat(Dialog, "{FFCC33}/UnlockHouse {FFFFFF}- Unlocks your house.\n\n", sizeof(Dialog));
  281. strcat(Dialog, "{FF0000}/CreateHouse {15FF00}- Creates a house [LOGGED AS RCON].", sizeof(Dialog));
  282. return 1;
  283. }
  284.  
  285. //------------------------------------------------------------------------------
  286.  
  287. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  288. {
  289. if(dialogid == DIALOG_EDITID)
  290. {
  291. if(response)
  292. {
  293. new string[144], file[50];
  294. hid = strval(inputtext);
  295. format(file, sizeof(file), "Houses/%d.ini", hid);
  296. if(!fexist(file)) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}This house doesn't exist in data-base.");
  297. format(string, sizeof(string), "{FF0000}[EDIT-MODE]: {FFFFFF}Currently editing house: {FF0000}%d.", strval(inputtext));
  298. SendClientMessage(playerid, -1, string);
  299. ShowPlayerDialog(playerid, DIALOG_EDIT, DIALOG_STYLE_LIST, "Edit House:", "Edit Price\nEdit Interior\nSet Owned\nLock House\nUnlock House\nTeleport House\nEnter House\nExit House", "Select", "Back");
  300. }
  301. else
  302. {
  303. SendClientMessage(playerid, -1, "{FF0000}[HOUSE]: {FFFFFF}You don't edit house now.");
  304. }
  305. }
  306. if(dialogid == DIALOG_EDIT)
  307. {
  308. if(response)
  309. {
  310. if(listitem == 0)
  311. {
  312. ShowPlayerDialog(playerid, DIALOG_EDITPRICE, DIALOG_STYLE_INPUT, "Edit Price", "{FFFFFF}Please, input below new house's price:", "Continue", "Back");
  313. }
  314. if(listitem == 1)
  315. {
  316. ShowPlayerDialog(playerid, DIALOG_EDITINTERIOR, DIALOG_STYLE_INPUT, "Edit Interior", "{FFFFFF}Please, input below house's interior:", "Continue", "Back");
  317. }
  318. if(listitem == 2)
  319. {
  320. new file[50], string[144];
  321. HouseInfo[hid][hOwned] = 0;
  322. format(file, sizeof(file), "Houses/%d.ini", hid);
  323. if(fexist(file))
  324. {
  325. dini_IntSet(file, "Owned", 0);
  326. }
  327. format(string, sizeof(string), "{FF0000}[EDIT-MODE]: {FFFFFF}House setted ownable.");
  328. SendClientMessage(playerid, -1, string);
  329. ShowPlayerDialog(playerid, DIALOG_EDIT, DIALOG_STYLE_LIST, "Edit House:", "Edit Price\nEdit Interior\nSet Owned\nLock House\nUnlock House\nTeleport House\nEnter House\nExit House", "Select", "Back");
  330. }
  331. if(listitem == 3)
  332. {
  333. HouseInfo[hid][hLocked] = 1;
  334. SendClientMessage(playerid, -1, "{FF0000}[EDIT-MODE]: {FFFFFF}House locked.");
  335. ShowPlayerDialog(playerid, DIALOG_EDIT, DIALOG_STYLE_LIST, "Edit House:", "Edit Price\nEdit Interior\nSet Owned\nLock House\nUnlock House\nTeleport House\nEnter House\nExit House", "Select", "Back");
  336. }
  337. if(listitem == 4)
  338. {
  339. HouseInfo[hid][hLocked] = 0;
  340. SendClientMessage(playerid, -1, "{FF0000}[EDIT-MODE]: {FFFFFF}House unlocked.");
  341. ShowPlayerDialog(playerid, DIALOG_EDIT, DIALOG_STYLE_LIST, "Edit House:", "Edit Price\nEdit Interior\nSet Owned\nLock House\nUnlock House\nTeleport House\nEnter House\nExit House", "Select", "Back");
  342. }
  343. if(listitem == 5)
  344. {
  345. SetPlayerPos(playerid, HouseInfo[hid][hX], HouseInfo[hid][hY], HouseInfo[hid][hZ]);
  346. SendClientMessage(playerid, -1, "{FF0000}[EDIT-MODE]: {FFFFFF}Teleported to house.");
  347. ShowPlayerDialog(playerid, DIALOG_EDIT, DIALOG_STYLE_LIST, "Edit House:", "Edit Price\nEdit Interior\nSet Owned\nLock House\nUnlock House\nTeleport House\nEnter House\nExit House", "Select", "Back");
  348. }
  349. if(listitem == 6)
  350. {
  351. SetPlayerPos(playerid, HouseInfo[hid][hX], HouseInfo[hid][hY], HouseInfo[hid][hZ]);
  352. SetPlayerInterior(playerid, HouseInfo[hid][hInterior]);
  353. SendClientMessage(playerid, -1, "{FF0000}[EDIT-MODE]: {FFFFFF}Entered in house.");
  354. }
  355. if(listitem == 7)
  356. {
  357. SetPlayerPos(playerid, HouseInfo[hid][hX], HouseInfo[hid][hY], HouseInfo[hid][hZ]);
  358. SetPlayerInterior(playerid, 0);
  359. SendClientMessage(playerid, -1, "{FF0000}[EDIT-MODE]: {FFFFFF}House exited to pick-up position.");
  360. ShowPlayerDialog(playerid, DIALOG_EDIT, DIALOG_STYLE_LIST, "Edit House:", "Edit Price\nEdit Interior\nSet Owned\nLock House\nUnlock House\nTeleport House\nEnter House\nExit House", "Select", "Back");
  361. }
  362. }
  363. else
  364. {
  365. ShowPlayerDialog(playerid, DIALOG_EDITID, DIALOG_STYLE_INPUT, "House ID", "{FFFFFF}Please, input below house ID wich you want to edit:", "Continue", "Exit");
  366. }
  367. }
  368. if(dialogid == DIALOG_EDITPRICE)
  369. {
  370. if(response)
  371. {
  372. new file[50], string[144];
  373. HouseInfo[hid][hPrice] = strval(inputtext);
  374. format(file, sizeof(file), "Houses/%d.ini", hid);
  375. if(fexist(file))
  376. {
  377. dini_IntSet(file, "Price", HouseInfo[hid][hPrice]);
  378. }
  379. format(string, sizeof(string), "{FF0000}[EDIT-MODE]: {FFFFFF}New price of house: {FF0000}%d {FFFFFF}it's {FF0000}%d.", hid, HouseInfo[hid][hPrice]);
  380. SendClientMessage(playerid, -1, string);
  381. ShowPlayerDialog(playerid, DIALOG_EDIT, DIALOG_STYLE_LIST, "Edit House:", "Edit Price\nEdit Interior\nSet Owned\nLock House\nUnlock House\nTeleport House\nEnter House\nExit House", "Select", "Back");
  382. }
  383. else
  384. {
  385. ShowPlayerDialog(playerid, DIALOG_EDIT, DIALOG_STYLE_LIST, "Edit House:", "Edit Price\nEdit Interior\nSet Owned\nLock House\nUnlock House\nTeleport House\nEnter House\nExit House", "Select", "Back");
  386. }
  387. }
  388. if(dialogid == DIALOG_EDITINTERIOR)
  389. {
  390. if(response)
  391. {
  392. new file[50], string[144];
  393. HouseInfo[hid][hInterior] = strval(inputtext);
  394. format(file, sizeof(file), "Houses/%d.ini", hid);
  395. if(fexist(file))
  396. {
  397. dini_IntSet(file, "Interior", HouseInfo[hid][hInterior]);
  398. }
  399. format(string, sizeof(string), "{FF0000}[EDIT-MODE]: {FFFFFF}New interior of house: {FF0000}%d {FFFFFF}it's {FF0000}%d.", hid, HouseInfo[hid][hInterior]);
  400. SendClientMessage(playerid, -1, string);
  401. ShowPlayerDialog(playerid, DIALOG_EDIT, DIALOG_STYLE_LIST, "Edit House:", "Edit Price\nEdit Interior\nSet Owned\nLock House\nUnlock House\nTeleport House\nEnter House\nExit House", "Select", "Back");
  402. }
  403. else
  404. {
  405. ShowPlayerDialog(playerid, DIALOG_EDIT, DIALOG_STYLE_LIST, "Edit House:", "Edit Price\nEdit Interior\nSet Owned\nLock House\nUnlock House\nTeleport House\nEnter House\nExit House", "Select", "Back");
  406. }
  407. }
  408. return 1;
  409. }
  410.  
  411. //------------------------------------------------------------------------------
  412.  
  413. public OnFilterScriptInit()
  414. {
  415. LoadHouses();
  416. return 1;
  417. }
  418.  
  419. //------------------------------------------------------------------------------
  420.  
  421. stock LoadHouses()
  422. {
  423. new file[50], labelstring[144], stringlabel[144];
  424. for(new i = 0; i < MAX_HOUSES; i++)
  425. {
  426. format(file, sizeof(file), "Houses/%d.ini", i);
  427. if(fexist(file))
  428. {
  429. HouseInfo[i][hOwned] = dini_Int(file, "Owned");
  430. HouseInfo[i][hPrice] = dini_Int(file, "Price");
  431. HouseInfo[i][hInterior] = dini_Int(file, "Interior");
  432. HouseInfo[i][hX] = dini_Float(file, "Position X");
  433. HouseInfo[i][hY] = dini_Float(file, "Position Y");
  434. HouseInfo[i][hZ] = dini_Float(file, "Position Z");
  435. HouseInfo[i][hEnterX] = dini_Float(file, "Enter X");
  436. HouseInfo[i][hEnterY] = dini_Float(file, "Enter Y");
  437. HouseInfo[i][hEnterZ] = dini_Float(file, "Enter Z");
  438. strmid(HouseInfo[i][hOwner], dini_Get(file, "Owner"), false, strlen(dini_Get(file, "Owner")), MAX_PLAYER_NAME);
  439. format(labelstring, sizeof(labelstring), "{15FF00}House ID: {FFFFFF}%d\n{15FF00}Status: {FFFFFF}For Sale\n{15FF00}Price: {FFFFFF}%d", i, HouseInfo[i][hPrice]);
  440. format(stringlabel, sizeof(stringlabel), "{15FF00}House ID: {FFFFFF}%d\n{15FF00}Owner: {FFFFFF}%s\n{15FF00}Price: {FFFFFF}%d", i, HouseInfo[i][hOwner], HouseInfo[i][hPrice]);
  441. if(HouseInfo[i][hOwned] == 0)
  442. {
  443. HouseInfo[i][hPick] = CreatePickup(1273, 1, HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ]);
  444. HouseInfo[i][hLabel] = Create3DTextLabel(labelstring, 0xFFFFFFFF, HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ], 30.0, 0, 0);
  445. }
  446. else if(HouseInfo[i][hOwned] == 1)
  447. {
  448. HouseInfo[i][hPick] = CreatePickup(1272, 1, HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ]);
  449. HouseInfo[i][hLabel] = Create3DTextLabel(stringlabel, 0xFFFFFFFF, HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ], 30.0, 0, 0);
  450. }
  451. houseid++;
  452. }
  453. }
  454. print(" ");
  455. print(" ");
  456. printf(" LOADED HOUSE: %d/%d", houseid, MAX_HOUSES);
  457. print(" ");
  458. print(" ");
  459. return 1;
  460. }
  461.  
  462. //------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment