Advertisement
Guest User

Modified Sasinosoft houses system

a guest
Jul 16th, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 58.57 KB | None | 0 0
  1. /*
  2.                                      ___                                                 ___  _
  3.                                     (  _`\               _                             /'___)( )_
  4.                                     | (_(_)   _ _   ___ (_)  ___     _     ___    _   | (__  | ,_)
  5.                                     `\__ \  /'_` )/',__)| |/' _ `\ /'_`\ /',__) /'_`\ | ,__) | |
  6.                                     ( )_) |( (_| |\__, \| || ( ) |( (_) )\__, \( (_) )| |    | |_
  7.                                     `\____)`\__,_)(____/(_)(_) (_)`\___/'(____/`\___/'(_)    `\__)
  8.  
  9.                                     ( ) ( )                                     /'__`\    /' _`\
  10.                                     | |_| |   _    _   _   ___    __    ___    (_)  ) )   | ( ) |
  11.                                     |  _  | /'_`\ ( ) ( )/',__) /'__`\/',__)      /' /    | | | |
  12.                                     | | | |( (_) )| (_) |\__, \(  ___/\__, \    /' /( ) _ | (_) |
  13.                                     (_) (_)`\___/'`\___/'(____/`\____)(____/   (_____/'(_)`\___/'
  14.  
  15. */
  16. // Sasinosoft Houses 2.0 - By Sasino97 - December 2012 - January 2013
  17. // Totally rewritten from scratch
  18. // This filterscript only works for SA-MP Server 0.3e or higher
  19.  
  20. /*
  21.                                                             PLACE THIS IN YOUR GAMEMODE:
  22.  
  23.  
  24. #define BOX_STYLE_CMD "{33AA33}COMMAND"
  25. #define BOX_STYLE_ERROR "{FF0000}ERROR"
  26. #define BOX_STYLE_WARNING "{FF8000}WARNING"
  27.  
  28. stock CreateHouse(Float:eX, Float:eY, Float:eZ, Float:iX, Float:iY, Float:iZ, price, interior, exterior = 0, virtualWorld = 1)
  29. {
  30.     return CallRemoteFunction("FS_CreateHouse", "ffffffiiii", eX, eY, eZ, iX, iY, iZ, price, interior, exterior, virtualWorld);
  31. }
  32. stock CreateBusiness(title[MAX_PLAYER_NAME], earning, Float:eX, Float:eY, Float:eZ, Float:iX, Float:iY, Float:iZ, price, interior, exterior = 0, virtualWorld = 1, iconmarker = 37, itemlist[1024] = "_")
  33. {
  34.     return CallRemoteFunction("FS_CreateBusiness", "siffffffiiiiis", title, earning, eX, eY, eZ, iX, iY, iZ, price, interior, exterior, virtualWorld, iconmarker, itemlist);
  35. }
  36. stock GiveBusinessMoney(shopid, money) { return CallRemoteFunction("FS_GiveBusinessMoney", "ii", shopid, money); }
  37. stock GetBusinessMoney(shopid) { return CallRemoteFunction("FS_GetBusinessMoney", "i", shopid); }
  38. stock GiveBusinessGoods(shopid, goods) { return CallRemoteFunction("FS_GiveBusinessGoods", "ii", shopid, goods); }
  39. stock GetBusinessGoods(shopid) { return CallRemoteFunction("FS_GetBusinessGoods", "i", shopid); }
  40. stock MsgBox(playerid, style[], text[]) { return CallRemoteFunction("FS_MsgBox", "iss", playerid, style, text); }
  41.  
  42. forward OnPlayerBuyItem(playerid, shopid, itemid);
  43. public OnPlayerBuyItem(playerid, shopid, itemid)
  44. {
  45.     // Put here code
  46.     return 1;
  47. }
  48.  
  49. */
  50.  
  51. #include <a_samp>
  52. #include <SII> // NOTICE: Make sure that INI_MAX_LINES in SII.inc is at least 512 (By default it's 256) otherwise not all of the furniture will be saved. If you don't want to, then decrease the furniture limit to 30.
  53. #include <streamer>
  54.  
  55. #define FILTERSCRIPT
  56. new hcp[MAX_PLAYERS];
  57.  
  58. #if !defined EditObject
  59. #error "This filterscript only works for SA-MP Server 0.3e or higher. Please download the lastest SA-MP Server package."
  60. #endif
  61.  
  62. // Main Settings
  63. // Warning: changing any of these and then recompling the code could result in bugs if there are already created houses or businesses. Change them before using it in your game.
  64. #define MAX_HOUSES 50 // Set to whatever you want (default = 50). A big value could cause long looping times.
  65. #define MAX_SHOPS 50 // Set to whatever you want (default = 50). A big value could cause long looping times.
  66. #define MAX_TITLE 20 // The max length of the title of a shop
  67. #define MAX_TITLE_STR "20" // The same as above, but make it as string.
  68. #define MAX_FURNITURE 50 // The max number of furniture a house can have. If you make this bigger remember to edit MAX_INI_LINES into SII
  69. #define VISIT_TIME 60000 // The time a player has to visit a house.
  70. #define HOUSE_FILE "Sasinosoft/Houses/House%d.ini" //Set to whatever you want (default = "Sasinosoft/Houses/House%d.ini")
  71. #define SHOP_FILE "Sasinosoft/Shops/Shop%d.ini" //Set to whatever you want (default = "Sasinosoft/Houses/House%d.ini")
  72. #define SAVED_HOUSES_FILE "Sasinosoft/Houses/SavedHouses.txt" // The file where the houses saved with /savehouse are written
  73. #define SAVED_SHOPS_FILE "Sasinosoft/Shops/SavedShops.txt" // The file where the stores/shops saved with /savestore are written
  74. #define GOOD_PRICE 100 // 1 good = 1 player can buy 1 item (default = 100$ per good)
  75. #define SELL_MULTIPLIER 0.8 // When a player sells a house, a furniture or a shop he will receive the initial price of the shop multiplied by this value
  76. #define INVALID_OWNER "LOK18F75J" // Never change this. If you set this to a common nickname and that player connects I don't know what will happen. If you change this while there are unbought houses they will result as bought.
  77. #define INVALID_HOUSE_ID -255 // Use only a negative value
  78. #define KEY KEY_LOOK_BEHIND // The key to press to open dialogs
  79. #define KEY_STRING "\"MMB\"" // The same, but in a string
  80. #define NO_ITEMS_STRING "{FF0000}Nothing to buy" // String displayed in a shop without nothing to buy
  81. #define MAP_ICONS 1 // If defined to 1, on the map will be created icons.
  82. #define CONSOLE 1 // if defined to 1, the important things are printed to the console (and then to server_log.txt)
  83. #define ShowNoMoneyMessage(%0) FS_MsgBox(%0, BOX_STYLE_ERROR, "You don't have enough money.") // A useful macro
  84. #define GREEN 0x33AA33AA
  85. #define RED 0xFF0000C8
  86.  
  87.  
  88. // Furniture
  89. #define FURNITURE_NUMBER 55
  90. #define INVALID_FURNITURE_ID 0
  91. stock FurnitureInfo[][] =
  92. {// {[0]object, [1]price, [2]name}
  93.     {0, 0, "INVALID_FURNITURE_ID"}, // 0
  94.     {2165, 1500, "Desk and PC"}, // 1
  95.     {2356, 100, "Desk chair"}, // 2
  96.     {2028, 350, "CJD500 console"}, // 3
  97.     {2779, 600, "Arcade machine"}, // 4
  98.     {2030, 750, "Marble table"}, // 5
  99.     {2086, 1000, "Glass table"}, // 6
  100.     {2112, 300, "Wood table"}, // 7
  101.     {2115, 600, "Big wood table"}, // 8
  102.     {2079, 80, "Chair A"}, // 9
  103.     {2120, 150, "Chair B"}, // 10
  104.     {2121, 50, "Red folding chair"}, // 11
  105.     {2096, 100, "Rocking chair"}, // 12
  106.     {2069, 100, "Lamp"}, // 13
  107.     {2103, 800, "Radio"}, // 14
  108.     {2132, 200, "White Sink"}, // 15
  109.     {2141, 900, "White Fridge"}, // 16
  110.     {2149, 600, "Microwave oven"}, // 17
  111.     {2161, 500, "Book shelf"}, // 18
  112.     {2167, 750, "Wardrobe"}, // 19
  113.     {2202, 1500, "Photocopier"}, // 20
  114.     {2313, 900, "TV Shelf + DVD Player"}, // 21
  115.     {2312, 1200, "Television A"}, // 22
  116.     {2316, 1200, "Television B"}, // 23
  117.     {2322, 1200, "Television C"}, // 24
  118.     {2298, 1000, "Blue Bed"}, // 25
  119.     {2299, 1000, "Brown Bed"}, // 26
  120.     {2300, 1000, "Yellow Bed"}, // 27
  121.     {2301, 1000, "Green and Blue Bed"}, // 28
  122.     {2526, 1250, "Bath"}, // 29
  123.     {2527, 1200, "Shower"}, // 30
  124.     {2524, 200, "Washbasin"}, // 31
  125.     {2525, 200, "Toilet"}, // 32
  126.     {1208, 1200, "Washing Machine"}, // 33
  127.     {1762, 1200, "Armchair A"}, // 34
  128.     {1765, 1200, "Armchair B"}, // 35
  129.     {1761, 700, "Sofa A"}, // 36
  130.     {1764, 700, "Sofa B"}, // 37
  131.     {1409, 20, "Trash can"}, // 38
  132.     {2627, 1000, "Tapis Roulant"}, // 39
  133.     {2630, 800, "Cyclette"}, // 40
  134.     {2964, 1000, "Pool Table"}, // 41
  135.     {1502, 200, "Door"}, // 42
  136.     {19317, 600, "Bass Guitar"}, // 43
  137.     {2134, 300, "White Kitchen Part 1"}, // 44
  138.     {2133, 300, "White Kitchen Part 2"}, // 45
  139.     {2131, 300, "White Kitchen Part 3"}, // 46
  140.     {2130, 200, "Red Sink"}, // 47
  141.     {2128, 900, "Red Fridge"}, // 48
  142.     {2127, 300, "Red Kitchen Part 1"}, // 49
  143.     {2129, 300, "Red Kitchen Part 2"}, // 50
  144.     {2294, 300, "Red Kitchen Part 3"}, // 51
  145.     {19166, 100, "San Andreas Picture"}, // 52
  146.     {19172, 100, "Santa Maria Beach Picture"}, // 53
  147.     {19173, 100, "San Fierro Picture"} // 54
  148.     // Add more if you wish, but remember to redefine FURNITURE_NUMBER
  149. };
  150.  
  151. // Box styles
  152. #define BOX_STYLE_CMD "{33AA33}COMMAND"
  153. #define BOX_STYLE_ERROR "{FF0000}ERROR"
  154. #define BOX_STYLE_WARNING "{FF8000}WARNING"
  155.  
  156. // Dialogs
  157. #define DIALOG_FORSALE_HOUSE 470 //
  158. #define DIALOG_MY_HOUSE 471 //
  159. #define DIALOG_OTHERS_HOUSE 472 //
  160. #define DIALOG_FORSALE_BIZ 473 //
  161. #define DIALOG_MY_BIZ 474 //
  162. #define DIALOG_OTHERS_BIZ 475 //
  163. #define DIALOG_HOUSE_MENU 476 //
  164. #define DIALOG_SELL_HOUSE 477 //
  165. #define DIALOG_RENAME_SHOP 478 //
  166. #define DIALOG_SELL_SHOP 479 //
  167. #define DIALOG_SUPPLY 480 //
  168. #define DIALOG_STORE_MONEY 481 //
  169. #define DIALOG_WITHDRAW_MONEY 482 //
  170. #define DIALOG_EDIT_FURNITURE 483 //
  171. #define DIALOG_SELL_FURNITURE 484 //
  172. #define DIALOG_BUY_FURNITURE 485 //
  173. #define DIALOG_MOVE_FURNITURE 486 //
  174. #define DIALOG_FURNITURE_BOUGHT 487 //
  175. #define DIALOG_SHOP 488 //
  176. #define DIALOG_SHOP_MENU 489 //
  177.  
  178. stock SetLastHouse(playerid, houseid)       { return SetPVarInt(playerid, "LastHouse", houseid); }
  179. stock SetLastShop(playerid, shopid)         { return SetPVarInt(playerid, "LastShop", shopid); }
  180. stock GetLastHouse(playerid)                { return GetPVarInt(playerid, "LastHouse"); }
  181. stock GetLastShop(playerid)                 { return GetPVarInt(playerid, "LastShop"); }
  182.  
  183. new pVisitTimer[MAX_PLAYERS];
  184.  
  185. enum hInfo
  186. {
  187.     Owner[MAX_PLAYER_NAME],
  188.     Price,
  189.     ownhouse,
  190.     Interior,
  191.     Exterior,
  192.     VirtualWorld, // Useful for making 2 houses with the same interior
  193.     Locked,
  194.     Float:InteriorX,
  195.     Float:InteriorY,
  196.     Float:InteriorZ,
  197.     Float:ExteriorX,
  198.     Float:ExteriorY,
  199.     Float:ExteriorZ,
  200.     // Storage
  201.     Money,
  202.     Weapon[13],
  203.     Ammo[13],
  204.     // Furniture
  205.     FCount,
  206.     FModel[MAX_FURNITURE],
  207.     FurnitureObj[MAX_FURNITURE],
  208.     Float:FPosX[MAX_FURNITURE],
  209.     Float:FPosY[MAX_FURNITURE],
  210.     Float:FPosZ[MAX_FURNITURE],
  211.     Float:FRotX[MAX_FURNITURE],
  212.     Float:FRotY[MAX_FURNITURE],
  213.     Float:FRotZ[MAX_FURNITURE]
  214. };
  215.  
  216. new HouseInfo[MAX_HOUSES][hInfo];
  217. new HousePickup[MAX_HOUSES];
  218. new HousePickup2[MAX_HOUSES];
  219. new HouseIcon[MAX_HOUSES];
  220.  
  221. enum bInfo
  222. {
  223.     bTitle[MAX_TITLE],
  224.     bOwner[MAX_PLAYER_NAME],
  225.     bPrice,
  226.     bInterior,
  227.     bExterior,
  228.     bVirtualWorld,
  229.     bLocked,
  230.     Float:bInteriorX,
  231.     Float:bInteriorY,
  232.     Float:bInteriorZ,
  233.     Float:bExteriorX,
  234.     Float:bExteriorY,
  235.     Float:bExteriorZ,
  236.     // Stats
  237.     bEarning,
  238.     bGoods,
  239.     bMoney,
  240.     bItemList[1024]
  241. };
  242.  
  243. new BusinessInfo[MAX_SHOPS][bInfo];
  244. new BusinessPickup[MAX_SHOPS];
  245. new BusinessPickup2[MAX_SHOPS];
  246. new BusinessIcon[MAX_HOUSES];
  247.  
  248. public OnFilterScriptInit()
  249. {
  250.     print("\n---------------------------------------");
  251.     print("          Sasinosoft Houses 2.0        \n");
  252.     print("---------------------------------------\n");
  253.     print("Sasinosoft Houses by Sasino97 2.0 has been loaded.");
  254.     return 1;
  255. }
  256.  
  257. public OnFilterScriptExit()
  258. {
  259.     for(new i=0;i<MAX_HOUSES;i++)
  260.     {
  261.         DestroyDynamicPickup(HousePickup[i]);
  262.         DestroyDynamicPickup(HousePickup2[i]);
  263.         DestroyDynamicMapIcon(HouseIcon[i]);
  264.     }
  265.     for(new i=0;i<MAX_SHOPS;i++)
  266.     {
  267.         DestroyDynamicPickup(BusinessPickup[i]);
  268.         DestroyDynamicPickup(BusinessPickup2[i]);
  269.         DestroyDynamicMapIcon(BusinessIcon[i]);
  270.     }
  271.     return 1;
  272. }
  273.  
  274. public OnPlayerConnect(playerid)
  275. {
  276.     new housefile[64];
  277.     format(housefile, 64, HOUSE_FILE,  Owner);
  278.     SetLastHouse(playerid, INVALID_HOUSE_ID);
  279.     SetLastShop(playerid, INVALID_HOUSE_ID);
  280.     /*INI_Open(housefile);
  281.     HouseInfo[Owner][ownhouse] = INI_ReadInt("Owned");*/
  282.     return 1;
  283. }
  284.  
  285. public OnPlayerSpawn(playerid)
  286. {
  287.     SetPlayerVirtualWorld(playerid, 0);
  288.     SetLastHouse(playerid, INVALID_HOUSE_ID);
  289.     SetLastShop(playerid, INVALID_HOUSE_ID);
  290.     return 1;
  291. }
  292.  
  293. public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
  294. {
  295.     if(response == EDIT_RESPONSE_UPDATE) return 1;
  296.     new ini[64];
  297.     new key[24];
  298.     for(new hID = 0; hID < MAX_HOUSES; hID ++)
  299.     {
  300.         for(new i = 0; i < MAX_FURNITURE; i ++)
  301.         {
  302.             if(objectid == HouseInfo[hID][FurnitureObj][i])
  303.             {
  304.                 if(response) // Clicked on the save icon
  305.                 {
  306.                     format(ini, 64, HOUSE_FILE, hID);
  307.                     INI_Open(ini);
  308.  
  309.                     HouseInfo[hID][FPosX][i] = x; HouseInfo[hID][FPosY][i] = y; HouseInfo[hID][FPosZ][i] = z;
  310.                     HouseInfo[hID][FRotX][i] = rx; HouseInfo[hID][FRotY][i] = ry; HouseInfo[hID][FRotZ][i] = rz;
  311.                     format(key, 24, "FPosX%d", i); INI_WriteFloat(key, HouseInfo[hID][FPosX][i]);
  312.                     format(key, 24, "FPosY%d", i); INI_WriteFloat(key, HouseInfo[hID][FPosY][i]);
  313.                     format(key, 24, "FPosZ%d", i); INI_WriteFloat(key, HouseInfo[hID][FPosZ][i]);
  314.                     format(key, 24, "FRotX%d", i); INI_WriteFloat(key, HouseInfo[hID][FRotX][i]);
  315.                     format(key, 24, "FRotY%d", i); INI_WriteFloat(key, HouseInfo[hID][FRotY][i]);
  316.                     format(key, 24, "FRotZ%d", i); INI_WriteFloat(key, HouseInfo[hID][FRotZ][i]);
  317.  
  318.                     SetDynamicObjectPos(objectid, HouseInfo[hID][FPosX][i], HouseInfo[hID][FPosY][i], HouseInfo[hID][FPosZ][i]);
  319.                     SetDynamicObjectRot(objectid, HouseInfo[hID][FRotX][i], HouseInfo[hID][FRotY][i], HouseInfo[hID][FRotZ][i]);
  320.  
  321.                     INI_Save();
  322.                     INI_Close();
  323.                 }
  324.                 else // Pressed ESC
  325.                 {
  326.                     SetDynamicObjectPos(objectid, HouseInfo[hID][FPosX][i], HouseInfo[hID][FPosY][i], HouseInfo[hID][FPosZ][i]);
  327.                     SetDynamicObjectRot(objectid, HouseInfo[hID][FRotX][i], HouseInfo[hID][FRotY][i], HouseInfo[hID][FRotZ][i]);
  328.                 }
  329.                 break;
  330.             }
  331.         }
  332.     }
  333.     return 1;
  334. }
  335.  
  336. #define Command(%0) !strcmp(cmd, %0, true)
  337. public OnPlayerCommandText(playerid, cmdtext[])
  338. {
  339.     // Commands that help scripters to create new houses and stores for the game
  340.     new cmd[256];
  341.     new idx;
  342.     cmd = strtok(cmdtext, idx);
  343.  
  344.     if(Command("/savehouse"))
  345.     {
  346.         if(IsPlayerAdmin(playerid))
  347.         {
  348.             new Float:X, Float:Y, Float:Z;
  349.             new I;
  350.             GetPlayerPos(playerid, X, Y, Z);
  351.             I = GetPlayerInterior(playerid);
  352.  
  353.             new comment[128];
  354.             comment = strrest(cmdtext, idx);
  355.             new File: fileid = fopen(SAVED_HOUSES_FILE, io_append);
  356.             if(fileid)
  357.             {
  358.                 new string[256];
  359.                 format(string, 256, "CreateHouse(%.2f, %.2f, %.2f, interiorX, interiorY, interiorZ, price, interior, %d, virtualworld); // %s\r\n", X, Y, Z, I, comment);
  360.                 fwrite(fileid, string);
  361.                 fclose(fileid);
  362.                 FS_MsgBox(playerid, "{33AA33}SUCCESS", "The house has been saved to \""SAVED_HOUSES_FILE"\"");
  363.             }
  364.             else FS_MsgBox(playerid, BOX_STYLE_ERROR, "An error has occurred! Maybe the directory doesn't exist.");
  365.             return 1;
  366.         }
  367.     }
  368.     if(Command("/findhouse")){
  369.         if(HouseInfo[Owner][ownhouse] == 1) {
  370.           hcp[playerid] = 1;
  371.           SendClientMessage(playerid,GREEN,"Goto the red marker in the radar to find your house.");
  372.           SetPlayerCheckpoint(playerid,HouseInfo[playerid][ExteriorX], HouseInfo[playerid][ExteriorY], HouseInfo[playerid][ExteriorZ],3.0);
  373.           return 1;}
  374.           else if(HouseInfo[Owner][ownhouse] == 0){
  375.             SendClientMessage(playerid,RED,"You don't own house!");}
  376.         return 1;}
  377.    
  378.     if(Command("/savestore") || Command("/savebiz") || Command("/saveshop"))
  379.     {
  380.         if(IsPlayerAdmin(playerid))
  381.         {
  382.             new Float:X, Float:Y, Float:Z;
  383.             new I;
  384.             GetPlayerPos(playerid, X, Y, Z);
  385.             I = GetPlayerInterior(playerid);
  386.             new comment[128];
  387.             comment = strrest(cmdtext, idx);
  388.             new File: fileid = fopen(SAVED_SHOPS_FILE, io_append);
  389.             if(fileid)
  390.             {
  391.                 new string[256];
  392.                 format(string, 256, "CreateBusiness(title, earning, %.2f, %.2f, %.2f, interiorX, interiorY, interiorZ, price, interior, %d, virtualworld, iconmarker, item_list[]); // %s\r\n", X, Y, Z, I, comment);
  393.                 fwrite(fileid, string);
  394.                 fclose(fileid);
  395.                 FS_MsgBox(playerid, "{33AA33}SUCCESS", "The store has been saved to \""SAVED_SHOPS_FILE"\"");
  396.             }
  397.             else FS_MsgBox(playerid, BOX_STYLE_ERROR, "An error has occurred! Maybe the directory doesn't exist.");
  398.             return 1;
  399.         }
  400.     }
  401.     return 0;
  402. }
  403.  
  404. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  405. {
  406.     if(newkeys & KEY)
  407.     {
  408.         new name[24];
  409.         GetPlayerName(playerid, name, 24);
  410.         for(new i=0; i<MAX_HOUSES; i++)
  411.         {
  412.             if(IsPlayerInRangeOfPoint(playerid, 1, HouseInfo[i][InteriorX], HouseInfo[i][InteriorY], HouseInfo[i][InteriorZ]) && GetPlayerVirtualWorld(playerid) == HouseInfo[i][VirtualWorld])
  413.             {
  414.                 return ExitHouse(playerid, i);
  415.             }
  416.         }
  417.         for(new i=0; i<MAX_SHOPS; i++)
  418.         {
  419.             if(IsPlayerInRangeOfPoint(playerid, 1, BusinessInfo[i][bInteriorX], BusinessInfo[i][bInteriorY], BusinessInfo[i][bInteriorZ]) && GetPlayerVirtualWorld(playerid) == BusinessInfo[i][bVirtualWorld])
  420.             {
  421.                 return ExitShop(playerid, i);
  422.             }
  423.         }
  424.         if(GetHouseID(playerid) != INVALID_HOUSE_ID) return OpenHouseDialog(playerid, GetHouseID(playerid));
  425.         if(GetShopID(playerid) != INVALID_HOUSE_ID) return OpenBusinessDialog(playerid, GetShopID(playerid));
  426.  
  427.         new LH = GetLastHouse(playerid);
  428.         if(LH != INVALID_HOUSE_ID && !strcmp(name, HouseInfo[LH][Owner], true))
  429.         {
  430.             ShowHouseMenu(playerid);
  431.             return 1;
  432.         }
  433.         new LS = GetLastShop(playerid);
  434.         if(LS != INVALID_HOUSE_ID)
  435.         {
  436.             if(!strcmp(name, BusinessInfo[LS][bOwner], true)) // he is the owner
  437.             {
  438.                 ShowBusinessMenu(playerid);
  439.             }
  440.             else
  441.             {
  442.                 ShowPlayerDialog(playerid, DIALOG_SHOP, DIALOG_STYLE_LIST, BusinessInfo[LS][bTitle], BusinessInfo[LS][bItemList], "Buy", "Cancel");
  443.             }
  444.             return 1;
  445.         }
  446.     }
  447.     return 1;
  448. }
  449.  
  450. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  451. {
  452.     new hID = GetHouseID(playerid);
  453.     new sID = GetShopID(playerid);
  454.     switch(dialogid)
  455.     {
  456.         case DIALOG_HOUSE_MENU:
  457.         {
  458.             hID = GetLastHouse(playerid);
  459.             if(!response) return 1;
  460.             switch(listitem)
  461.             {
  462.                 case 0: // Store money
  463.                 {
  464.                     new string[128];
  465.                     format(string, 128, "Current money: %d - Insert the money to deposit", HouseInfo[hID][Money]);
  466.                     ShowPlayerDialog(playerid, DIALOG_STORE_MONEY, DIALOG_STYLE_INPUT, "{33AA33}STORE MONEY", string, "OK", "Cancel");
  467.                 }
  468.                 case 1: // Withdraw money
  469.                 {
  470.                     new string[128];
  471.                     format(string, 128, "Current money: %d - Insert the money to withdraw", HouseInfo[hID][Money]);
  472.                     ShowPlayerDialog(playerid, DIALOG_WITHDRAW_MONEY, DIALOG_STYLE_INPUT, "{33AA33}WITHDRAW MONEY", string, "OK", "Cancel");
  473.                 }
  474.                 case 2: // Store weapons
  475.                 {
  476.                     new ini[64];
  477.                     format(ini, 64, HOUSE_FILE, hID);
  478.                     INI_Open(ini);
  479.                     new key[24];
  480.                     for(new x = 0; x < 13; x ++)
  481.                     {
  482.                         format(key, 24, "Weapon%d", x);
  483.                         HouseInfo[hID][Weapon][x] = INI_ReadInt(key);
  484.                         format(key, 24, "Ammo%d", x);
  485.                         HouseInfo[hID][Ammo][x] = INI_ReadInt(key);
  486.                         GivePlayerWeapon(playerid, HouseInfo[hID][Weapon][x], HouseInfo[hID][Ammo][x]);
  487.                     }
  488.                     INI_Close();
  489.                     INI_Open(ini);
  490.                     for(new x = 0; x < 13; x ++)
  491.                     {
  492.                         GetPlayerWeaponData(playerid, x, HouseInfo[hID][Weapon][x], HouseInfo[hID][Ammo][x]);
  493.                         if(HouseInfo[hID][Weapon][x] == 0) continue;
  494.                         format(key, 24, "Weapon%d", x);
  495.                         INI_WriteInt(key, HouseInfo[hID][Weapon][x]);
  496.                         format(key, 24, "Ammo%d", x);
  497.                         INI_WriteInt(key, HouseInfo[hID][Ammo][x]);
  498.                     }
  499.                     INI_Save();
  500.                     INI_Close();
  501.                     ResetPlayerWeapons(playerid);
  502.                     FS_MsgBox(playerid, BOX_STYLE_CMD, "All weapons stored.");
  503.                 }
  504.                 case 3: // Collect weapons
  505.                 {
  506.                     new ini[64];
  507.                     new key[24];
  508.                     format(ini, 64, HOUSE_FILE, hID);
  509.  
  510.                     // Read weapons and give them to player
  511.                     INI_Open(ini);
  512.                     new count = 0;
  513.                     for(new x = 0; x < 13; x ++)
  514.                     {
  515.                         format(key, 24, "Weapon%d", x);
  516.                         HouseInfo[hID][Weapon][x] = INI_ReadInt(key);
  517.                         format(key, 24, "Ammo%d", x);
  518.                         HouseInfo[hID][Ammo][x] = INI_ReadInt(key);
  519.                         if(HouseInfo[hID][Weapon][x] != 0)
  520.                         {
  521.                             count += 1;
  522.                             GivePlayerWeapon(playerid, HouseInfo[hID][Weapon][x], HouseInfo[hID][Ammo][x]);
  523.                         }
  524.                     }
  525.                     INI_Close();
  526.                     // Delete weapons from storage
  527.                     INI_Open(ini);
  528.                     for(new x = 0; x < 13; x ++)
  529.                     {
  530.                         HouseInfo[hID][Weapon][x] = 0;
  531.                         HouseInfo[hID][Ammo][x] = 0;
  532.                         format(key, 24, "Weapon%d", x);
  533.                         INI_WriteInt(key, HouseInfo[hID][Weapon][x]);
  534.                         format(key, 24, "Ammo%d", x);
  535.                         INI_WriteInt(key, HouseInfo[hID][Ammo][x]);
  536.                     }
  537.                     INI_Save();
  538.                     INI_Close();
  539.                     format(key, 24, "%d weapons collected.", count);
  540.                     if(count != 0) FS_MsgBox(playerid, BOX_STYLE_CMD, key);
  541.                     else FS_MsgBox(playerid, BOX_STYLE_ERROR, "You have no weapons in your storage!");
  542.                 }
  543.                 case 4: // Edit furniture
  544.                 {
  545.                     new bigstring[2048];
  546.                     new string[64];
  547.                     hID = GetLastHouse(playerid);
  548.                     for(new i = 0; i < MAX_FURNITURE; i++)
  549.                     {
  550.                         if(HouseInfo[hID][FModel][i] == INVALID_FURNITURE_ID)
  551.                         {
  552.                             format(string, 64, "%d - {FF0000}Empty", i+1);
  553.                         }
  554.                         else
  555.                         {
  556.                             if(HouseInfo[hID][FPosX][i] != 0.0) format(string, 64, "%d - %s - {33AA33}in house", i+1, FurnitureInfo[HouseInfo[hID][FModel][i]][2]); // Edit
  557.                             else format(string, 64, "%d - %s - {0000FF}in storage", i+1, FurnitureInfo[HouseInfo[hID][FModel][i]][2]); // Place
  558.                         }
  559.                         format(bigstring, sizeof(bigstring), "%s%s\n", bigstring, string);
  560.                     }
  561.                     ShowPlayerDialog(playerid, DIALOG_EDIT_FURNITURE, DIALOG_STYLE_LIST, "{33AA33}Select a furniture to place/edit.", bigstring, "Edit", "Cancel");
  562.                 }
  563.                 case 5: // Buy furniture
  564.                 {
  565.                     ShowFurnitureMenu(playerid);
  566.                 }
  567.                 case 6: // Sell furniture
  568.                 {
  569.                     new bigstring[2048];
  570.                     new string[64];
  571.                     hID = GetLastHouse(playerid);
  572.                     for(new i = 0; i < MAX_FURNITURE; i++)
  573.                     {
  574.                         if(HouseInfo[hID][FModel][i] == INVALID_FURNITURE_ID)
  575.                         {
  576.                             format(string, 64, "%d - {FF0000}Empty", i+1);
  577.                         }
  578.                         else
  579.                         {
  580.                             format(string, 64, "%d - %s {33AA33}(%d$)", i+1, FurnitureInfo[HouseInfo[hID][FModel][i]][2], floatround(FurnitureInfo[HouseInfo[hID][FModel][i]][1]*SELL_MULTIPLIER));
  581.                         }
  582.                         format(bigstring, sizeof(bigstring), "%s%s\n", bigstring, string);
  583.                     }
  584.                     ShowPlayerDialog(playerid, DIALOG_SELL_FURNITURE, DIALOG_STYLE_LIST, "{33AA33}Select a furniture to sell.", bigstring, "Sell", "Cancel");
  585.                 }
  586.             }
  587.             return 1;
  588.         }
  589.         case DIALOG_EDIT_FURNITURE:
  590.         {
  591.             if(!response) return 1;
  592.             new i = listitem;
  593.             hID = GetLastHouse(playerid);
  594.             if(HouseInfo[hID][FModel][i] == INVALID_FURNITURE_ID) return FS_MsgBox(playerid, BOX_STYLE_ERROR, "Invalid furniture selected.");
  595.             if(HouseInfo[hID][FPosX][i] != 0.0)
  596.             {
  597.                 if(!IsValidDynamicObject(HouseInfo[hID][FurnitureObj][i])) return FS_MsgBox(playerid, BOX_STYLE_ERROR, "Invalid dynamic object.");
  598.                 EditDynamicObject(playerid, HouseInfo[hID][FurnitureObj][i]);
  599.             }
  600.             else
  601.             {
  602.                 new Float:X, Float:Y, Float:Z;
  603.                 GetPlayerPos(playerid, X, Y, Z);
  604.                 GetXYInFrontOfPlayer(playerid, X, Y, 2.0);
  605.                 HouseInfo[hID][FPosX][i] = X; HouseInfo[hID][FPosY][i] = Y; HouseInfo[hID][FPosZ][i] = Z;
  606.                 HouseInfo[hID][FRotX][i] = 0; HouseInfo[hID][FRotY][i] = 0; HouseInfo[hID][FRotZ][i] = 0;
  607.                 HouseInfo[hID][FurnitureObj][i] = CreateDynamicObject(FurnitureInfo[HouseInfo[hID][FModel][i]][0], HouseInfo[hID][FPosX][i], HouseInfo[hID][FPosY][i], HouseInfo[hID][FPosZ][i], HouseInfo[hID][FRotX][i], HouseInfo[hID][FRotY][i], HouseInfo[hID][FRotZ][i], HouseInfo[hID][VirtualWorld], HouseInfo[hID][Interior], -1, 50.0);
  608.                 SaveFurniturePosition(hID, i);
  609.             }
  610.             return 1;
  611.         }
  612.         case DIALOG_BUY_FURNITURE:
  613.         {
  614.             if(!response) return 1;
  615.             if(GetPlayerMoney(playerid) < FurnitureInfo[listitem][1]) return ShowNoMoneyMessage(playerid);
  616.             hID = GetLastHouse(playerid);
  617.             BuyFurniture(playerid, hID, listitem+1);
  618.             return 1;
  619.         }
  620.         case DIALOG_SELL_FURNITURE:
  621.         {
  622.             if(!response) return 1;
  623.             new i = listitem;
  624.             new fname[128];
  625.             hID = GetLastHouse(playerid);
  626.             if(HouseInfo[hID][FModel][i] == INVALID_FURNITURE_ID) return FS_MsgBox(playerid, BOX_STYLE_ERROR, "Invalid furniture selected.");
  627.             new money = floatround(FurnitureInfo[HouseInfo[hID][FModel][i]][1]*SELL_MULTIPLIER);
  628.             GivePlayerMoney(playerid, money);
  629.             format(fname, 128, "{FFFFFF}You sold a {0000FF}\"%s\"{FFFFFF} for {33AA33}%d$.", FurnitureInfo[HouseInfo[hID][FModel][i]][2], money);
  630.             FS_MsgBox(playerid, BOX_STYLE_CMD, fname);
  631.             HouseInfo[hID][FModel][i] = INVALID_FURNITURE_ID;
  632.             HouseInfo[hID][FPosX][i] = 0; HouseInfo[hID][FPosY][i] = 0; HouseInfo[hID][FPosZ][i] = 0;
  633.             HouseInfo[hID][FRotX][i] = 0; HouseInfo[hID][FRotY][i] = 0; HouseInfo[hID][FRotZ][i] = 0;
  634.             if(IsValidDynamicObject(HouseInfo[hID][FurnitureObj][i])) DestroyDynamicObject(HouseInfo[hID][FurnitureObj][i]);
  635.             HouseInfo[hID][FurnitureObj][i] = 0;
  636.             HouseInfo[hID][FCount] -= 1;
  637.             format(fname, 128, HOUSE_FILE, hID);
  638.             new key[24];
  639.             INI_Open(fname);
  640.             INI_WriteInt("FCount", HouseInfo[hID][FCount]);
  641.             format(key, 24, "FModel%d", i); INI_WriteInt(key, INVALID_FURNITURE_ID);
  642.             INI_Save();
  643.             INI_Close();
  644.  
  645.             return 1;
  646.         }
  647.         case DIALOG_FURNITURE_BOUGHT:
  648.         {
  649.             if(response) ShowFurnitureMenu(playerid);
  650.             return 1;
  651.         }
  652.         case DIALOG_STORE_MONEY:
  653.         {
  654.             if(!response) return 1;
  655.  
  656.             new string[128];
  657.             hID = GetLastHouse(playerid);
  658.             sID = GetLastShop(playerid);
  659.             new val = strval(inputtext);
  660.             if(val < 0 || val > GetPlayerMoney(playerid)) return ShowNoMoneyMessage(playerid);
  661.             GivePlayerMoney(playerid, -val);
  662.             HouseInfo[hID][Money] += val;
  663.             format(string, 128, "%d$ stored in your house.", val);
  664.             FS_MsgBox(playerid, BOX_STYLE_CMD, string);
  665.             format(string, 128, HOUSE_FILE, hID);
  666.             INI_Open(string);
  667.             INI_WriteInt("Money", HouseInfo[hID][Money]);
  668.             INI_Save();
  669.             INI_Close();
  670.             return 1;
  671.         }
  672.         case DIALOG_WITHDRAW_MONEY:
  673.         {
  674.             if(!response) return 1;
  675.  
  676.             new string[128];
  677.             hID = GetLastHouse(playerid);
  678.             sID = GetLastShop(playerid);
  679.             new val = strval(inputtext);
  680.             if(val < 0 || val > HouseInfo[hID][Money]) return ShowNoMoneyMessage(playerid);
  681.             GivePlayerMoney(playerid, val);
  682.             HouseInfo[hID][Money] -= val;
  683.             format(string, 128, "%d$ withdrew from your house.", val);
  684.             FS_MsgBox(playerid, BOX_STYLE_CMD, string);
  685.             format(string, 128, HOUSE_FILE, hID);
  686.             INI_Open(string);
  687.             INI_WriteInt("Money", HouseInfo[hID][Money]);
  688.             INI_Save();
  689.             INI_Close();
  690.             return 1;
  691.         }
  692.         case DIALOG_FORSALE_HOUSE:
  693.         {
  694.             if(!response) return 1;
  695.             if(listitem == 0)
  696.             {
  697.                 if(HouseInfo[Owner][ownhouse] == 1) return SendClientMessage(playerid,RED,"You're allowed to buy one house only.");
  698.                 if(GetPlayerMoney(playerid) < HouseInfo[hID][Price]) return ShowNoMoneyMessage(playerid);
  699.                 BuyHouse(playerid, hID);
  700.             }
  701.             else if(listitem == 1)
  702.             {
  703.                 EnterHouse(playerid, hID);
  704.                 FS_MsgBox(playerid, BOX_STYLE_CMD, "You are visiting this house.");
  705.                 pVisitTimer[playerid] = SetTimerEx("ExitHouse", VISIT_TIME, false, "ii", playerid, hID);
  706.             }
  707.             return 1;
  708.         }
  709.         case DIALOG_MY_HOUSE:
  710.         {
  711.             if(!response) return 1;
  712.             switch(listitem)
  713.             {
  714.                 case 0: // entra
  715.                 {
  716.                     EnterHouse(playerid, hID);
  717.                 }
  718.                 case 1: // apri/chiudi
  719.                 {
  720.                     LockUnlockHouse(playerid, hID);
  721.                 }
  722.                 case 2: // vendi
  723.                 {
  724.                     new string[64];
  725.                     format(string, 64, "{33AA33}Do you want to sell your house for %d$?\n{FF0000}All the money, the weapons and the furniture in your storage will remain there, and the next owner can use them.", floatround(HouseInfo[hID][Price]*SELL_MULTIPLIER));
  726.                     ShowPlayerDialog(playerid, DIALOG_SELL_HOUSE, DIALOG_STYLE_MSGBOX, "{FF8000}CONFIRMATION", string, "Sell", "Don't sell");
  727.                 }
  728.             }
  729.             return 1;
  730.         }
  731.         case DIALOG_OTHERS_HOUSE:
  732.         {
  733.             if(!response) return 1;
  734.             if(HouseInfo[hID][Locked] == 1)
  735.             {
  736.                 FS_MsgBox(playerid, BOX_STYLE_ERROR, "This house is {FF0000}locked.");
  737.             }
  738.             else
  739.             {
  740.                 EnterHouse(playerid, hID);
  741.             }
  742.             return 1;
  743.         }
  744.         case DIALOG_SELL_HOUSE:
  745.         {
  746.             if(response)
  747.             {
  748.                 SellHouse(playerid, hID);
  749.             }
  750.             else
  751.             {
  752.                 FS_MsgBox(playerid, BOX_STYLE_WARNING, "House not sold.");
  753.             }
  754.             return 1;
  755.         }
  756.         case DIALOG_SHOP:
  757.         {
  758.             if(!response) return 1;
  759.             sID = GetLastShop(playerid);
  760.             CallRemoteFunction("OnPlayerBuyItem", "iii", playerid, sID, listitem);
  761.             return 1;
  762.         }
  763.         case DIALOG_SHOP_MENU:
  764.         {
  765.             sID = GetLastShop(playerid);
  766.             if(!response) return 1;
  767.             switch(listitem)
  768.             {
  769.                 case 0: //Rename your shop
  770.                 {
  771.                     new string[68];
  772.                     format(string, 68, "Current Name: %s", BusinessInfo[sID][bTitle]);
  773.                     ShowPlayerDialog(playerid, DIALOG_RENAME_SHOP, DIALOG_STYLE_INPUT, "{33AA33}RENAME", string, "OK", "Cancel");
  774.                 }
  775.                 case 1: //Collect your earnings
  776.                 {
  777.                     if(BusinessInfo[sID][bMoney] == 0) return FS_MsgBox(playerid, BOX_STYLE_ERROR, "The cash register is empty.");
  778.                     new string[128];
  779.                     GivePlayerMoney(playerid, BusinessInfo[sID][bMoney]);
  780.                     format(string, 128, "You earned %d$.", BusinessInfo[sID][bMoney]);
  781.                     FS_MsgBox(playerid, BOX_STYLE_CMD, string);
  782.  
  783.                     BusinessInfo[sID][bMoney] = 0;
  784.                     format(string, 128, SHOP_FILE, sID);
  785.                     INI_Open(string);
  786.                     INI_WriteInt("Money", 0);
  787.                     INI_Save();
  788.                     INI_Close();
  789.                 }
  790.                 case 2: //Supply goods for your shop
  791.                 {
  792.                     new string[68];
  793.                     format(string, 68, "Goods price: %d$/good", GOOD_PRICE);
  794.                     ShowPlayerDialog(playerid, DIALOG_SUPPLY, DIALOG_STYLE_INPUT, "{33AA33}Enter the amount to buy", string, "OK", "Cancel");
  795.                 }
  796.                 case 3:
  797.                 {
  798.                     ShowPlayerDialog(playerid, DIALOG_SHOP, DIALOG_STYLE_LIST, "{33AA33}Select an item from your shop.", BusinessInfo[sID][bItemList], "Buy", "Cancel");
  799.                 }
  800.             }
  801.             return 1;
  802.         }
  803.         case DIALOG_FORSALE_BIZ:
  804.         {
  805.             if(!response) return 1;
  806.             switch(listitem)
  807.             {
  808.                 case 0:
  809.                 {
  810.                     if(GetPlayerMoney(playerid) < BusinessInfo[sID][bEarning]) return ShowNoMoneyMessage(playerid);
  811.                     GivePlayerMoney(playerid, -BusinessInfo[sID][bEarning]);
  812.                     EnterShop(playerid, sID);
  813.                 }
  814.                 case 1:
  815.                 {
  816.                     if(GetPlayerMoney(playerid) < BusinessInfo[sID][bPrice]) return ShowNoMoneyMessage(playerid);
  817.                     BuyShop(playerid, sID);
  818.                 }
  819.             }
  820.             return 1;
  821.         }
  822.         case DIALOG_MY_BIZ:
  823.         {
  824.             if(!response) return 1;
  825.             switch(listitem)
  826.             {
  827.                 case 0: //Enter your shop
  828.                 {
  829.                     EnterShop(playerid, sID);
  830.                 }
  831.                 case 1: //Open/Close the shop
  832.                 {
  833.                     LockUnlockShop(playerid, sID);
  834.                 }
  835.                 case 2: //Sell your shop
  836.                 {
  837.                     new string[64];
  838.                     format(string, 64, "{33AA33}Do you want to sell your store for %d$?\n{FF0000}All the money and the goods will remain there.", floatround(BusinessInfo[sID][bPrice]*SELL_MULTIPLIER));
  839.                     ShowPlayerDialog(playerid, DIALOG_SELL_SHOP, DIALOG_STYLE_MSGBOX, "{FF8000}CONFIRMATION", string, "Sell", "Don't sell");
  840.                 }
  841.             }
  842.             return 1;
  843.         }
  844.         case DIALOG_SELL_SHOP:
  845.         {
  846.             if(response)
  847.             {
  848.                 SellShop(playerid, sID); // Changed in 2.2, previously it was hID, and it was making a bug where player couldn't sell their stores.
  849.             }
  850.             else
  851.             {
  852.                 FS_MsgBox(playerid, BOX_STYLE_WARNING, "Store not sold.");
  853.             }
  854.             return 1;
  855.         }
  856.         case DIALOG_OTHERS_BIZ:
  857.         {
  858.             if(!response) return 1;
  859.             if(BusinessInfo[sID][bLocked] == 1) return FS_MsgBox(playerid, BOX_STYLE_ERROR, "This store is closed.");
  860.             //if(BusinessInfo[sID][bGoods] <= 0) return FS_MsgBox(playerid, BOX_STYLE_ERROR, "This store is out of stock.");
  861.             if(GetPlayerMoney(playerid) < BusinessInfo[sID][bEarning]) return ShowNoMoneyMessage(playerid);
  862.  
  863.             GivePlayerMoney(playerid, -BusinessInfo[sID][bEarning]);
  864.             EnterShop(playerid, sID);
  865.             BusinessInfo[sID][bMoney] += BusinessInfo[sID][bEarning];
  866.             //BusinessInfo[sID][bGoods] -= 1;
  867.             new filename[128];
  868.             format(filename, 128, SHOP_FILE, sID);
  869.             INI_Open(filename);
  870.             INI_WriteInt("Money", BusinessInfo[sID][bMoney]);
  871.             //INI_WriteInt("Goods", BusinessInfo[sID][bGoods]);
  872.             INI_Save();
  873.             INI_Close();
  874.             return 1;
  875.         }
  876.         case DIALOG_RENAME_SHOP:
  877.         {
  878.             sID = GetLastShop(playerid);
  879.             if(!response) return 1;
  880.             if(strlen(inputtext) > MAX_TITLE) return FS_MsgBox(playerid, BOX_STYLE_ERROR, "The max length is "MAX_TITLE_STR"!");
  881.             format(BusinessInfo[sID][bTitle], MAX_TITLE, inputtext);
  882.             new filename[128];
  883.             format(filename, 128, SHOP_FILE, sID);
  884.             INI_Open(filename);
  885.             INI_WriteString("Title", BusinessInfo[sID][bTitle]);
  886.             INI_Save();
  887.             INI_Close();
  888.             format(filename, 128, "Store name changed to %s!", BusinessInfo[sID][bTitle]);
  889.             FS_MsgBox(playerid, BOX_STYLE_CMD, filename); // I used again filename here to not create a new var and waste more cells.
  890.             return 1;
  891.         }
  892.         case DIALOG_SUPPLY:
  893.         {
  894.             sID = GetLastShop(playerid);
  895.             if(!response) return 1;
  896.             new value = strval(inputtext);
  897.             if(value <= 0 || value > 500) return FS_MsgBox(playerid, BOX_STYLE_ERROR, "Enter an amount between 1 and 500!");
  898.             new cost = GOOD_PRICE * value;
  899.             if(GetPlayerMoney(playerid) < cost) return ShowNoMoneyMessage(playerid);
  900.             BusinessInfo[sID][bGoods] += value;
  901.             GivePlayerMoney(playerid, -cost);
  902.             new filename[128];
  903.             format(filename, 128, SHOP_FILE, sID);
  904.             INI_Open(filename);
  905.             INI_WriteInt("Goods", BusinessInfo[sID][bGoods]);
  906.             INI_Save();
  907.             INI_Close();
  908.             format(filename, 128, "You just bought %d goods for your store for %d$!", value, cost);
  909.             FS_MsgBox(playerid, BOX_STYLE_CMD, filename);
  910.             return 1;
  911.         }
  912.     }
  913.     return 0;
  914. }
  915.  
  916. forward FS_MsgBox(playerid, caption[], text[]);
  917. public FS_MsgBox(playerid, caption[], text[])
  918. {
  919.     ShowPlayerDialog(playerid, 469, DIALOG_STYLE_MSGBOX, caption, text, "OK", "");
  920.     return 1;
  921. }
  922.  
  923. forward FS_CreateHouse(Float:eX, Float:eY, Float:eZ, Float:iX, Float:iY, Float:iZ, price, interior, exterior, virtualWorld);
  924. public FS_CreateHouse(Float:eX, Float:eY, Float:eZ, Float:iX, Float:iY, Float:iZ, price, interior, exterior, virtualWorld)
  925. {
  926.     static hCount;
  927.     new hID = hCount; hCount += 1;
  928.  
  929.     HouseInfo[hID][Price] = price;
  930.     HouseInfo[hID][Interior] = interior;
  931.     HouseInfo[hID][Exterior] = exterior;
  932.     HouseInfo[hID][VirtualWorld] = virtualWorld;
  933.     HouseInfo[hID][InteriorX] = iX;
  934.     HouseInfo[hID][InteriorY] = iY;
  935.     HouseInfo[hID][InteriorZ] = iZ;
  936.     HouseInfo[hID][ExteriorX] = eX;
  937.     HouseInfo[hID][ExteriorY] = eY;
  938.     HouseInfo[hID][ExteriorZ] = eZ;
  939.     HouseInfo[Owner][ownhouse] = 0;
  940.  
  941.     new housefile[64];
  942.     format(housefile, 64, HOUSE_FILE, hID);
  943.  
  944.     if(!INI_Exist(housefile)) // If not existing
  945.     {
  946.         INI_Open(housefile);
  947.         //
  948.         format(HouseInfo[hID][Owner], MAX_PLAYER_NAME, INVALID_OWNER);   INI_WriteString("Owner", HouseInfo[hID][Owner]);
  949.         HouseInfo[hID][Locked] = 1;  INI_WriteInt("Locked", HouseInfo[hID][Locked]);
  950.         HouseInfo[hID][Money] = 0;  INI_WriteInt("Money", HouseInfo[hID][Money]);
  951.         HouseInfo[Owner][ownhouse] = 0; INI_WriteInt("Owned",HouseInfo[Owner][ownhouse]);
  952.         new key[24];
  953.         for(new x = 0; x < 13; x ++)
  954.         {
  955.             HouseInfo[hID][Weapon][x] = 0;
  956.             HouseInfo[hID][Ammo][x] = 0;
  957.             format(key, 24, "Weapon%d", x); INI_WriteInt(key, HouseInfo[hID][Weapon][x]);
  958.             format(key, 24, "Ammo%d", x); INI_WriteInt(key, HouseInfo[hID][Ammo][x]);
  959.         }
  960.         HouseInfo[hID][FCount] = 0;  INI_WriteInt("FCount", HouseInfo[hID][FCount]);
  961.         for(new i = 0; i < MAX_FURNITURE; i ++)
  962.         {
  963.             HouseInfo[hID][FModel][i] = INVALID_FURNITURE_ID;
  964.             HouseInfo[hID][FPosX][i] = 0.0; HouseInfo[hID][FPosY][i] = 0.0; HouseInfo[hID][FPosZ][i] = 0.0;
  965.             HouseInfo[hID][FRotX][i] = 0.0; HouseInfo[hID][FRotY][i] = 0.0; HouseInfo[hID][FRotZ][i] = 0.0;
  966.             format(key, 24, "FModel%d", i); INI_WriteInt(key, HouseInfo[hID][FModel][i]);
  967.             format(key, 24, "FPosX%d", i); INI_WriteFloat(key, HouseInfo[hID][FPosX][i]);
  968.             format(key, 24, "FPosY%d", i); INI_WriteFloat(key, HouseInfo[hID][FPosY][i]);
  969.             format(key, 24, "FPosZ%d", i); INI_WriteFloat(key, HouseInfo[hID][FPosZ][i]);
  970.             format(key, 24, "FRotX%d", i); INI_WriteFloat(key, HouseInfo[hID][FRotX][i]);
  971.             format(key, 24, "FRotY%d", i); INI_WriteFloat(key, HouseInfo[hID][FRotY][i]);
  972.             format(key, 24, "FRotZ%d", i); INI_WriteFloat(key, HouseInfo[hID][FRotZ][i]);
  973.         }
  974.  
  975.         //
  976.         INI_Save();
  977.         INI_Close();
  978.  
  979.         #if CONSOLE == 1
  980.         printf("Created new house - ID: %d - Ext: %d, %f, %f, %f - Int: %d, %f, %f, %f - Price: %d - World: %d", hID, HouseInfo[hID][Exterior], HouseInfo[hID][ExteriorX], HouseInfo[hID][ExteriorY], HouseInfo[hID][ExteriorZ], HouseInfo[hID][Interior], HouseInfo[hID][InteriorX], HouseInfo[hID][InteriorY], HouseInfo[hID][InteriorZ], HouseInfo[hID][Price], HouseInfo[hID][VirtualWorld]);
  981.         #endif
  982.     }
  983.     else
  984.     {
  985.         INI_Open(housefile);
  986.         //
  987.         INI_ReadString(HouseInfo[hID][Owner], "Owner", MAX_PLAYER_NAME);
  988.         HouseInfo[hID][Locked] = INI_ReadInt("Locked");
  989.         HouseInfo[hID][Money] = INI_ReadInt("Money");
  990.         new key[32];
  991.         for(new x = 0; x < 13; x ++)
  992.         {
  993.             format(key, 32, "Weapon%d", x);
  994.             HouseInfo[hID][Weapon][x] = INI_ReadInt(key);
  995.             format(key, 32, "Ammo%d", x);
  996.             HouseInfo[hID][Ammo][x] = INI_ReadInt(key);
  997.         }
  998.         HouseInfo[hID][FCount] = INI_ReadInt("FCount");
  999.         for(new i = 0; i < MAX_FURNITURE; i ++)
  1000.         {
  1001.             format(key, 32, "FModel%d", i); HouseInfo[hID][FModel][i] = INI_ReadInt(key);
  1002.             format(key, 32, "FPosX%d", i); HouseInfo[hID][FPosX][i] = INI_ReadFloat(key);
  1003.             format(key, 32, "FPosY%d", i); HouseInfo[hID][FPosY][i] = INI_ReadFloat(key);
  1004.             format(key, 32, "FPosZ%d", i); HouseInfo[hID][FPosZ][i] = INI_ReadFloat(key);
  1005.             format(key, 32, "FRotX%d", i); HouseInfo[hID][FRotX][i] = INI_ReadFloat(key);
  1006.             format(key, 32, "FRotY%d", i); HouseInfo[hID][FRotY][i] = INI_ReadFloat(key);
  1007.             format(key, 32, "FRotZ%d", i); HouseInfo[hID][FRotZ][i] = INI_ReadFloat(key);
  1008.             if(HouseInfo[hID][FPosX][i] != 0.0) HouseInfo[hID][FurnitureObj][i] = CreateDynamicObject(FurnitureInfo[HouseInfo[hID][FModel][i]][0], HouseInfo[hID][FPosX][i], HouseInfo[hID][FPosY][i], HouseInfo[hID][FPosZ][i], HouseInfo[hID][FRotX][i], HouseInfo[hID][FRotY][i], HouseInfo[hID][FRotZ][i], HouseInfo[hID][VirtualWorld], HouseInfo[hID][Interior], -1, 50.0);
  1009.         }
  1010.         //
  1011.         INI_Save();
  1012.         INI_Close();
  1013.  
  1014.         #if CONSOLE == 1
  1015.         printf("Loaded house - ID: %d - Owner: %s - Locked: %d", hID, HouseInfo[hID][Owner], HouseInfo[hID][Locked]);
  1016.         #endif
  1017.     }
  1018.     if(!strcmp(HouseInfo[hID][Owner], INVALID_OWNER, true)) //for sale
  1019.     {
  1020.         HousePickup[hID] = CreateDynamicPickup(1273, 23, HouseInfo[hID][ExteriorX], HouseInfo[hID][ExteriorY], HouseInfo[hID][ExteriorZ]);
  1021.         #if MAP_ICONS == 1
  1022.         HouseIcon[hID] = CreateDynamicMapIcon(HouseInfo[hID][ExteriorX], HouseInfo[hID][ExteriorY], HouseInfo[hID][ExteriorZ], 31, 0, _, _, _, 800.0);
  1023.         #endif
  1024.     }
  1025.     else // not for sale
  1026.     {
  1027.         HousePickup[hID] = CreateDynamicPickup(1272, 23, HouseInfo[hID][ExteriorX], HouseInfo[hID][ExteriorY], HouseInfo[hID][ExteriorZ]);
  1028.         #if MAP_ICONS == 1
  1029.         HouseIcon[hID] = CreateDynamicMapIcon(HouseInfo[hID][ExteriorX], HouseInfo[hID][ExteriorY], HouseInfo[hID][ExteriorZ], 32, 0, _, _, _, 800.0);
  1030.         #endif
  1031.     }
  1032.     HousePickup2[hID] = CreateDynamicPickup(1272, 23, HouseInfo[hID][InteriorX], HouseInfo[hID][InteriorY], HouseInfo[hID][InteriorZ]);
  1033.     Create3DTextLabel("House - Press "KEY_STRING" to open the menu", 0xFFFF00FF, HouseInfo[hID][ExteriorX],HouseInfo[hID][ExteriorY], HouseInfo[hID][ExteriorZ]+1, 20, 0, 1);
  1034.     Create3DTextLabel("Press "KEY_STRING" to exit", 0xFFFF00FF, HouseInfo[hID][InteriorX], HouseInfo[hID][InteriorY], HouseInfo[hID][InteriorZ]+1, 20, HouseInfo[hID][VirtualWorld], 1);
  1035.     return hID;
  1036. }
  1037.  
  1038. forward FS_CreateBusiness(title[MAX_PLAYER_NAME], earning, Float:eX, Float:eY, Float:eZ, Float:iX, Float:iY, Float:iZ, price, interior, exterior, virtualWorld, iconmarker, itemlist[1024]);
  1039. public FS_CreateBusiness(title[MAX_PLAYER_NAME], earning, Float:eX, Float:eY, Float:eZ, Float:iX, Float:iY, Float:iZ, price, interior, exterior, virtualWorld, iconmarker, itemlist[1024])
  1040. {
  1041.     static bCount;
  1042.     new hID = bCount; bCount += 1;
  1043.  
  1044.     BusinessInfo[hID][bPrice] = price;
  1045.     BusinessInfo[hID][bInterior] = interior;
  1046.     BusinessInfo[hID][bExterior] = exterior;
  1047.     BusinessInfo[hID][bVirtualWorld] = virtualWorld;
  1048.     BusinessInfo[hID][bInteriorX] = iX;
  1049.     BusinessInfo[hID][bInteriorY] = iY;
  1050.     BusinessInfo[hID][bInteriorZ] = iZ;
  1051.     BusinessInfo[hID][bExteriorX] = eX;
  1052.     BusinessInfo[hID][bExteriorY] = eY;
  1053.     BusinessInfo[hID][bExteriorZ] = eZ;
  1054.     BusinessInfo[hID][bEarning] = earning;
  1055.     if(strcmp(itemlist, "_") != 0) format(BusinessInfo[hID][bItemList], 1024, itemlist);
  1056.     else format(BusinessInfo[hID][bItemList], 1024, NO_ITEMS_STRING);
  1057.  
  1058.     new bizfile[64];
  1059.     format(bizfile, 64, SHOP_FILE, hID);
  1060.  
  1061.     if(!INI_Exist(bizfile)) // If not existing
  1062.     {
  1063.         INI_Open(bizfile);
  1064.         //
  1065.         format(BusinessInfo[hID][bTitle], MAX_PLAYER_NAME, title);   INI_WriteString("Title", BusinessInfo[hID][bTitle]);
  1066.         format(BusinessInfo[hID][bOwner], MAX_PLAYER_NAME, INVALID_OWNER);   INI_WriteString("Owner", BusinessInfo[hID][bOwner]);
  1067.         BusinessInfo[hID][bLocked] = 0;  INI_WriteInt("Locked", BusinessInfo[hID][bLocked]);
  1068.         BusinessInfo[hID][bMoney] = 0;  INI_WriteInt("Money", BusinessInfo[hID][bMoney]);
  1069.         BusinessInfo[hID][bGoods] = 10;  INI_WriteInt("Goods", BusinessInfo[hID][bGoods]);
  1070.         //
  1071.         INI_Save();
  1072.         INI_Close();
  1073.  
  1074.         #if CONSOLE == 1
  1075.         printf("Created new business - ID: %d - Name: %s - Ext: %d, %f, %f, %f - Int: %d, %f, %f, %f - Price: %d - World: %d", hID, BusinessInfo[hID][bTitle], BusinessInfo[hID][bExterior], BusinessInfo[hID][bExteriorX], BusinessInfo[hID][bExteriorY], BusinessInfo[hID][bExteriorZ], BusinessInfo[hID][bInterior], BusinessInfo[hID][bInteriorX], BusinessInfo[hID][bInteriorY], BusinessInfo[hID][bInteriorZ], BusinessInfo[hID][bPrice], BusinessInfo[hID][bVirtualWorld]);
  1076.         #endif
  1077.     }
  1078.     else
  1079.     {
  1080.         INI_Open(bizfile);
  1081.         //
  1082.         INI_ReadString(BusinessInfo[hID][bTitle], "Title", MAX_TITLE);
  1083.         INI_ReadString(BusinessInfo[hID][bOwner], "Owner", MAX_PLAYER_NAME);
  1084.         BusinessInfo[hID][bLocked] = INI_ReadInt("Locked");
  1085.         BusinessInfo[hID][bMoney] = INI_ReadInt("Money");
  1086.         BusinessInfo[hID][bGoods] = INI_ReadInt("Goods");
  1087.         //
  1088.         INI_Close();
  1089.  
  1090.         #if CONSOLE == 1
  1091.         printf("Loaded store - ID: %d - Title: %s - Owner: %s", hID, BusinessInfo[hID][bTitle], BusinessInfo[hID][bOwner]);
  1092.         #endif
  1093.     }
  1094.     if(!strcmp(BusinessInfo[hID][bOwner], INVALID_OWNER, true)) //for sale
  1095.     {
  1096.         BusinessPickup[hID] = CreateDynamicPickup(1272, 23, BusinessInfo[hID][bExteriorX], BusinessInfo[hID][bExteriorY], BusinessInfo[hID][bExteriorZ]);
  1097.     }
  1098.     else // not for sale
  1099.     {
  1100.         BusinessPickup[hID] = CreateDynamicPickup(1318, 23, BusinessInfo[hID][bExteriorX], BusinessInfo[hID][bExteriorY], BusinessInfo[hID][bExteriorZ]);
  1101.     }
  1102.     #if MAP_ICONS == 1
  1103.     BusinessIcon[hID] = CreateDynamicMapIcon(BusinessInfo[hID][bExteriorX], BusinessInfo[hID][bExteriorY], BusinessInfo[hID][bExteriorZ], iconmarker, 0, _, _, _, 800.0);
  1104.     #endif
  1105.     BusinessPickup2[hID] = CreateDynamicPickup(1318, 23, BusinessInfo[hID][bInteriorX], BusinessInfo[hID][bInteriorY], BusinessInfo[hID][bInteriorZ]);
  1106.     Create3DTextLabel("Business - Press "KEY_STRING" to open the menu", 0xFFFF00FF, BusinessInfo[hID][bExteriorX],BusinessInfo[hID][bExteriorY], BusinessInfo[hID][bExteriorZ]+1, 20, 0, 1);
  1107.     Create3DTextLabel("Press "KEY_STRING" to exit", 0xFFFF00FF, BusinessInfo[hID][bInteriorX], BusinessInfo[hID][bInteriorY], BusinessInfo[hID][bInteriorZ]+1, 20, BusinessInfo[hID][bVirtualWorld], 1);
  1108.     return hID;
  1109. }
  1110.  
  1111. forward FS_GiveBusinessMoney(shopid, money);
  1112. public FS_GiveBusinessMoney(shopid, money)
  1113. {
  1114.     if(BusinessInfo[shopid][bMoney] + money < 0) return 0;
  1115.     BusinessInfo[shopid][bMoney] += money;
  1116.     new filename[128];
  1117.     format(filename, 128, SHOP_FILE, shopid);
  1118.     INI_Open(filename);
  1119.     INI_WriteInt("Money", BusinessInfo[shopid][bMoney]);
  1120.     INI_Save();
  1121.     INI_Close();
  1122.     return 1;
  1123. }
  1124.  
  1125. forward FS_GiveBusinessGoods(shopid, goods);
  1126. public FS_GiveBusinessGoods(shopid, goods)
  1127. {
  1128.     if(!strcmp(BusinessInfo[shopid][bOwner], INVALID_OWNER, true)) return 1;
  1129.     if(BusinessInfo[shopid][bGoods] + goods < 0) return 0;
  1130.     BusinessInfo[shopid][bGoods] += goods;
  1131.     new filename[128];
  1132.     format(filename, 128, SHOP_FILE, shopid);
  1133.     INI_Open(filename);
  1134.     INI_WriteInt("Goods", BusinessInfo[shopid][bGoods]);
  1135.     INI_Save();
  1136.     INI_Close();
  1137.     return 1;
  1138. }
  1139.  
  1140. forward FS_GetBusinessMoney(shopid); public FS_GetBusinessMoney(shopid) { return BusinessInfo[shopid][bMoney]; }
  1141. forward FS_GetBusinessGoods(shopid); public FS_GetBusinessGoods(shopid) { return BusinessInfo[shopid][bGoods]; }
  1142.  
  1143. stock BuyFurniture(playerid, houseid, modelid) // modelid is the furniture model id while fid is the instance id of a furniture.
  1144. {
  1145.     new fid = 0;
  1146.     while(fid < MAX_FURNITURE)
  1147.     {
  1148.         if(HouseInfo[houseid][FModel][fid] == INVALID_FURNITURE_ID) break;
  1149.         fid ++;
  1150.     }
  1151.     if(fid == MAX_FURNITURE || HouseInfo[houseid][FCount] >= MAX_FURNITURE) return FS_MsgBox(playerid, BOX_STYLE_ERROR, "You can't buy anymore furniture.");
  1152.     HouseInfo[houseid][FCount] += 1;
  1153.     new fname[64]; format(fname, 64, HOUSE_FILE, houseid);
  1154.     new key[24];
  1155.     HouseInfo[houseid][FModel][fid] = modelid;
  1156.     GivePlayerMoney(playerid, -FurnitureInfo[modelid][1]);
  1157.     INI_Open(fname);
  1158.     INI_WriteInt("FCount", HouseInfo[houseid][FCount]);
  1159.     format(key, 24, "FModel%d", fid); INI_WriteInt(key, HouseInfo[houseid][FModel][fid]);
  1160.     INI_Save();
  1161.     INI_Close();
  1162.     ShowPlayerDialog(playerid, DIALOG_FURNITURE_BOUGHT, DIALOG_STYLE_MSGBOX, "{33AA33}Do you want to keep shopping?", "{33AA33}You bought a new furniture!\n{FFFFFF}To put it into your house open the menu and select \"Place/Edit furniture\".", "Continue", "Finish");
  1163.     return fid;
  1164. }
  1165.  
  1166. stock SaveFurniturePosition(houseid, furnid) // Furnid is the instance id of the furniture.
  1167. {
  1168.     new fname[64]; format(fname, 64, HOUSE_FILE, houseid);
  1169.     new key[32];
  1170.     INI_Open(fname);
  1171.     format(key, 24, "FPosX%d", furnid); INI_WriteFloat(key, HouseInfo[houseid][FPosX][furnid]);
  1172.     format(key, 24, "FPosY%d", furnid); INI_WriteFloat(key, HouseInfo[houseid][FPosY][furnid]);
  1173.     format(key, 24, "FPosZ%d", furnid); INI_WriteFloat(key, HouseInfo[houseid][FPosZ][furnid]);
  1174.     format(key, 24, "FRotX%d", furnid); INI_WriteFloat(key, HouseInfo[houseid][FRotX][furnid]);
  1175.     format(key, 24, "FRotY%d", furnid); INI_WriteFloat(key, HouseInfo[houseid][FRotY][furnid]);
  1176.     format(key, 24, "FRotZ%d", furnid); INI_WriteFloat(key, HouseInfo[houseid][FRotZ][furnid]);
  1177.     INI_Save();
  1178.     INI_Close();
  1179.     return 1;
  1180. }
  1181.  
  1182. stock OpenHouseDialog(playerid, houseid)
  1183. {
  1184.     if(!strcmp(HouseInfo[houseid][Owner], INVALID_OWNER, true)) // the house is for sale
  1185.     {
  1186.         new string[128];
  1187.         if(GetPlayerMoney(playerid) >= HouseInfo[houseid][Price]) format(string, 128, "{33AA33}Buy this house for %d$\n{33AA33}Visit this house", HouseInfo[houseid][Price]);
  1188.         else format(string, 128, "{FF0000}Buy this house for %d$\n{33AA33}Visit this house", HouseInfo[houseid][Price]);
  1189.  
  1190.         ShowPlayerDialog(playerid, DIALOG_FORSALE_HOUSE, DIALOG_STYLE_LIST, "{33AA33}House for sale!", string, "OK", "Close");
  1191.         return 1;
  1192.     }
  1193.     else // not for sale
  1194.     {
  1195.         new string[128];
  1196.         new string2[128];
  1197.         new name[24];
  1198.         GetPlayerName(playerid, name, 24);
  1199.         if(!strcmp(name, HouseInfo[houseid][Owner], true)) // The player is the owner
  1200.         {
  1201.             ShowPlayerDialog(playerid, DIALOG_MY_HOUSE, DIALOG_STYLE_LIST, "{33AA33}Owned House - Owner: you", "{33AA33}Enter your house\n{33AA33}Open/Close the door\n{33AA33}Sell your house", "OK", "Close");
  1202.             return 0;
  1203.         }
  1204.         else // The player is not the owner
  1205.         {
  1206.             format(string, 128, "{33AA33}Owned House - Owner: %s", HouseInfo[houseid][Owner]);
  1207.             if(HouseInfo[houseid][Locked] == 0) format(string2, 128, "{33AA33}Enter this house");
  1208.             else format(string2, 128, "{FF0000}Enter this house");
  1209.             ShowPlayerDialog(playerid, DIALOG_OTHERS_HOUSE, DIALOG_STYLE_LIST, string, string2, "OK", "Close");
  1210.             return -1;
  1211.         }
  1212.     }
  1213. }
  1214.  
  1215. stock OpenBusinessDialog(playerid, bizid)
  1216. {
  1217.     if(!strcmp(BusinessInfo[bizid][bOwner], INVALID_OWNER, true))
  1218.     {
  1219.         new string[128];
  1220.         if(GetPlayerMoney(playerid) >= BusinessInfo[bizid][bPrice]) format(string, 128, "{33AA33}Enter this store (%d$)\n{33AA33}Buy this store for %d$", BusinessInfo[bizid][bEarning], BusinessInfo[bizid][bPrice]);
  1221.         else format(string, 128, "{33AA33}Enter this store (%d$)\n{FF0000}Buy this store for %d$", BusinessInfo[bizid][bEarning], BusinessInfo[bizid][bPrice]);
  1222.  
  1223.         ShowPlayerDialog(playerid, DIALOG_FORSALE_BIZ, DIALOG_STYLE_LIST, "{33AA33}Store for sale!", string, "OK", "Close");
  1224.         return 1;
  1225.     }
  1226.     else
  1227.     {
  1228.         new string[128];
  1229.         new string2[256];
  1230.         new name[24];
  1231.         GetPlayerName(playerid, name, 24);
  1232.         if(!strcmp(name, BusinessInfo[bizid][bOwner], true))
  1233.         {
  1234.             format(string, 128, "{33AA33}%s - Owner: you - Goods: %d - Earnings: %d$", BusinessInfo[bizid][bTitle], BusinessInfo[bizid][bGoods], BusinessInfo[bizid][bMoney]);
  1235.             format(string2, 256, "{33AA33}Enter your store\n{33AA33}Open/Close the store\n{33AA33}Sell your store");
  1236.             ShowPlayerDialog(playerid, DIALOG_MY_BIZ, DIALOG_STYLE_LIST, string, string2, "OK", "Close");
  1237.             return 0;
  1238.         }
  1239.         else
  1240.         {
  1241.             format(string, 128, "{33AA33}%s - Owner: %s", BusinessInfo[bizid][bTitle], BusinessInfo[bizid][bOwner]);
  1242.             if(BusinessInfo[bizid][bLocked] == 0 || GetPlayerMoney(playerid) >= BusinessInfo[bizid][bEarning]) format(string2, 256, "{33AA33}Enter this store (%d$)", BusinessInfo[bizid][bEarning]);
  1243.             else format(string2, 256, "{FF0000}Enter this store (%d$)", BusinessInfo[bizid][bEarning]);
  1244.             ShowPlayerDialog(playerid, DIALOG_OTHERS_BIZ, DIALOG_STYLE_LIST, string, string2, "OK", "Close");
  1245.             return -1;
  1246.         }
  1247.     }
  1248. }
  1249.  
  1250. stock ShowHouseMenu(playerid)
  1251. {
  1252.     return ShowPlayerDialog(playerid, DIALOG_HOUSE_MENU, DIALOG_STYLE_LIST, "{33AA33}House Menu", "Store money\nWithdraw money\nStore weapons\nCollect weapons\nPlace/Edit furniture\nBuy new furniture\nSell furniture", "OK", "Cancel");
  1253. }
  1254.  
  1255. stock ShowBusinessMenu(playerid)
  1256. {
  1257.     return ShowPlayerDialog(playerid, DIALOG_SHOP_MENU, DIALOG_STYLE_LIST, "{33AA33}Store Menu", "Rename your store\nCollect your earnings\nSupply goods for your store\nBuy an item from your store", "OK", "Cancel");
  1258. }
  1259.  
  1260. stock GetHouseID(playerid)
  1261. {
  1262.     for(new i=0; i<MAX_HOUSES; i++)
  1263.     {
  1264.         if(IsPlayerInRangeOfPoint(playerid, 1, HouseInfo[i][ExteriorX], HouseInfo[i][ExteriorY], HouseInfo[i][ExteriorZ]))
  1265.         {
  1266.             return i;
  1267.         }
  1268.     }
  1269.     return INVALID_HOUSE_ID;
  1270. }
  1271.  
  1272. stock GetShopID(playerid)
  1273. {
  1274.     for(new i=0; i<MAX_SHOPS; i++)
  1275.     {
  1276.         if(IsPlayerInRangeOfPoint(playerid, 1, BusinessInfo[i][bExteriorX], BusinessInfo[i][bExteriorY], BusinessInfo[i][bExteriorZ]))
  1277.         {
  1278.             return i;
  1279.         }
  1280.     }
  1281.     return INVALID_HOUSE_ID;
  1282. }
  1283.  
  1284. stock BuyHouse(playerid, houseid)
  1285. {
  1286.     new string[64];
  1287.     new name[24];
  1288.     GetPlayerName(playerid, name, 24);
  1289.     GivePlayerMoney(playerid, -HouseInfo[houseid][Price]);
  1290.     format(HouseInfo[houseid][Owner], 24, name);
  1291.     HouseInfo[houseid][Locked] = 0;
  1292.     HouseInfo[Owner][ownhouse] =1;
  1293.     format(string, 64, HOUSE_FILE, houseid);
  1294.     INI_Open(string);
  1295.     INI_WriteString("Owner", HouseInfo[houseid][Owner]);
  1296.     INI_WriteInt("Locked", HouseInfo[houseid][Locked]);
  1297.     INI_WriteInt("Owned", HouseInfo[Owner][ownhouse]);
  1298.     INI_Save();
  1299.     INI_Close();
  1300.  
  1301.     DestroyDynamicPickup(HousePickup[houseid]);
  1302.     HousePickup[houseid] = CreateDynamicPickup(1272, 23, HouseInfo[houseid][ExteriorX], HouseInfo[houseid][ExteriorY], HouseInfo[houseid][ExteriorZ]);
  1303.     #if MAP_ICONS == 1
  1304.     DestroyDynamicMapIcon(HouseIcon[houseid]);
  1305.     HouseIcon[houseid] = CreateDynamicMapIcon(HouseInfo[houseid][ExteriorX], HouseInfo[houseid][ExteriorY], HouseInfo[houseid][ExteriorZ], 32, 0, _, _, _, 800.0);
  1306.     #endif
  1307.  
  1308.     #if CONSOLE == 1
  1309.     printf("Player %s(%d) bought house ID %d.", name, playerid, houseid);
  1310.     #endif
  1311.     FS_MsgBox(playerid, "{33AA33}ACTION", "You bought this house.");
  1312.     return 1;
  1313. }
  1314.  
  1315. stock BuyShop(playerid, shopid)
  1316. {
  1317.     new string[64];
  1318.     new name[24];
  1319.     GetPlayerName(playerid, name, 24);
  1320.     GivePlayerMoney(playerid, -BusinessInfo[shopid][bPrice]);
  1321.     format(BusinessInfo[shopid][bOwner], 24, name);
  1322.     BusinessInfo[shopid][bLocked] = 0;
  1323.     format(string, 64, SHOP_FILE, shopid);
  1324.     INI_Open(string);
  1325.     INI_WriteString("Owner", BusinessInfo[shopid][bOwner]);
  1326.     INI_WriteInt("Locked", BusinessInfo[shopid][bLocked]);
  1327.     INI_Save();
  1328.     INI_Close();
  1329.     DestroyDynamicPickup(BusinessPickup[shopid]);
  1330.     BusinessPickup[shopid] = CreateDynamicPickup(1318, 23, BusinessInfo[shopid][bExteriorX], BusinessInfo[shopid][bExteriorY], BusinessInfo[shopid][bExteriorZ]);
  1331.     #if CONSOLE == 1
  1332.     printf("Player %s(%d) bought store ID %d.", name, playerid, shopid);
  1333.     #endif
  1334.     FS_MsgBox(playerid, "{33AA33}ACTION", "You bought this store.");
  1335.     return 1;
  1336. }
  1337.  
  1338. stock SellHouse(playerid, houseid)
  1339. {
  1340.     new string[256];
  1341.     new name[24];
  1342.     GetPlayerName(playerid, name, 24);
  1343.     GivePlayerMoney(playerid, floatround(HouseInfo[houseid][Price]*SELL_MULTIPLIER));
  1344.     format(HouseInfo[houseid][Owner], 24, INVALID_OWNER);
  1345.     HouseInfo[houseid][Locked] = 1;
  1346.     HouseInfo[Owner][ownhouse] =0;
  1347.     format(string, 256, HOUSE_FILE, houseid);
  1348.     INI_Open(string);
  1349.     INI_WriteString("Owner", HouseInfo[houseid][Owner]);
  1350.     INI_WriteInt("Locked", HouseInfo[houseid][Locked]);
  1351.     INI_WriteInt("Owned", HouseInfo[Owner][ownhouse]);
  1352.     INI_Save();
  1353.     INI_Close();
  1354.  
  1355.     DestroyDynamicPickup(HousePickup[houseid]);
  1356.     HousePickup[houseid] = CreateDynamicPickup(1273, 23, HouseInfo[houseid][ExteriorX], HouseInfo[houseid][ExteriorY], HouseInfo[houseid][ExteriorZ]);
  1357.     #if MAP_ICONS == 1
  1358.     DestroyDynamicMapIcon(HouseIcon[houseid]);
  1359.     HouseIcon[houseid] = CreateDynamicMapIcon(HouseInfo[houseid][ExteriorX], HouseInfo[houseid][ExteriorY], HouseInfo[houseid][ExteriorZ], 31, 0, _, _, _, 800.0);
  1360.     #endif
  1361.  
  1362.     #if CONSOLE == 1
  1363.     printf("Player %s(%d) sold house ID %d.", name, playerid, houseid);
  1364.     #endif
  1365.     FS_MsgBox(playerid, "{33AA33}ACTION", "You sold this house.");
  1366.     return 1;
  1367. }
  1368.  
  1369. stock SellShop(playerid, shopid)
  1370. {
  1371.     new string[256];
  1372.     new name[24];
  1373.     GetPlayerName(playerid, name, 24);
  1374.     GivePlayerMoney(playerid, floatround(BusinessInfo[shopid][bPrice]*SELL_MULTIPLIER));
  1375.     format(BusinessInfo[shopid][bOwner], 24, INVALID_OWNER);
  1376.     BusinessInfo[shopid][bLocked] = 1;
  1377.     format(string, 256, SHOP_FILE, shopid);
  1378.     INI_Open(string);
  1379.     INI_WriteString("Owner", BusinessInfo[shopid][bOwner]);
  1380.     INI_WriteInt("Locked", BusinessInfo[shopid][bLocked]);
  1381.     INI_Save();
  1382.     INI_Close();
  1383.     DestroyDynamicPickup(BusinessPickup[shopid]);
  1384.     BusinessPickup[shopid] = CreateDynamicPickup(1272, 23, BusinessInfo[shopid][bExteriorX], BusinessInfo[shopid][bExteriorY], BusinessInfo[shopid][bExteriorZ]);
  1385.     #if CONSOLE == 1
  1386.     printf("Player %s(%d) sold store ID %d.", name, playerid, shopid);
  1387.     #endif
  1388.     FS_MsgBox(playerid, "{33AA33}ACTION", "You sold this store.");
  1389.     return 1;
  1390. }
  1391.  
  1392. forward player_unfreeze(playerid);
  1393. public player_unfreeze(playerid) { return TogglePlayerControllable(playerid, true); }
  1394.  
  1395. stock EnterHouse(playerid, houseid)
  1396. {
  1397.     if(HouseInfo[Owner][ownhouse] == 0) {
  1398.         SetPlayerPos(playerid, HouseInfo[houseid][InteriorX], HouseInfo[houseid][InteriorY], HouseInfo[houseid][InteriorZ]);
  1399.         SetPlayerInterior(playerid, HouseInfo[houseid][Interior]);
  1400.         SetPlayerVirtualWorld(playerid, HouseInfo[houseid][VirtualWorld]);
  1401.         SetLastHouse(playerid, houseid);
  1402.         TogglePlayerControllable(playerid, false);
  1403.         GameTextForPlayer(playerid, "~r~Please Wait", 2000, 5);
  1404.         SetTimerEx("player_unfreeze", 2000, false, "i", playerid);
  1405.         return 1;}
  1406.     if(HouseInfo[Owner][ownhouse] == 1){
  1407.         SendClientMessage(playerid,GREEN,"Press 'MMB' to show house menu.");
  1408.         SetPlayerPos(playerid, HouseInfo[houseid][InteriorX], HouseInfo[houseid][InteriorY], HouseInfo[houseid][InteriorZ]);
  1409.         SetPlayerInterior(playerid, HouseInfo[houseid][Interior]);
  1410.         SetPlayerVirtualWorld(playerid, HouseInfo[houseid][VirtualWorld]);
  1411.         SetLastHouse(playerid, houseid);
  1412.         TogglePlayerControllable(playerid, false);
  1413.         GameTextForPlayer(playerid, "~r~Please Wait", 2000, 5);
  1414.         SetTimerEx("player_unfreeze", 2000, false, "i", playerid);
  1415.         return 1;}
  1416.     return 1;
  1417. }
  1418.  
  1419. stock EnterShop(playerid, shopid)
  1420. {
  1421.     SetPlayerPos(playerid, BusinessInfo[shopid][bInteriorX], BusinessInfo[shopid][bInteriorY], BusinessInfo[shopid][bInteriorZ]);
  1422.     SetPlayerInterior(playerid, BusinessInfo[shopid][bInterior]);
  1423.     SetPlayerVirtualWorld(playerid, BusinessInfo[shopid][bVirtualWorld]);
  1424.     SetLastShop(playerid, shopid);
  1425.     return 1;
  1426. }
  1427.  
  1428. forward ExitHouse(playerid, houseid);
  1429. public ExitHouse(playerid, houseid)
  1430. {
  1431.     SetPlayerPos(playerid, HouseInfo[houseid][ExteriorX], HouseInfo[houseid][ExteriorY], HouseInfo[houseid][ExteriorZ]);
  1432.     SetPlayerInterior(playerid, HouseInfo[houseid][Exterior]);
  1433.     SetPlayerVirtualWorld(playerid, 0);
  1434.     SetLastHouse(playerid, INVALID_HOUSE_ID);
  1435.     KillTimer(pVisitTimer[playerid]);
  1436.     return 1;
  1437. }
  1438.  
  1439. stock ExitShop(playerid, shopid)
  1440. {
  1441.     SetPlayerPos(playerid, BusinessInfo[shopid][bExteriorX], BusinessInfo[shopid][bExteriorY], BusinessInfo[shopid][bExteriorZ]);
  1442.     SetPlayerInterior(playerid, BusinessInfo[shopid][bExterior]);
  1443.     SetPlayerVirtualWorld(playerid, 0);
  1444.     SetLastShop(playerid, INVALID_HOUSE_ID);
  1445.     return 1;
  1446. }
  1447.  
  1448. stock LockUnlockHouse(playerid, houseid)
  1449. {
  1450.     if(HouseInfo[houseid][Locked] == 0)
  1451.     {
  1452.         HouseInfo[houseid][Locked] = 1;
  1453.         FS_MsgBox(playerid, BOX_STYLE_CMD, "House {FF0000}locked");
  1454.     }
  1455.     else
  1456.     {
  1457.         HouseInfo[houseid][Locked] = 0;
  1458.         FS_MsgBox(playerid, BOX_STYLE_CMD, "House {33AA33}unlocked");
  1459.     }
  1460.     new string[128];
  1461.     format(string, 128, HOUSE_FILE, houseid);
  1462.     INI_Open(string);
  1463.     INI_WriteInt("Locked", HouseInfo[houseid][Locked]);
  1464.     INI_Save();
  1465.     INI_Close();
  1466.     return 1;
  1467. }
  1468.  
  1469. stock LockUnlockShop(playerid, shopid)
  1470. {
  1471.     if(BusinessInfo[shopid][bLocked] == 0)
  1472.     {
  1473.         BusinessInfo[shopid][bLocked] = 1;
  1474.         FS_MsgBox(playerid, BOX_STYLE_CMD, "Store {FF0000}locked");
  1475.     }
  1476.     else
  1477.     {
  1478.         BusinessInfo[shopid][bLocked] = 0;
  1479.         FS_MsgBox(playerid, BOX_STYLE_CMD, "Store {33AA33}unlocked");
  1480.     }
  1481.     new string[128];
  1482.     format(string, 128, SHOP_FILE, shopid);
  1483.     INI_Open(string);
  1484.     INI_WriteInt("Locked", BusinessInfo[shopid][bLocked]);
  1485.     INI_Save();
  1486.     INI_Close();
  1487.     return 1;
  1488. }
  1489.  
  1490. stock GetEarnings(playerid, shopid)
  1491. {
  1492.     if(BusinessInfo[shopid][Money] <= 0) return FS_MsgBox(playerid, BOX_STYLE_ERROR, "The cash register is empty!");
  1493.     new string[64];
  1494.     GivePlayerMoney(playerid, BusinessInfo[shopid][Money]);
  1495.     format(string, 64, "You withdrew %d$!", BusinessInfo[shopid][Money]);
  1496.     FS_MsgBox(playerid, "{33AA33}ACTION", string);
  1497.     BusinessInfo[shopid][bMoney] = 0;
  1498.     format(string, 64, SHOP_FILE, shopid);
  1499.     INI_Open(string);
  1500.     INI_WriteInt("Money", BusinessInfo[shopid][Money]);
  1501.     INI_Save();
  1502.     INI_Close();
  1503.     return 1;
  1504. }
  1505.  
  1506. stock AddEarnings(shopid, money)
  1507. {
  1508.     BusinessInfo[shopid][bMoney] += money;
  1509.     new string[64];
  1510.     format(string, 64, SHOP_FILE, shopid);
  1511.     INI_Open(string);
  1512.     INI_WriteInt("Money", BusinessInfo[shopid][Money]);
  1513.     INI_Save();
  1514.     INI_Close();
  1515.     return 1;
  1516. }
  1517.  
  1518. stock ShowFurnitureMenu(playerid)
  1519. {
  1520.     new bigstring[2048];
  1521.     new string[64];
  1522.     new money = GetPlayerMoney(playerid);
  1523.     new i = 1;
  1524.     while(i < FURNITURE_NUMBER)
  1525.     {
  1526.         if(money >= FurnitureInfo[i][1]) format(string, 64, "{33AA33}%s - %d$", FurnitureInfo[i][2], FurnitureInfo[i][1]);
  1527.         else format(string, 64, "{FF0000}%s - %d$", FurnitureInfo[i][2], FurnitureInfo[i][1]);
  1528.         format(bigstring, sizeof(bigstring), "%s%s\n", bigstring, string);
  1529.         i++;
  1530.     }
  1531.     ShowPlayerDialog(playerid, DIALOG_BUY_FURNITURE, DIALOG_STYLE_LIST, "{33AA33}Buy a new furniture!", bigstring, "Buy", "Cancel");
  1532.     return 1;
  1533. }
  1534.  
  1535. stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
  1536. {
  1537.     new Float:a;
  1538.     GetPlayerPos(playerid, x, y, a);
  1539.     GetPlayerFacingAngle(playerid, a);
  1540.     if (GetPlayerVehicleID(playerid))
  1541.     {
  1542.       GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
  1543.     }
  1544.     x += (distance * floatsin(-a, degrees));
  1545.     y += (distance * floatcos(-a, degrees));
  1546. }
  1547.  
  1548. stock strtok(const string[], &index)
  1549. {
  1550.     new length = strlen(string);
  1551.     while ((index < length) && (string[index] <= ' '))
  1552.     {
  1553.         index++;
  1554.     }
  1555.  
  1556.     new offset = index;
  1557.     new result[20];
  1558.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  1559.     {
  1560.         result[index - offset] = string[index];
  1561.         index++;
  1562.     }
  1563.     result[index - offset] = EOS;
  1564.     return result;
  1565. }
  1566.  
  1567. stock strrest(const string[], &index)
  1568. {
  1569.     new length = strlen(string);
  1570.     while ((index < length) && (string[index] <= ' '))
  1571.     {
  1572.         index++;
  1573.     }
  1574.     new offset = index;
  1575.     new result[128];
  1576.     while ((index < length) && ((index - offset) < (sizeof(result) - 1)))
  1577.     {
  1578.         result[index - offset] = string[index];
  1579.         index++;
  1580.     }
  1581.     result[index - offset] = EOS;
  1582.     return result;
  1583. }
  1584.  
  1585. public OnPlayerEnterCheckpoint(playerid)
  1586. {
  1587.     if(hcp[playerid] == 1)
  1588.     {
  1589.         DisablePlayerCheckpoint(playerid);
  1590.         hcp[playerid] = 0;
  1591.         return 1;
  1592.     }
  1593.     return 1;
  1594. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement