Advertisement
Guest User

Untitled

a guest
Jul 28th, 2011
694
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. //#define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6. #include <SII>
  7. #include <zcmd>
  8. #include <sscanf>
  9.  
  10. #define MAX_HOUSE 50 // - Massime Case Creabili Aumentare se ne dovete creare di più
  11. #define H_FILE_PATH "SCHouse/%d.ini"// - Destinazione file Case.
  12. #define MENUCASA 5001 // - Dialog menù Casa
  13. #define MENUVENDICASA 5005 // - Dialog menù vendi Casa
  14. #define DEPOSITASOLDICASA 5006 // - Dialog Deposita Soldi
  15. #define RITIRASOLDICASA 5007 // - Dialog Ritira Soldi
  16.  
  17.  
  18.  
  19. enum HouseInfo
  20. {
  21. Float:X,
  22. Float:Y,
  23. Float:Z,
  24. Float:Xu,
  25. Float:Yu,
  26. Float:Zu,
  27. hText[64],
  28. hCosto,
  29. Interior,
  30. VirtualW,
  31. Proprietario[24],
  32. Comprata,
  33. Chiusa,
  34. Cassaforte
  35. }
  36.  
  37. new hInfo[MAX_HOUSE][HouseInfo];
  38. new InCasa[MAX_PLAYERS];
  39. new file[256], stringa[256], PickupID[MAX_HOUSE];
  40.  
  41.  
  42. public OnFilterScriptInit()
  43. {
  44. print("\n--------------------------------------");
  45. print(" Blank Filterscript by your name here");
  46. print("--------------------------------------\n");
  47. LoadHouse();
  48. return 1;
  49. }
  50.  
  51. public OnFilterScriptExit()
  52. {
  53. return 1;
  54. }
  55.  
  56. public OnPlayerConnect(playerid)
  57. {
  58. InCasa[playerid] = -1;
  59. return 1;
  60. }
  61.  
  62. CMD:creacasa(playerid, params[])
  63. {
  64. new ID, Costo, Float:Pos[3];
  65. if(sscanf(params, "dd", ID, Costo))return SendClientMessage(playerid, -1, "/creacasa [ID] [COSTO]");
  66. if(Costo < 0 || Costo > 1000000)return SendClientMessage(playerid, -1, "Costo troppo alto, Minimo 0 Massimo 1000000");
  67. if(!IsPlayerAdmin(playerid))return 0;
  68. format(file, sizeof(file), H_FILE_PATH, ID);
  69. if(INI_Exist(file))return SendClientMessage(playerid, -1, "C'è già una casa creata con questo ID!");
  70. GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  71. INI_Open(file);
  72. INI_WriteFloat("FloatX", Pos[0]);
  73. INI_WriteFloat("FloatY", Pos[1]);
  74. INI_WriteFloat("FloatZ", Pos[2]);
  75. INI_WriteFloat("FloatXUscita", 235.508994);
  76. INI_WriteFloat("FloatYUscita", 1189.169897);
  77. INI_WriteFloat("FloatZUscita", 1080.339966);
  78. INI_WriteString("Descrizione", "Nuova Casa");
  79. INI_WriteInt("CostoCasa", Costo);
  80. INI_WriteInt("Interior", 3);
  81. INI_WriteInt("VirtualW", ID+999);
  82. INI_WriteInt("Comprata", 0);
  83. INI_WriteInt("Chiusa", 0);
  84. INI_WriteInt("Cassaforte", 0);
  85. INI_WriteString("Proprietario", "Invendita");
  86. INI_Save();
  87. INI_Close();
  88. hInfo[ID][X] = Pos[0];
  89. hInfo[ID][Y] = Pos[1];
  90. hInfo[ID][Z] = Pos[2];
  91. hInfo[ID][Xu] = 235.508994;
  92. hInfo[ID][Yu] = 1189.169897;
  93. hInfo[ID][Zu] = 1080.339966;
  94. strmid(hInfo[ID][hText], "Casa in vendita", 0, strlen("Casa in vendita"), 999);
  95. hInfo[ID][hCosto] = Costo;
  96. hInfo[ID][Interior] = 3;
  97. hInfo[ID][VirtualW] = ID+999;
  98. hInfo[ID][Comprata] = 0;
  99. hInfo[ID][Chiusa] = 0;
  100. hInfo[ID][Cassaforte] = 0;
  101. strmid(hInfo[ID][Proprietario], "Invendita", 0, strlen("Invendita"), 999);
  102. PickupID[ID] = CreatePickup(1273, 24, Pos[0], Pos[1], Pos[2]);
  103. return 1;
  104. }
  105.  
  106. CMD:gotocasa(playerid, params[])
  107. {
  108. new ID;
  109. if(sscanf(params, "d", ID))return SendClientMessage(playerid, -1, "/gotocasa [ID]");
  110. if(!IsPlayerAdmin(playerid))return 0;
  111. SetPlayerInterior(playerid, 0);
  112. SetPlayerVirtualWorld(playerid, 0);
  113. SetPlayerPos(playerid, hInfo[ID][X], hInfo[ID][Y], hInfo[ID][Z]);
  114. return 1;
  115. }
  116.  
  117. CMD:sethcosto(playerid, params[])
  118. {
  119. new ID, Costo;
  120. if(sscanf(params, "dd", ID, Costo))return SendClientMessage(playerid, -1, "/sethcosto [Id Casa] [Costo]");
  121. if(!IsPlayerAdmin(playerid))return 0;
  122. hInfo[ID][hCosto] = Costo;
  123. format(file, sizeof(file), "Hai impostato alla casa ID %d il costo a $%d", ID, Costo);
  124. SendClientMessage(playerid, -1, file);
  125. return 1;
  126. }
  127.  
  128. CMD:sethexit(playerid, params[])
  129. {
  130. new ID, Float:x, Float:y, Float:z;
  131. if(sscanf(params, "d", ID))return SendClientMessage(playerid, -1, "/sethexit [Id Casa]");
  132. if(!IsPlayerAdmin(playerid))return 0;
  133. GetPlayerPos(playerid, x, y, z);
  134. hInfo[ID][Xu] = x;
  135. hInfo[ID][Yu] = y;
  136. hInfo[ID][Zu] = z;
  137. hInfo[ID][Interior] = GetPlayerInterior(playerid);
  138. format(file, sizeof(file), "Hai impostato alla casa ID %d l'uscita qui!", ID);
  139. SendClientMessage(playerid, -1, file);
  140. return 1;
  141. }
  142.  
  143. CMD:sethint(playerid, params[])
  144. {
  145. new ID, Int, string[128];
  146. if(sscanf(params, "dd", ID, Int))return SendClientMessage(playerid, -1, "/sethexit [Id Casa] [Interior]");
  147. if(!IsPlayerAdmin(playerid))return 0;
  148. if(Int > 0 && Int > 4) return SendClientMessage(playerid, -1, "ID nterior da 1 a 4!");
  149. switch(Int)
  150. {
  151. case 0:
  152. {
  153. hInfo[ID][Xu] = 235.508994;
  154. hInfo[ID][Yu] = 1189.169897;
  155. hInfo[ID][Zu] = 1080.339966;
  156. hInfo[ID][Interior] = 3;
  157. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  158. SendClientMessage(playerid, -1, string);
  159. }
  160. case 1:
  161. {
  162. hInfo[ID][Xu] = 225.756989;
  163. hInfo[ID][Yu] = 1240.000000;
  164. hInfo[ID][Zu] = 1082.149902;
  165. hInfo[ID][Interior] = 2;
  166. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  167. SendClientMessage(playerid, -1, string);
  168. }
  169. case 2:
  170. {
  171. hInfo[ID][Xu] = 223.043991;
  172. hInfo[ID][Yu] = 1289.259888;
  173. hInfo[ID][Zu] = 1082.199951;
  174. hInfo[ID][Interior] = 1;
  175. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  176. SendClientMessage(playerid, -1, string);
  177. }
  178. case 3:
  179. {
  180. hInfo[ID][Xu] = 225.630997;
  181. hInfo[ID][Yu] = 1022.479980;
  182. hInfo[ID][Zu] = 1084.069946;
  183. hInfo[ID][Interior] = 7;
  184. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  185. SendClientMessage(playerid, -1, string);
  186. }
  187. case 4:
  188. {
  189. hInfo[ID][Xu] = 295.138977;
  190. hInfo[ID][Yu] = 1474.469971;
  191. hInfo[ID][Zu] = 1080.519897;
  192. hInfo[ID][Interior] = 15;
  193. format(string, sizeof string, "Hai impostato alla casa ID %d l'interior a %d", ID, Int);
  194. SendClientMessage(playerid, -1, string);
  195. }
  196. }
  197. return 1;
  198. }
  199.  
  200. CMD:removehouse(playerid, params[])
  201. {
  202. new ID, string[128];
  203. if(sscanf(params, "d", ID))return SendClientMessage(playerid, -1, "/removehouse [Id Casa]");
  204. if(!IsPlayerAdmin(playerid))return 0;
  205. format(file, sizeof(file), H_FILE_PATH, ID);
  206. if(!INI_Exist(file))return SendClientMessage(playerid, -1, "Non c'è una casa con questo ID creata, quindi, non puoi eliminarla");
  207. INI_Open(file);
  208. INI_Remove(file);
  209. INI_Save();
  210. INI_Close();
  211. hInfo[ID][X] = 0.0;
  212. hInfo[ID][Y] = 0.0;
  213. hInfo[ID][Z] = 0.0;
  214. hInfo[ID][Interior] = 0;
  215. hInfo[ID][Cassaforte] = 0;
  216. DestroyPickup(PickupID[ID]);
  217. format(string, sizeof(string), "Hai eliminato la casa ID %d", ID);
  218. SendClientMessage(playerid, -1, string);
  219. return 1;
  220. }
  221.  
  222. public OnPlayerPickUpPickup(playerid, pickupid)
  223. {
  224. if(pickupid == PickupID[GetH(playerid)])// Quando il player entra nel pickup delle case.
  225. {
  226. if(hInfo[GetH(playerid)][Comprata] == 0)
  227. {
  228. format(stringa, sizeof(stringa), "%s~n~~w~Costo Casa: ~g~$%d", hInfo[GetH(playerid)][hText], hInfo[GetH(playerid)][hCosto]);
  229. GameTextForPlayer(playerid, stringa, 3500, 3);
  230. }
  231. else if(hInfo[GetH(playerid)][Comprata] == 1)
  232. {
  233. format(stringa, sizeof(stringa), "~n~~w~Proprietario: ~g~%s", hInfo[GetH(playerid)][Proprietario]);
  234. GameTextForPlayer(playerid, stringa, 3500, 3);
  235. }
  236. }
  237. return 1;
  238. }
  239.  
  240. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  241. {
  242. if(newkeys == KEY_SECONDARY_ATTACK)//Entrata Case
  243. {
  244. for(new i = 0; i < MAX_HOUSE; i++)
  245. {
  246. if(InCasa[playerid] == -1 && IsPlayerInRangeOfPoint(playerid, 1.0, hInfo[i][X], hInfo[i][Y], hInfo[i][Z]))
  247. {
  248. if(hInfo[i][Chiusa] == 1)return SendClientMessage(playerid, -1, "[INFO:] Casa Chiusa!");
  249. SetPlayerPos(playerid, hInfo[i][Xu], hInfo[i][Yu], hInfo[i][Zu]);
  250. SetPlayerInterior(playerid, hInfo[i][Interior]);
  251. SetPlayerVirtualWorld(playerid, hInfo[i][VirtualW]);
  252. InCasa[playerid] = i;
  253. }
  254. else if(InCasa[playerid] != -1 && IsPlayerInRangeOfPoint(playerid, 2.0, hInfo[InCasa[playerid]][Xu], hInfo[InCasa[playerid]][Yu], hInfo[InCasa[playerid]][Zu]))
  255. {
  256. if(GetPlayerVirtualWorld(playerid) == hInfo[i][VirtualW])
  257. {
  258. if(hInfo[i][Chiusa] == 1)return SendClientMessage(playerid, -1, "[INFO:] Casa Chiusa!");
  259. SetPlayerPos(playerid, hInfo[i][X], hInfo[i][Y], hInfo[i][Z]);
  260. SetPlayerInterior(playerid, 0);
  261. SetPlayerVirtualWorld(playerid, 0);
  262. InCasa[playerid] = -1;
  263. }
  264. }
  265. }
  266. }
  267. if(newkeys == KEY_JUMP)
  268. {
  269. if(IsPlayerInRangeOfPoint(playerid, 1.0, hInfo[GetH(playerid)][X], hInfo[GetH(playerid)][Y], hInfo[GetH(playerid)][Z]))
  270. {
  271. if(GetPlayerMoney(playerid) < hInfo[GetH(playerid)][hCosto])return SendClientMessage(playerid, -1, "Non hai abbastanza Soldi!");
  272. if(hInfo[GetH(playerid)][Comprata] == 1)return SendClientMessage(playerid, -1, "Questa casa non è in vendita!");
  273. hInfo[GetH(playerid)][Comprata] = 1;
  274. GivePlayerMoney(playerid, -hInfo[GetH(playerid)][hCosto]);
  275. new nome[24];
  276. GetPlayerName(playerid, nome, sizeof(nome));
  277. SendClientMessage(playerid, -1, "Hai comprato questa casa con successo!");
  278. InCasa[playerid] = GetH(playerid);
  279. SetPlayerPos(playerid, hInfo[GetH(playerid)][Xu], hInfo[GetH(playerid)][Yu], hInfo[GetH(playerid)][Zu]);
  280. SetPlayerInterior(playerid, hInfo[GetH(playerid)][Interior]);
  281. SetPlayerVirtualWorld(playerid, hInfo[GetH(playerid)][VirtualW]);
  282. DestroyPickup(PickupID[GetH(playerid)]);
  283. PickupID[GetH(playerid)] = CreatePickup(1272, 24, hInfo[GetH(playerid)][X], hInfo[GetH(playerid)][Y], hInfo[GetH(playerid)][Z]);
  284. INI_Open(file);
  285. INI_WriteString("Proprietario", nome);
  286. hInfo[GetH(playerid)][Proprietario] = nome;
  287. INI_WriteString("Descrizione", "Casa non in vendita");
  288. INI_WriteInt("Comprata", 1);
  289. INI_Save();
  290. INI_Close();
  291. }
  292. }
  293. if(newkeys == KEY_WALK)
  294. {
  295. if(IsPlayerInRangeOfPoint(playerid, 1.0, hInfo[GetH(playerid)][X], hInfo[GetH(playerid)][Y], hInfo[GetH(playerid)][Z]))
  296. {
  297. new nome[24];
  298. GetPlayerName(playerid, nome, sizeof(nome));
  299. if(strcmp(hInfo[GetH(playerid)][Proprietario], nome) != 0) return SendClientMessage(playerid,0xFF1E00FF,"Questa casa non è tua!");
  300. if(hInfo[GetH(playerid)][Comprata] == 0)return SendClientMessage(playerid,0xFF1E00FF,"Questa casa non è tua!");
  301. ShowPlayerDialog(playerid, MENUCASA, DIALOG_STYLE_LIST, "Casa", "Vendi Casa\nChiudi/Apri Casa\nRitira Soldi\nDeposita Soldi", "Seleziona", "Annulla");
  302. }
  303. return 1;
  304. }
  305. return 1;
  306. }
  307.  
  308. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  309. {
  310. if(dialogid == MENUCASA && response)
  311. {
  312. if(!response)return 0;
  313. switch(listitem)
  314. {
  315. case 0:
  316. {
  317. new string[128];
  318. format(string, sizeof(string), "Sei sicuro di voler vendere la tua casa per $%d ?", hInfo[GetH(playerid)][hCosto]/2);
  319. ShowPlayerDialog(playerid, MENUVENDICASA, DIALOG_STYLE_MSGBOX, "Vendi", string, "Si", "No");
  320. }
  321. case 1:
  322. {
  323. if(hInfo[GetH(playerid)][Chiusa] == 0)
  324. {
  325. hInfo[GetH(playerid)][Chiusa] = 1;
  326. SendClientMessage(playerid, -1, "[INFO:] Hai chiuso la tua casa");
  327. SaveHouse();
  328. }
  329. else if(hInfo[GetH(playerid)][Chiusa] == 1)
  330. {
  331. hInfo[GetH(playerid)][Chiusa] = 0;
  332. SendClientMessage(playerid, -1, "[INFO:] Hai aperto la tua casa");
  333. SaveHouse();
  334. }
  335. }
  336. case 2:ShowPlayerDialog(playerid, RITIRASOLDICASA, DIALOG_STYLE_INPUT, "Ritiro", "Scrivi la cifra che vuoi ritirare dalla casa", "Ritira", "Annulla");
  337. case 3:ShowPlayerDialog(playerid, DEPOSITASOLDICASA, DIALOG_STYLE_INPUT, "Deposito", "Scrivi la cifra che vuoi depositare in casa", "Deposita", "Annulla");
  338. }
  339. return 1;
  340. }
  341. if(dialogid == MENUVENDICASA && response)
  342. {
  343. if(!response)return 0;
  344. new string[256];
  345. GivePlayerMoney(playerid, hInfo[GetH(playerid)][hCosto]/2);
  346. format(string, sizeof(string), "Hai venduto la tua casa per $%d ", hInfo[GetH(playerid)][hCosto]/2);
  347. SendClientMessage(playerid, -1, string);
  348. hInfo[GetH(playerid)][Comprata] = 0;
  349. DestroyPickup(PickupID[GetH(playerid)]);
  350. PickupID[GetH(playerid)] = CreatePickup(1273, 24, hInfo[GetH(playerid)][X], hInfo[GetH(playerid)][Y], hInfo[GetH(playerid)][Z]);
  351. format(file, sizeof(file), H_FILE_PATH, GetH(playerid));
  352. INI_Open(file);
  353. INI_WriteString("Proprietario", "Nessuno");
  354. INI_WriteInt("Comprata", 0);
  355. INI_Save();
  356. INI_Close();
  357. SaveHouse();
  358. }
  359. if(dialogid == DEPOSITASOLDICASA && response)
  360. {
  361. new string[200];
  362. if(!response)return 0;
  363. 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");
  364. hInfo[GetH(playerid)][Cassaforte] = hInfo[GetH(playerid)][Cassaforte]+strval(inputtext);
  365. format(string, sizeof(string), "Hai depositato %d in casa tua, ricorda di non venderla quando hai soldi in casa, oppure li perderai", strval(inputtext));
  366. SendClientMessage(playerid, -1, string);
  367. GivePlayerMoney(playerid, -strval(inputtext));
  368. }
  369. if(dialogid == RITIRASOLDICASA && response)
  370. {
  371. new string[200];
  372. if(!response)return 0;
  373. 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");
  374. hInfo[GetH(playerid)][Cassaforte] = hInfo[GetH(playerid)][Cassaforte]-strval(inputtext);
  375. format(string, sizeof(string), "Hai ritirato %d dalla tua casa!", strval(inputtext));
  376. SendClientMessage(playerid, -1, string);
  377. GivePlayerMoney(playerid, -strval(inputtext));
  378. }
  379. return 1;
  380. }
  381.  
  382.  
  383. stock GetH(playerid)//Getta l'ID della casa in cui il player è..
  384. {
  385. for(new i=0; i<MAX_HOUSE; i++)
  386. {
  387. if(IsPlayerInRangeOfPoint(playerid, 2.0, hInfo[i][X], hInfo[i][Y], hInfo[i][Z]))
  388. {
  389. return i;
  390. }
  391. }
  392. return -230;
  393. }
  394.  
  395. stock SaveHouse()//Carica Le case
  396. {
  397. for(new i = 0; i<MAX_HOUSE; i++)
  398. {
  399. format(file, sizeof(file), H_FILE_PATH, i);
  400. if(INI_Exist(file))
  401. {
  402. INI_Open(file);
  403. INI_WriteFloat("FloatX", hInfo[i][X ]);
  404. INI_WriteFloat("FloatY", hInfo[i][Y]);
  405. INI_WriteFloat("FloatZ", hInfo[i][Z]);
  406. INI_WriteFloat("FloatXUscita", hInfo[i][Xu]);
  407. INI_WriteFloat("FloatYUscita", hInfo[i][Yu]);
  408. INI_WriteFloat("FloatZUscita", hInfo[i][Zu]);
  409. INI_WriteString("Descrizione", hInfo[i][hText]);
  410. INI_WriteInt("CostoCasa", hInfo[i][hCosto]);
  411. INI_WriteInt("Interior", hInfo[i][Interior]);
  412. INI_WriteInt("VirtualW", hInfo[i][VirtualW]);
  413. INI_WriteInt("Comprata", hInfo[i][Comprata]);
  414. INI_WriteInt("Chiusa", hInfo[i][Chiusa]);
  415. INI_WriteInt("Cassaforte", hInfo[i][Cassaforte]);
  416. INI_WriteString("Proprietario", hInfo[i][Proprietario]);
  417. INI_Save();
  418. INI_Close();
  419. }
  420. }
  421. }
  422. stock LoadHouse()//Carica Le case
  423. {
  424. new Nome[MAX_PLAYER_NAME], Desc[64];
  425. for(new i = 0; i<MAX_HOUSE; i++)
  426. {
  427. format(file, sizeof(file), H_FILE_PATH, i);
  428. if(INI_Exist(file))
  429. {
  430. INI_Open(file);
  431. hInfo[i][X] = INI_ReadFloat("FloatX");
  432. hInfo[i][Y] = INI_ReadFloat("FloatY");
  433. hInfo[i][Z] = INI_ReadFloat("FloatZ");
  434. hInfo[i][Xu] = INI_ReadFloat("FloatXUscita");
  435. hInfo[i][Yu] = INI_ReadFloat("FloatYUscita");
  436. hInfo[i][Zu] = INI_ReadFloat("FloatZUscita");
  437. INI_ReadString(Desc, "Descrizione", 128);
  438. hInfo[i][hText] = Desc;
  439. hInfo[i][hCosto] = INI_ReadInt("CostoCasa");
  440. hInfo[i][Interior] = INI_ReadInt("Interior");
  441. hInfo[i][VirtualW] = INI_ReadInt("VirtualW");
  442. hInfo[i][Comprata] = INI_ReadInt("Comprata");
  443. hInfo[i][Cassaforte] = INI_ReadInt("Cassaforte");
  444. hInfo[i][Chiusa] = INI_ReadInt("Chiusa");
  445. INI_ReadString(Nome, "Proprietario", 128);
  446. hInfo[i][Proprietario] = Nome;
  447. INI_Close();
  448. if(hInfo[i][Comprata] == 0)
  449. {
  450. PickupID[i] = CreatePickup(1273, 24, hInfo[i][X], hInfo[i][Y], hInfo[i][Z]);
  451.  
  452. }
  453. else if(hInfo[i][Comprata] == 1)
  454. {
  455. PickupID[i] = CreatePickup(1272, 24, hInfo[i][X], hInfo[i][Y], hInfo[i][Z]);
  456.  
  457. }
  458. }
  459. }
  460. }
Advertisement
RAW Paste Data Copied
Advertisement