SeC

House System v2.0 by Cirs Carandente AkA S&C

SeC
Aug 4th, 2011
1,444
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* House SYstem v2.0 creato da S&C AkA Cirs Carandente, Non rimuovere i crediti
  2. * ~ Ringraziamenti: Cirs Carandente AkA S&C per il [FS]
  3. * ~ Ringraziamenti: Team SAMP for SAMP :D
  4. * ~ Ringraziamenti: [DRuG]Slick Per SII include
  5. * ~ Ringraziamenti: Incognito for stramer INCLUDE
  6. */
  7.  
  8. #include <a_samp>
  9. #include <SII>
  10. #include <zcmd>
  11. #include <sscanf>
  12. #include <streamer>
  13.  
  14. #define MAX_HOUSE 50 // - Massime Case Creabili Aumentare se ne dovete creare di più
  15. #define H_FILE_PATH "SCHouse/%d.ini"// - Destinazione file Case.
  16. #define MENUCASA 5001 // - Dialog menù Casa
  17. #define MENUVENDICASA 5005 // - Dialog menù vendi Casa
  18. #define DEPOSITASOLDICASA 5006 // - Dialog Deposita Soldi
  19. #define RITIRASOLDICASA 5007 // - Dialog Ritira Soldi
  20.  
  21. #define ROSSO 0xff0000ff
  22. #define GIALLO 0xffff00ff
  23. #define BIANCO 0xffffffff
  24. #define VIOLA 0xff00ffff
  25. #define VERDE 0x00ff00ff
  26. #define BLU 0x0000ffff
  27. #define ARANCIONE 0xff4f00ff
  28.  
  29. enum HouseInfo
  30. {
  31. Float:X,
  32. Float:Y,
  33. Float:Z,
  34. Float:Xu,
  35. Float:Yu,
  36. Float:Zu,
  37. hText[64],
  38. hCosto,
  39. Interior,
  40. VirtualW,
  41. Proprietario[24],
  42. Comprata,
  43. Chiusa,
  44. Cassaforte,
  45. Text3D:DText,
  46. }
  47.  
  48. new hInfo[MAX_HOUSE][HouseInfo];
  49. new InCasa[MAX_PLAYERS];
  50. new file[256], stringa[256], PickupID[MAX_HOUSE], MapIconID[MAX_HOUSE];
  51.  
  52.  
  53. public OnFilterScriptInit()
  54. {
  55. print("\n--------------------------------------");
  56. print(" Blank Filterscript by your name here");
  57. print("--------------------------------------\n");
  58. LoadHouse();
  59. return 1;
  60. }
  61.  
  62. public OnFilterScriptExit()
  63. {
  64. return 1;
  65. }
  66.  
  67. public OnPlayerConnect(playerid)
  68. {
  69. InCasa[playerid] = -1;
  70. return 1;
  71. }
  72.  
  73. CMD:creacasa(playerid, params[])
  74. {
  75. new ID, Costo, Float:Pos[3];
  76. if(sscanf(params, "dd", ID, Costo))return SendClientMessage(playerid, VERDE, "/creacasa [ID] [COSTO]");
  77. if(Costo < 0 || Costo > 1000000)return SendClientMessage(playerid, ROSSO, "Costo troppo alto, Minimo 0 Massimo 1000000");
  78. if(!IsPlayerAdmin(playerid))return 0;
  79. format(file, sizeof(file), H_FILE_PATH, ID);
  80. if(INI_Exist(file))return SendClientMessage(playerid, ROSSO, "C'è già una casa creata con questo ID!");
  81. GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  82. INI_Open(file);
  83. INI_WriteFloat("FloatX", Pos[0]);
  84. INI_WriteFloat("FloatY", Pos[1]);
  85. INI_WriteFloat("FloatZ", Pos[2]);
  86. INI_WriteFloat("FloatXUscita", 235.508994);
  87. INI_WriteFloat("FloatYUscita", 1189.169897);
  88. INI_WriteFloat("FloatZUscita", 1080.339966);
  89. INI_WriteString("Descrizione", "Nuova Casa");
  90. INI_WriteInt("CostoCasa", Costo);
  91. INI_WriteInt("Interior", 3);
  92. INI_WriteInt("VirtualW", ID+999);
  93. INI_WriteInt("Comprata", 0);
  94. INI_WriteInt("Chiusa", 0);
  95. INI_WriteInt("Cassaforte", 0);
  96. INI_WriteString("Proprietario", "Invendita");
  97. INI_Save();
  98. INI_Close();
  99. hInfo[ID][X] = Pos[0];
  100. hInfo[ID][Y] = Pos[1];
  101. hInfo[ID][Z] = Pos[2];
  102. hInfo[ID][Xu] = 235.508994;
  103. hInfo[ID][Yu] = 1189.169897;
  104. hInfo[ID][Zu] = 1080.339966;
  105. strmid(hInfo[ID][hText], "Casa in vendita", 0, strlen("Casa in vendita"), 999);
  106. hInfo[ID][hCosto] = Costo;
  107. hInfo[ID][Interior] = 3;
  108. hInfo[ID][VirtualW] = ID+999;
  109. hInfo[ID][Comprata] = 0;
  110. hInfo[ID][Chiusa] = 0;
  111. hInfo[ID][Cassaforte] = 0;
  112. strmid(hInfo[ID][Proprietario], "Invendita", 0, strlen("Invendita"), 999);
  113. PickupID[ID] = CreatePickup(1273, 24, Pos[0], Pos[1], Pos[2], GetPlayerInterior(playerid));
  114. new stringatext[128];
  115. format(stringatext, sizeof(stringatext), "[ID: %d]Casa in Vendita. Costo: $%d.",ID, hInfo[ID][hCosto]);
  116. hInfo[ID][DText] = Create3DTextLabel(stringatext, VIOLA,Pos[0], Pos[1], Pos[2], 20.0, 0);
  117. MapIconID[ID] = CreateDynamicMapIcon(Pos[0], Pos[1], Pos[2], 31, 0, 0, 0, playerid, 100.0);
  118. return 1;
  119. }
  120.  
  121. CMD:gotocasa(playerid, params[])
  122. {
  123. new ID;
  124. if(sscanf(params, "d", ID))return SendClientMessage(playerid, VERDE, "/gotocasa [ID]");
  125. if(!IsPlayerAdmin(playerid))return 0;
  126. SetPlayerInterior(playerid, 0);
  127. SetPlayerVirtualWorld(playerid, 0);
  128. SetPlayerPos(playerid, hInfo[ID][X], hInfo[ID][Y], hInfo[ID][Z]);
  129. return 1;
  130. }
  131.  
  132. CMD:sethcosto(playerid, params[])
  133. {
  134. new ID, Costo;
  135. if(sscanf(params, "dd", ID, Costo))return SendClientMessage(playerid, VERDE, "/sethcosto [Id Casa] [Costo]");
  136. if(!IsPlayerAdmin(playerid))return 0;
  137. hInfo[ID][hCosto] = Costo;
  138. format(file, sizeof(file), "Hai impostato alla casa ID %d il costo a $%d", ID, Costo);
  139. SendClientMessage(playerid, ARANCIONE, file);
  140. return 1;
  141. }
  142.  
  143. CMD:sethexit(playerid, params[])
  144. {
  145. new ID, Float:x, Float:y, Float:z;
  146. if(sscanf(params, "d", ID))return SendClientMessage(playerid, VERDE, "/sethexit [Id Casa]");
  147. if(!IsPlayerAdmin(playerid))return 0;
  148. GetPlayerPos(playerid, x, y, z);
  149. hInfo[ID][Xu] = x;
  150. hInfo[ID][Yu] = y;
  151. hInfo[ID][Zu] = z;
  152. hInfo[ID][Interior] = GetPlayerInterior(playerid);
  153. format(file, sizeof(file), "Hai impostato alla casa ID %d l'uscita qui!", ID);
  154. SendClientMessage(playerid, ARANCIONE, file);
  155. return 1;
  156. }
  157.  
  158. CMD:sethint(playerid, params[])
  159. {
  160. new ID, Int, string[128];
  161. if(sscanf(params, "dd", ID, Int))return SendClientMessage(playerid, VERDE, "/sethexit [Id Casa] [Interior]");
  162. if(!IsPlayerAdmin(playerid))return 0;
  163. if(Int > 0 && Int > 26) return SendClientMessage(playerid, -1, "ID interior da 0 a 26!");
  164. switch(Int)
  165. {
  166. case 0:
  167. {
  168. hInfo[ID][Xu] = 235.508994;
  169. hInfo[ID][Yu] = 1189.169897;
  170. hInfo[ID][Zu] = 1080.339966;
  171. hInfo[ID][Interior] = 3;
  172. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  173. SendClientMessage(playerid, ARANCIONE, string);
  174. }
  175. case 1:
  176. {
  177. hInfo[ID][Xu] = 225.756989;
  178. hInfo[ID][Yu] = 1240.000000;
  179. hInfo[ID][Zu] = 1082.149902;
  180. hInfo[ID][Interior] = 2;
  181. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  182. SendClientMessage(playerid, ARANCIONE, string);
  183. }
  184. case 2:
  185. {
  186. hInfo[ID][Xu] = 223.043991;
  187. hInfo[ID][Yu] = 1289.259888;
  188. hInfo[ID][Zu] = 1082.199951;
  189. hInfo[ID][Interior] = 1;
  190. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  191. SendClientMessage(playerid, ARANCIONE, string);
  192. }
  193. case 3:
  194. {
  195. hInfo[ID][Xu] = 225.630997;
  196. hInfo[ID][Yu] = 1022.479980;
  197. hInfo[ID][Zu] = 1084.069946;
  198. hInfo[ID][Interior] = 7;
  199. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  200. SendClientMessage(playerid, ARANCIONE, string);
  201. }
  202. case 4:
  203. {
  204. hInfo[ID][Xu] = 295.138977;
  205. hInfo[ID][Yu] = 1474.469971;
  206. hInfo[ID][Zu] = 1080.519897;
  207. hInfo[ID][Interior] = 15;
  208. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  209. SendClientMessage(playerid, ARANCIONE, string);
  210. }
  211. case 5:
  212. {
  213. hInfo[ID][Xu] = 328.493988;
  214. hInfo[ID][Yu] = 1480.589966;
  215. hInfo[ID][Zu] = 1084.449951;
  216. hInfo[ID][Interior] = 15;
  217. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  218. SendClientMessage(playerid, ARANCIONE, string);
  219. }
  220. case 6:
  221. {
  222. hInfo[ID][Xu] = 385.803986;
  223. hInfo[ID][Yu] = 1471.769897;
  224. hInfo[ID][Zu] = 1080.209961;
  225. hInfo[ID][Interior] = 15;
  226. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  227. SendClientMessage(playerid, ARANCIONE, string);
  228. }
  229. case 7:
  230. {
  231. hInfo[ID][Xu] = 375.971985;
  232. hInfo[ID][Yu] = 1417.269897;
  233. hInfo[ID][Zu] = 1081.409912;
  234. hInfo[ID][Interior] = 15;
  235. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  236. SendClientMessage(playerid, ARANCIONE, string);
  237. }
  238. case 8:
  239. {
  240. hInfo[ID][Xu] = 490.810974;
  241. hInfo[ID][Yu] = 1401.489990;
  242. hInfo[ID][Zu] = 1080.339966;
  243. hInfo[ID][Interior] = 2;
  244. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  245. SendClientMessage(playerid, ARANCIONE, string);
  246. }
  247. case 9:
  248. {
  249. hInfo[ID][Xu] = 447.734985;
  250. hInfo[ID][Yu] = 1400.439941;
  251. hInfo[ID][Zu] = 1084.339966;
  252. hInfo[ID][Interior] = 2;
  253. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  254. SendClientMessage(playerid, ARANCIONE, string);
  255. }
  256. case 10:
  257. {
  258. hInfo[ID][Xu] = 227.722992;
  259. hInfo[ID][Yu] = 1114.389893;
  260. hInfo[ID][Zu] = 1081.189941;
  261. hInfo[ID][Interior] = 5;
  262. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  263. SendClientMessage(playerid, ARANCIONE, string);
  264. }
  265. case 11:
  266. {
  267. hInfo[ID][Xu] = 260.983978;
  268. hInfo[ID][Yu] = 1286.549927;
  269. hInfo[ID][Zu] = 1080.299927;
  270. hInfo[ID][Interior] = 4;
  271. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  272. SendClientMessage(playerid, ARANCIONE, string);
  273. }
  274. case 12:
  275. {
  276. hInfo[ID][Xu] = 221.666992;
  277. hInfo[ID][Yu] = 1143.389893;
  278. hInfo[ID][Zu] = 1082.679932;
  279. hInfo[ID][Interior] = 4;
  280. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  281. SendClientMessage(playerid, ARANCIONE, string);
  282. }
  283. case 13:
  284. {
  285. hInfo[ID][Xu] = 27.132700;
  286. hInfo[ID][Yu] = 1341.149902;
  287. hInfo[ID][Zu] = 1084.449951;
  288. hInfo[ID][Interior] = 10;
  289. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  290. SendClientMessage(playerid, ARANCIONE, string);
  291. }
  292. case 14:
  293. {
  294. hInfo[ID][Xu] = -262.601990;
  295. hInfo[ID][Yu] = 1456.619995;
  296. hInfo[ID][Zu] = 1084.449951;
  297. hInfo[ID][Interior] = 4;
  298. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  299. SendClientMessage(playerid, ARANCIONE, string);
  300. }
  301. case 15:
  302. {
  303. hInfo[ID][Xu] = 22.778299;
  304. hInfo[ID][Yu] = 1404.959961;
  305. hInfo[ID][Zu] = 1084.449951;
  306. hInfo[ID][Interior] = 5;
  307. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  308. SendClientMessage(playerid, ARANCIONE, string);
  309. }
  310. case 16:
  311. {
  312. hInfo[ID][Xu] = 140.278000;
  313. hInfo[ID][Yu] = 1368.979980;
  314. hInfo[ID][Zu] = 1083.969971;
  315. hInfo[ID][Interior] = 5;
  316. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  317. SendClientMessage(playerid, ARANCIONE, string);
  318. }
  319. case 17:
  320. {
  321. hInfo[ID][Xu] = 234.045990;
  322. hInfo[ID][Yu] = 1064.879883;
  323. hInfo[ID][Zu] = 1084.309937;
  324. hInfo[ID][Interior] = 6;
  325. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  326. SendClientMessage(playerid, ARANCIONE, string);
  327. }
  328. case 18:
  329. {
  330. hInfo[ID][Xu] = -68.294098;
  331. hInfo[ID][Yu] = 1353.469971;
  332. hInfo[ID][Zu] = 1080.279907;
  333. hInfo[ID][Interior] = 6;
  334. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  335. SendClientMessage(playerid, ARANCIONE, string);
  336. }
  337. case 19:
  338. {
  339. hInfo[ID][Xu] = -285.548981;
  340. hInfo[ID][Yu] = 1470.979980;
  341. hInfo[ID][Zu] = 1084.449951;
  342. hInfo[ID][Interior] = 15;
  343. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  344. SendClientMessage(playerid, ARANCIONE, string);
  345. }
  346. case 20:
  347. {
  348. hInfo[ID][Xu] = -42.581997;
  349. hInfo[ID][Yu] = 1408.109985;
  350. hInfo[ID][Zu] = 1084.449951;
  351. hInfo[ID][Interior] = 8;
  352. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  353. SendClientMessage(playerid, ARANCIONE, string);
  354. }
  355. case 21:
  356. {
  357. hInfo[ID][Xu] = 83.345093;
  358. hInfo[ID][Yu] = 1324.439941;
  359. hInfo[ID][Zu] = 1083.889893;
  360. hInfo[ID][Interior] = 9;
  361. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  362. SendClientMessage(playerid, ARANCIONE, string);
  363. }
  364. case 22:
  365. {
  366. hInfo[ID][Xu] = 260.941986;
  367. hInfo[ID][Yu] = 1238.509888;
  368. hInfo[ID][Zu] = 1084.259888;
  369. hInfo[ID][Interior] = 9;
  370. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  371. SendClientMessage(playerid, ARANCIONE, string);
  372. }
  373. case 23:
  374. {
  375. hInfo[ID][Xu] = 260.941986;
  376. hInfo[ID][Yu] = 1238.509888;
  377. hInfo[ID][Zu] = 1084.259888;
  378. hInfo[ID][Interior] = 9;
  379. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  380. SendClientMessage(playerid, ARANCIONE, string);
  381. }
  382. case 24:
  383. {
  384. hInfo[ID][Xu] = 244.411987;
  385. hInfo[ID][Yu] = 305.032990;
  386. hInfo[ID][Zu] = 999.231995;
  387. hInfo[ID][Interior] = 1;
  388. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  389. SendClientMessage(playerid, ARANCIONE, string);
  390. }
  391. case 25:
  392. {
  393. hInfo[ID][Xu] = 271.884979;
  394. hInfo[ID][Yu] = 306.631989;
  395. hInfo[ID][Zu] = 999.325989;
  396. hInfo[ID][Interior] = 2;
  397. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  398. SendClientMessage(playerid, ARANCIONE, string);
  399. }
  400. case 26:
  401. {
  402. hInfo[ID][Xu] = 291.282990;
  403. hInfo[ID][Yu] = 310.031982;
  404. hInfo[ID][Zu] = 999.154968;
  405. hInfo[ID][Interior] = 3;
  406. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  407. SendClientMessage(playerid, ARANCIONE, string);
  408. }
  409. }
  410. return 1;
  411. }
  412.  
  413. CMD:removehouse(playerid, params[])
  414. {
  415. new ID, string[128];
  416. if(sscanf(params, "d", ID))return SendClientMessage(playerid, VERDE, "/removehouse [Id Casa]");
  417. if(!IsPlayerAdmin(playerid))return 0;
  418. format(file, sizeof(file), H_FILE_PATH, ID);
  419. if(!INI_Exist(file))return SendClientMessage(playerid, ROSSO, "Non c'è una casa con questo ID creata, quindi, non puoi eliminarla");
  420. INI_Open(file);
  421. INI_Remove(file);
  422. INI_Save();
  423. INI_Close();
  424. hInfo[ID][X] = 0.0;
  425. hInfo[ID][Y] = 0.0;
  426. hInfo[ID][Z] = 0.0;
  427. hInfo[ID][Interior] = 0;
  428. hInfo[ID][Cassaforte] = 0;
  429. DestroyPickup(PickupID[ID]);
  430. Delete3DTextLabel(hInfo[ID][DText]);
  431. DestroyDynamicMapIcon(MapIconID[ID]);
  432. format(string, sizeof(string), "Hai eliminato la casa ID %d", ID);
  433. SendClientMessage(playerid, BLU, string);
  434. return 1;
  435. }
  436.  
  437. CMD:vendicasa(playerid, params[])
  438. {
  439. new ID, string[128];
  440. if(sscanf(params, "d", ID))return SendClientMessage(playerid, VERDE, "/vendicasa [Id Casa]");
  441. if(!IsPlayerAdmin(playerid))return 0;
  442. format(file, sizeof(file), H_FILE_PATH, ID);
  443. if(!INI_Exist(file))return SendClientMessage(playerid, ROSSO, "Non c'è una casa con questo ID creata, quindi, non puoi venderla");
  444. INI_Open(file);
  445. INI_WriteInt("Comprata", 0);
  446. INI_WriteString("Proprietario", "Nessuno");
  447. INI_Save();
  448. INI_Close();
  449. hInfo[ID][Comprata] = 0;
  450. DestroyPickup(PickupID[ID]);
  451. PickupID[ID] = CreatePickup(1272, 24, hInfo[ID][X], hInfo[ID][Y], hInfo[ID][Z], GetPlayerInterior(playerid));
  452. Delete3DTextLabel(hInfo[ID][DText]);
  453. new stringatext[128];
  454. format(stringatext, sizeof(stringatext), "[ID: %d]Casa in Vendita. Costo: $%d.", ID, hInfo[ID][hCosto]);
  455. hInfo[ID][DText] = Create3DTextLabel(stringatext,VIOLA, hInfo[ID][X], hInfo[ID][Y], hInfo[ID][Z], 20.0, 0);
  456. format(string, sizeof(string), "Hai venduto la casa ID %d", ID);
  457. SendClientMessage(playerid, BLU, string);
  458. return 1;
  459. }
  460.  
  461. public OnPlayerPickUpPickup(playerid, pickupid)
  462. {
  463. if(pickupid == PickupID[GetH(playerid)])// Quando il player entra nel pickup delle case.
  464. {
  465. if(hInfo[GetH(playerid)][Comprata] == 0)
  466. {
  467. format(stringa, sizeof(stringa), "ID: [%d] ~n~ Descrizione: %s~n~~w~Costo Casa: ~g~$%d", GetH(playerid), hInfo[GetH(playerid)][hText], hInfo[GetH(playerid)][hCosto]);
  468. GameTextForPlayer(playerid, stringa, 3500, 3);
  469. }
  470. else if(hInfo[GetH(playerid)][Comprata] == 1)
  471. {
  472. format(stringa, sizeof(stringa), "ID: [%d] ~n~~w~Proprietario: ~g~%s", GetH(playerid), hInfo[GetH(playerid)][Proprietario]);
  473. GameTextForPlayer(playerid, stringa, 3500, 3);
  474. }
  475. }
  476. return 1;
  477. }
  478.  
  479. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  480. {
  481. if(newkeys == KEY_SECONDARY_ATTACK)//Entrata Case
  482. {
  483. for(new i = 0; i < MAX_HOUSE; i++)
  484. {
  485. if(InCasa[playerid] == -1 && IsPlayerInRangeOfPoint(playerid, 1.0, hInfo[i][X], hInfo[i][Y], hInfo[i][Z]))
  486. {
  487. if(hInfo[i][Chiusa] == 1)return SendClientMessage(playerid, VERDE, "[INFO:] Casa Chiusa!");
  488. SetPlayerPos(playerid, hInfo[i][Xu], hInfo[i][Yu], hInfo[i][Zu]);
  489. SetPlayerInterior(playerid, hInfo[i][Interior]);
  490. SetPlayerVirtualWorld(playerid, hInfo[i][VirtualW]);
  491. InCasa[playerid] = i;
  492. }
  493. else if(InCasa[playerid] != -1 && IsPlayerInRangeOfPoint(playerid, 2.0, hInfo[InCasa[playerid]][Xu], hInfo[InCasa[playerid]][Yu], hInfo[InCasa[playerid]][Zu]))
  494. {
  495. if(GetPlayerVirtualWorld(playerid) == hInfo[i][VirtualW])
  496. {
  497. if(hInfo[i][Chiusa] == 1)return SendClientMessage(playerid, VERDE, "[INFO:] Casa Chiusa!");
  498. SetPlayerPos(playerid, hInfo[i][X], hInfo[i][Y], hInfo[i][Z]);
  499. SetPlayerInterior(playerid, 0);
  500. SetPlayerVirtualWorld(playerid, 0);
  501. InCasa[playerid] = -1;
  502. }
  503. }
  504. }
  505. }
  506. if(newkeys == KEY_JUMP)
  507. {
  508. if(IsPlayerInRangeOfPoint(playerid, 1.0, hInfo[GetH(playerid)][X], hInfo[GetH(playerid)][Y], hInfo[GetH(playerid)][Z]))
  509. {
  510. if(GetPlayerMoney(playerid) < hInfo[GetH(playerid)][hCosto])return SendClientMessage(playerid, ROSSO, "Non hai abbastanza Soldi!");
  511. if(hInfo[GetH(playerid)][Comprata] == 1)return SendClientMessage(playerid, VERDE, "Questa casa non è in vendita!");
  512. hInfo[GetH(playerid)][Comprata] = 1;
  513. GivePlayerMoney(playerid, -hInfo[GetH(playerid)][hCosto]);
  514. new nome[24];
  515. GetPlayerName(playerid, nome, sizeof(nome));
  516. SendClientMessage(playerid, BLU, "Hai comprato questa casa con successo!");
  517. InCasa[playerid] = GetH(playerid);
  518. SetPlayerPos(playerid, hInfo[GetH(playerid)][Xu], hInfo[GetH(playerid)][Yu], hInfo[GetH(playerid)][Zu]);
  519. SetPlayerInterior(playerid, hInfo[GetH(playerid)][Interior]);
  520. SetPlayerVirtualWorld(playerid, hInfo[GetH(playerid)][VirtualW]);
  521. DestroyPickup(PickupID[GetH(playerid)]);
  522. PickupID[GetH(playerid)] = CreatePickup(1272, 24, hInfo[GetH(playerid)][X], hInfo[GetH(playerid)][Y], hInfo[GetH(playerid)][Z], GetPlayerInterior(playerid)); Delete3DTextLabel(hInfo[GetH(playerid)][DText]);
  523. DestroyDynamicMapIcon(MapIconID[GetH(playerid)]);
  524. MapIconID[GetH(playerid)] = CreateDynamicMapIcon(hInfo[GetH(playerid)][X], hInfo[GetH(playerid)][Y], hInfo[GetH(playerid)][Z], 32, 0, 0, 0, playerid, 50.0);
  525. INI_Open(file);
  526. INI_WriteString("Proprietario", nome);
  527. hInfo[GetH(playerid)][Proprietario] = nome;
  528. INI_WriteString("Descrizione", "Casa non in vendita");
  529. INI_WriteInt("Comprata", 1);
  530. INI_Save();
  531. INI_Close();
  532. Delete3DTextLabel(hInfo[GetH(playerid)][DText]);
  533. new stringatext[128];
  534. format(stringatext, sizeof(stringatext), "[ID: %d] Casa non in Vendita. Proprietario: %s.", GetH(playerid), hInfo[GetH(playerid)][Proprietario]);
  535. hInfo[GetH(playerid)][DText] = Create3DTextLabel(stringatext,VIOLA, hInfo[GetH(playerid)][X], hInfo[GetH(playerid)][Y], hInfo[GetH(playerid)][Z], 20.0, 0);
  536.  
  537. }
  538. }
  539. if(newkeys == KEY_WALK)
  540. {
  541. if(IsPlayerInRangeOfPoint(playerid, 1.0, hInfo[GetH(playerid)][X], hInfo[GetH(playerid)][Y], hInfo[GetH(playerid)][Z]))
  542. {
  543. new nome[24];
  544. GetPlayerName(playerid, nome, sizeof(nome));
  545. if(strcmp(hInfo[GetH(playerid)][Proprietario], nome) != 0) return SendClientMessage(playerid,0xFF1E00FF,"Questa casa non è tua!");
  546. if(hInfo[GetH(playerid)][Comprata] == 0)return SendClientMessage(playerid,0xFF1E00FF,"Questa casa non è tua!");
  547. ShowPlayerDialog(playerid, MENUCASA, DIALOG_STYLE_LIST, "Casa", "Vendi Casa\nChiudi/Apri Casa\nRitira Soldi\nDeposita Soldi", "Seleziona", "Annulla");
  548. }
  549. return 1;
  550. }
  551. return 1;
  552. }
  553.  
  554. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  555. {
  556. if(dialogid == MENUCASA && response)
  557. {
  558. if(!response)return 0;
  559. switch(listitem)
  560. {
  561. case 0:
  562. {
  563. new string[128];
  564. format(string, sizeof(string), "Sei sicuro di voler vendere la tua casa per $%d ?", hInfo[GetH(playerid)][hCosto]/2);
  565. ShowPlayerDialog(playerid, MENUVENDICASA, DIALOG_STYLE_MSGBOX, "Vendi", string, "Si", "No");
  566. }
  567. case 1:
  568. {
  569. if(hInfo[GetH(playerid)][Chiusa] == 0)
  570. {
  571. hInfo[GetH(playerid)][Chiusa] = 1;
  572. SendClientMessage(playerid, GIALLO, "[INFO:] Hai chiuso la tua casa");
  573. SaveHouse();
  574. }
  575. else if(hInfo[GetH(playerid)][Chiusa] == 1)
  576. {
  577. hInfo[GetH(playerid)][Chiusa] = 0;
  578. SendClientMessage(playerid, GIALLO, "[INFO:] Hai aperto la tua casa");
  579. SaveHouse();
  580. }
  581. }
  582. case 2:ShowPlayerDialog(playerid, RITIRASOLDICASA, DIALOG_STYLE_INPUT, "Ritiro", "Scrivi la cifra che vuoi ritirare dalla casa", "Ritira", "Annulla");
  583. case 3:ShowPlayerDialog(playerid, DEPOSITASOLDICASA, DIALOG_STYLE_INPUT, "Deposito", "Scrivi la cifra che vuoi depositare in casa", "Deposita", "Annulla");
  584. }
  585. return 1;
  586. }
  587. if(dialogid == MENUVENDICASA && response)
  588. {
  589. if(!response)return 0;
  590. new string[256];
  591. GivePlayerMoney(playerid, hInfo[GetH(playerid)][hCosto]/2);
  592. format(string, sizeof(string), "Hai venduto la tua casa per $%d ", hInfo[GetH(playerid)][hCosto]/2);
  593. SendClientMessage(playerid, BLU, string);
  594. hInfo[GetH(playerid)][Comprata] = 0;
  595. DestroyPickup(PickupID[GetH(playerid)]);
  596. PickupID[GetH(playerid)] = CreatePickup(1273, 24, hInfo[GetH(playerid)][X], hInfo[GetH(playerid)][Y], hInfo[GetH(playerid)][Z], GetPlayerInterior(playerid));
  597. format(file, sizeof(file), H_FILE_PATH, GetH(playerid));
  598. INI_Open(file);
  599. INI_WriteString("Proprietario", "Nessuno");
  600. INI_WriteInt("Comprata", 0);
  601. INI_Save();
  602. INI_Close();
  603. SaveHouse();
  604. Delete3DTextLabel(hInfo[GetH(playerid)][DText]);
  605. new stringatext[128];
  606. format(stringatext, sizeof(stringatext), "[ID: %d] Casa in Vendita. Costo: %d.", GetH(playerid), hInfo[GetH(playerid)][hCosto]);
  607. hInfo[GetH(playerid)][DText] = Create3DTextLabel(stringatext, VIOLA, hInfo[GetH(playerid)][X], hInfo[GetH(playerid)][Y], hInfo[GetH(playerid)][Z], 20.0, 0);
  608.  
  609. }
  610. if(dialogid == DEPOSITASOLDICASA && response)
  611. {
  612. new string[200];
  613. if(!response)return 0;
  614. if(GetPlayerMoney(playerid) < strval(inputtext))return ShowPlayerDialog(playerid, DEPOSITASOLDICASA, DIALOG_STYLE_INPUT, "Deposito", "Non hai tutti questi soldi!\nScrivi la cifra che vuoi depositare in casa", "Deposita", "Annulla");
  615. hInfo[GetH(playerid)][Cassaforte] = hInfo[GetH(playerid)][Cassaforte]+strval(inputtext);
  616. format(string, sizeof(string), "Hai depositato %d in casa tua", strval(inputtext));
  617. SendClientMessage(playerid, BLU, string);
  618. GivePlayerMoney(playerid, -strval(inputtext));
  619. }
  620. if(dialogid == RITIRASOLDICASA && response)
  621. {
  622. new string[200];
  623. if(!response)return 0;
  624. if(strval(inputtext) > hInfo[GetH(playerid)][Cassaforte])return ShowPlayerDialog(playerid, RITIRASOLDICASA, DIALOG_STYLE_INPUT, "Ritiro", "Non hai tutti questi soldi in casa!\nScrivi la cifra che vuoi ritirare dalla casa", "Ritira", "Annulla");
  625. if(0 < strval(inputtext))return SendClientMessage(playerid, ROSSO, "Importo invalido!");
  626. hInfo[GetH(playerid)][Cassaforte] = hInfo[GetH(playerid)][Cassaforte]-strval(inputtext);
  627. format(string, sizeof(string), "Hai ritirato %d dalla tua casa!", strval(inputtext));
  628. SendClientMessage(playerid, BLU, string);
  629. GivePlayerMoney(playerid, strval(inputtext));
  630. }
  631. return 1;
  632. }
  633.  
  634.  
  635. stock GetH(playerid)//Getta l'ID della casa in cui il player è..
  636. {
  637. for(new i=0; i<MAX_HOUSE; i++)
  638. {
  639. if(IsPlayerInRangeOfPoint(playerid, 2.0, hInfo[i][X], hInfo[i][Y], hInfo[i][Z]))
  640. {
  641. return i;
  642. }
  643. }
  644. return -230;
  645. }
  646.  
  647. stock SaveHouse()//Carica Le case
  648. {
  649. for(new i = 0; i<MAX_HOUSE; i++)
  650. {
  651. format(file, sizeof(file), H_FILE_PATH, i);
  652. if(INI_Exist(file))
  653. {
  654. INI_Open(file);
  655. INI_WriteFloat("FloatX", hInfo[i][X]);
  656. INI_WriteFloat("FloatY", hInfo[i][Y]);
  657. INI_WriteFloat("FloatZ", hInfo[i][Z]);
  658. INI_WriteFloat("FloatXUscita", hInfo[i][Xu]);
  659. INI_WriteFloat("FloatYUscita", hInfo[i][Yu]);
  660. INI_WriteFloat("FloatZUscita", hInfo[i][Zu]);
  661. INI_WriteString("Descrizione", hInfo[i][hText]);
  662. INI_WriteInt("CostoCasa", hInfo[i][hCosto]);
  663. INI_WriteInt("Interior", hInfo[i][Interior]);
  664. INI_WriteInt("VirtualW", hInfo[i][VirtualW]);
  665. INI_WriteInt("Comprata", hInfo[i][Comprata]);
  666. INI_WriteInt("Chiusa", hInfo[i][Chiusa]);
  667. INI_WriteInt("Cassaforte", hInfo[i][Cassaforte]);
  668. INI_WriteString("Proprietario", hInfo[i][Proprietario]);
  669. INI_Save();
  670. INI_Close();
  671. }
  672. }
  673. }
  674. stock LoadHouse()//Carica Le case
  675. {
  676. new Nome[MAX_PLAYER_NAME], Desc[64];
  677. for(new i = 0; i<MAX_HOUSE; i++)
  678. {
  679. for(new a = 0; a<MAX_PLAYERS; a++)
  680. {
  681. format(file, sizeof(file), H_FILE_PATH, i);
  682. if(INI_Exist(file))
  683. {
  684. INI_Open(file);
  685. hInfo[i][X] = INI_ReadFloat("FloatX");
  686. hInfo[i][Y] = INI_ReadFloat("FloatY");
  687. hInfo[i][Z] = INI_ReadFloat("FloatZ");
  688. hInfo[i][Xu] = INI_ReadFloat("FloatXUscita");
  689. hInfo[i][Yu] = INI_ReadFloat("FloatYUscita");
  690. hInfo[i][Zu] = INI_ReadFloat("FloatZUscita");
  691. INI_ReadString(Desc, "Descrizione", 128);
  692. hInfo[i][hText] = Desc;
  693. hInfo[i][hCosto] = INI_ReadInt("CostoCasa");
  694. hInfo[i][Interior] = INI_ReadInt("Interior");
  695. hInfo[i][VirtualW] = INI_ReadInt("VirtualW");
  696. hInfo[i][Comprata] = INI_ReadInt("Comprata");
  697. hInfo[i][Cassaforte] = INI_ReadInt("Cassaforte");
  698. hInfo[i][Chiusa] = INI_ReadInt("Chiusa");
  699. INI_ReadString(Nome, "Proprietario", 128);
  700. hInfo[i][Proprietario] = Nome;
  701. INI_Close();
  702. if(hInfo[i][Comprata] == 0)
  703. {
  704. PickupID[i] = CreatePickup(1273, 24, hInfo[i][X], hInfo[i][Y], hInfo[i][Z], GetPlayerInterior(i));
  705. MapIconID[i] = CreateDynamicMapIcon(hInfo[i][X], hInfo[i][Y], hInfo[i][Z], 31, 0, 0, 0, a, 50.0);
  706. new stringatext[128];
  707. format(stringatext, sizeof(stringatext), "[ID: %d] Casa in Vendita. Costo: $%d.", i, hInfo[i][hCosto]);
  708. hInfo[i][DText] = Create3DTextLabel(stringatext,VIOLA, hInfo[i][X], hInfo[i][Y], hInfo[i][Z], 20.0, 0);
  709. }
  710. else if(hInfo[i][Comprata] == 1)
  711. {
  712. PickupID[i] = CreatePickup(1272, 24, hInfo[i][X], hInfo[i][Y], hInfo[i][Z], GetPlayerInterior(i));
  713. MapIconID[i] = CreateDynamicMapIcon(hInfo[i][X], hInfo[i][Y], hInfo[i][Z], 32, 0, 0, 0, a, 50.0);
  714. new stringatext[128];
  715. format(stringatext, sizeof(stringatext), "[ID: %d] Casa non in Vendita. Proprietario: %s.", i, hInfo[i][Proprietario]);
  716. hInfo[i][DText] = Create3DTextLabel(stringatext,VIOLA, hInfo[i][X], hInfo[i][Y], hInfo[i][Z], 20.0, 0);
  717. }
  718. }
  719. }
  720. }
  721. }
RAW Paste Data