Advertisement
BlooDMasK

Untitled

Jul 19th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 20.58 KB | None | 0 0
  1. #include <a_samp>
  2. #include <sscanf2>
  3. #include <YSI\y_ini>
  4. #include <YSI\y_hooks>
  5. #include "../include/gl_common.inc"
  6. #include <zcmd>
  7. #include <streamer>
  8.  
  9. #define SCM SendClientMessage
  10. #define NOTADMIN ">> Non puoi usare questo comando!"
  11.  
  12. //COLORI
  13. #define COL_TITLES "{FFEE00}"
  14. #define COL_BIANCO "{FFFFFF}"
  15. #define COL_ROSSO "{F81414}"
  16. #define COL_VERDE "{00FF22}"
  17. #define COL_AZZU "{D6D8FF}"
  18. #define COL_BLU "{0000C1}"
  19. #define COLORE_POLIZIA 0x00D9E6FF
  20. #define COLORE_MEDICI 0xFF0000FF
  21. #define BIANCO 0xFFFFFFFF
  22. #define NERO 0x000000FF
  23. #define VERDE 0x005700FF
  24. #define BLU 0x0000FFFF
  25. #define GIALLO 0xFFEE00FF
  26. #define GIALLOSCURO 0xFFB900FF
  27. #define ARANCIONE 0xFF6600FF
  28. #define GRIGIO 0xAFAFAFAA
  29. #define ROSSO 0xFF0000FF
  30. #define COLOR_FADE1 0xE6E6E6E6
  31. #define COLOR_FADE2 0xC8C8C8C8
  32. #define COLOR_FADE3 0xAAAAAAAA
  33. #define COLOR_FADE4 0x8C8C8C8C
  34. #define COLOR_FADE5 0x6E6E6E6E
  35. #define COLOR_GRAD1 0xB4B5B7FF
  36. #define COLOR_GRAD2 0xBFC0C2FF
  37. #define COLOR_GRAD3 0xCBCCCEFF
  38. #define COLOR_GRAD4 0xD8D8D8FF
  39. #define COLOR_GRAD5 0xE3E3E3FF
  40. #define COLOR_GRAD6 0xF0F0F0FF
  41. #define DVERDE 0x5DFF00FF
  42.  
  43. #define DIALOG_GESTIONE_CASA 150
  44. #define DIALOG_GESTIONE_CASSAFORTE 151
  45. #define DIALOG_GESTIONE_PRELEVA 152
  46. #define DIALOG_GESTIONE_DEPOSITA 153
  47.  
  48.  
  49. //PATH
  50. #define HPATH "/Utenti/Case/%i.ini"
  51. new Text3D:hlabel[500];
  52. new Soldi[MAX_PLAYERS];
  53.  
  54. enum HomeInfo{
  55.      Float:hPosX,
  56.      Float:hPosY,
  57.      Float:hPosZ,
  58.      Float:hPosA,
  59.      Float:hPosXX,
  60.      Float:hPosYY,
  61.      Float:hPosZZ,
  62.      Float:hPosAA,
  63.      hIntID,
  64.      hProprietario[MAX_PLAYER_NAME],
  65.      hComprato,
  66.      hIcon,
  67.      hPrezzo,
  68.      hCassa,
  69.      hInterior,
  70.      hVirtualWorld,
  71. };
  72. new hInfo[500][HomeInfo];
  73.  
  74. #if defined FILTERSCRIPT
  75.  
  76. public OnFilterScriptInit()
  77. {
  78.     new stri[500];
  79.    
  80.     for(new id = 1; id < sizeof(MAX_HOME); id++){
  81.     format(stri, sizeof(stri), HPATH, id);
  82.     INI_ParseFile(stri, "loadhome_%s", .bExtra = true, .extra = id );
  83.     new strin[250];
  84.     if(hInfo[id][hComprato] == 0){
  85.     format(strin, sizeof(strin), "Casa[ID:%d]\nProprietario: %s\nPrezzo: %d\n Per comprare premi Y",id,hInfo[id][hProprietario],hInfo[id][hPrezzo]);
  86.     hInfo[id][hIcon] = CreateDynamicPickup(1273, 1, hInfo[id][hPosX], hInfo[id][hPosY], hInfo[id][hPosZ],0);
  87.     hlabel[id] = CreateDynamic3DTextLabel(strin, GIALLO, hInfo[id][hPosX], hInfo[id][hPosY], hInfo[id][hPosZ], 3.0, INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0,0);
  88.     }else if(hInfo[id][hComprato] == 1){
  89.     hInfo[id][hIcon] = CreateDynamicPickup(1272, 1, hInfo[id][hPosX], hInfo[id][hPosY], hInfo[id][hPosZ]);
  90.     format(stri, sizeof(stri), "Casa[ID:%d]\nProprietario: %s\nPrezzo: %d\n Premi Y per interagire",id,hInfo[id][hProprietario],hInfo[id][hPrezzo]);
  91.     hlabel[id] = CreateDynamic3DTextLabel(strin, GIALLO, hInfo[id][hPosX], hInfo[id][hPosY], hInfo[id][hPosZ]);}
  92.     }
  93.     return 1;
  94. }
  95.  
  96. public OnFilterScriptExit()
  97. {
  98.     for(new id = 1; id < sizeof(MAX_HOME); id++){
  99.     if(hInfo[id][hPrezzo] == 0) break;
  100.     SaveHome(id);}
  101.     return 1;
  102. }
  103.  
  104. #else
  105.  
  106. main() {}
  107.  
  108. #endif
  109.  
  110.  
  111. CMD:ccasa(playerid, params[]){
  112.  
  113.  
  114.     if(!IsPlayerAdmin(playerid)) return SCM(playerid, GRIGIO, NOTADMIN);
  115.     new prezzo, interior, string0[240], string1[240], id, Float:X, Float:Y, Float:Z, Float:A;
  116.     if(sscanf(params, "ii", prezzo, interior)) return SCM(playerid, GIALLO, "/ccasa [PREZZO] [INTERIOR-ID (1-25)]");
  117.     if(prezzo < 1) return SCM(playerid, GRIGIO, "Prezzo invalido");
  118.     if(interior < 1 || interior > 25) return SCM(playerid, GRIGIO, "ID invalido! Interior ID [1-25]");
  119.     for(new h = 1;h < sizeof(hInfo); h++){
  120.     if(hInfo[h][hPrezzo] == 0){
  121.     id = h;
  122.     break;}}
  123.     GetPlayerPos(playerid, X,Y,Z);
  124.     GetPlayerFacingAngle(playerid, A);
  125.     hInfo[id][hPrezzo] = prezzo;
  126.     hInfo[id][hComprato] = 0;
  127.     hInfo[id][hPosX] = X;
  128.     hInfo[id][hPosY] = Y;
  129.     hInfo[id][hPosZ] = Z;
  130.     hInfo[id][hPosA] = A;
  131.     hInfo[id][hInterior] = interior;
  132.     hInfo[id][hVirtualWorld] = id;
  133.     hInfo[id][hIcon] = CreateDynamicPickup(1273, 1, hInfo[id][hPosX], hInfo[id][hPosY], hInfo[id][hPosZ],0);
  134.     format(string0, sizeof(string0), "Nessuno");
  135.     strmid(hInfo[id][hProprietario], string0, 0, strlen(string0), 255);
  136.  
  137.     format(string1, sizeof(string1), "Casa[ID:%d]\nProprietario: %s\nPrezzo: %d\n Per comprare premi Y", id, hInfo[id][hProprietario], hInfo[id][hPrezzo]);
  138.     hlabel[id] = CreateDynamic3DTextLabel(string1, GIALLO, hInfo[id][hPosX], hInfo[id][hPosY], hInfo[id][hPosZ], 3.0, INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0,0);
  139.  
  140. //==Save Interior===============================================================
  141.  
  142.     if(hInfo[id][hInterior] == 1){//ryder 2
  143.     hInfo[id][hIntID] = 2;
  144.     hInfo[id][hPosXX] = 2466.3015;
  145.     hInfo[id][hPosYY] = -1698.5970;
  146.     hInfo[id][hPosZZ] = 1013.507;}
  147.  
  148.     else if(hInfo[id][hInterior] == 2){//CJ's 3
  149.     hInfo[id][hIntID] = 3;
  150.     hInfo[id][hPosXX] = 2495.7905;
  151.     hInfo[id][hPosYY] = -1694.3346;
  152.     hInfo[id][hPosZZ] = 1014.7422;}
  153.  
  154.     else if(hInfo[id][hInterior] == 3){//wuzimu 1
  155.     hInfo[id][hIntID] = 1;
  156.     hInfo[id][hPosXX] = -2167.8662;
  157.     hInfo[id][hPosYY] = 642.4196;
  158.     hInfo[id][hPosZZ] = 1057.5938;}
  159.  
  160.     else if(hInfo[id][hInterior] == 4){//safehouse group 1
  161.     hInfo[id][hIntID] = 1;
  162.     hInfo[id][hPosXX] = 2233.6919;
  163.     hInfo[id][hPosYY] = -1112.8107;
  164.     hInfo[id][hPosZZ] = 1050.8828;}
  165.  
  166.     else if(hInfo[id][hInterior] == 5){//safehouse group 3
  167.     hInfo[id][hIntID] = 3;
  168.     hInfo[id][hPosXX] = 2319.1255;
  169.     hInfo[id][hPosYY] = -1023.9523;
  170.     hInfo[id][hPosZZ] = 1050.2109;}
  171.  
  172.     else if(hInfo[id][hInterior] == 6){//safehouse group 4
  173.     hInfo[id][hIntID] = 4;
  174.     hInfo[id][hPosXX] = 2259.4136;
  175.     hInfo[id][hPosYY] = -1136.4128;
  176.     hInfo[id][hPosZZ] = 1050.6403;}
  177.  
  178.     else if(hInfo[id][hInterior] == 7){// budget inn motel room 12
  179.     hInfo[id][hIntID] = 12;
  180.     hInfo[id][hPosXX] = 446.3247;
  181.     hInfo[id][hPosYY] = 509.9662;
  182.     hInfo[id][hPosZZ] = 1001.4195;}
  183.  
  184.     else if(hInfo[id][hInterior] == 8){// pair of uburlgar houses 2
  185.     hInfo[id][hIntID] = 2;
  186.     hInfo[id][hPosXX] = 447.1108;
  187.     hInfo[id][hPosYY] = 1399.5410;
  188.     hInfo[id][hPosZZ] = 1084.3047;}
  189.  
  190.     else if(hInfo[id][hInterior] == 9){// burlglary house x11 5
  191.     hInfo[id][hIntID] = 5;
  192.     hInfo[id][hPosXX] = 229.1724;
  193.     hInfo[id][hPosYY] = 1114.5135;
  194.     hInfo[id][hPosZZ] = 1080.9922;}
  195.  
  196.     else if(hInfo[id][hInterior] == 10){// burlglary house x12 4
  197.     hInfo[id][hIntID] = 4;
  198.     hInfo[id][hPosXX] = 261.5108;
  199.     hInfo[id][hPosYY] = 1286.0137;
  200.     hInfo[id][hPosZZ] = 1080.2578;}
  201.  
  202.     else if(hInfo[id][hInterior] == 11){// burlglary house x14 10
  203.     hInfo[id][hIntID] = 10;
  204.     hInfo[id][hPosXX] = 24.3769;
  205.     hInfo[id][hPosYY] = 1341.1829;
  206.     hInfo[id][hPosZZ] = 1084.3750;}
  207.  
  208.     else if(hInfo[id][hInterior] == 12){// burlglary house x13 4
  209.     hInfo[id][hIntID] = 4;
  210.     hInfo[id][hPosXX] = 221.6766;
  211.     hInfo[id][hPosYY] = 1142.4962;
  212.     hInfo[id][hPosZZ] = 1082.6094;}
  213.  
  214.     else if(hInfo[id][hInterior] == 13){// villona 12
  215.     hInfo[id][hIntID] = 12;
  216.     hInfo[id][hPosXX] = 2324.2932;
  217.     hInfo[id][hPosYY] = -1148.6160;
  218.     hInfo[id][hPosZZ] = 1050.7101;}
  219.  
  220.     else if(hInfo[id][hInterior] == 14){// bulgrrg house x15 4
  221.     hInfo[id][hIntID] = 4;
  222.     hInfo[id][hPosXX] = -262.0143;
  223.     hInfo[id][hPosYY] = 1456.4313;
  224.     hInfo[id][hPosZZ] = 1084.3672;}
  225.  
  226.     else if(hInfo[id][hInterior] == 15){// bulgrrg house x16 5
  227.     hInfo[id][hIntID] = 5;
  228.     hInfo[id][hPosXX] = 22.6792;
  229.     hInfo[id][hPosYY] = 1405.1183;
  230.     hInfo[id][hPosZZ] = 1084.4297;}
  231.  
  232.     else if(hInfo[id][hInterior] == 16){// bulgrrg house x17 enorme da mappare 5
  233.     hInfo[id][hIntID] = 5;
  234.     hInfo[id][hPosXX] = 140.4665;
  235.     hInfo[id][hPosYY] = 1368.1595;
  236.     hInfo[id][hPosZZ] = 1083.8625;}
  237.  
  238.     else if(hInfo[id][hInterior] == 17){// bulgrrg house x18 6
  239.     hInfo[id][hIntID] = 6;
  240.     hInfo[id][hPosXX] = 234.2826;
  241.     hInfo[id][hPosYY] = 1065.2290;
  242.     hInfo[id][hPosZZ] = 1084.2101;}
  243.  
  244.     else if(hInfo[id][hInterior] == 18){// bulgrrg house x19 6
  245.     hInfo[id][hIntID] = 6;
  246.     hInfo[id][hPosXX] = -68.2355;
  247.     hInfo[id][hPosYY] = 1353.9028;
  248.     hInfo[id][hPosZZ] = 1080.2109;}
  249.  
  250.     else if(hInfo[id][hInterior] == 19){// bulgrrg house x20 15
  251.     hInfo[id][hIntID] = 15;
  252.     hInfo[id][hPosXX] = -285.4269;
  253.     hInfo[id][hPosYY] = 1470.9344;
  254.     hInfo[id][hPosZZ] = 1084.3750;}
  255.  
  256.     else if(hInfo[id][hInterior] == 20){// caligula's roof 1
  257.     hInfo[id][hIntID] = 1;
  258.     hInfo[id][hPosXX] = 2215.4458;
  259.     hInfo[id][hPosYY] = -1076.7493;
  260.     hInfo[id][hPosZZ] = 1050.4844;}
  261.  
  262.     else if(hInfo[id][hInterior] == 21){// old venturas strip casino 2
  263.     hInfo[id][hIntID] = 2;
  264.     hInfo[id][hPosXX] = 2236.8916;
  265.     hInfo[id][hPosYY] = -1078.7402;
  266.     hInfo[id][hPosZZ] = 1049.0234;}
  267.  
  268.     else if(hInfo[id][hInterior] == 22){// verdant bluffs safehouse 8
  269.     hInfo[id][hIntID] = 8;
  270.     hInfo[id][hPosXX] = 2365.1089;
  271.     hInfo[id][hPosYY] = -1133.0795;
  272.     hInfo[id][hPosZZ] = 1050.8750;}
  273.  
  274.     else if(hInfo[id][hInterior] == 23){// burgr x21 8
  275.     hInfo[id][hIntID] = 8;
  276.     hInfo[id][hPosXX] = -42.7078;
  277.     hInfo[id][hPosYY] = 1406.8553;
  278.     hInfo[id][hPosZZ] = 1084.4297;}
  279.  
  280.     else if(hInfo[id][hInterior] == 24){// burgr x22 9
  281.     hInfo[id][hIntID] = 9;
  282.     hInfo[id][hPosXX] = 84.9231;
  283.     hInfo[id][hPosYY] = 1324.3130;
  284.     hInfo[id][hPosZZ] = 1083.8594;}
  285.  
  286.     else if(hInfo[id][hInterior] == 25){// burgr x23 9
  287.     hInfo[id][hIntID] = 9;
  288.     hInfo[id][hPosXX] = 260.5242;
  289.     hInfo[id][hPosYY] = 1238.9857;
  290.     hInfo[id][hPosZZ] = 1084.2578;}
  291.  
  292.     //===CREA IL FILE DELLA CASA===//
  293.     new file4[403];
  294.     format(file4, sizeof(file4), HPATH, id);
  295.     new INI:File = INI_Open(file4);
  296.     INI_SetTag(File,"data");
  297.     INI_WriteString(File,"Proprietario", hInfo[id][hProprietario]);
  298.     INI_WriteInt(File,"Comprato", hInfo[id][hComprato]);
  299.     INI_WriteInt(File,"Prezzo", hInfo[id][hPrezzo]);
  300.     INI_WriteInt(File,"Interior", hInfo[id][hInterior]);
  301.     INI_WriteInt(File,"VirtualWorld", hInfo[id][hVirtualWorld]);
  302.     INI_WriteInt(File,"IntID", hInfo[id][hIntID]);
  303.     INI_WriteFloat(File,"PosX", hInfo[id][hPosX]);
  304.     INI_WriteFloat(File,"PosY", hInfo[id][hPosY]);
  305.     INI_WriteFloat(File,"PosZ", hInfo[id][hPosZ]);
  306.     INI_WriteFloat(File,"PosA", hInfo[id][hPosA]);
  307.     INI_WriteFloat(File,"PosXX", hInfo[id][hPosXX]);
  308.     INI_WriteFloat(File,"PosYY", hInfo[id][hPosYY]);
  309.     INI_WriteFloat(File,"PosZZ", hInfo[id][hPosZZ]);
  310.     INI_WriteFloat(File,"PosAA", hInfo[id][hPosAA]);
  311.     INI_WriteInt(File,"Cassa", 0);
  312.     INI_Close(File);
  313.     return 1;
  314. }
  315.  
  316. CMD:carica(playerid, params[]){//non ci metto il break.
  317.  
  318.     new stri[500];
  319.    
  320.     for(new id = 1; id < sizeof(hInfo); id++){
  321.  
  322.     format(stri, sizeof(stri), HPATH, id);
  323.     INI_ParseFile(stri, "loadhome_%s", .bExtra = true, .extra = id );
  324.     new strin[250], strinn[250];
  325.     if(hInfo[id][hComprato] == 0){
  326.     format(strin, sizeof(strin), "Casa[ID:%d]\nProprietario: %s\nPrezzo: %d\n Per comprare premi Y",id,hInfo[id][hProprietario],hInfo[id][hPrezzo]);
  327.     hInfo[id][hIcon] = CreateDynamicPickup(1273, 1, hInfo[id][hPosX], hInfo[id][hPosY], hInfo[id][hPosZ],0);
  328.     hlabel[id] = CreateDynamic3DTextLabel(strin, GIALLO, hInfo[id][hPosX], hInfo[id][hPosY], hInfo[id][hPosZ], 3.0, INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0,0);
  329.     }else if(hInfo[id][hComprato] == 1){
  330.     hInfo[id][hIcon] = CreateDynamicPickup(1272, 1, hInfo[id][hPosX], hInfo[id][hPosY], hInfo[id][hPosZ]);
  331.     format(strinn, sizeof(strinn), "Casa[ID:%d]\nProprietario: %s\nPrezzo: %d\n Premi Y per interagire",id,hInfo[id][hProprietario],hInfo[id][hPrezzo]);
  332.     hlabel[id] = CreateDynamic3DTextLabel(strinn, GIALLO, hInfo[id][hPosX], hInfo[id][hPosY], hInfo[id][hPosZ], 3.0, INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0,0);}}
  333.     return 1;
  334. }
  335.  
  336. CMD:messaggio(playerid, params[]){
  337. for(new mex = 1; mex < 10; mex++){
  338. SCM(playerid, GIALLO, "<10");
  339. if(mex == 10){
  340. SCM(playerid, GIALLO, "10");}
  341. }
  342. return 1;
  343. }
  344.  
  345. CMD:soldi(playerid,params[]){
  346. Soldi[playerid] = Soldi[playerid]+5000;
  347. return 1;
  348. }
  349.  
  350. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  351. {
  352.     if(dialogid == DIALOG_GESTIONE_CASA)
  353.     {
  354.         if(!response) {}
  355.         if(response)
  356.         {
  357.             switch(listitem)
  358.             {
  359.                 case 0:
  360.                 {
  361.                 ShowPlayerDialog(playerid, DIALOG_GESTIONE_CASSAFORTE, DIALOG_STYLE_LIST, "Gestione Cassaforte", "Bilancio\n Deposita\n Preleva", "Ok", "Indietro");
  362.                 }
  363.                 case 1:
  364.                 {
  365.                 new id = IsPlayerNearHomeEnt(playerid), str[500], string[200], string1[200];
  366.                 Soldi[playerid] = Soldi[playerid]+hInfo[id][hPrezzo]/2;
  367.                 DestroyDynamicPickup(hInfo[id][hIcon]);
  368.                 hInfo[id][hIcon] = CreateDynamicPickup(1273, 1, hInfo[id][hPosX], hInfo[id][hPosY], hInfo[id][hPosZ],0);
  369.                 format(string, sizeof(string), "Nessuno");
  370.                 strmid(hInfo[id][hProprietario], string, 0, strlen(string), 255);
  371.                 format(string1, sizeof(string1), "Casa[ID:%d]\nProprietario: %s\nPrezzo: %d\n Per comprare premi Y",id,hInfo[id][hProprietario],hInfo[id][hPrezzo]);
  372.                 DestroyDynamic3DTextLabel(hlabel[id]);
  373.                 hlabel[id] = CreateDynamic3DTextLabel(string1, GIALLO, hInfo[id][hPosX], hInfo[id][hPosY], hInfo[id][hPosZ], 3.0, INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0,0);
  374.                 hInfo[id][hComprato] = 0;
  375.                 SCM(playerid, GIALLO, "Hai venduto la tua casa ricavandone il 50% dal prezzo originale.");
  376.                 SaveHome(id);
  377.                 INI_ParseFile(str, "loadcon_%s", .bExtra = true, .extra = id );
  378.                 }
  379.                
  380.             }
  381.         }
  382.     }
  383.     if(dialogid == DIALOG_GESTIONE_CASSAFORTE)
  384.     {
  385.         if(!response) return ShowPlayerDialog(playerid, DIALOG_GESTIONE_CASA, DIALOG_STYLE_LIST, "Gestione","Cassaforte\n Vendi","Ok","Esci");
  386.         if(response)
  387.         {
  388.         switch(listitem)
  389.         {
  390.             case 0:
  391.             {
  392.                 new string[200], id = IsPlayerNearHomeEnt(playerid);
  393.                 format(string, sizeof(string), "Bilancio Cassaforte (%d $)", hInfo[id][hCassa]);
  394.                 SCM(playerid, GIALLO, string);
  395.                 ShowPlayerDialog(playerid, DIALOG_GESTIONE_CASSAFORTE, DIALOG_STYLE_LIST, "Gestione Cassaforte","Bilancio\n Deposita\n Preleva","Ok","Esci");
  396.             }
  397.             case 1:
  398.             {
  399.                 ShowPlayerDialog(playerid, DIALOG_GESTIONE_DEPOSITA, DIALOG_STYLE_INPUT, "Gestione Cassaforte","Inserisci l'ammonto che vuoi depositare:","Deposita","Esci");
  400.             }
  401.             case 2:
  402.             {
  403.                 ShowPlayerDialog(playerid, DIALOG_GESTIONE_PRELEVA, DIALOG_STYLE_INPUT, "Gestione Cassaforte","Inserisci l'ammonto che vuoi prelevare:","Preleva","Esci");
  404.             }
  405.         }
  406.         }
  407.     }
  408.     if(dialogid == DIALOG_GESTIONE_DEPOSITA)
  409.     {
  410.         if(!response) return ShowPlayerDialog(playerid, DIALOG_GESTIONE_CASSAFORTE, DIALOG_STYLE_LIST, "Gestione Cassaforte","Bilancio\n Deposita\n Preleva","Ok","Esci");
  411.         if(response)
  412.         {
  413.             new soldi, string[200], id = IsPlayerNearHomeEnt(playerid);
  414.             if(sscanf(inputtext, "d", soldi)) return ShowPlayerDialog(playerid, DIALOG_GESTIONE_DEPOSITA, DIALOG_STYLE_INPUT, "Gestione Cassaforte","{FF0000}Inserisci un ammonto valido da depositare!","Deposita","Indietro");
  415.             if(soldi > GetPlayerMoney(playerid)) return ShowPlayerDialog(playerid, DIALOG_GESTIONE_DEPOSITA, DIALOG_STYLE_INPUT, "Gestione Cassaforte","{FF0000}Non possiedi tutti questi soldi!","Deposita","Indietro");
  416.             hInfo[id][hCassa]= soldi + hInfo[id][hCassa];
  417.             //COMANDO PER TOGLIERE SOLDI
  418.             format(string, sizeof(string), "Hai depositato %d $ nella tua Cassaforte!\n Il nuovo Bilancio è di %d $", soldi, hInfo[id][hCassa]);
  419.             SCM(playerid, GIALLO, string);
  420.             ShowPlayerDialog(playerid, DIALOG_GESTIONE_CASA, DIALOG_STYLE_LIST, "Gestione","Cassaforte\n Vendi","Ok","Esci");
  421.         }
  422.     }
  423.     if(dialogid == DIALOG_GESTIONE_PRELEVA)
  424.     {
  425.         if(!response) return ShowPlayerDialog(playerid, DIALOG_GESTIONE_CASSAFORTE, DIALOG_STYLE_LIST, "Gestione Cassaforte","Bilancio\n Deposita\n Preleva","Ok","Indietro");
  426.         if(response)
  427.         {
  428.             new soldi, string[200], id = IsPlayerNearHomeEnt(playerid);
  429.             if(sscanf(inputtext, "d", soldi)) return ShowPlayerDialog(playerid, DIALOG_GESTIONE_PRELEVA, DIALOG_STYLE_INPUT, "Gestione Cassaforte","{FF0000}Inserisci un ammonto valido da prelevare!","Preleva","Indietro");
  430.             if(soldi > hInfo[id][hCassa]) return ShowPlayerDialog(playerid, DIALOG_GESTIONE_PRELEVA, DIALOG_STYLE_INPUT, "Gestione Cassaforte","{FF0000}Non possiedi tutti questi soldi in Cassaforte!","Preleva","Indietro");
  431.             hInfo[id][hCassa]= soldi - hInfo[id][hCassa];
  432.             //COMANDO PER DARE SOLDI
  433.             format(string, sizeof(string), "Hai prelevato %d $ dalla tua Cassaforte!\n Il nuovo Bilancio è di %d $", soldi, hInfo[id][hCassa]);
  434.             SCM(playerid, GIALLO, string);
  435.             ShowPlayerDialog(playerid, DIALOG_GESTIONE_CASA, DIALOG_STYLE_LIST, "Gestione","Cassaforte\n Vendi","Ok","Esci");
  436.         }
  437.     }
  438.     return 1;
  439. }
  440.  
  441. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  442. {
  443.     //COMPRA/GESTISCI
  444.     if(newkeys & KEY_YES && IsPlayerNearHomeEnt(playerid)){
  445.     new string2[350], str[500], id = IsPlayerNearHomeEnt(playerid);
  446.     if(id == -1 || id == 0) return SCM(playerid, ROSSO, "Non sei vicino alla casa!");
  447.     if(hInfo[id][hComprato] == 0){
  448.     if(Soldi[playerid] < hInfo[id][hPrezzo]) return SCM(playerid, ROSSO, "Non hai soldi a sufficienza!");
  449.     Soldi[playerid] = Soldi[playerid]-hInfo[id][hPrezzo];
  450.     format(str, sizeof(str), HPATH, id);
  451.     DestroyDynamicPickup(hInfo[id][hIcon]);
  452.     DestroyDynamic3DTextLabel(hlabel[id]);
  453.     hInfo[id][hProprietario] = GetName(playerid);
  454.     hInfo[id][hIcon] = CreateDynamicPickup(1272, 1, hInfo[id][hPosX],hInfo[id][hPosY],hInfo[id][hPosZ]);
  455.     format(string2, sizeof(string2), "Casa[ID:%d]\nProprietario: %s\nPrezzo: %d\n Premi Y per interagire",id,hInfo[id][hProprietario],hInfo[id][hPrezzo]);
  456.     hlabel[id] = CreateDynamic3DTextLabel(string2, GIALLO, hInfo[id][hPosX], hInfo[id][hPosY], hInfo[id][hPosZ], 3.0, INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0,0);
  457.     hInfo[id][hComprato] = 1;
  458.     SaveHome(id);
  459.     INI_ParseFile(str, "loadhome_%s", .bExtra = true, .extra = id );
  460.  
  461.     }else if(hInfo[id][hComprato] == 1){
  462.     if(strcmp(hInfo[id][hProprietario], GetName(playerid))){ SCM(playerid, ROSSO, "Non sei il proprietario della casa!");}
  463.     else { ShowPlayerDialog(playerid, DIALOG_GESTIONE_CASA, DIALOG_STYLE_LIST, "Gestione","Cassaforte\n Vendi","Ok","Esci");}
  464.     }}
  465.    
  466.    
  467.     if(newkeys & KEY_SECONDARY_ATTACK && IsPlayerInRangeOfPoint(playerid, 2.0, hInfo[id][hPosX],hInfo[id][hPosY],hInfo[id][hPosZ])){//ENTRA
  468.     for(new id = 1; id < sizeof(hInfo); id++){
  469.     SetPlayerVirtualWorld(playerid, hInfo[id][hVirtualWorld]);
  470.     SetPlayerInterior(playerid, hInfo[id][hIntID]);
  471.     SetPlayerPos(playerid, hInfo[id][hPosXX], hInfo[id][hPosYY], hInfo[id][hPosZZ]);}}
  472.    
  473.     if(newkeys & KEY_SECONDARY_ATTACK && IsPlayerNearHomeExt(playerid)){//ESCI
  474.     new id = IsPlayerNearHomeExt(playerid);
  475.     SetPlayerVirtualWorld(playerid, 0);
  476.     SetPlayerInterior(playerid, 0);
  477.     SetPlayerPos(playerid, hInfo[id][hPosX], hInfo[id][hPosY], hInfo[id][hPosZ]);}
  478.  
  479.     return 1;
  480. }
  481.  
  482. forward SaveHome(id);
  483. public SaveHome(id)
  484. {
  485.     new file4[403];
  486.     format(file4, sizeof(file4), HPATH, id);
  487.     new INI:File = INI_Open(file4);
  488.     INI_SetTag(File,"data");
  489.     INI_WriteString(File,"Proprietario", hInfo[id][hProprietario]);
  490.     INI_WriteInt(File,"Comprato", hInfo[id][hComprato]);
  491.     INI_WriteInt(File,"Prezzo", hInfo[id][hPrezzo]);
  492.     INI_WriteInt(File,"Interior", hInfo[id][hInterior]);
  493.     INI_WriteInt(File,"VirtualWorld", hInfo[id][hVirtualWorld]);
  494.     INI_WriteInt(File,"IntID", hInfo[id][hIntID]);
  495.     INI_WriteFloat(File,"PosX", hInfo[id][hPosX]);
  496.     INI_WriteFloat(File,"PosY", hInfo[id][hPosY]);
  497.     INI_WriteFloat(File,"PosZ", hInfo[id][hPosZ]);
  498.     INI_WriteFloat(File,"PosA", hInfo[id][hPosA]);
  499.     INI_WriteFloat(File,"PosXX", hInfo[id][hPosXX]);
  500.     INI_WriteFloat(File,"PosYY", hInfo[id][hPosYY]);
  501.     INI_WriteFloat(File,"PosZZ", hInfo[id][hPosZZ]);
  502.     INI_WriteFloat(File,"PosAA", hInfo[id][hPosAA]);
  503.     INI_WriteInt(File,"Cassa", 0);
  504.    
  505.     INI_Close(File);
  506.     return 1;
  507. }
  508.  
  509. forward loadhome_data(id, name[], value[]);
  510. public loadhome_data(id, name[], value[])
  511. {
  512.     INI_String("Proprietario", hInfo[id][hProprietario], 24);
  513.     INI_Int("Comprato", hInfo[id][hComprato]);
  514.     INI_Int("Prezzo", hInfo[id][hPrezzo]);
  515.     INI_Int("Interior", hInfo[id][hInterior]);
  516.     INI_Int("VirtualWorld", hInfo[id][hVirtualWorld]);
  517.     INI_Int("IntID", hInfo[id][hIntID]);
  518.     INI_Float("PosX", hInfo[id][hPosX]);
  519.     INI_Float("PosY", hInfo[id][hPosY]);
  520.     INI_Float("PosZ", hInfo[id][hPosZ]);
  521.     INI_Float("PosA", hInfo[id][hPosA]);
  522.     INI_Float("PosXX", hInfo[id][hPosXX]);
  523.     INI_Float("PosYY", hInfo[id][hPosYY]);
  524.     INI_Float("PosZZ", hInfo[id][hPosZZ]);
  525.     INI_Float("PosAA", hInfo[id][hPosAA]);
  526.     INI_Int("Cassa", hInfo[id][hCassa]);
  527.     return 1;
  528. }
  529.  
  530.  
  531. IsPlayerNearHomeExt(playerid)
  532. {
  533.     for(new w = 1; w < 500; w++)
  534.     {
  535.         if(IsPlayerInRangeOfPoint(playerid, 2.0, hInfo[w][hPosXX],hInfo[w][hPosYY],hInfo[w][hPosZZ])) return w;
  536.     }
  537.     return -1;
  538. }
  539.  
  540. IsPlayerNearHomeEnt(playerid)
  541. {
  542.     for(new b = 1; b < 500; b++)
  543.     {
  544.         if(IsPlayerInRangeOfPoint(playerid, 2.0, hInfo[b][hPosX],hInfo[b][hPosY],hInfo[b][hPosZ])) return b;
  545.     }
  546.     return -1;
  547. }
  548.  
  549. stock GetName(playerid)
  550. {
  551.     new pName[MAX_PLAYER_NAME];
  552.     GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  553.     return pName;
  554. }
  555.  
  556. stock RemoveUnderScore(playerid)
  557. {
  558.     new name[MAX_PLAYER_NAME];
  559.     GetPlayerName(playerid,name,sizeof(name));
  560.     for(new i = 0; i < MAX_PLAYER_NAME; i++)
  561.     {
  562.         if(name[i] == '_') name[i] = ' ';
  563.     }
  564.     return name;
  565. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement