Guest User

House Sistem

a guest
Apr 14th, 2014
897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 23.51 KB | None | 0 0
  1.  
  2. #define FILTERSCRIPT
  3.  
  4. #include <a_samp>
  5. #include <float>
  6. #include <foreach>
  7. #include < YSI\y_ini >
  8. #include < YSI\y_amx >
  9. #include < YSI\y_commands >
  10. #include <Streamer>
  11. #include <sscanf2>
  12.  
  13. #define COLOR_WHITE 0xFFFFFFAA
  14. #define GRAY 0xCECECEFF
  15. #define COLOR_LIGHTGREEN 0x9ACD32AA
  16.  
  17. #define DIALOG_PMONEY 7000
  18. #define DIALOG_TMONEY 7001
  19.  
  20.  
  21. #define PRESSED(%0) \
  22.     (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  23. #define randomEx(%0,%1)             (random((%1) - (%0)) + (%0))
  24. #define MAX_HOUSE 500
  25. enum Houses
  26. {
  27.     hOwner[MAX_PLAYER_NAME],
  28.     hOwned,
  29.     hLocked,
  30.     hAppointed,
  31.     hMoney,
  32.     hGun,
  33.     hGunAmmo,
  34.     hPrice,
  35.     hInt,
  36.     hLevel,
  37.     Float:hEnterX,
  38.     Float:hEnterY,
  39.     Float:hEnterZ,
  40.     Float:hExitX,
  41.     Float:hExitZ,
  42.     Float:hExitY
  43. };
  44.  
  45. new HouseInfo[MAX_HOUSE][Houses];
  46. new HEID[MAX_PLAYERS];
  47. new HousePick[sizeof(HouseInfo)];
  48. new Text3D:HouseText[sizeof(HouseInfo)];
  49.  
  50. public OnFilterScriptInit()
  51. {
  52.     print(" Dinamican sistem kuca by Kevin(Bilsen Jahjagic)");
  53.     new string[828];
  54.     for(new h = 0; h < sizeof(HouseInfo); h++)
  55.     {
  56.         new gFile[35];
  57.         format(gFile, 35, "Houses/%d.ini" ,h);
  58.         INI_ParseFile(gFile, "LoadHouses", .bExtra = true, .extra = h);
  59.         if(HouseInfo[h][hAppointed] == 1)
  60.         {
  61.             if(HouseInfo[h][hOwned] == 0)
  62.             {
  63.                 format(string,sizeof(string),"{458B00}[Na prodaju] \n {458B00}[Adresa] - {FFFFFF}[%d] \n {458B00}[Cijena] - {FFFFFF}[$%d]\n {458B00}[Level] - {FFFFFF}[%d]", h, HouseInfo[h][hPrice], HouseInfo[h][hLevel]);
  64.                 HouseText[h] = CreateDynamic3DTextLabel(string ,0x00FF00AA, HouseInfo[h][hEnterX], HouseInfo[h][hEnterY], HouseInfo[h][hEnterZ], 10);
  65.                 HousePick[h] = CreateDynamicPickup(1273, 1, HouseInfo[h][hEnterX], HouseInfo[h][hEnterY], HouseInfo[h][hEnterZ]);
  66.             }
  67.             if(HouseInfo[h][hOwned] == 1)
  68.             {
  69.                 format(string,sizeof(string),"{0033FF}[Vlasnik] - {FFFFFF}[%s] \n {0033FF}[Adresa] - {FFFFFF}[%d] \n {0033FF}[Level] - {FFFFFF}[%d]", HouseInfo[h][hOwner], h, HouseInfo[h][hLevel]);
  70.                 HouseText[h] = CreateDynamic3DTextLabel(string ,0x00FFFFAA, HouseInfo[h][hEnterX], HouseInfo[h][hEnterY], HouseInfo[h][hEnterZ], 10);
  71.                 HousePick[h] = CreateDynamicPickup(1273, 1, HouseInfo[h][hEnterX], HouseInfo[h][hEnterY], HouseInfo[h][hEnterZ]);
  72.             }
  73.         }
  74.     }
  75.     return 1;
  76. }
  77. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  78. {
  79.     new name[24];
  80.     if(PRESSED(KEY_SECONDARY_ATTACK))
  81.     {
  82.         for(new i = 0; i < sizeof(HouseInfo); i++)
  83.         {
  84.             if (IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]))
  85.             {
  86.                 GetPlayerName(playerid, name, sizeof(name));
  87.                 if(HouseInfo[i][hLocked] == 0 || !strcmp(HouseInfo[i][hOwner], name, true ))
  88.                 {
  89.                     SetPlayerInterior(playerid, HouseInfo[i][hInt]); SetPlayerVirtualWorld(playerid, i);
  90.                     SetPlayerPos(playerid, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]);
  91.                     HEID[playerid] = i;
  92.                 }
  93.                 else
  94.                 {
  95.                     GameTextForPlayer(playerid, "~r~Zakljucano", 5000, 1);
  96.                     return 1;
  97.                 }
  98.             }
  99.         }
  100.         if(HEID[playerid] != -1)
  101.         {
  102.             for(new i = 0; i < sizeof(HouseInfo); i++)
  103.             {
  104.                 if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  105.                 {
  106.                     SetPlayerInterior(playerid,0); SetPlayerVirtualWorld(playerid,0);
  107.                     SetPlayerPos(playerid, HouseInfo[HEID[playerid]][hEnterX], HouseInfo[HEID[playerid]][hEnterY], HouseInfo[HEID[playerid]][hEnterZ]);
  108.                     HEID[playerid] = -1;
  109.                     return 1;
  110.                 }
  111.             }
  112.         }
  113.     }
  114.     return 1;
  115. }
  116. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  117. {
  118.     if(dialogid == DIALOG_PMONEY && response)
  119.     {
  120.     new novac, string[128];
  121.     if(sscanf(inputtext, "i", novac))
  122.     {
  123.         ShowPlayerDialog(playerid, DIALOG_PMONEY, DIALOG_STYLE_INPUT, "Kuca", "Unesite kolicinu novca koju zelite da ostavite.", "Unesi", "Izadji");
  124.         return 1;
  125.     }
  126.     if(novac > GetPlayerMoney(playerid))
  127.     {
  128.         SendClientMessage(playerid, GRAY, "Nemate toliko novca.");
  129.         return 1;
  130.     }
  131.     if(novac < 1)
  132.     {
  133.         SendClientMessage(playerid, GRAY, "Suma ne moze biti manja od 1.");
  134.         return 1;
  135.     }
  136.     HouseInfo[HEID[playerid]][hMoney] += novac;
  137.     GivePlayerMoney(playerid,-novac);
  138.     format(string, sizeof(string), "Stavili ste $%d u sef.", novac);
  139.     SendClientMessage(playerid, COLOR_WHITE, string);
  140.     SaveHouse(HEID[playerid]);
  141.     return 1;
  142.     }
  143.    
  144.     if(dialogid == DIALOG_TMONEY && response)
  145.     {
  146.     new novac, string[128];
  147.     if(sscanf(inputtext, "i", novac))
  148.     {
  149.         ShowPlayerDialog(playerid, DIALOG_TMONEY, DIALOG_STYLE_INPUT, "Kuca", "Unesite kolicinu novca koju zelite da uzmete.", "Unesi", "Izadji");
  150.         return 1;
  151.     }
  152.     if(novac > HouseInfo[HEID[playerid]][hMoney])
  153.     {
  154.         SendClientMessage(playerid, GRAY, "Nemate toliko novca u kuci.");
  155.         return 1;
  156.     }
  157.     if(novac < 1)
  158.     {
  159.         SendClientMessage(playerid, GRAY, "Suma ne moze biti manja od 1.");
  160.         return 1;
  161.     }
  162.     HouseInfo[HEID[playerid]][hMoney] -= novac;
  163.     GivePlayerMoney(playerid, novac);
  164.     format(string, sizeof(string), "Uzeli ste $%d iz sefa.", novac);
  165.     SendClientMessage(playerid, COLOR_WHITE, string);
  166.     SaveHouse(HEID[playerid]);
  167.     return 1;
  168.     }
  169.     return 0;
  170. }
  171. stock SaveHouse(h)
  172. {
  173.     new dFile[128];
  174.     format(dFile, sizeof(dFile),"Houses/%d.ini",h);
  175.     new
  176.     INI:File = INI_Open(dFile);
  177.     INI_WriteString(File, "Vlasnik", HouseInfo[h][hOwner]);
  178.     INI_WriteInt(File, "Posjedovana", HouseInfo[h][hOwned]);
  179.     INI_WriteInt(File, "Zakljucana", HouseInfo[h][hLocked]);
  180.     INI_WriteInt(File, "Postavljena", HouseInfo[h][hAppointed]);
  181.     INI_WriteInt(File, "Level", HouseInfo[h][hLevel]);
  182.     INI_WriteInt(File, "Cijena", HouseInfo[h][hPrice]);
  183.     INI_WriteInt(File, "Novac", HouseInfo[h][hMoney]);
  184.     INI_WriteInt(File, "Oruzije", HouseInfo[h][hGun]);
  185.     INI_WriteInt(File, "Metkovi", HouseInfo[h][hGunAmmo]);
  186.     INI_WriteFloat(File, "UlazX", HouseInfo[h][hEnterX]);
  187.     INI_WriteFloat(File, "UlazY", HouseInfo[h][hEnterY]);
  188.     INI_WriteFloat(File, "UlazZ", HouseInfo[h][hEnterZ]);
  189.     INI_WriteInt(File, "Enterijer", HouseInfo[h][hInt]);
  190.     INI_WriteFloat(File, "IzlazX", HouseInfo[h][hExitX]);
  191.     INI_WriteFloat(File, "IzlazY", HouseInfo[h][hExitY]);
  192.     INI_WriteFloat(File, "IzlazZ", HouseInfo[h][hExitZ]);
  193.  
  194.     INI_Close(File);
  195. }
  196. forward LoadHouses(h, name[], value[]);
  197. public LoadHouses(h, name[], value[])
  198. {
  199.     INI_String("Vlasnik", HouseInfo[h][hOwner], 24);
  200.     INI_Int("Posjedovana", HouseInfo[h][hOwned]);
  201.     INI_Int("Zakljucana", HouseInfo[h][hLocked]);
  202.     INI_Int("Postavljena", HouseInfo[h][hAppointed]);
  203.     INI_Int("Level", HouseInfo[h][hLevel]);
  204.     INI_Int("Cijena", HouseInfo[h][hPrice]);
  205.     INI_Int("Novac", HouseInfo[h][hMoney]);
  206.     INI_Int("Oruzije", HouseInfo[h][hGun]);
  207.     INI_Int("Metkovi", HouseInfo[h][hGunAmmo]);
  208.     INI_Float("UlazX", HouseInfo[h][hEnterX]);
  209.     INI_Float("UlazY", HouseInfo[h][hEnterY]);
  210.     INI_Float("UlazZ", HouseInfo[h][hEnterZ]);
  211.     INI_Int("Enterijer", HouseInfo[h][hInt]);
  212.     INI_Float("IzlazX", HouseInfo[h][hExitX]);
  213.     INI_Float("IzlazY", HouseInfo[h][hExitY]);
  214.     INI_Float("IzlazZ", HouseInfo[h][hExitZ]);
  215.     return 1;
  216. }
  217. stock TPUpdate(h)
  218. {
  219.     new string[828];
  220.     DestroyDynamicPickup(HousePick[h]);
  221.     DestroyDynamic3DTextLabel(HouseText[h]);
  222.     if(HouseInfo[h][hOwned] == 0)
  223.     {
  224.         format(string,sizeof(string),"{458B00}[Na prodaju] \n {458B00}[Adresa] - {FFFFFF}[%d] \n {458B00}[Cijena] - {FFFFFF}[$%d]\n {458B00}[Level] - {FFFFFF}[%d]", h, HouseInfo[h][hPrice], HouseInfo[h][hLevel]);
  225.         HouseText[h] = CreateDynamic3DTextLabel(string ,0x00FF00AA, HouseInfo[h][hEnterX], HouseInfo[h][hEnterY], HouseInfo[h][hEnterZ], 10);
  226.         HousePick[h] = CreateDynamicPickup(1273, 1, HouseInfo[h][hEnterX], HouseInfo[h][hEnterY], HouseInfo[h][hEnterZ]);
  227.     }
  228.     if(HouseInfo[h][hOwned] == 1)
  229.     {
  230.         format(string,sizeof(string),"{0033FF}[Vlasnik] - {FFFFFF}[%s] \n {0033FF}[Adresa] - {FFFFFF}[%d] \n {0033FF}[Level] - {FFFFFF}[%d]", HouseInfo[h][hOwner], h, HouseInfo[h][hLevel]);
  231.         HouseText[h] = CreateDynamic3DTextLabel(string ,0x00FFFFAA, HouseInfo[h][hEnterX], HouseInfo[h][hEnterY], HouseInfo[h][hEnterZ], 10);
  232.         HousePick[h] = CreateDynamicPickup(1272, 1, HouseInfo[h][hEnterX], HouseInfo[h][hEnterY], HouseInfo[h][hEnterZ]);
  233.     }
  234. }
  235. stock RemovePlayerWeapon(playerid, weaponid)
  236. {
  237.     new plyWeapons[12];
  238.     new plyAmmo[12];
  239.  
  240.     for(new slot = 0; slot != 12; slot++)
  241.     {
  242.         new wep, ammo;
  243.         GetPlayerWeaponData(playerid, slot, wep, ammo);
  244.  
  245.         if(wep != weaponid)
  246.         {
  247.             GetPlayerWeaponData(playerid, slot, plyWeapons[slot], plyAmmo[slot]);
  248.         }
  249.     }
  250.  
  251.     ResetPlayerWeapons(playerid);
  252.     for(new slot = 0; slot != 12; slot++)
  253.     {
  254.         GivePlayerWeapon(playerid, plyWeapons[slot], plyAmmo[slot]);
  255.     }
  256. }
  257. YCMD:h(playerid, params[], help)
  258. {
  259.     new string[128];
  260.     new text[24];
  261.     new name[24];
  262.     if(sscanf(params, "s[24]",text))
  263.     {
  264.         SendClientMessage(playerid, COLOR_LIGHTGREEN, "________________Kuca________________");
  265.         SendClientMessage(playerid, GRAY, "** Kuca ** Koristenje:(/house [ime])");
  266.         SendClientMessage(playerid, GRAY, "** Kuca ** Dostupna imena: buy, sell, info, lock, locate");
  267.         SendClientMessage(playerid, GRAY, "** Kuca ** Dostupna imena: putmoney, takemoney, putgun, takegun");
  268.         SendClientMessage(playerid, COLOR_LIGHTGREEN, "______________________________________");
  269.         return 1;
  270.     }
  271.     if(strcmp(text,"buy", true) == 0)
  272.     {
  273.         for(new i = 0; i < sizeof(HouseInfo); i++)
  274.         {
  275.             GetPlayerName(playerid, name, sizeof(name));
  276.             if(strcmp(HouseInfo[i][hOwner], name, true))
  277.             {
  278.                 SendClientMessage(playerid, GRAY, "Vec posjedujete kucu!");
  279.                 return 1;
  280.             }
  281.             if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]) && HouseInfo[i][hOwned] == 0)
  282.             {
  283.                 if(GetPlayerMoney(playerid) < HouseInfo[i][hPrice])
  284.                 {
  285.                 SendClientMessage(playerid, GRAY, "Nemate dovoljno novca za kupovinu ove kuce!");
  286.                 return 1;
  287.                 }
  288.                 if(GetPlayerScore(playerid) < HouseInfo[i][hLevel])
  289.                 {
  290.                 SendClientMessage(playerid, GRAY, "Nemate dovoljan level za kupovinu ove kuce!");
  291.                 return 1;
  292.                 }
  293.                 format(HouseInfo[i][hOwner], 24, "%s", name);
  294.                 HouseInfo[i][hOwned] = 1;
  295.                 GivePlayerMoney(playerid, -HouseInfo[i][hPrice]);
  296.                 SendClientMessage(playerid, COLOR_WHITE, "Cestitamo na kupovini nove kuce!");
  297.                 TPUpdate(i);
  298.                 SaveHouse(i);
  299.                 return 1;
  300.             }
  301.         }
  302.         return 1;
  303.     }
  304.     if(strcmp(text,"sell", true) == 0)
  305.     {
  306.         for(new i = 0; i < sizeof(HouseInfo); i++)
  307.         {
  308.             GetPlayerName(playerid, name, sizeof(name));
  309.             if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]) && !strcmp(HouseInfo[i][hOwner], name, true))
  310.             {
  311.             format(HouseInfo[i][hOwner], 24, "Drzava");
  312.             HouseInfo[i][hOwned] = 0;
  313.             HouseInfo[i][hLocked] = 1;
  314.             TPUpdate(i);
  315.             SaveHouse(i);
  316.             return 1;
  317.             }
  318.         }
  319.         return 1;
  320.     }
  321.     if(strcmp(text,"info", true) == 0)
  322.     {
  323.         for(new i = 0; i < sizeof(HouseInfo); i++)
  324.         {
  325.             GetPlayerName(playerid, name, sizeof(name));
  326.             if(IsPlayerInRangeOfPoint(playerid, 10,  HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]) && !strcmp(HouseInfo[i][hOwner], name, true))
  327.             {
  328.                 format(string, sizeof(string), "Novac: %d\nOruzije: %d(%d)", HouseInfo[i][hMoney], HouseInfo[i][hGun], HouseInfo[i][hGunAmmo]);
  329.                 ShowPlayerDialog( playerid, 6677, DIALOG_STYLE_MSGBOX, "Kucni Sef", string, "Ok", "" );
  330.             }
  331.         }
  332.         return 1;
  333.     }
  334.     if(strcmp(text,"lock", true) == 0)
  335.     {
  336.         for(new i = 0; i < sizeof(HouseInfo); i++)
  337.         {
  338.             GetPlayerName(playerid, name, sizeof(name));
  339.             if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]) && !strcmp(HouseInfo[i][hOwner], name, true) && GetPlayerVirtualWorld(playerid) == i || IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]) && !strcmp(HouseInfo[i][hOwner], name, true) && GetPlayerVirtualWorld(playerid) == i)
  340.             {
  341.                 if(HouseInfo[i][hLocked] == 0)
  342.                 {
  343.                     HouseInfo[i][hLocked] = 1;
  344.                     SendClientMessage(playerid, COLOR_WHITE, "Zakljucali ste kucu!");
  345.                     return 1;
  346.                 }
  347.                 else
  348.                 {
  349.                     HouseInfo[i][hLocked] = 0;
  350.                     SendClientMessage(playerid, COLOR_WHITE, "Otkljucali ste kucu!");
  351.                     return 1;
  352.                 }
  353.             }
  354.         }
  355.         return 1;
  356.     }
  357.     if(strcmp(text,"locate", true) == 0)
  358.     {
  359.         for(new i = 0; i < sizeof(HouseInfo); i++)
  360.         {
  361.             GetPlayerName(playerid, name, sizeof(name));
  362.             if(!strcmp(HouseInfo[i][hOwner], name, true))
  363.             {
  364.                 SetPlayerCheckpoint(playerid, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ], 5.0);
  365.                 SendClientMessage(playerid, COLOR_WHITE, "Vasa kuca je oznacena na mapi crvenim markerom!");
  366.                 return 1;
  367.             }
  368.             else
  369.             {
  370.                 SendClientMessage(playerid, GRAY, "Vi ne posjedujete kucu!");
  371.                 return 1;
  372.             }
  373.         }
  374.         return 1;
  375.     }
  376.     if(strcmp(text,"putmoney", true) == 0)
  377.     {
  378.         for(new i = 0; i < sizeof(HouseInfo); i++)
  379.         {
  380.             GetPlayerName(playerid, name, sizeof(name));
  381.             if(IsPlayerInRangeOfPoint(playerid, 10,  HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]) && !strcmp(HouseInfo[i][hOwner], name, true))
  382.             {
  383.                 ShowPlayerDialog(playerid, DIALOG_PMONEY, DIALOG_STYLE_INPUT, "Kuca", "Unesite kolicinu novca koju zelite da ostavite.", "Unesi", "Izadji");
  384.                 return 1;
  385.             }
  386.         }
  387.         return 1;
  388.     }
  389.     if(strcmp(text,"takemoney", true) == 0)
  390.     {
  391.         for(new i = 0; i < sizeof(HouseInfo); i++)
  392.         {
  393.             GetPlayerName(playerid, name, sizeof(name));
  394.             if(IsPlayerInRangeOfPoint(playerid, 10,  HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]) && !strcmp(HouseInfo[i][hOwner], name, true))
  395.             {
  396.                 ShowPlayerDialog(playerid, DIALOG_TMONEY, DIALOG_STYLE_INPUT, "Kuca", "Unesite kolicinu novca koju zelite da uzmete.", "Unesi", "Izadji");
  397.                 return 1;
  398.             }
  399.         }
  400.         return 1;
  401.     }
  402.     if(strcmp(text,"putgun", true) == 0)
  403.     {
  404.         new gname[24];
  405.         for(new i = 0; i < sizeof(HouseInfo); i++)
  406.         {
  407.             GetPlayerName(playerid, name, sizeof(name));
  408.             if(IsPlayerInRangeOfPoint(playerid, 10,  HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]) && !strcmp(HouseInfo[i][hOwner], name, true))
  409.             {
  410.                 if(HouseInfo[i][hGun] != 0) return SendClientMessage(playerid, GRAY, "U sefu vec ima oruzije!");
  411.                 if(GetPlayerWeapon(playerid) != 0 && GetPlayerAmmo(playerid) != 0)
  412.                 {
  413.                     GetWeaponName(GetPlayerWeapon(playerid), gname, sizeof(gname));
  414.                     RemovePlayerWeapon(playerid, GetPlayerWeapon(playerid));
  415.                     HouseInfo[i][hGun] = GetPlayerWeapon(playerid);
  416.                     HouseInfo[i][hGunAmmo] = GetPlayerAmmo(playerid);
  417.                     format(string, sizeof(string), "Stavili ste %s u sef.", gname);
  418.                     SendClientMessage(playerid, COLOR_WHITE, string);
  419.                     SaveHouse(i);
  420.                 }
  421.                 else
  422.                 {
  423.                     SendClientMessage(playerid, GRAY, "Nemate oruzije ili u njemu nema metaka!");
  424.                 }
  425.                 return 1;
  426.             }
  427.         }
  428.         return 1;
  429.     }
  430.     if(strcmp(text,"takegun", true) == 0)
  431.     {
  432.         new gname[24];
  433.         for(new i = 0; i < sizeof(HouseInfo); i++)
  434.         {
  435.             GetPlayerName(playerid, name, sizeof(name));
  436.             if(IsPlayerInRangeOfPoint(playerid, 10,  HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]) && !strcmp(HouseInfo[i][hOwner], name, true))
  437.             {
  438.                 if(HouseInfo[i][hGun] != 0)
  439.                 {
  440.                     GivePlayerWeapon(playerid, HouseInfo[i][hGun], HouseInfo[i][hGunAmmo]);
  441.                     GetWeaponName(HouseInfo[i][hGun], gname, sizeof(gname));
  442.                     format(string, sizeof(string), "Uzeli ste %s iz sefa.", gname);
  443.                     SendClientMessage(playerid, COLOR_WHITE, string);
  444.                     HouseInfo[i][hGun] = 0;
  445.                     HouseInfo[i][hGunAmmo] = 0;
  446.                     SaveHouse(i);
  447.                 }
  448.                 else
  449.                 {
  450.                     SendClientMessage(playerid, GRAY, "U sefu nema oruzije!");
  451.                 }
  452.                 return 1;
  453.             }
  454.         }
  455.         return 1;
  456.     }
  457.     return 1;
  458. }
  459. YCMD:createhouse(playerid, params[], help)
  460. {
  461.         new Float:X, Float:Y, Float:Z; new hid = 0;
  462.         new cijena, level, entr;
  463.         if(IsPlayerAdmin(playerid))
  464.         {
  465.             if(sscanf(params, "iii",cijena, level, entr))
  466.             {
  467.             SendClientMessage(playerid, GRAY, "/createhouse [cijena] [level] [enterijer]");
  468.             return 1;
  469.             }
  470.             GetPlayerPos(playerid, X,Y,Z);
  471.             for(new h = 1; h < sizeof(HouseInfo); h++)
  472.             {
  473.                 if(HouseInfo[h][hAppointed] == 1)
  474.                 {
  475.                     hid = h + 1;
  476.                 }
  477.                 if(hid == 0)
  478.                 {
  479.                     hid = 1;
  480.                 }
  481.             }
  482.             if(entr < 1  || entr > 5)
  483.             {
  484.                 SendClientMessage(playerid, GRAY, "Enterijer ne moze biti manji od 1 ni veci od 5.");
  485.                 return 1;
  486.             }
  487.             format(HouseInfo[hid][hOwner], 24, "%s", "Drzava");
  488.             HouseInfo[hid][hEnterX] = X;
  489.             HouseInfo[hid][hEnterY] = Y;
  490.             HouseInfo[hid][hEnterZ] = Z;
  491.             HouseInfo[hid][hOwned] = 0;
  492.             HouseInfo[hid][hAppointed] = 1;
  493.             HouseInfo[hid][hLocked] = 0;
  494.             HouseInfo[hid][hMoney] = 0;
  495.             HouseInfo[hid][hGun] = 0;
  496.             HouseInfo[hid][hGunAmmo] = 0;
  497.             HouseInfo[hid][hPrice] = cijena;
  498.             HouseInfo[hid][hLevel] = level;
  499.             TPUpdate(hid);
  500.             SendClientMessage(playerid, COLOR_WHITE, "Napravili ste novu kucu!");
  501.             if(entr == 1)
  502.             {
  503.                 HouseInfo[hid][hExitX] = 2308.7400;
  504.                 HouseInfo[hid][hExitY] = -1212.4301;
  505.                 HouseInfo[hid][hExitZ] = 1049.0234;
  506.                 HouseInfo[hid][hInt] = 6;
  507.                 SaveHouse(hid);
  508.                 return 1;
  509.             }
  510.             else if(entr == 2)
  511.             {
  512.                 HouseInfo[hid][hExitX] = 244.4120;
  513.                 HouseInfo[hid][hExitY] = 305.0330;
  514.                 HouseInfo[hid][hExitZ] = 999.1484;
  515.                 HouseInfo[hid][hInt] = 1;
  516.                 SaveHouse(hid);
  517.                 return 1;
  518.             }
  519.             else if(entr == 3)
  520.             {
  521.                 HouseInfo[hid][hExitX] = 267.1469;
  522.                 HouseInfo[hid][hExitY] = 304.9806;
  523.                 HouseInfo[hid][hExitZ] = 999.1484;
  524.                 HouseInfo[hid][hInt] = 2;
  525.                 SaveHouse(hid);
  526.                 return 1;
  527.             }
  528.             else if(entr == 4)
  529.             {
  530.                 HouseInfo[hid][hExitX] = 2259.9094;
  531.                 HouseInfo[hid][hExitY] = -1135.8812;
  532.                 HouseInfo[hid][hExitZ] = 1050.6328;
  533.                 HouseInfo[hid][hInt] = 10;
  534.                 SaveHouse(hid);
  535.                 return 1;
  536.             }
  537.             else if(entr == 5)
  538.             {
  539.                 HouseInfo[hid][hExitX] = 318.5494;
  540.                 HouseInfo[hid][hExitY] = 1115.0696;
  541.                 HouseInfo[hid][hExitZ] = 1083.8828;
  542.                 HouseInfo[hid][hInt] = 5;
  543.                 SaveHouse(hid);
  544.                 return 1;
  545.             }
  546.         }
  547.         return 1;
  548.     }
  549. YCMD:deletehouse(playerid, params[], help)
  550. {
  551.         new id, remv[24], string[64];
  552.         if(IsPlayerAdmin(playerid))
  553.         {
  554.             if(sscanf(params, "i", id))
  555.             {
  556.             SendClientMessage(playerid, GRAY, "/deletehouse [id kuce]");
  557.             return 1;
  558.             }
  559.             if(HouseInfo[id][hAppointed] == 1)
  560.             {
  561.                 HouseInfo[id][hAppointed] = 0;
  562.                 HouseInfo[id][hEnterX] = 0;
  563.                 HouseInfo[id][hEnterY] = 0;
  564.                 HouseInfo[id][hEnterZ] = 0;
  565.                 DestroyDynamic3DTextLabel(HouseText[id]);
  566.                 DestroyDynamicPickup(HousePick[id]);
  567.                 format(string, sizeof(string),"Unistili ste kucu id %d.", id);
  568.                 SendClientMessage(playerid, COLOR_WHITE, string);
  569.                 format(remv, sizeof(remv),"Houses/%d.ini", id);
  570.                 fremove(remv);
  571.                 return 1;
  572.             }
  573.         }
  574.         return 1;
  575.     }
  576. YCMD:edithouse(playerid, params[], help)
  577. {
  578.     if(IsPlayerAdmin(playerid))
  579.     {
  580.         new izbor[48]; new kolicina;
  581.         if(sscanf(params, "s[24]i", izbor, kolicina))
  582.         {
  583.             SendClientMessage(playerid, GRAY, "/edithouse cijena/level/int [kolicina]");
  584.             return 1;
  585.         }
  586.         if(strcmp(izbor,"cijena",true) == 0)
  587.         {
  588.             if(kolicina < 1)
  589.             {
  590.                 SendClientMessage(playerid, GRAY, "Cijena ne moze biti manja od 1.");
  591.                 return 1;
  592.             }
  593.             for(new i = 0; i < sizeof(HouseInfo); i++)
  594.             {
  595.                 new string[128];
  596.                 if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]))
  597.                 {
  598.                     HouseInfo[i][hPrice] = kolicina;
  599.                     format(string, sizeof(string), "Postavili ste cijenu kuce %d na $%d.", i, kolicina);
  600.                     SendClientMessage(playerid, COLOR_WHITE, string);
  601.                     TPUpdate(i);
  602.                     SaveHouse(i);
  603.                     return 1;
  604.                 }
  605.             }
  606.             return 1;
  607.         }
  608.         if(strcmp(izbor,"level",true) == 0)
  609.         {
  610.             if(kolicina < 1)
  611.             {
  612.                 SendClientMessage(playerid, GRAY, "Level ne moze biti manji od 1.");
  613.                 return 1;
  614.             }
  615.             for(new i = 0; i < sizeof(HouseInfo); i++)
  616.             {
  617.                 new string[128];
  618.                 if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]))
  619.                 {
  620.                     HouseInfo[i][hLevel] = kolicina;
  621.                     format(string, sizeof(string), "Postavili ste level kuce %d na %d.", i, kolicina);
  622.                     SendClientMessage(playerid, COLOR_WHITE, string);
  623.                     TPUpdate(i);
  624.                     SaveHouse(i);
  625.                     return 1;
  626.                 }
  627.             }
  628.             return 1;
  629.         }
  630.         if(strcmp(izbor,"int",true) == 0)
  631.         {
  632.             if(kolicina < 1 || kolicina > 5)
  633.             {
  634.                 SendClientMessage(playerid,GRAY,"Enterijer ne moze biti manji od 1 ni veci od 5!");
  635.                 return 1;
  636.             }
  637.             for(new i = 0; i < sizeof(HouseInfo); i++)
  638.             {
  639.                 new string[128];
  640.                 if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]))
  641.                 {
  642.                     if(kolicina == 1)
  643.                     {
  644.                         HouseInfo[i][hExitX] = 2308.7400;
  645.                         HouseInfo[i][hExitY] = -1212.4301;
  646.                         HouseInfo[i][hExitZ] = 1049.0234;
  647.                         HouseInfo[i][hInt] = 6;
  648.                         SaveHouse(i);
  649.                         format(string, sizeof(string), "Postavili ste enterijer kuce %d na %d.", i, kolicina);
  650.                         SendClientMessage(playerid, COLOR_WHITE, string);
  651.                         return 1;
  652.                     }
  653.                     if(kolicina == 2)
  654.                     {
  655.                         HouseInfo[i][hExitX] = 244.4120;
  656.                         HouseInfo[i][hExitY] = 305.0330;
  657.                         HouseInfo[i][hExitZ] = 999.1484;
  658.                         HouseInfo[i][hInt] = 1;
  659.                         SaveHouse(i);
  660.                         format(string, sizeof(string), "Postavili ste enterijer kuce %d na %d.", i, kolicina);
  661.                         SendClientMessage(playerid, COLOR_WHITE, string);
  662.                         return 1;
  663.                     }
  664.                     if(kolicina == 3)
  665.                     {
  666.                         HouseInfo[i][hExitX] = 267.1469;
  667.                         HouseInfo[i][hExitY] = 304.9806;
  668.                         HouseInfo[i][hExitZ] = 999.1484;
  669.                         HouseInfo[i][hInt] = 2;
  670.                         SaveHouse(i);
  671.                         format(string, sizeof(string), "Postavili ste enterijer kuce %d na %d.", i, kolicina);
  672.                         SendClientMessage(playerid, COLOR_WHITE, string);
  673.                         return 1;
  674.                     }
  675.                     if(kolicina == 4)
  676.                     {
  677.                         HouseInfo[i][hExitX] = 2259.9094;
  678.                         HouseInfo[i][hExitY] = -1135.8812;
  679.                         HouseInfo[i][hExitZ] = 1050.6328;
  680.                         HouseInfo[i][hInt] = 10;
  681.                         SaveHouse(i);
  682.                         format(string, sizeof(string), "Postavili ste enterijer kuce %d na %d.", i, kolicina);
  683.                         SendClientMessage(playerid, COLOR_WHITE, string);
  684.                         return 1;
  685.                     }
  686.                     if(kolicina == 5)
  687.                     {
  688.                         HouseInfo[i][hExitX] = 318.5494;
  689.                         HouseInfo[i][hExitY] = 1115.0696;
  690.                         HouseInfo[i][hExitZ] = 1083.8828;
  691.                         HouseInfo[i][hInt] = 5;
  692.                         SaveHouse(i);
  693.                         format(string, sizeof(string), "Postavili ste enterijer kuce %d na %d.", i, kolicina);
  694.                         SendClientMessage(playerid, COLOR_WHITE, string);
  695.                         return 1;
  696.                     }
  697.                 }
  698.             }
  699.             return 1;
  700.         }
  701.     }
  702.     return 1;
  703. }
Advertisement
Add Comment
Please, Sign In to add comment