Guest User

Untitled

a guest
Jun 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.99 KB | None | 0 0
  1. /*
  2. DINAMICAN SISTEM STANOVA
  3. _________________________________________________________________________________________________________________
  4. | [FILTERSCRIPT LOG] |
  5. | BY : VANILLA |
  6. |------ [23.12.2011] --- [Basic v1.0]-----------------------------------------------------------------------------|
  7. | - Skripta je prevedena na Hrvatski |
  8. | - Komande su prebacene iz DCMD-a u ZCMD, lakse citanje,ljepse izgleda i brze je |
  9. | - Neke komande postavljene su u dijalog |
  10. | - Ubacene su boje u neke komande da bi bile ljepse vizualno |
  11. | - Prikazivanje informacija stanova je promjenjeno iz GameTexta u 3DTextLabel |
  12. |------ [26.12.2011] --- [Update v1.1]----------------------------------------------------------------------------|
  13. | - Spremanje u skripti prebaceno iz dinija u y_Ini |
  14. | - Skripta je optimizirana |
  15. |------ [11.02.2012] --- [Update v1.2]----------------------------------------------------------------------------|
  16. | - Od sada, kada stan nema vlasnika pise : Nitko |
  17. | - Od sada, level je stalno prikazivao crveno - crveno, sada prikazuje crveno-zuto |
  18. | - Komanda /staninfo je vizualno uljepsana bojama |
  19. | - Komande /zakljucajstan i /otkljucaj stan , sada su jedna komanda /lock (ljepse je,lakse za zapamtit i brze) |
  20. | - Komande /ulaz,/izlaz (za ulazak i izlazak iz stana) su uklonite,od sada se u stanove ulazi sa tipkom enter |
  21. | - Popravljen bug sa prikazivanjem pri kupnji stana ( od sada kada kupite stan pisati ce vase informacije ) |
  22. |_________________________________________________________________________________________________________________|
  23.  
  24. -> -> ***************** [GAGI HELP] ******************* - POMOZI MI ZA ULAZ/IZLAZ I ZAKLJUCAVANJE/OTKLJUCAVANJE STANA
  25.  
  26. - HVALA -> ZEEX - ZCMD
  27. -> Y_LESS - SSCANF, YSI
  28. -> STEFAN - NAPRAVIO HOUSE SYSTEM
  29. -> GAGI - POMOGAO MI OKO SVEGA [CJELOKUPNO FS] + (POMOC U UPDATE V1.2)
  30. -> VANILLA - PREVEO FS, PREBACIO KOMANDE IZ DCMD U ZCMD(BASIC V1.0 , UPDATE V1.2)
  31. -> PARADOX - PREBACIO SKRIPTU IZ DINI-A U Y_INI , OPTIMIZIRAO(UPDATE V1.1)
  32. -> N0NE - BUG FIX(ULAZ/IZLAZ)
  33.  
  34. - OSTAVITE OVE CREDITSE AKO ZELITE DA VAM I DALJE POMAZEMO -
  35. - HVALA -
  36. */
  37.  
  38. #include <a_samp>
  39. #include <YSI\y_ini>
  40. #include <YSI\y_va>
  41. #include <zcmd>
  42. #include <sscanf2>
  43. /*---- [DEFINICIJE BOJA] ----*/
  44. #define COLOR_NEKA 0xFFFFFF
  45. #define BIJELA "{FFFFFF}"
  46. #define CRNA "{0E0101}"
  47. #define SIVA "{C3C3C3}"
  48. #define ZELENA "{6EF83C}"
  49. #define CRVENA "{F81414}"
  50. #define ZUTA "{F3FF02}"
  51. #define NARANDZASTA "{FFAF00}"
  52. #define LIME "{B7FF00}"
  53. #define CYAN "{00FFEE}"
  54. #define SVJETLO_PLAVA "{00C0FF}"
  55. #define PLAVA "{0049FF}"
  56. #define COL_MAGENTA "{F300FF}"
  57. #define COL_VIOLET "{B700FF}"
  58. #define ROZA "{FF00EA}"
  59. #define COL_MARONE "{A90202}"
  60. #define COL_PARAM "{3FCD02}"
  61. #define COL_VALUE "{A3E4FF}"
  62. #define COL_RULE "{F9E8B7}"
  63. #define COL_RULE2 "{FBDF89}"
  64. #define COL_RWHITE "{FFFFFF}"
  65. #define SVJETLO_ZELENA "{C9FFAB}"
  66. #define SVJETLO_CRVENA "{FFA1A1}"
  67. #define SVJETLO_CRVENA2 "{C77D87}"
  68. #define MAX_STANOVA 100 // Max Stans allowed to be created
  69. #define PTP_RADIUS 2.0 // Radius of PlayerToPoint Function
  70. #define SCM SendClientMessage
  71. enum stInfo
  72. {
  73. stName[24],
  74. stSellable,
  75. stSell,
  76. stRent,
  77. stLevel,
  78. stPickup,
  79. Float:stExitX,
  80. Float:stExitY,
  81. Float:stExitZ,
  82. stVirtualWorld,
  83. stLocked
  84. }
  85. new
  86. StanInfo[MAX_STANOVA][stInfo];
  87.  
  88. new
  89. Float:StansCoords[13][3] = {
  90. {222.9534, 1287.7649, 1082.1406}, // Sml - 1 bedroom
  91. {261.0827, 1284.6899, 1080.2578}, // Sml - 1 bedroom
  92. {260.6734, 1237.7909, 1084.2578}, // Sml - 1 bedroom
  93. {376.7426, 1417.3226, 1081.3281}, // Sml - 1 bedroom
  94. {295.2874, 1473.2769, 1080.2578}, // Med - 2 bedroom
  95. {327.9431, 1478.3801, 1084.4375}, // Med - 2 bedroom
  96. {2270.1050, -1210.3917, 1047.5625}, // Med - 2 bedroom
  97. {447.1211, 1397.8444, 1084.3047}, // Med - 2 bedroom
  98. {2196.0063, -1204.6326, 1049.0234}, // Lrg - 3 bedroom
  99. {235.3416, 1187.2882, 1080.2578}, // Lrg - 3 bedroom
  100. {490.9987, 1399.4164, 1080.2578}, // Lrg - 3 bedroom
  101. {227.1212, 1114.1840, 1080.9972}, // Lrg - 4 bedroom
  102. {225.6624, 1022.5345, 1084.0145} // Xlrg - 4 bedrooms
  103. };
  104.  
  105. new
  106. StansLevels[13][2] = {
  107. {1, 2000}, // Sml - 1 bedroom
  108. {4, 4500}, // Sml - 1 bedroom
  109. {9, 7000}, // Sml - 1 bedroom
  110. {15, 10000}, // Sml - 1 bedroom
  111. {15, 17000}, // Med - 2 bedroom
  112. {15, 23000}, // Med - 2 bedroom
  113. {10, 34000}, // Med - 2 bedroom
  114. {2, 62000}, // Med - 2 bedroom
  115. {6, 102000}, // Lrg - 3 bedroom
  116. {3, 156000}, // Lrg - 3 bedroom
  117. {2, 188000}, // Lrg - 3 bedroom
  118. {5, 235000}, // Lrg - 4 bedroom
  119. {7, 295000} // Xlrg - 4 bedrooms
  120. };
  121.  
  122. new
  123. gChatMsg[128];
  124.  
  125. public OnFilterScriptInit()
  126. {
  127. print("\n--------------------------------------");
  128. print(" DINAMICAN SISTEM STANOVA - UCITAN!!!");
  129. print("--------------------------------------\n");
  130. for(new st = 0; st <= MAX_STANOVA; st++) // Player Homes
  131. {
  132. LoadPlayerStan(st);
  133. }
  134. return true;
  135. }
  136.  
  137. public OnFilterScriptExit()
  138. {
  139. return true;
  140. }
  141.  
  142. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  143. {
  144. if( newkeys == KEY_SECONDARY_ATTACK )
  145. {
  146. for(new st = 0; st <= MAX_STANOVA; st++)
  147. {
  148. if(IsPlayerInRangeOfPoint(playerid, PTP_RADIUS, StanInfo[st][stExitX], StanInfo[st][stExitY], StanInfo[st][stExitZ]))
  149. {
  150. new Level = StanInfo[st][stLevel];
  151. if(StanInfo[st][stLocked] == 1 && strcmp(StanInfo[st][stName], GetName(playerid), false) != 0) return SendClientMessage(playerid, -1, ""CRVENA"[STAN]:"ZELENA" Ovaj stan je zakljucan.");
  152. SetPlayerPos(playerid, StansCoords[Level][0], StansCoords[Level][1], StansCoords[Level][2]);
  153. SetPlayerInterior(playerid, StansLevels[Level][0]);
  154. SetPlayerVirtualWorld(playerid, StanInfo[st][stVirtualWorld]);
  155.  
  156. break;
  157. }
  158. }
  159. }
  160. if( newkeys == KEY_SECONDARY_ATTACK )
  161. {
  162. for(new stan = 0; stan<= MAX_STANOVA; stan++)
  163. {
  164. new st = GetPlayerVirtualWorld(playerid);
  165. if(IsPlayerInRangeOfPoint(playerid, PTP_RADIUS, StansCoords[StanInfo[st][stLevel]][0], StansCoords[StanInfo[st][stLevel]][1], StansCoords[StanInfo[st][stLevel]][2]))
  166. {
  167. SetPlayerPos(playerid, StanInfo[st][stExitX], StanInfo[st][stExitY], StanInfo[st][stExitZ]);
  168. SetPlayerInterior(playerid, 0);
  169. SetPlayerVirtualWorld(playerid, 0);
  170. }
  171. }
  172. }
  173. return true;
  174. }
  175.  
  176. // -------------- [ZCMD KOMANDE] ---------------
  177. CMD:stanhelp(playerid,params[])
  178. {
  179. ShowPlayerDialog(playerid, 6382, DIALOG_STYLE_MSGBOX, "Stan - Pomoc", ""ZELENA"Vlasnik\n"SIVA"/(un)sellStan, /(un)lockStan, /rentprice, /tenants, /evict, /Stan (upgrade/downgrade\n"ZELENA"Ostali\n"SIVA"/Staninfo, /buyStan, /(un)rentStan, /enter, /exit", "Uredu", "");
  180. return true;
  181. }
  182.  
  183. CMD:staninfo(playerid,params[])
  184. {
  185. for(new st = 0; st <= MAX_STANOVA; st++)
  186. {
  187. if(IsPlayerInRangeOfPoint(playerid, PTP_RADIUS, StanInfo[st][stExitX], StanInfo[st][stExitY], StanInfo[st][stExitZ]))
  188. {
  189. new IsLocked[24];
  190. if(StanInfo[st][stLocked] == 1) IsLocked = "Zakljucana";
  191. else IsLocked = "Otkljucana";
  192. new text1[256];
  193. format(text1, sizeof(text1), ""SVJETLO_PLAVA"Vlasnik: "BIJELA"%s"SVJETLO_PLAVA" - Level:"BIJELA" [%d]"SVJETLO_PLAVA" - Cijena Renta:"BIJELA" [%d$]"SVJETLO_PLAVA"\nProdajna Cijena:"BIJELA" [%d$]"SVJETLO_PLAVA" - Vrata:"BIJELA" [%d]"SVJETLO_PLAVA" - ID Stana:"BIJELA" [%d]", StanInfo[st][stName], StanInfo[st][stLevel], StanInfo[st][stRent], StanInfo[st][stSell], IsLocked, st);
  194. ShowPlayerDialog(playerid, 6389, DIALOG_STYLE_MSGBOX, ""SVJETLO_PLAVA"Stan - Informacije", text1, "Uredu", "");
  195. }
  196. }
  197. return true;
  198. }
  199.  
  200. /*
  201. CMD:ulaz(playerid, params[])
  202. {
  203. for(new st = 0; st <= MAX_STANOVA; st++)
  204. {
  205. if(IsPlayerInRangeOfPoint(playerid, PTP_RADIUS, StanInfo[st][stExitX], StanInfo[st][stExitY], StanInfo[st][stExitZ]))
  206. {
  207. new
  208. Level = StanInfo[st][stLevel];
  209.  
  210. if(StanInfo[st][stLocked] == 1 && strcmp(StanInfo[st][stName], GetName(playerid), false) != 0) return SendClientMessage(playerid, -1, ""CRVENA"[STAN]:"ZELENA" Ovaj stan je zakljucan.");
  211.  
  212. SetPlayerPos(playerid, StansCoords[Level][0], StansCoords[Level][1], StansCoords[Level][2]);
  213. SetPlayerInterior(playerid, StansLevels[Level][0]);
  214. SetPlayerVirtualWorld(playerid, StanInfo[st][stVirtualWorld]);
  215.  
  216. break;
  217. }
  218. }
  219. return true;
  220. }
  221.  
  222. CMD:izlaz(playerid,params[])
  223. {
  224. new st = GetPlayerVirtualWorld(playerid);
  225. for(new stan = 0; stan<= MAX_STANOVA; stan++)
  226. {
  227. if(IsPlayerInRangeOfPoint(playerid, PTP_RADIUS, StansCoords[StanInfo[st][stLevel]][0], StansCoords[StanInfo[st][stLevel]][1], StansCoords[StanInfo[st][stLevel]][2]))
  228. {
  229. SetPlayerPos(playerid, StanInfo[st][stExitX], StanInfo[st][stExitY], StanInfo[st][stExitZ]);
  230. SetPlayerInterior(playerid, 0);
  231. SetPlayerVirtualWorld(playerid, 0);
  232. }
  233. }
  234. return true;
  235. }
  236. */
  237. CMD:kupistan(playerid,params[])
  238. {
  239. for(new st = 0; st <= MAX_STANOVA; st++)
  240. {
  241. if(IsPlayerInRangeOfPoint(playerid, PTP_RADIUS, StanInfo[st][stExitX], StanInfo[st][stExitY], StanInfo[st][stExitZ]))
  242. {
  243. if(strcmp(StanInfo[st][stName],GetName(playerid), false) != 0)
  244. {
  245. if(StanInfo[st][stSellable] == 1)
  246. {
  247. if(GetPlayerMoney(playerid) < StanInfo[st][stSell]) return SendClientMessage(playerid, -1, ""CRVENA"[STAN]:"ZELENA" Nemate dovoljno novca za kupovinu ovog stana.");
  248.  
  249. DestroyPickup(StanInfo[st][stPickup]);
  250. StanInfo[st][stPickup] = CreatePickup(1272,23, StanInfo[st][stExitX], StanInfo[st][stExitY], StanInfo[st][stExitZ]); // bought
  251. StanInfo[st][stSellable] = 0; GivePlayerMoney(playerid, -StanInfo[st][stSell]);
  252. format(StanInfo[st][stName], 24, "%s", GetName(playerid)); SpremiStanove(st);
  253. StanInfo[st][stPickup] = CreatePickup(1272,23, StanInfo[st][stExitX], StanInfo[st][stExitY], StanInfo[st][stExitZ]); // bought
  254. new stanLabel[170];
  255. format(stanLabel, sizeof(stanLabel), ""CRVENA"Vlasnik: "ZUTA"%s\n"CRVENA"Level: "ZUTA"%d\n"CRVENA"Cijena Renta: "ZUTA"%d", StanInfo[st][stName], StanInfo[st][stLevel], StanInfo[st][stRent]);
  256. // Update3DTextLabelText(stanLabel, -1, StanInfo[st][stExitX], StanInfo[st][stExitY], StanInfo[st][stExitZ], 13.0, 0);
  257. }
  258. else return SendClientMessage(playerid, -1, ""CRVENA"[STAN]:"ZELENA" Ovaj stan nije za prodaju.");
  259. }
  260. else return SendClientMessage(playerid, -1, ""CRVENA"[STAN]:"ZELENA" Nemozete kupiti vlastiti stan.");
  261. }
  262. }
  263. return false;
  264. }
  265.  
  266. CMD:cijenarenta(playerid,params[])
  267. {
  268. new
  269. Price;
  270.  
  271. if(sscanf(params, "i", Price)) return SendClientMessage(playerid, -1, ""CRVENA"[KORISTI]: /cijenarenta [cijena renta]");
  272. else if(Price < 0 || Price > 2500) return SendClientMessage(playerid, -1, ""CRVENA"Cijena renta nemoze biti ispod 0 ili iznad 2500$");
  273. else
  274. {
  275. for(new st = 0; st <= MAX_STANOVA; st++)
  276. {
  277. if(IsPlayerInRangeOfPoint(playerid, PTP_RADIUS, StanInfo[st][stExitX], StanInfo[st][stExitY], StanInfo[st][stExitZ]))
  278. {
  279. if(strcmp(StanInfo[st][stName],GetName(playerid), false ) == 0)
  280. {
  281. StanInfo[st][stRent] = Price; SpremiStanove(st);
  282. }
  283. else return SendClientMessage(playerid, -1, ""CRVENA"[STAN]:"ZELENA" Niste vlasnik ovog stana.");
  284. }
  285. }
  286. }
  287. return true;
  288. }
  289.  
  290. CMD:stan(playerid,params[])
  291. {
  292. new
  293. tmp[64];
  294.  
  295. if(sscanf(params, "s", tmp))
  296. {
  297. SendClientMessage(playerid, -1, ""CRVENA"[KORISTI]: /stan (upgrade/downgrade)");
  298. SendFormattedMessage(playerid, -1, "Stan: 0[%d], 1[%d], 2[%d], 3[%d], 4[%d], 5[%d], 6[%d]", StansLevels[0][1], StansLevels[1][1], StansLevels[2][1], StansLevels[3][1], StansLevels[4][1], StansLevels[5][1], StansLevels[6][1]);
  299. SendFormattedMessage(playerid, -1, "7[%d], 8[%d], 9[%d], 10[%d], 11[%d], 12[%d]", StansLevels[7][1], StansLevels[8][1], StansLevels[9][1], StansLevels[10][1], StansLevels[11][1], StansLevels[12][1]);
  300. return 1;
  301. }
  302. else if(strcmp(tmp, "upgrade", true) == 0)
  303. {
  304. for(new st = 0; st <= MAX_STANOVA; st++)
  305. {
  306. if(IsPlayerInRangeOfPoint(playerid, PTP_RADIUS, StanInfo[st][stExitX], StanInfo[st][stExitY], StanInfo[st][stExitZ]))
  307. {
  308. if(strcmp(StanInfo[st][stName], GetName(playerid), false) == 0)
  309. {
  310. if(StanInfo[st][stLevel]+1 > 12) return SendClientMessage(playerid, -1, "Ne mozete staviti level vaseg stana na vise od 12");
  311.  
  312. new
  313. Level = StansLevels[StanInfo[st][stLevel] + 1][1];
  314.  
  315. SendFormattedMessage(playerid, -1, "Unaprijedili ste svoj stan,i to vas je kostalo %d$", Level);
  316.  
  317. StanInfo[st][stLevel] = (StanInfo[st][stLevel]+1);
  318. GivePlayerMoney(playerid, -Level);
  319. SpremiStanove(st);
  320. }
  321. else return SendClientMessage(playerid, -1, ""CRVENA"[STAN]:"ZELENA" Niste vlasnik ovog stana.");
  322. }
  323. }
  324. }
  325. else if(strcmp(tmp, "downgrade", true) == 0)
  326. {
  327. for(new st = 0; st <= MAX_STANOVA; st++)
  328. {
  329. if(IsPlayerInRangeOfPoint(playerid, PTP_RADIUS, StanInfo[st][stExitX], StanInfo[st][stExitY], StanInfo[st][stExitZ]))
  330. {
  331. if(strcmp(StanInfo[st][stName], GetName(playerid), false) == 0)
  332. {
  333. if(StanInfo[st][stLevel]-1 < 0) return SendClientMessage(playerid, -1, "Ne mozete staviti level vaseg stana na manje od 0");
  334.  
  335. new
  336. Level = StansLevels[StanInfo[st][stLevel] - 1][1];
  337.  
  338. SendFormattedMessage(playerid, -1, "Maknili ste neka unaprijedenja svog stana,i od toga ste dobili $%d", Level);
  339.  
  340. StanInfo[st][stLevel] = (StanInfo[st][stLevel]-1);
  341. GivePlayerMoney(playerid, Level);
  342. SpremiStanove(st);
  343. }
  344. else return SendClientMessage(playerid, -1, ""CRVENA"[STAN]:"ZELENA" Niste vlasnik ovog stana.");
  345. }
  346. }
  347. }
  348. return true;
  349. }
  350.  
  351. // KOMANDA LOCK
  352.  
  353. CMD:lock(playerid,params[])
  354. {
  355. for(new st = 0; st <= MAX_STANOVA; st++)
  356. {
  357. if(IsPlayerInRangeOfPoint(playerid, PTP_RADIUS, StanInfo[st][stExitX], StanInfo[st][stExitY], StanInfo[st][stExitZ]))// return SCM(playerid,-1,""CRVENA"[STAN]:"ZELENA"Niste vlasnik ovog stana!");
  358. {
  359. if(strcmp(StanInfo[st][stName], GetName(playerid), false) == 0)
  360. {
  361. if(StanInfo[st][stLocked] == 1)
  362. {
  363. StanInfo[st][stLocked] = 0;
  364. SpremiStanove(st);
  365. SendClientMessage(playerid, -1, ""CRVENA"[STAN]:"ZELENA"Otkljucali ste svoj stan.");
  366. }
  367. else
  368. {
  369. StanInfo[st][stLocked] = 1;
  370. SpremiStanove(st);
  371. SendClientMessage(playerid, -1, ""CRVENA"[STAN]:"ZELENA"Zakljucali ste svoj stan.");
  372. }
  373. }
  374. }
  375. }
  376. return 1;
  377. }
  378. /*
  379. CMD:otkljucajstan(playerid,params[])
  380. {
  381. for(new st = 0; st <= MAX_STANOVA; st++)
  382. {
  383. if(IsPlayerInRangeOfPoint(playerid, PTP_RADIUS, StanInfo[st][stExitX], StanInfo[st][stExitY], StanInfo[st][stExitZ]))
  384. {
  385. if(strcmp(StanInfo[st][stName], GetName(playerid), false) == 0)
  386. {
  387. if(StanInfo[st][stLocked] == 1) return SendClientMessage(playerid, -1, ""CRVENA"ERROR: "ZELENA"This Stan is allready locked.");
  388.  
  389. StanInfo[st][stLocked] = 1;
  390. SpremiStanove(st);
  391.  
  392. SendClientMessage(playerid, -1, ""CRVENA"[STAN]:"ZELENA" Zakljucali ste svoj stna.");
  393. }
  394. else return SendClientMessage(playerid, -1, ""CRVENA"[STAN]:"ZELENA" Niste vlasnik ovog stana.");
  395. }
  396. }
  397. return true;
  398. }
  399.  
  400. CMD:zakljucajstan(playerid,params[])
  401. {
  402. for(new st = 0; st <= MAX_STANOVA; st++)
  403. {
  404. if(IsPlayerInRangeOfPoint(playerid, PTP_RADIUS, StanInfo[st][stExitX], StanInfo[st][stExitY], StanInfo[st][stExitZ]))
  405. {
  406. if(strcmp(StanInfo[st][stName], GetName(playerid), false) == 0)
  407. {
  408. if(StanInfo[st][stLocked] == 0) return SendClientMessage(playerid, -1, ""CRVENA"ERROR: "ZELENA"Ovaj stan je vec otkljucan.");
  409.  
  410. StanInfo[st][stLocked] = 0;
  411. SpremiStanove(st);
  412.  
  413. SendClientMessage(playerid, -1, ""CRVENA"[STAN]:"ZELENA" Otkljucali ste svoj stan.");
  414. }
  415. else return SendClientMessage(playerid, -1, ""CRVENA"[STAN]:"ZELENA" Niste vlasnik ovog stana.");
  416. }
  417. }
  418. return true;
  419. }*/
  420.  
  421.  
  422. CMD:prodajstan(playerid,params[])
  423. {
  424. new Sell;
  425. if(sscanf(params, "i", Sell)) return SendClientMessage(playerid, -1, ""CRVENA"[KORISTI]: /prodajstan [cijena]");
  426. else if(Sell < 0 || Sell > 250000) return SendClientMessage(playerid, -1, ""CRVENA"[STAN]:"ZELENA" Cijena nemoze biti ispod 0 ili iznad 250 tisuca");
  427. else
  428. {
  429. for(new st = 0; st <= MAX_STANOVA; st++)
  430. {
  431. if(IsPlayerInRangeOfPoint(playerid, PTP_RADIUS, StanInfo[st][stExitX], StanInfo[st][stExitY], StanInfo[st][stExitZ]))
  432. {
  433. if(strcmp(StanInfo[st][stName], GetName(playerid), false) == 0)
  434. {
  435. DestroyPickup(StanInfo[st][stPickup]);
  436. StanInfo[st][stPickup] = CreatePickup(1273, 23, StanInfo[st][stExitX], StanInfo[st][stExitY], StanInfo[st][stExitZ]); // not bought
  437. StanInfo[st][stSellable] = 1; StanInfo[st][stSell] = Sell; SpremiStanove(st);
  438. }
  439. else return SendClientMessage(playerid, -1, ""CRVENA"[STAN]:"ZELENA" Niste vlasnik ovog stana.");
  440. }
  441. }
  442. }
  443. return true;
  444. }
  445.  
  446. CMD:unsellstan(playerid,params[])
  447. {
  448. for(new st = 0; st<= MAX_STANOVA; st++)
  449. {
  450. if(IsPlayerInRangeOfPoint(playerid, PTP_RADIUS, StanInfo[st][stExitX], StanInfo[st][stExitY], StanInfo[st][stExitZ]))
  451. {
  452. if(strcmp(StanInfo[st][stName], GetName(playerid), false) == 0)
  453. {
  454. DestroyPickup(StanInfo[st][stPickup]);
  455. StanInfo[st][stPickup] = CreatePickup(1272,23, StanInfo[st][stExitX], StanInfo[st][stExitY], StanInfo[st][stExitZ]); // bought
  456. StanInfo[st][stSellable] = 0; SpremiStanove(st);
  457. }
  458. else return SendClientMessage(playerid, -1, ""CRVENA"[STAN]:"ZELENA" Niste vlasnik ovog stana.");
  459. }
  460. }
  461. return true;
  462. }
  463.  
  464. CMD:napravistan(playerid,params[])
  465. {
  466. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, ""CRVENA"ERROR:"ZELENA" Samo administratori mogu koristiti ovu komandu!");
  467. else
  468. {
  469. new Sell,lvl;
  470. if(sscanf(params, "ii", Sell, lvl)) return SendClientMessage(playerid, -1, ""CRVENA"[KORISTI]: /napravistan [cijena] [level]");
  471. else if(Sell < 0 || Sell > 250000) return SendClientMessage(playerid, -1, ""CRVENA"Cijena nemoze biti ispod 0 ili iznad 250 tisuca");
  472. else if(lvl < 0 || lvl > 12) return SendClientMessage(playerid, -1, ""CRVENA"Level nemoze biti ispod 0 ili iznad 12");
  473. else CreatePlayerStan(playerid, Sell, lvl);
  474. }
  475. return true;
  476. }
  477.  
  478. CMD:unististan(playerid,params[])
  479. {
  480. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, ""CRVENA"ERROR:"ZELENA" Samo administratori mogu koristiti ovu komandu!");
  481. else
  482. {
  483. new Stanid;
  484. if(sscanf(params, "i", Stanid)) return SendClientMessage(playerid, -1, ""CRVENA"[KORISTI]: /unististan [ID stana]");
  485. else UnistiStan(playerid, Stanid);
  486. }
  487. return true;
  488. }
  489.  
  490. ////////////////////////////////////////////
  491. // STOCKOVI , CALLBACKOVI I OSTALO //
  492. //////////////////////////////////////////
  493. forward LoadStan_Data(stanid, name[], value[]);
  494. public LoadStan_Data(stanid, name[], value[])
  495. {
  496. INI_String("Name", StanInfo[stanid][stName], MAX_PLAYER_NAME);
  497. INI_Int("For_Sell", StanInfo[stanid][stSellable]);
  498. INI_Int("Sell_Price", StanInfo[stanid][stSell]);
  499. INI_Int("Rent_Price", StanInfo[stanid][stRent]);
  500. INI_Int("Stan_Level", StanInfo[stanid][stLevel]);
  501. INI_Float("Exit_Coord:X", StanInfo[stanid][stExitX]);
  502. INI_Float("Exit_Coord:Y", StanInfo[stanid][stExitY]);
  503. INI_Float("Exit_Coord:Z", StanInfo[stanid][stExitZ]);
  504. INI_Int("VirtualWorld", StanInfo[stanid][stVirtualWorld]);
  505. INI_Int("Status", StanInfo[stanid][stLocked]);
  506. return 1;
  507. }
  508.  
  509. stock CreatePlayerStan(playerid, sellprice, StanLvl)
  510. {
  511. if((ReturnNextUnusedStanID()-1) >= MAX_STANOVA) return SendClientMessage(playerid, -1, ""CRVENA"[STAN]:"ZELENA" Napravljen je maksimalan broj stanova.");
  512.  
  513. new Stan[64], Float:X, Float:Y, Float:Z; GetPlayerPos(playerid, X, Y, Z);
  514. new NextStanID = ReturnNextUnusedStanID();
  515. new World = ReturnNextUnusedStanID();
  516.  
  517. format(Stan, sizeof(Stan), "/Stanovi/stan%d.ini", NextStanID);
  518.  
  519. if(!fexist(Stan))
  520. {
  521. new
  522. INI:stanFile = INI_Open(Stan);
  523.  
  524. INI_WriteString(stanFile, "Name", "Nema");
  525. INI_WriteInt(stanFile, "For_Sell", 1);
  526. INI_WriteInt(stanFile, "Sell_Price", sellprice);
  527. INI_WriteInt(stanFile, "Rent_Price", 1000);
  528. INI_WriteInt(stanFile, "Stan_Level", StanLvl);
  529. INI_WriteFloat(stanFile, "Exit_Coord:X", X);
  530. INI_WriteFloat(stanFile, "Exit_Coord:Y", Y);
  531. INI_WriteFloat(stanFile, "Exit_Coord:Z", Z);
  532. INI_WriteInt(stanFile, "VirtualWorld", NextStanID);
  533. INI_WriteInt(stanFile, "Status", 0);
  534. INI_Close(stanFile);
  535. LoadPlayerStan(NextStanID);
  536. SendClientMessage(playerid, -1, ""CRVENA"[STAN]:"ZELENA" Stan je uspjesno napravljen.");
  537. }
  538. return true;
  539. }
  540.  
  541. stock LoadPlayerStan(stanid)
  542. {
  543. new Stan[64];
  544.  
  545. format(Stan, sizeof(Stan), "/Stanovi/stan%d.ini", stanid);
  546.  
  547. if(fexist(Stan))
  548. {
  549. INI_ParseFile(Stan, "LoadStan_%s", .bExtra = true, .extra = stanid);
  550.  
  551. /*format(StanInfo[Stanid][stName], MAX_PLAYER_NAME, "%s", dini_Get(Stan, "Name"));
  552.  
  553. StanInfo[Stanid][stSellable] = dini_Int(Stan, "For_Sell");
  554. StanInfo[Stanid][stSell] = dini_Int(Stan, "Sell_Price");
  555. StanInfo[Stanid][stRent] = dini_Int(Stan, "Rent_Price");
  556. StanInfo[Stanid][stLevel] = dini_Int(Stan, "Stan_Level");
  557. StanInfo[Stanid][stExitX] = dini_Float(Stan, "Exit_Coord:X");
  558. StanInfo[Stanid][stExitY] = dini_Float(Stan, "Exit_Coord:Y");
  559. StanInfo[Stanid][stExitZ] = dini_Float(Stan, "Exit_Coord:Z");
  560. StanInfo[Stanid][stVirtualWorld] = dini_Int(Stan, "VirtualWorld");
  561. StanInfo[Stanid][stLocked] = dini_Int(Stan, "Status");*/
  562.  
  563. new
  564. stanLabel[170];
  565.  
  566. if(StanInfo[stanid][stSellable] == 1)
  567. {
  568. StanInfo[stanid][stPickup] = CreatePickup(1273, 23, StanInfo[stanid][stExitX], StanInfo[stanid][stExitY], StanInfo[stanid][stExitZ]); // not bought
  569.  
  570. format(stanLabel, sizeof(stanLabel), ""ZELENA"[STAN NA PRODAJU]\n"CRVENA"Vlasnik:"ZUTA" %s\n"CRVENA"Level: "ZUTA"%d\n"CRVENA"Cijena: "ZUTA"%d\n"CRVENA"Cijena Renta: "ZUTA"%d", StanInfo[stanid][stName], StanInfo[stanid][stLevel], StanInfo[stanid][stSell], StanInfo[stanid][stRent]);
  571. Create3DTextLabel(stanLabel, -1, StanInfo[stanid][stExitX], StanInfo[stanid][stExitY], StanInfo[stanid][stExitZ], 13.0, 0);
  572. }
  573. else
  574. {
  575. StanInfo[stanid][stPickup] = CreatePickup(1272,23, StanInfo[stanid][stExitX], StanInfo[stanid][stExitY], StanInfo[stanid][stExitZ]); // bought
  576.  
  577. format(stanLabel, sizeof(stanLabel), ""CRVENA"Vlasnik: "ZUTA"%s\n"CRVENA"Level: "ZUTA"%d\n"CRVENA"Cijena Renta: "ZUTA"%d", StanInfo[stanid][stName], StanInfo[stanid][stLevel], StanInfo[stanid][stRent]);
  578. Create3DTextLabel(stanLabel, -1, StanInfo[stanid][stExitX], StanInfo[stanid][stExitY], StanInfo[stanid][stExitZ], 13.0, 0);
  579. }
  580. }
  581. return true;
  582. }
  583.  
  584. stock SpremiStanove(Stanid)
  585. {
  586. new
  587. Stan[64];
  588.  
  589. format(Stan, sizeof(Stan), "/Stanovi/stan%d.ini", Stanid);
  590.  
  591. if(fexist(Stan))
  592. {
  593. new INI:stanFile = INI_Open(Stan);
  594. INI_WriteString(stanFile, "Name", StanInfo[Stanid][stName]);
  595. INI_WriteInt(stanFile, "For_Sell", StanInfo[Stanid][stSellable]);
  596. INI_WriteInt(stanFile, "Sell_Price", StanInfo[Stanid][stSell]);
  597. INI_WriteInt(stanFile, "Rent_Price", StanInfo[Stanid][stRent]);
  598. INI_WriteInt(stanFile, "Stan_Level", StanInfo[Stanid][stLevel]);
  599. INI_WriteFloat(stanFile, "Exit_Coord:X", StanInfo[Stanid][stExitX]);
  600. INI_WriteFloat(stanFile, "Exit_Coord:Y", StanInfo[Stanid][stExitY]);
  601. INI_WriteFloat(stanFile, "Exit_Coord:Z", StanInfo[Stanid][stExitZ]);
  602. INI_WriteInt(stanFile, "VirtualWorld", StanInfo[Stanid][stVirtualWorld]);
  603. INI_WriteInt(stanFile, "Status", StanInfo[Stanid][stLocked]);
  604. INI_Close(stanFile);
  605. }
  606. return true;
  607. }
  608.  
  609. stock ReturnNextUnusedStanID()
  610. {
  611. new Stan[64];
  612. for(new st = 0; st<= MAX_STANOVA; st++)
  613. {
  614. format(Stan, sizeof(Stan), "/Stanovi/stan%d.ini", st);
  615. if(!fexist(Stan)) return st;
  616. }
  617. return true;
  618. }
  619.  
  620. stock UnistiStan(playerid, Stanid)
  621. {
  622. new Stan[64];
  623. format(Stan, sizeof(Stan), "/Stanovi/stan%d.ini", Stanid);
  624. if(fexist(Stan))
  625. {
  626. fremove(Stan);
  627. DestroyPickup(StanInfo[Stanid][stPickup]);
  628. SendClientMessage(playerid, -1, ""CRVENA"[STAN]:"ZELENA" Taj stan je unisten.");
  629. }
  630. else return SendClientMessage(playerid, -1, ""CRVENA"ERROR: "ZELENA"ID Stana kojeg zelite unistiti ne postoji!");
  631. return false;
  632. }
  633.  
  634. stock GetName(playerid)
  635. {
  636. static
  637. pName[MAX_PLAYER_NAME];
  638.  
  639. pName = "Invalid PlayerID";
  640.  
  641. if(playerid != INVALID_PLAYER_ID)
  642. {
  643. GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  644. }
  645. return pName;
  646. }
  647.  
  648. stock SendFormattedMessage(playerid, colour, text[], va_args<>)
  649. {
  650. va_format(gChatMsg, 128, text, va_start<3>);
  651. SendClientMessage(playerid, colour, gChatMsg);
  652. return 1;
  653. }
Add Comment
Please, Sign In to add comment