Advertisement
Guest User

Business system

a guest
Jul 31st, 2014
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 94.12 KB | None | 0 0
  1. #define MAX_BUSINESS 200
  2. #define BIZ_VW_OFFSET 1000
  3. #define BIZROB_COOLDOWN 7200
  4.  
  5. new bizinit = 0;
  6. enum EBusinessType {
  7.     EBusinessType_247, //0
  8.     EBusinessType_D_NormCar, //1
  9.     EBusinessType_D_FastCar, //2
  10.     EBusinessType_D_Boat, //3
  11.     EBusinessType_SexShop, //4
  12.     EBusinessType_GasStation, //5
  13.     EBusinessType_Restaurant, //6
  14.     EBusinessType_PizzaStack, //aka fast food 7
  15.     EBusinessType_PaintBall, //8
  16.     EBusinessType_Bar, //9
  17.     EBusinessType_D_Bike, //10
  18.     EBusinessType_D_Plane, //11
  19.     EBusinessType_Ammunation, //12
  20.     EBusinessType_RaceTrack, //LS stadium 13
  21.     EBusinessType_D_Truck, //transport trucks, etc 14
  22.     EBusinessType_FurnitureStore, //15
  23.     EBusinessType_FishStore, //16
  24.     EBusinessType_VehicleRental, //17
  25. };
  26.  
  27. enum EBusinessInfo {
  28.     EBusinessID,
  29.     EBusinessName[64],
  30.     EBusinessPrice,
  31.     EBusinessLevel,
  32.     EBusinessOwner, //SQL ID OF OWNER
  33.     EBusinessOwnerName[MAX_PLAYER_NAME], //character name of owner
  34.     EBusinessExtortionist, //SQL ID of extortionist
  35.     EBusinessExtortionName[MAX_PLAYER_NAME],
  36.     Float:EBusinessEntranceX,
  37.     Float:EBusinessEntranceY,
  38.     Float:EBusinessEntranceZ,
  39.     Float:EBusinessExitX,
  40.     Float:EBusinessExitY,
  41.     Float:EBusinessExitZ,
  42.     EBusinessInterior,
  43.     EBusinessVW,
  44.     Text3D:EBusinessText,
  45.     EBusinessPickup,
  46.     EBusinessType:EBType,
  47.     EBusinessLocked,//opened or not
  48.     EBusinessEntranceFee,
  49.     EBusinessExitPickup,
  50.     EBusinessTill, //how much money is in the till
  51.     EBusinessProducts,
  52.     EBusinessMaxProducts,
  53.     EBusinessLastRobbery, //unix time of last robbery
  54. };
  55. new Business[MAX_BUSINESS][EBusinessInfo];
  56.  
  57. enum EBCarInfo {
  58.     EBCarModelID,
  59.     EBCarPrice,
  60. };
  61. new EBDNormalCars[][EBCarInfo] = {
  62. {400,20000},
  63. {401,20000},
  64. //{402,65000},
  65. {404,15000},
  66. {405,25000},
  67. {410,20000},
  68. {412,10000},
  69. {413,10000},
  70. {414,12000},
  71. {418,15000},
  72. {419,10000},
  73. {422,15000},
  74. {426,30000},
  75. {436,20000},
  76. {439,50000},
  77. {440,20000},
  78. {442,100000},
  79. {456,60000},
  80. {458,20000},
  81. {466,10000},
  82. {467,18000},
  83. {474,10000},
  84. {478,10000},
  85. {479,15000},
  86. {482,42000},
  87. {483,50000},
  88. {491,25000},
  89. {492,30000},
  90. {498,30000},
  91. {499,17500},
  92. {500,25000},
  93. {505,50000},
  94. {508,100000},
  95. {516,15000},
  96. {517,25000},
  97. {518,15000},
  98. {526,22000},
  99. {527,15000},
  100. {529,10000},
  101. {534,30000},
  102. {535,57000},
  103. {536,14000},
  104. {540,41000},
  105. {542,10000},
  106. {543,10000},
  107. {546,10000},
  108. {547,10000},
  109. {549,8000},
  110. {550,15000},
  111. {551,30000},
  112. {554,25000},
  113. //{560,149999},
  114. {566,30000},
  115. {567,15000},
  116. {568,65000},
  117. {575,18500},
  118. {576,25000},
  119. {585,10000},
  120. {586,42000},
  121. {589,41000},
  122. {496,15000},
  123. {600,15000},
  124. {602,28000},
  125. {604,1000},
  126. {605,1000}
  127. };
  128. new EBDFastCars[][EBCarInfo] = {
  129. {429,250000},
  130. {409,200000},
  131. {580,125000},
  132. {402,150000},
  133. {603,150000},
  134. //{434,15000},
  135. {507,75000},
  136. {533,50000},
  137. {562,65000},
  138. {470,250000},
  139. //{541,600000},
  140. //{451,1000000},
  141. {445,150000},
  142. //{415,500000},
  143. {579,40000},
  144. {558,60000},
  145. {559,50000},
  146. {421,220000},
  147. {555,37000},
  148. {477,200000},
  149. //{560,900000},
  150. {480,180000},
  151. //{411,1500000},
  152. {475,40000},
  153. //{480,200000},
  154. {506,150000},
  155. //{562,80000},
  156. {565,60000},
  157. //{545,500000},
  158. {587,180000}
  159. };
  160.  
  161. new EBDBikes[][EBCarInfo] = {
  162. {509,300},
  163. {481,600},
  164. {510,5000},
  165. {581,7000},
  166. {461, 10000},
  167. {462, 15000},
  168. {521, 25000},
  169. //{522, 350000},
  170. {463, 13000},
  171. {468, 11000},
  172. {471, 3000},
  173. {586, 20000}
  174. };
  175. new EBDBoats[][EBCarInfo] = {
  176. {472,50000},
  177. {473,80000},
  178. {493,250000},
  179. {595,150000},
  180. {484,160000},
  181. {453,150000},
  182. {452,400000},
  183. {446,250000},
  184. {454,300000}
  185. };
  186. new EBDPlanes[][EBCarInfo] = {
  187. {511,150000},
  188. {512,225000},
  189. {593,250000},
  190. {519,500000},
  191. {460,275000},
  192. {513,300000},
  193. {487,350000},
  194. {469,250000}
  195. };
  196.  
  197. new EBDTrucks[][EBCarInfo] = {
  198. {499,80000},
  199. {482,42000},
  200. //{422,15000},
  201. {489,75000},
  202. {609,75000},
  203. {524,180000},
  204. {578,150000},
  205. {455,250000},
  206. {403,330000},
  207. {414,200000},
  208. {443,230000},
  209. {514,280000},
  210. {413,50000},
  211. {515,450000},
  212. //{440,95000},
  213. {543,10000},
  214. {459,65000},
  215. {531,12000},
  216. {552,75000},
  217. {478,12000},
  218. {456, 85000}
  219. //{428,500000}
  220. };
  221.  
  222. enum EDrinkInfo {
  223.     EDrinkName[32],
  224.     EDrinkSpecialAction,
  225.     EDrinkPrice,
  226.     Float:EDrinkHealthBoost,
  227.     EDrinkAction[32]
  228. };
  229. new Drinks[][EDrinkInfo] = {{"Water",SPECIAL_ACTION_NONE,10,5.0,  "* %s drinks a glass of water."},
  230.                             {"Sprunk",SPECIAL_ACTION_DRINK_SPRUNK,25,5.0,  "* %s drinks a sprunk."},
  231.                             {"Wine",SPECIAL_ACTION_DRINK_WINE ,55,5.0,  "* %s drinks a glass of wine."},
  232.                             {"Beer",SPECIAL_ACTION_DRINK_BEER ,35,5.0,  "* %s drinks a glass of beer."},
  233.                             {"Vodka",SPECIAL_ACTION_DRINK_WINE, 55, 5.0, "* %s drinks a vodka"}
  234.                             };
  235. enum EGasPumpInfo {
  236.     Float:EGasPumpX,
  237.     Float:EGasPumpY,
  238.     Float:EGasPumpZ
  239. };
  240. new GasPumps[][EGasPumpInfo] = {
  241.     {1942.857910,-1773.203002,13.390598}, //Idlewood gas
  242.     {1004.042236,-937.868041,42.179687}, //Vinewood gas
  243.     {655.164245,-564.591308,16.335937}, //Dillimore gas
  244.     {-92.035842,-1168.831542,2.447296}, //West LS Gas
  245.     {2404.325439, -1383.679321, 24.214141}, //Pumps SE LS
  246.     {-1605.830810, -2711.739990, 48.945312}, //angel pine
  247.     {-1676.026245, 417.433990, 7.179687}, //sf near bridge
  248.     {2115.626708, 918.848937, 10.820312}, //lv near highway/strip
  249.     {2199.068603, 2476.527099, 10.820312} //lv near pd
  250. };
  251.  
  252. new DriveThrus[][EGasPumpInfo] = {
  253. {1214.189941, -906.483276, 42.921615},
  254. {2409.918212, -1487.343139, 23.825125},
  255. {2376.004638, -1909.422485, 13.382812},
  256. {799.527648, -1629.614013, 13.382812}
  257. };
  258.  
  259. enum ECarRentalInfo {
  260.     ECarRental_ModelID,
  261.     ECarRental_HourlyRate
  262. };
  263. new RentableCars[][ECarRentalInfo] = {
  264.     {402,500},
  265.     {409,2500},
  266.     {411,8000},
  267.     {415,5000},
  268.     {422,500},
  269.     {426,500},
  270.     {428,1000},
  271.     {429,7000},
  272.     {431,3000},
  273.     {451,8000},
  274.     {469,10000},
  275.     {489,800},
  276.     {521,800},
  277.     {522,4000},
  278.     {487,15000}
  279. };
  280. #define GasMax 200
  281. #define MAX_BUYABLE 10
  282.  
  283. enum {
  284.     BIZ_DEALER_OFFSET = EBusiness_Base+1,
  285.     EBusiness_247BuyMenu,
  286.     EBusiness_247NumberInput,
  287.     EBusiness_247BuyMenuEnd = EBusiness_247NumberInput + MAX_BUYABLE + 1,
  288.     EBusiness_SexBuyMenu,
  289.     EBusiness_SexNumberInput,
  290.     EBusiness_SexBuyMenuEnd = EBusiness_SexNumberInput + MAX_BUYABLE + 1,
  291.     BIZ_DEALER_DEALERSHIP_MENU,
  292.     EBusiness_FastCarMenu,
  293.     EBusiness_BikeCarMenu,
  294.     EBusiness_BoatCarMenu,
  295.     EBusiness_PlaneCarMenu,
  296.     EBusiness_RestaurantMenu,
  297.     EBusiness_DrinkMenu,
  298.     EBusiness_LockBuy,
  299.     EBusiness_FastFoodMenu,
  300.     EBusiness_AmmunationMenu,
  301.     EBusiness_LottoChoose,
  302.     EBusiness_EnterLottoNumber,
  303.     EBusiness_TruckCarMenu,
  304.     EBusiness_FishStoreMenu,
  305.     EBusiness_FishSell,
  306.     EBusiness_RentalMenu,
  307.     EBusiness_End,
  308. };
  309. enum EMenuType {
  310.     EType_Item,
  311.     EType_NumSelect, //to say 10 lockpicks
  312.     EType_Menu,
  313. };
  314. enum EBuyableItems {
  315.     EBIDisplayName[32],
  316.     EBIPrice,
  317.     EMenuType:EBIType,
  318.     EBIOnBuyCallback[32],
  319. };
  320. new Buyable24Items[][EBuyableItems] = {
  321.     {"Dice",5,EType_Item,"On247ItemBuy"},
  322.     {"GPS",200,EType_Item,"On247ItemBuy"},
  323.     {"Vehicle Tracer",250,EType_NumSelect,"On247ItemBuy"},
  324.     {"Walkie Talkie",25,EType_Item,"On247ItemBuy"},
  325.     {"Vehicle Lock Picks",50,EType_NumSelect,"On247ItemBuy"},
  326.     {"Vehicle Locks",300,EType_Menu,"ShowVehicleLockBuy"},
  327.     {"Gas Can",75,EType_NumSelect,"On247ItemBuy"},
  328.     {"Lottery Tickets",250,EType_Menu,"ShowLotteryTicketBuy"},
  329.     {"Cell Phone",100,EType_Item,"On247ItemBuy"},
  330.     {"New Phone Number",100,EType_Item,"Generate247PhoneNumber"},
  331.     {"Cigars",25,EType_NumSelect,"On247ItemBuy"},
  332.     {"Fertilizer",50, EType_NumSelect,"On247ItemBuy"},
  333.     {"Phone Book",50,EType_Item,"On247ItemBuy"},
  334.     {"MP3 Player",250,EType_Item,"On247ItemBuy"},
  335.     {"Mask",20000,EType_Item,"On247ItemBuy"},
  336.     {"Camera",100,EType_Item,"On247ItemBuy"},
  337.     {"Shovel",50,EType_Item,"On247ItemBuy"},
  338.     {"Flowers",50,EType_Item,"On247ItemBuy"},
  339.     {"Pool Cue",75,EType_Item,"On247ItemBuy"},
  340.     {"Cane",100,EType_Item,"On247ItemBuy"},
  341.     {"Spray Can",250,EType_Item,"On247ItemBuy"}
  342. };
  343.  
  344. new BuyableSexItems[][EBuyableItems] = {
  345.     {"Purple Dildo",1000000,EType_Item,"OnSexItemBuy"},
  346.     {"Dildo",1000,EType_Item,"OnSexItemBuy"},
  347.     {"Vibrator",2000,EType_Item,"OnSexItemBuy"},
  348.     {"Small Vibrator",500,EType_Item,"OnSexItemBuy"},
  349.     {"Condoms",10,EType_NumSelect,"OnSexItemBuy"}
  350. };
  351.  
  352. new BuyableRestaurantItems[][EBuyableItems] = {
  353.     {"Small Meal",15,EType_Item,"OnRestaurantBuy"},
  354.     {"Medium Meal",20,EType_Item,"OnRestaurantBuy"},
  355.     {"Large Meal",35,EType_Item,"OnRestaurantBuy"}
  356. };
  357.  
  358. new BuyableFastfoodItems[][EBuyableItems] = {
  359.     {"Fries",10,EType_Item,"OnFastFoodBuy"},
  360.     {"Burger",15,EType_Item,"OnFastFoodBuy"},
  361.     {"Large Burger",35,EType_Item,"OnFastFoodBuy"}
  362. };
  363.  
  364. new BuyableFishStoreItems[][EBuyableItems] = {
  365.     {"Fish Burger",15,EType_Item,"OnFishBuy"},
  366.     {"Large Fish Burger",25,EType_Item,"OnFishBuy"},
  367.     {"Fish Sticks",15,EType_Item,"OnFishBuy"},
  368.     {"Sell Fish",250,EType_Menu,"ShowSellFishMenu"}
  369. };
  370. enum EBuyableGuns {
  371.     EBuyableGunType, //0 = gun, 1 = armour, 2 = health, 3 = special item
  372.     EBuyableGunID,
  373.     EBuyableGunPrice,
  374.     EBuyableGunNeedLicense,
  375. };
  376. new BuyableAmmunationGuns[][EBuyableGuns] = {
  377.     {0,22,5000,1},
  378.     {0,25,13000,1},
  379.     {1,50,5000,0},
  380.     {2,50,1000,0},
  381.     {0,41,250,0},
  382.     {3,0,100000,0}
  383. };
  384.  
  385. enum EBuyableCarLocks {
  386.     ELockType:EBLockType,
  387.     EBLockPrice,
  388. };
  389. new BuyableCarLocks[][EBuyableCarLocks] = {
  390.     {ELockType_Simple,500},
  391.     {ELockType_Remote,1500},
  392.     {ELockType_Advanced,7500},
  393.     {ELockType_Satellite,20000},
  394.     {ELockType_HighTech,40000},
  395.     {ELockType_TitaniumLaser,70000},
  396.     {ELockType_BioMetric, 100000}
  397. };
  398. forward onLoadBusiness();
  399. forward onBusinessUpdate(index);
  400. forward OnGeneratePhoneNumber(playerid);
  401. forward On247ItemBuy(playerid, itemid, biz, total);
  402. forward Generate247PhoneNumber(playerid, itemid, biz, total);
  403. forward OnSexItemBuy(playerid, itemid, biz, total);
  404.  
  405. businessOnGameModeInit() {
  406.     LoadBusinesses();
  407.     for(new i=0;i<sizeof(DriveThrus);i++) {
  408.         CreateDynamicPickup(1239, 16, DriveThrus[i][EGasPumpX],DriveThrus[i][EGasPumpY],DriveThrus[i][EGasPumpZ]);
  409.         CreateDynamic3DTextLabel("(( /drivethru ))", X11_ORANGE,  DriveThrus[i][EGasPumpX],DriveThrus[i][EGasPumpY],DriveThrus[i][EGasPumpZ]+1.0,10.0);
  410.     }
  411. }
  412. LoadBusinesses() {
  413.     query[0] = 0;//[512];
  414.     format(query,sizeof(query),"SELECT `business`.`id`,`name`,`owner`,`c1`.`username`,`extortion`,`c2`.`username`,`EntranceX`,`EntranceY`,`EntranceZ`,`ExitX`,`ExitY`,`ExitZ`,`business`.`interior`,`type`,`value`,`locked`,`entrancefee`,`till`,`products`,`maxproducts` FROM `business` LEFT JOIN `characters` AS `c1` ON `business`.`owner` = `c1`.`id` LEFT JOIN `characters` AS `c2` ON `business`.`extortion` = `c2`.`id`");
  415.     mysql_function_query(g_mysql_handle, query, true, "onLoadBusiness", "");
  416. }
  417. public onLoadBusiness() {
  418.     new data[1728],id_val;
  419.     new Float:f_val;
  420.     new rows,fields;
  421.     cache_get_data(rows,fields);
  422.     printf("Number of businesses: %d\n", rows);
  423.     for(new index=0;index<rows;index++) {
  424.         new i = findFreeBusiness();
  425.         cache_get_row(index, 0, data); //business SQL id
  426.         id_val = strval(data);
  427.         Business[i][EBusinessID] = id_val;
  428.         cache_get_row(index, 1, data); //business name
  429.         format(Business[i][EBusinessName],64,"%s",data);
  430.         cache_get_row(index, 2, data); //owner SQL id
  431.         id_val = strval(data);
  432.         Business[i][EBusinessOwner] = id_val;
  433.         if(Business[i][EBusinessOwner] == 0) {
  434.             format(Business[i][EBusinessOwnerName],MAX_PLAYER_NAME,"No-One");
  435.         } else if(Business[i][EBusinessOwner] == -1) {
  436.             format(Business[i][EBusinessOwnerName],MAX_PLAYER_NAME,"The State");
  437.         } else {
  438.             cache_get_row(index, 3, data); //owner username
  439.             format(Business[i][EBusinessOwnerName],MAX_PLAYER_NAME,"%s",data);
  440.         }
  441.         cache_get_row(index, 4, data); //extortion
  442.         id_val = strval(data);
  443.         Business[i][EBusinessExtortionist] = id_val;
  444.         if(id_val != 0) {
  445.             cache_get_row(index, 5, data); //extortionist username
  446.             format(Business[i][EBusinessExtortionName],MAX_PLAYER_NAME,"%s",data);
  447.         }
  448.         cache_get_row(index, 6, data);
  449.         f_val = floatstr(data);
  450.         Business[i][EBusinessEntranceX] = f_val;
  451.         cache_get_row(index, 7, data);
  452.         f_val = floatstr(data);
  453.         Business[i][EBusinessEntranceY] = f_val;
  454.         cache_get_row(index, 8, data);
  455.         f_val = floatstr(data);
  456.         Business[i][EBusinessEntranceZ] = f_val;
  457.        
  458.  
  459.         cache_get_row(index, 9, data);
  460.         f_val = floatstr(data);
  461.         Business[i][EBusinessExitX] = f_val;
  462.         cache_get_row(index, 10, data);
  463.         f_val = floatstr(data);
  464.         Business[i][EBusinessExitY] = f_val;
  465.         cache_get_row(index, 11, data);
  466.         f_val = floatstr(data);
  467.         Business[i][EBusinessExitZ] = f_val;
  468.         cache_get_row(index, 12, data);
  469.         id_val = strval(data);
  470.         Business[i][EBusinessInterior] = id_val;
  471.         cache_get_row(index, 13, data);
  472.         id_val = strval(data);
  473.         Business[i][EBType] = EBusinessType:id_val;
  474.         cache_get_row(index, 14, data);
  475.         id_val = strval(data);
  476.         Business[i][EBusinessPrice] = id_val;
  477.         cache_get_row(index, 15, data);
  478.         id_val = strval(data);
  479.         Business[i][EBusinessLocked] = id_val;
  480.         Business[i][EBusinessVW] = i+BIZ_VW_OFFSET;
  481.         cache_get_row(index, 16, data);
  482.         id_val = strval(data);
  483.         Business[i][EBusinessEntranceFee] = id_val;
  484.         cache_get_row(index, 17, data);
  485.         id_val = strval(data);
  486.         Business[i][EBusinessTill] = id_val;
  487.        
  488.         cache_get_row(index, 18, data);
  489.         id_val = strval(data);
  490.         Business[i][EBusinessProducts] = id_val;
  491.        
  492.         cache_get_row(index, 19, data);
  493.         id_val = strval(data);
  494.         Business[i][EBusinessMaxProducts] = id_val;
  495.         Business[i][EBusinessPickup] = CreateDynamicPickup(Business[i][EBusinessOwner]>0?1239:1239, 16, Business[i][EBusinessEntranceX], Business[i][EBusinessEntranceY], Business[i][EBusinessEntranceZ]);
  496.         getBiz3DLabelText(i, data, sizeof(data));
  497.         Business[i][EBusinessText] = CreateDynamic3DTextLabel(data, 0xFFFFFFFF, Business[i][EBusinessEntranceX], Business[i][EBusinessEntranceY], Business[i][EBusinessEntranceZ]+1.5,10.0);
  498.         if(!IsDealership(i) && !IsFishStore(i) && !IsCarRental(i))
  499.             Business[i][EBusinessExitPickup] = CreateDynamicPickup(1318, 16, Business[i][EBusinessExitX],Business[i][EBusinessExitY],Business[i][EBusinessExitZ], Business[i][EBusinessVW], Business[i][EBusinessInterior]);
  500.         printf("Loaded business ID %d\n",Business[i][EBusinessID]);
  501.     }
  502.     if(bizinit == 0) {
  503.         sellInactiveBusinesses();
  504.         bizinit = 1;
  505.     }
  506.     printf("Businesses loaded.\n");
  507. }
  508. businessPickupPickup(playerid, pickupid) {
  509.     for(new i=0;i<sizeof(Business);i++) {
  510.         if(Business[i][EBusinessPickup] == pickupid) {
  511.             if(Business[i][EBusinessLocked] == 1) break;
  512.             if(IsDealership(i)) {
  513.                 GameTextForPlayer(playerid, "~g~Dealership~w~~n~Type /buy to buy a vehicle!", 2000, 3);
  514.             } else if(IsFishStore(i)) {
  515.                 GameTextForPlayer(playerid, "~g~Fish Store~w~~n~Type /buy to buy food, and sell fish!", 2000, 3);
  516.             } else if(IsCarRental(i)) {
  517.                 GameTextForPlayer(playerid, "~g~Car Rental~w~~n~Type /buy to rent a vehicle!", 2000, 3);
  518.             }
  519.         }
  520.     }
  521. }
  522. YCMD:bizentrance(playerid, params[], help) {
  523.     if(help) {
  524.         SendClientMessage(playerid, X11_WHITE,"Marks the entrance of a business for creation");
  525.         return 1;
  526.     }
  527.     new Float:X,Float:Y,Float:Z;
  528.     GetPlayerPos(playerid, X, Y, Z);
  529.     SetPVarFloat(playerid,"BizEntranceX", X);
  530.     SetPVarFloat(playerid,"BizEntranceY", Y);
  531.     SetPVarFloat(playerid,"BizEntranceZ", Z);
  532.     SendClientMessage(playerid, COLOR_LIGHTGREEN, "Business entrance Marked!");
  533.     return 1;
  534. }
  535. YCMD:bizexit(playerid, params[], help) {
  536.     if(help) {
  537.         SendClientMessage(playerid, X11_WHITE,"Marks the exit of a business for creation");
  538.         return 1;
  539.     }
  540.     new Float:X,Float:Y,Float:Z;
  541.     GetPlayerPos(playerid, X, Y, Z);
  542.     SetPVarFloat(playerid,"BizExitX", X);
  543.     SetPVarFloat(playerid,"BizExitY", Y);
  544.     SetPVarFloat(playerid,"BizExitZ", Z);
  545.     SetPVarInt(playerid, "BizInterior", GetPlayerInterior(playerid));
  546.     SendClientMessage(playerid, COLOR_LIGHTGREEN, "Business exit Marked!");
  547.     return 1;
  548. }
  549. YCMD:makebiz(playerid, params[], help) {
  550.     if(help) {
  551.         SendClientMessage(playerid, X11_WHITE,"Marks the exit of a business for creation");
  552.         return 1;
  553.     }
  554.     new type,price,level,name[64];
  555.     if (!sscanf(params, "ddds[64]", type,price,level,name))
  556.     {
  557.         SendClientMessage(playerid, COLOR_LIGHTGREEN, "Attempting to create Business.");
  558.     } else {
  559.         SendClientMessage(playerid, X11_WHITE,"USAGE: /makebiz [type] [price] [level] [name]");
  560.         SendClientMessage(playerid, X11_LIGHTBLUE,"Notice: use /bizentrance and /bizexit first!");
  561.         return 1;
  562.     }
  563.     makeBusiness(GetPVarFloat(playerid,"BizEntranceX"),GetPVarFloat(playerid,"BizEntranceY"),GetPVarFloat(playerid,"BizEntranceZ"),GetPVarFloat(playerid,"BizExitX"),GetPVarFloat(playerid,"BizExitY"),GetPVarFloat(playerid,"BizExitZ"), GetPVarInt(playerid,"BizInterior"),EBusinessType:type,price,level,name);
  564.     return 1;
  565. }
  566. YCMD:movebizexit(playerid, params[], help) {
  567.    
  568. }
  569. YCMD:reloadbusiness(playerid, params[], help) {
  570.     if(help) {
  571.         SendClientMessage(playerid, X11_WHITE,"Marks the exit of a business for creation");
  572.         return 1;
  573.     }
  574.     new id;
  575.     if (!sscanf(params, "d", id))
  576.     {
  577.         SendClientMessage(playerid, COLOR_LIGHTGREEN, "Reloading business");
  578.         for(new i=0;i<sizeof(Business);i++) {
  579.             if(Business[i][EBusinessID] == id) {
  580.                 reloadBusiness(i);
  581.                 return 1;
  582.             }
  583.         }
  584.         SendClientMessage(playerid, X11_WHITE, "Failed to reload business");
  585.     } else {
  586.         SendClientMessage(playerid, X11_WHITE,"USAGE: /reloadbusiness [sqlid]");
  587.     }
  588.     return 1;
  589. }
  590.  
  591. GetNumOwnedBusinesses(playerid) {
  592.     new num;
  593.     for(new i=0;i<sizeof(Business);i++) {
  594.         if(Business[i][EBusinessOwner] == GetPVarInt(playerid, "CharID")) {
  595.             num++;
  596.         }
  597.     }
  598.     return num;
  599. }
  600. YCMD:buybiz(playerid, params[], help) {
  601.     new index = getStandingBusiness(playerid);
  602.     if(index == -1) {
  603.         SendClientMessage(playerid, X11_WHITE, "You must be standing at a business");
  604.         return 1;
  605.     }
  606.     new num = GetNumOwnedBusinesses(playerid);
  607.     if(num >= GetPVarInt(playerid, "MaxBusinesses")) {
  608.         SendClientMessage(playerid, X11_TOMATO_2, "You cannot own any more businesses!");
  609.         return 1;
  610.     }
  611.     if(Business[index][EBusinessOwner] != 0) {
  612.         SendClientMessage(playerid, X11_WHITE, "This business is already owned");
  613.         return 1;
  614.     }
  615.     if(GetPVarInt(playerid,"Level") < Business[index][EBusinessLevel]) {
  616.         SendClientMessage(playerid, X11_WHITE, "You are not a high enough level to buy this.");
  617.         return 1;
  618.     }
  619.     if(GetMoneyEx(playerid) < Business[index][EBusinessPrice]) {
  620.         SendClientMessage(playerid, X11_WHITE, "You do not have enough money.");
  621.         return 1;
  622.     }
  623.     GiveMoneyEx(playerid, -Business[index][EBusinessPrice]);
  624.     setBusinessOwner(index, GetPVarInt(playerid, "CharID"));
  625.     SendClientMessage(playerid, X11_GREEN, "Congratulations on your purchase.");
  626.     return 1;
  627. }
  628. YCMD:extortion(playerid, params[], help) {
  629.     new index = getStandingBusiness(playerid);
  630.     if(index == -1) {
  631.         SendClientMessage(playerid, X11_WHITE, "You must be standing at a business");
  632.         return 1;
  633.     }
  634.     if((Business[index][EBusinessOwner] != GetPVarInt(playerid,"CharID") && !isBizAdmin(playerid)) || Business[index][EBusinessOwner] == 0) {
  635.         SendClientMessage(playerid, X11_WHITE, "You don't own this business.");
  636.         return 1;
  637.     }
  638.     new user, msg[128];
  639.     if(!sscanf(params, "k<playerLookup>", user)) {
  640.         if(!IsPlayerConnectEx(user)) {
  641.             SendClientMessage(playerid, X11_TOMATO_2, "User not found!");
  642.             return 1;
  643.         }
  644.         setExtortionist(index, GetPVarInt(user, "CharID"));
  645.         format(msg, sizeof(msg), "* You have been made the extortionist of %s.",Business[index][EBusinessName]);
  646.         SendClientMessage(user, COLOR_LIGHTGREEN, msg);
  647.         format(msg, sizeof(msg), "* You have made %s the extortionist of %s.",GetPlayerNameEx(playerid, ENameType_RPName_NoMask),Business[index][EBusinessName]);
  648.         SendClientMessage(playerid, COLOR_LIGHTGREEN, msg);
  649.     } else {
  650.         SendClientMessage(playerid, COLOR_LIGHTGREEN, "* Extortionist Removed");
  651.         setExtortionist(index, 0);
  652.     }
  653.     return 1;
  654. }
  655. YCMD:sellbiz(playerid, params[], help) {
  656.     new index = getStandingBusiness(playerid);
  657.     if(index == -1) {
  658.         SendClientMessage(playerid, X11_WHITE, "You must be standing at a business");
  659.         return 1;
  660.     }
  661.     if(!isBizAdmin(playerid) && Business[index][EBusinessOwner] != GetPVarInt(playerid,"CharID") || Business[index][EBusinessOwner] == 0) {
  662.         SendClientMessage(playerid, X11_WHITE, "You don't own this business.");
  663.         return 1;
  664.     }
  665.     GiveMoneyEx(playerid, floatround(Business[index][EBusinessPrice]*0.8));
  666.     setBusinessOwner(index, 0);
  667.     SendClientMessage(playerid, X11_GREEN, "You have sold your business!");
  668.     return 1;
  669. }
  670. isBizAdmin(playerid) {
  671.     if(EAdminFlags:GetPVarInt(playerid, "AdminFlags") & EAdminFlags_BusinessAdmin) {
  672.         return 1;
  673.     }
  674.     return 0;
  675. }
  676. YCMD:bizfee(playerid, params[], help) {
  677.     new index = getStandingBusiness(playerid);
  678.     if(help) {
  679.         SendClientMessage(playerid, X11_WHITE, "Set a business fee");
  680.         return 1;
  681.     }
  682.     if(index == -1) {
  683.         SendClientMessage(playerid, X11_WHITE, "You must be standing at a business");
  684.         return 1;
  685.     }
  686.     if(!isBizAdmin(playerid) && Business[index][EBusinessOwner] != GetPVarInt(playerid,"CharID")) {
  687.         SendClientMessage(playerid, X11_WHITE, "You don't own this business.");
  688.         return 1;
  689.     }
  690.     new fee;
  691.     if (!sscanf(params, "d", fee))
  692.     {
  693.         if(fee < 0 || fee > 5) {
  694.             SendClientMessage(playerid, X11_RED2,"Fee must be above $0 and below $5");
  695.             return 1;
  696.         }
  697.         setBusinessFee(index, fee);
  698.         SendClientMessage(playerid, X11_GREEN, "Fee updated");
  699.     } else {
  700.         SendClientMessage(playerid, X11_WHITE,"USAGE: /bizfee [fee]");
  701.     }
  702.     return 1;
  703. }
  704. YCMD:bizname(playerid, params[], help) {
  705.     if(help) {
  706.         SendClientMessage(playerid, X11_WHITE, "Set a business name");
  707.         return 1;
  708.     }
  709.     new index = getStandingBusiness(playerid);
  710.     if(index == -1) {
  711.         SendClientMessage(playerid, X11_WHITE, "You must be standing at a business.");
  712.         return 1;
  713.     }
  714.     if(!isBizAdmin(playerid) && Business[index][EBusinessOwner] != GetPVarInt(playerid,"CharID")) {
  715.         SendClientMessage(playerid, X11_WHITE, "You don't own this business.");
  716.         return 1;
  717.     }
  718.     new name[64];
  719.     if(!sscanf(params, "s[64]",name)) {
  720.         setBusinessName(index, name);
  721.         SendClientMessage(playerid, COLOR_LIGHTGREEN, "* Name Set!");
  722.     } else {
  723.         SendClientMessage(playerid, X11_WHITE, "USAGE: /bizname [name]");
  724.     }
  725.     return 1;
  726. }
  727. YCMD:open(playerid, params[], help) {
  728.     new index = getStandingBusiness(playerid);
  729.     if(index == -1) {
  730.         SendClientMessage(playerid, X11_WHITE, "You must be standing at a business.");
  731.         return 1;
  732.     }
  733.     if(!isBizAdmin(playerid) && Business[index][EBusinessOwner] != GetPVarInt(playerid,"CharID")) {
  734.         SendClientMessage(playerid, X11_WHITE, "You don't own this business.");
  735.         return 1;
  736.     }
  737.     if(Business[index][EBusinessLocked] == 1) {
  738.         Business[index][EBusinessLocked] = 0;
  739.         GameTextForPlayer(playerid, "~w~Business ~g~Open", 5000, 6);
  740.         PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
  741.     } else {
  742.         Business[index][EBusinessLocked] = 1;
  743.         GameTextForPlayer(playerid, "~w~Business ~r~Closed", 5000, 6);
  744.         PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
  745.     }
  746.     query[0] = 0;//[128];
  747.     format(query,sizeof(query),"UPDATE `business` SET `locked` = %d WHERE `id` = %d", Business[index][EBusinessLocked], Business[index][EBusinessID]);
  748.     mysql_function_query(g_mysql_handle, query, true, "onBusinessUpdate", "d",index);
  749.     return 1;
  750. }
  751. YCMD:drivethru(playerid, params[], help) {
  752.     if(help) {
  753.         SendClientMessage(playerid, X11_WHITE, "Buy food from a drive thru");
  754.         return 1;
  755.     }
  756.     new carid = GetPlayerVehicleID(playerid);
  757.     if(carid == 0) {
  758.         SendClientMessage(playerid, X11_RED2, "You must be in a vehicle.");
  759.         return 1;
  760.     }
  761.     new found = 0;
  762.     for(new i=0;i<sizeof(DriveThrus);i++) {
  763.         if(IsPlayerInRangeOfPoint(playerid, 20.0, DriveThrus[i][EGasPumpX], DriveThrus[i][EGasPumpY], DriveThrus[i][EGasPumpZ])) {
  764.             found = 1;
  765.         }
  766.     }
  767.     if(!found) {
  768.         SendClientMessage(playerid, X11_RED2, "You must be at a drive thru");
  769.         return 1;
  770.     }
  771.     new bizid = getStandingBusiness(playerid, 55.0);
  772.     if(bizid == -1) {
  773.         SendClientMessage(playerid, X11_RED2, "Error: Associated business not found, contact an admin.");
  774.         return 1;
  775.     }
  776.     if(Business[bizid][EBusinessLocked] == 1 || Business[bizid][EBusinessOwner] == 0) {
  777.         SendClientMessage(playerid, X11_RED2, "* Sorry, we are closed!");
  778.         return 1;
  779.     }
  780.     showFastFoodMenu(playerid, bizid);
  781.     return 1;
  782. }
  783. YCMD:fuel(playerid, params[], help) {
  784.     if(help) {
  785.         SendClientMessage(playerid, X11_WHITE, "Fuels a players cars");
  786.         return 1;
  787.     }
  788.     new carid = GetPlayerVehicleID(playerid);
  789.     if(carid == 0) {
  790.         new Float:X, Float:Y, Float:Z, foundcar = 1;
  791.         carid = GetClosestVehicle(playerid);
  792.         GetVehiclePos(carid, X, Y, Z);
  793.         if(carid == -1 || !IsPlayerInRangeOfPoint(playerid, 8.0,X,Y,Z)){
  794.             //SendClientMessage(playerid, X11_TOMATO_2, "You are not close enough to any vehicle!");
  795.             //return 1;
  796.             foundcar = 0;
  797.         }
  798.         new numcans = GetPVarInt(playerid, "GasCans");
  799.         if(numcans > 0 && foundcar) {
  800.             if(VehicleInfo[carid][EVEngine] == 1) {
  801.                 SendClientMessage(playerid, X11_RED2, "You can't fuel a car while it is running!");
  802.                 return 1;
  803.             }
  804.             new curfuel = VehicleInfo[carid][EVFuel];
  805.             format(tempstr, sizeof(tempstr), "* %s fuels the vehicle.", GetPlayerNameEx(playerid, ENameType_RPName));
  806.             ProxMessage(30.0, playerid, tempstr, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  807.             curfuel += 15;
  808.             if(curfuel > 100) {
  809.                 curfuel = 100;             
  810.                 format(tempstr, sizeof(tempstr), "* Some fuel spills down the side.", GetPlayerNameEx(playerid, ENameType_RPName));
  811.                 ProxMessage(30.0, playerid, tempstr, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  812.             }
  813.             VehicleInfo[carid][EVFuel] = curfuel;
  814.             CheckGas();
  815.             SetPVarInt(playerid, "GasCans", --numcans);
  816.             return 1;
  817.         }
  818.         SendClientMessage(playerid, X11_RED2, "You must be in a vehicle.");
  819.         return 1;
  820.     }
  821.     if(VehicleInfo[carid][EVEngine] == 1) {
  822.         SendClientMessage(playerid, X11_RED2, "You can't fuel your car while it is running!");
  823.         return 1;
  824.     }
  825.     new found = 0;
  826.     for(new i=0;i<sizeof(GasPumps);i++) {
  827.         if(IsPlayerInRangeOfPoint(playerid, 20.0, GasPumps[i][EGasPumpX], GasPumps[i][EGasPumpY], GasPumps[i][EGasPumpZ])) {
  828.             found = 1;
  829.         }
  830.     }
  831.     if(!found) {
  832.         SendClientMessage(playerid, X11_RED2, "You must be at a gas pump");
  833.         return 1;
  834.     }
  835.     new bizid = getStandingBusiness(playerid, 35.0);
  836.     if(bizid == -1) {
  837.         SendClientMessage(playerid, X11_RED2, "Error: Associated business not found, contact an admin.");
  838.         return 1;
  839.     }
  840.     if(Business[bizid][EBusinessLocked] == 1 || Business[bizid][EBusinessOwner] == 0) {
  841.         SendClientMessage(playerid, X11_RED2, "* Sorry, we are closed!");
  842.         return 1;
  843.     }
  844.     format(tempstr, sizeof(tempstr), "* %s fuels the vehicle.", GetPlayerNameEx(playerid, ENameType_RPName));
  845.     ProxMessage(30.0, playerid, tempstr, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  846.     GameTextForPlayer(playerid,"~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~Re-Fueling Vehicle, please wait",2000,3);
  847.     new RefuelWait = GasMax - VehicleInfo[carid][EVFuel];
  848.     RefuelWait = (RefuelWait*100);
  849.     SetTimerEx("FuelCar", RefuelWait, 0, "ddd", playerid, carid,bizid);
  850.     return 1;
  851. }
  852. forward FuelCar(playerid, carid, business);
  853. public FuelCar(playerid, carid, business) {
  854.     new toadd = GasMax - VehicleInfo[carid][EVFuel];
  855.     new price = toadd;
  856.     if(VehicleInfo[carid][EVEngine] == 1) {
  857.         SendClientMessage(playerid, X11_RED2, "Engine is running, cannot fuel vehicle");
  858.         return 1;
  859.     }
  860.     if(GetMoneyEx(playerid) < price) {
  861.         SendClientMessage(playerid, X11_RED2, "You do not have enough money to fill the vehicle");
  862.         return 1;
  863.     }
  864.     /*
  865.     if(Business[business][EBusinessProducts] < toadd) {
  866.         SendClientMessage(playerid, X11_RED2, "* Sorry, we are out of fuel!");
  867.         return 1;
  868.     }
  869.     */
  870.     format(tempstr,sizeof(tempstr),"Vehicle filled up for: $%s",getNumberString(price));
  871.     SendClientMessage(playerid, COLOR_LIGHTGREEN, tempstr);
  872.     VehicleInfo[carid][EVFuel] += toadd;
  873.     addToBusinessProducts(business, -toadd);
  874.     addToBusinessTill(business, floatround(price/2));
  875.     CheckGas();
  876.     return 1;
  877. }
  878. YCMD:buy(playerid, params[], help) {
  879.     if(help) {
  880.         SendClientMessage(playerid, X11_WHITE, "Used to buy things from a business");
  881.         return 1;
  882.     }
  883.     new i, foundentrance,foundexit;
  884.     i = getBusinessInside(playerid);
  885.     if(i == -1) {
  886.         i = getStandingBusiness(playerid, 15.0);
  887.         if(i == -1) {
  888.             new ibiz = getIBizInside(playerid);
  889.             if(ibiz == -1) {
  890.             SendClientMessage(playerid, X11_WHITE, "Couldn't find a business");
  891.             return 1;
  892.             } else {
  893.                 showIBizMenu(playerid, ibiz);
  894.                 return 1;
  895.             }
  896.         } else {
  897.             foundentrance = 1;
  898.         }
  899.     } else {
  900.         foundexit = 1;
  901.     }
  902.     if(Business[i][EBusinessLocked] == 1 || Business[i][EBusinessOwner] == 0) {
  903.         SendClientMessage(playerid, X11_TOMATO_2, "This business is closed!");
  904.         return 1;
  905.     }
  906.     SetPVarInt(playerid, "BuyingBiz", i);
  907.     if(IsDealership(i) && foundentrance) {
  908.         showDealershipMenu(playerid, i);
  909.     } else if(Business[i][EBType] == EBusinessType_247 && foundexit) {
  910.         show247Menu(playerid, i);
  911.     } else if(Business[i][EBType] == EBusinessType_SexShop && foundexit) {
  912.         showSexShopMenu(playerid, i);
  913.     } else if(Business[i][EBType] == EBusinessType_Restaurant && foundexit) {
  914.         showRestaurantMenu(playerid, i);
  915.     } else if(Business[i][EBType] == EBusinessType_PizzaStack && foundexit) {
  916.         showFastFoodMenu(playerid, i);
  917.     } else if(Business[i][EBType] == EBusinessType_Ammunation && foundexit) {
  918.         showAmmunationMenu(playerid, i);
  919.     } else if(Business[i][EBType] == EBusinessType_FishStore && foundentrance) {
  920.         showFishStoreMenu(playerid, i);
  921.     } else if(IsCarRental(i) &&  foundentrance) {
  922.         showRentalMenu(playerid, i);
  923.     }
  924.     return 1;
  925. }
  926. sendMessageToBusinesses(playerid, Float:radi = 30.0, msg[], color) {
  927.     for(new i=0;i<sizeof(Business);i++) {
  928.         if(IsPlayerInRangeOfPoint(playerid, radi, Business[i][EBusinessEntranceX],Business[i][EBusinessEntranceY],Business[i][EBusinessEntranceZ])) {
  929.             SendAreaMessage(radi, Business[i][EBusinessExitX],Business[i][EBusinessExitY],Business[i][EBusinessExitZ], Business[i][EBusinessVW], msg, color);
  930.         } else if(IsPlayerInRangeOfPoint(playerid, radi, Business[i][EBusinessExitX],Business[i][EBusinessExitY],Business[i][EBusinessExitZ])) {
  931.             SendAreaMessage(radi, Business[i][EBusinessEntranceX],Business[i][EBusinessEntranceY],Business[i][EBusinessEntranceZ], 0, msg, color);
  932.         }
  933.     }
  934.     return 1;
  935. }
  936. show247Menu(playerid, bizid) {
  937.     #pragma unused bizid
  938.     dialogstr[0] = 0;
  939.     for(new i=0;i<sizeof(Buyable24Items);i++) {
  940.         if(Buyable24Items[i][EBIType] == EType_Item) {
  941.             format(tempstr,sizeof(tempstr),"%s - $%s\n",Buyable24Items[i][EBIDisplayName],getNumberString(Buyable24Items[i][EBIPrice]));
  942.         }else if(Buyable24Items[i][EBIType] == EType_NumSelect) {
  943.             format(tempstr,sizeof(tempstr),"%s - $%s/each\n",Buyable24Items[i][EBIDisplayName],getNumberString(Buyable24Items[i][EBIPrice]));
  944.         } else {
  945.             format(tempstr,sizeof(tempstr),"%s\n",Buyable24Items[i][EBIDisplayName]);
  946.         }
  947.         strcat(dialogstr,tempstr,sizeof(dialogstr));
  948.     }
  949.     ShowPlayerDialog(playerid, _:EBusiness_247BuyMenu, DIALOG_STYLE_LIST, "24/7 Buy Menu",dialogstr,"Select", "Quit");
  950.     return 1;
  951. }
  952. showSexShopMenu(playerid, bizid) {
  953.     #pragma unused bizid
  954.     dialogstr[0] = 0;
  955.     for(new i=0;i<sizeof(BuyableSexItems);i++) {
  956.         if(BuyableSexItems[i][EBIType] == EType_Item) {
  957.             format(tempstr,sizeof(tempstr),"%s        $%s\n",BuyableSexItems[i][EBIDisplayName],getNumberString(BuyableSexItems[i][EBIPrice]));
  958.         }else if(BuyableSexItems[i][EBIType] == EType_NumSelect) {
  959.             format(tempstr,sizeof(tempstr),"%s        $%s/each\n",BuyableSexItems[i][EBIDisplayName],getNumberString(BuyableSexItems[i][EBIPrice]));
  960.         } else {
  961.             format(tempstr,sizeof(tempstr),"%s",BuyableSexItems[i][EBIDisplayName]);
  962.         }
  963.         strcat(dialogstr,tempstr,sizeof(dialogstr));
  964.     }
  965.     ShowPlayerDialog(playerid, _:EBusiness_SexBuyMenu, DIALOG_STYLE_LIST, "Sex Shop Buy Menu",dialogstr,"Select", "Quit");
  966.     return 1;
  967. }
  968. showRestaurantMenu(playerid, bizid) {
  969.     #pragma unused bizid
  970.     dialogstr[0] = 0;
  971.     for(new i=0;i<sizeof(BuyableRestaurantItems);i++) {
  972.         if(BuyableRestaurantItems[i][EBIType] == EType_Item) {
  973.             format(tempstr,sizeof(tempstr),"%s        $%s\n",BuyableRestaurantItems[i][EBIDisplayName],getNumberString(BuyableRestaurantItems[i][EBIPrice]));
  974.         }else if(BuyableRestaurantItems[i][EBIType] == EType_NumSelect) {
  975.             format(tempstr,sizeof(tempstr),"%s        $%s/each\n",BuyableRestaurantItems[i][EBIDisplayName],getNumberString(BuyableRestaurantItems[i][EBIPrice]));
  976.         } else {
  977.             format(tempstr,sizeof(tempstr),"%s",BuyableRestaurantItems[i][EBIDisplayName]);
  978.         }
  979.         strcat(dialogstr,tempstr,sizeof(dialogstr));
  980.     }
  981.     ShowPlayerDialog(playerid, _:EBusiness_RestaurantMenu, DIALOG_STYLE_LIST, "Restaurant Buy Menu",dialogstr,"Select", "Quit");
  982.     return 1;
  983. }
  984. showFastFoodMenu(playerid, bizid) {
  985.     dialogstr[0] = 0;
  986.     for(new i=0;i<sizeof(BuyableFastfoodItems);i++) {
  987.         if(BuyableFastfoodItems[i][EBIType] == EType_Item) {
  988.             format(tempstr,sizeof(tempstr),"%s        $%s\n",BuyableFastfoodItems[i][EBIDisplayName],getNumberString(BuyableFastfoodItems[i][EBIPrice]));
  989.         }else if(BuyableFastfoodItems[i][EBIType] == EType_NumSelect) {
  990.             format(tempstr,sizeof(tempstr),"%s        $%s/each\n",BuyableFastfoodItems[i][EBIDisplayName],getNumberString(BuyableFastfoodItems[i][EBIPrice]));
  991.         } else {
  992.             format(tempstr,sizeof(tempstr),"%s",BuyableFastfoodItems[i][EBIDisplayName]);
  993.         }
  994.         strcat(dialogstr,tempstr,sizeof(dialogstr));
  995.     }
  996.     SetPVarInt(playerid, "BuyingBiz", bizid);
  997.     ShowPlayerDialog(playerid, _:EBusiness_FastFoodMenu, DIALOG_STYLE_LIST, "Fast Food Buy Menu",dialogstr,"Select", "Quit");
  998.     return 1;
  999. }
  1000. showFishStoreMenu(playerid, bizid) {
  1001.     #pragma unused bizid
  1002.     dialogstr[0] = 0;
  1003.     for(new i=0;i<sizeof(BuyableFishStoreItems);i++) {
  1004.         if(BuyableFishStoreItems[i][EBIType] == EType_Item) {
  1005.             format(tempstr,sizeof(tempstr),"%s        $%s\n",BuyableFishStoreItems[i][EBIDisplayName],getNumberString(BuyableFishStoreItems[i][EBIPrice]));
  1006.         }else if(BuyableFishStoreItems[i][EBIType] == EType_NumSelect) {
  1007.             format(tempstr,sizeof(tempstr),"%s        $%s/each\n",BuyableFishStoreItems[i][EBIDisplayName],getNumberString(BuyableFishStoreItems[i][EBIPrice]));
  1008.         } else {
  1009.             format(tempstr,sizeof(tempstr),"%s",BuyableFishStoreItems[i][EBIDisplayName]);
  1010.         }
  1011.         strcat(dialogstr,tempstr,sizeof(dialogstr));
  1012.     }
  1013.     ShowPlayerDialog(playerid, _:EBusiness_FishStoreMenu, DIALOG_STYLE_LIST, "Fast Food Buy Menu",dialogstr,"Select", "Quit");
  1014. }
  1015. showRentalMenu(playerid, bizid) {
  1016.     dialogstr[0] = 0;
  1017.     tempstr[0] = 0;
  1018.     for(new i=0;i<sizeof(RentableCars);i++) {
  1019.         format(tempstr, sizeof(tempstr), "%s        $%s/hour\n", VehiclesName[RentableCars[i][ECarRental_ModelID]-400], getNumberString(RentableCars[i][ECarRental_HourlyRate]));
  1020.         strcat(dialogstr,tempstr,sizeof(dialogstr));
  1021.     }
  1022.     new model;
  1023.     for(new i=0;i<MAX_VEHICLES;i++) {
  1024.         if(VehicleInfo[i][EVType] == EVehicleType_RentCar) {
  1025.             if(VehicleInfo[i][EVOwner] == playerid) {
  1026.                 model = GetVehicleModel(i);
  1027.                 format(tempstr, sizeof(tempstr), "Return %s\n", VehiclesName[model-400]);
  1028.                 strcat(dialogstr,tempstr,sizeof(dialogstr));
  1029.             }
  1030.         }
  1031.     }
  1032.     ShowPlayerDialog(playerid, _:EBusiness_RentalMenu, DIALOG_STYLE_LIST, "Vehicle Rental Menu",dialogstr,"Select", "Cancel");
  1033.     SetPVarInt(playerid, "BuyingBiz", bizid);
  1034. }
  1035. showAmmunationMenu(playerid, bizid) {
  1036.     #pragma unused bizid
  1037.     dialogstr[0] = 0;
  1038.     new gunname[32];
  1039.     for(new i=0;i<sizeof(BuyableAmmunationGuns);i++) {
  1040.         if(BuyableAmmunationGuns[i][EBuyableGunType] == 0) {
  1041.             GetWeaponNameEx(BuyableAmmunationGuns[i][EBuyableGunID],gunname, sizeof(gunname));
  1042.             format(tempstr,sizeof(tempstr),"%s - $%s\n",gunname,getNumberString(BuyableAmmunationGuns[i][EBuyableGunPrice]));
  1043.         } else if(BuyableAmmunationGuns[i][EBuyableGunType] == 1) {
  1044.             format(tempstr,sizeof(tempstr),"+%d Armour - $%s\n",BuyableAmmunationGuns[i][EBuyableGunID],getNumberString(BuyableAmmunationGuns[i][EBuyableGunPrice]));
  1045.         } else if(BuyableAmmunationGuns[i][EBuyableGunType] == 2) {
  1046.             format(tempstr,sizeof(tempstr),"+%d Health - $%s\n",BuyableAmmunationGuns[i][EBuyableGunID],getNumberString(BuyableAmmunationGuns[i][EBuyableGunPrice]));
  1047.         }else if(BuyableAmmunationGuns[i][EBuyableGunType] == 3) {
  1048.             format(tempstr,sizeof(tempstr),"%s - $%s\n", GetCarryingItemName(BuyableAmmunationGuns[i][EBuyableGunID]) ,getNumberString(BuyableAmmunationGuns[i][EBuyableGunPrice]));
  1049.         }
  1050.         strcat(dialogstr,tempstr,sizeof(dialogstr));
  1051.     }
  1052.     ShowPlayerDialog(playerid, EBusiness_AmmunationMenu, DIALOG_STYLE_LIST, "Ammunation Buy Menu",dialogstr,"Buy", "Quit");
  1053.     return 1;
  1054. }
  1055. businessTryEnter(playerid) {
  1056.     for(new i=0;i<MAX_BUSINESS;i++) {
  1057.         if(Business[i][EBusinessID] != 0) {
  1058.             if(IsPlayerInRangeOfPoint(playerid,1.5,Business[i][EBusinessEntranceX], Business[i][EBusinessEntranceY], Business[i][EBusinessEntranceZ])) {
  1059.                 enterBiz(playerid, i);
  1060.             } else if(IsPlayerInRangeOfPoint(playerid,1.5,Business[i][EBusinessExitX],Business[i][EBusinessExitY],Business[i][EBusinessExitZ])) {
  1061.                 if(GetPlayerVirtualWorld(playerid) == Business[i][EBusinessVW]) {
  1062.                     exitBiz(playerid, i);
  1063.                 }
  1064.             }
  1065.         }
  1066.     }
  1067. }
  1068. enterBiz(playerid, index) {
  1069.     if((Business[index][EBusinessLocked] == 1 && Business[index][EBusinessOwner] != GetPVarInt(playerid,"CharID")) || Business[index][EBusinessOwner] == 0 || IsDealership(index) || IsFishStore(index) || IsCarRental(index)) {
  1070.         GameTextForPlayer(playerid, "~r~Locked", 2000, 1);
  1071.         return 1;
  1072.     }
  1073.     if(Business[index][EBusinessEntranceFee] != 0) {
  1074.         if(GetMoneyEx(playerid) < Business[index][EBusinessEntranceFee]) {
  1075.             SendClientMessage(playerid, X11_RED2, "You don't have enough money to enter.");
  1076.             return 1;
  1077.         } else {
  1078.             GiveMoneyEx(playerid, -Business[index][EBusinessEntranceFee]);
  1079.             format(tempstr, sizeof(tempstr), "~y~%s~n~~r~-$%s", Business[index][EBusinessName], getNumberString(Business[index][EBusinessEntranceFee]));
  1080.             GameTextForPlayer(playerid, tempstr, 2000, 3);
  1081.             bizIncome(index, Business[index][EBusinessEntranceFee]/2);
  1082.         }
  1083.     }
  1084.     if(Business[index][EBType] == EBusinessType_PaintBall) {
  1085.         SetPlayerVirtualWorld(playerid, Business[index][EBusinessVW]);
  1086.         putPlayerInPaintball(playerid);
  1087.         return 1;
  1088.     } else if(Business[index][EBType] == EBusinessType_RaceTrack) {
  1089.         SetPlayerVirtualWorld(playerid, Business[index][EBusinessVW]);
  1090.         putPlayerInRacing(playerid);
  1091.     }
  1092.     if(Business[index][EBusinessExitX] != 0 || Business[index][EBusinessExitY] != 0 || Business[index][EBusinessExitZ] != 0) {
  1093.         SetPlayerPos(playerid,Business[index][EBusinessExitX],Business[index][EBusinessExitY],Business[index][EBusinessExitZ]);
  1094.         SetPlayerInterior(playerid, Business[index][EBusinessInterior]);
  1095.         SetPlayerVirtualWorld(playerid, Business[index][EBusinessVW]);
  1096.     }
  1097.     showBusinessHelp(playerid, Business[index][EBType]);
  1098.     return 0;
  1099. }
  1100. exitBiz(playerid, index) {
  1101.     if(IsDealership(index) || IsFishStore(index)) {
  1102.         return 0;
  1103.     }
  1104.     SetPlayerPos(playerid,Business[index][EBusinessEntranceX],Business[index][EBusinessEntranceY],Business[index][EBusinessEntranceZ]);
  1105.     SetPlayerInterior(playerid, 0);
  1106.     SetPlayerVirtualWorld(playerid, 0);
  1107.     return 1;
  1108. }
  1109. bizIncome(index, price) {
  1110.     Business[index][EBusinessTill] += price;
  1111.     query[0] = 0;//[128];
  1112.     format(query,sizeof(query),"UPDATE `business` SET `till` = %d WHERE `id` = %d",Business[index][EBusinessTill],Business[index][EBusinessID]);
  1113.     mysql_function_query(g_mysql_handle, query, true, "EmptyCallback", "");
  1114. }
  1115. forward OnBusinessCreate(Float:X,Float:Y,Float:Z,Float:EX,Float:EY,Float:EZ,interior, EBusinessType:type, price, level,name[]);
  1116. public OnBusinessCreate(Float:X,Float:Y,Float:Z,Float:EX,Float:EY,Float:EZ,interior, EBusinessType:type, price, level,name[]) {
  1117.     new id = mysql_insert_id();
  1118.     new index = findFreeBusiness();
  1119.     new data[128];
  1120.     if(index == -1) {
  1121.             ABroadcast(X11_RED,"[AdmWarn]: Failed to create business. Business array is full.",EAdminFlags_BasicAdmin);
  1122.             return 0;
  1123.     }
  1124.     Business[index][EBusinessID] = id;
  1125.     format(Business[index][EBusinessName],64,"%s",name);
  1126.     Business[index][EBusinessEntranceX] = X;
  1127.     Business[index][EBusinessEntranceY] = Y;
  1128.     Business[index][EBusinessEntranceZ] = Z;
  1129.     Business[index][EBusinessExitX] = EX;
  1130.     Business[index][EBusinessExitY] = EY;
  1131.     Business[index][EBusinessExitZ] = EZ;
  1132.     Business[index][EBusinessInterior] = interior;
  1133.     Business[index][EBType] = EBusinessType:type;
  1134.     Business[index][EBusinessVW] = index+BIZ_VW_OFFSET;
  1135.     Business[index][EBusinessExtortionName][0] = 0;
  1136.     Business[index][EBusinessExtortionist] = 0;
  1137.     Business[index][EBusinessPrice] = price;
  1138.     Business[index][EBusinessPickup] = CreateDynamicPickup(1273, 16, Business[index][EBusinessEntranceX], Business[index][EBusinessEntranceY], Business[index][EBusinessEntranceZ]);
  1139.     if(Business[index][EBusinessExitX] != 0)
  1140.         Business[index][EBusinessExitPickup] = CreateDynamicPickup(1318, 16, Business[index][EBusinessExitX],Business[index][EBusinessExitY],Business[index][EBusinessExitZ], Business[index][EBusinessVW], Business[index][EBusinessInterior]);
  1141.     getBiz3DLabelText(index, data, sizeof(data));
  1142.     Business[index][EBusinessText] = CreateDynamic3DTextLabel(data, X11_ORANGE, Business[index][EBusinessEntranceX], Business[index][EBusinessEntranceY], Business[index][EBusinessEntranceZ]+1.5,10.0);
  1143.     format(data,sizeof(data),"[AdmNotice]: Business ID: %d",id);
  1144.     ABroadcast(X11_RED,data,EAdminFlags_BasicAdmin);
  1145.     return 1;
  1146. }
  1147. findFreeBusiness() {
  1148.     for(new i=0;i<sizeof(Business);i++) {
  1149.         if(Business[i][EBusinessID] == 0) {
  1150.             return i;
  1151.         }
  1152.     }
  1153.     return -1;
  1154. }
  1155. makeBusiness(Float:X,Float:Y,Float:Z,Float:EX,Float:EY,Float:EZ,interior, EBusinessType:type, price, level,name[]) {
  1156.     query[0] = 0;
  1157.     mysql_real_escape_string(name,tempstr,g_mysql_handle);
  1158.     format(query,sizeof(query),"INSERT INTO `business` (`EntranceX`,`EntranceY`,`EntranceZ`,`ExitX`,`ExitY`,`ExitZ`,`interior`,`type`,`value`,`level`,`name`) VALUES (%f,%f,%f,%f,%f,%f,%d,%d,%d,%d,\"%s\")",
  1159.     X,Y,Z,EX,EY,EZ,interior,_:type,price,level,tempstr);
  1160.     mysql_function_query(g_mysql_handle, query, true, "OnBusinessCreate", "ffffffdddds",X,Y,Z,EX,EY,EZ,interior,_:type,price,level,name);
  1161. }
  1162. getBiz3DLabelText(index, dst[], len) {
  1163.     if(Business[index][EBusinessOwner] == 0) {
  1164.         format(dst, len, "{FFFFFF}$$ For Sale $$\n$%s\n\n{FF0000}%s",getNumberString(Business[index][EBusinessPrice]), Business[index][EBusinessName]);
  1165.     } else {
  1166.         new openmsg[532];
  1167.         if(Business[index][EBusinessLocked] == 0) {
  1168.             format(openmsg,sizeof(openmsg),"{00FF00}OPEN");
  1169.         } else {
  1170.             format(openmsg,sizeof(openmsg),"{FF0000}CLOSED");
  1171.         }
  1172.         new ext[532];
  1173.         if(Business[index][EBusinessExtortionist] != 0) {
  1174.             format(ext, sizeof(ext), "\n{FFFFFF}Extortion: {FF0000}%s",Business[index][EBusinessExtortionName]);
  1175.         } else ext[0] = 0;
  1176.         new fee[532];
  1177.         if(Business[index][EBusinessEntranceFee] != 0) {
  1178.             format(fee, sizeof(fee), "\n{FFFFFF}Entrance Fee: {FF0000}$%s",getNumberString(Business[index][EBusinessEntranceFee]));
  1179.         } else fee[0] = 0;
  1180.         format(dst, len, "%s\n\n{FF0000}%s%s\n{FFFFFF}Owner: {FF0000}%s%s", openmsg, Business[index][EBusinessName],fee,Business[index][EBusinessOwnerName],ext);
  1181.     }
  1182. }
  1183. public onBusinessUpdate(index) {
  1184.     reloadBusiness(index);
  1185. }
  1186. reloadBusiness(index) {
  1187.     new id = Business[index][EBusinessID];
  1188.     Business[index][EBusinessID] = 0;
  1189.     DestroyDynamic3DTextLabel(Business[index][EBusinessText]);
  1190.     DestroyDynamicPickup(Business[index][EBusinessPickup]);
  1191.     DestroyDynamicPickup(Business[index][EBusinessExitPickup]);
  1192.     query[0] = 0;//[512];
  1193.     format(query,sizeof(query),"SELECT `business`.`id`,`name`,`owner`,`c1`.`username`,`extortion`,`c2`.`username`,`EntranceX`,`EntranceY`,`EntranceZ`,`ExitX`,`ExitY`,`ExitZ`,`business`.`interior`,`type`,`value`,`locked`,`entrancefee`,`till`,`products`,`maxproducts` FROM `business` LEFT JOIN `characters` AS `c1` ON `business`.`owner` = `c1`.`id` LEFT JOIN `characters` AS `c2` ON `business`.`extortion` = `c2`.`id` WHERE `business`.`id` = %d",id);
  1194.     mysql_function_query(g_mysql_handle, query, true, "onLoadBusiness", "");
  1195. }
  1196. setBusinessOwner(index, sqlid) {
  1197.     query[0] = 0;//[128];
  1198.     format(query,sizeof(query),"UPDATE `business` SET `owner` = %d WHERE `id` = %d", sqlid, Business[index][EBusinessID]);
  1199.     mysql_function_query(g_mysql_handle, query, true, "onBusinessUpdate", "d",index);
  1200. }
  1201. setBusinessFee(index, fee) {
  1202.     query[0] = 0;//[128];
  1203.     format(query,sizeof(query),"UPDATE `business` SET `entrancefee` = %d WHERE `id` = %d", fee, Business[index][EBusinessID]);
  1204.     mysql_function_query(g_mysql_handle, query, true, "onBusinessUpdate", "d",index);
  1205. }
  1206. getStandingBusiness(playerid, Float:distance = 1.5) {
  1207.     for(new i=0;i<sizeof(Business);i++) {
  1208.         if(IsPlayerInRangeOfPoint(playerid,distance,Business[i][EBusinessEntranceX], Business[i][EBusinessEntranceY], Business[i][EBusinessEntranceZ])) {
  1209.             return i;
  1210.         } else if(IsPlayerInRangeOfPoint(playerid,distance,Business[i][EBusinessExitX], Business[i][EBusinessExitY], Business[i][EBusinessExitZ])) {
  1211.                 if(IsDealership(i) || IsFishStore(i)) {
  1212.                     return i;
  1213.                 }
  1214.             }
  1215.     }
  1216.     return -1;
  1217. }
  1218. getBusinessInside(playerid, Float:distance = 150.0) {
  1219.     new vw = GetPlayerVirtualWorld(playerid);
  1220.     for(new i=0;i<sizeof(Business);i++) {
  1221.         if(IsPlayerInRangeOfPoint(playerid,distance,Business[i][EBusinessExitX], Business[i][EBusinessExitY], Business[i][EBusinessExitZ])) {
  1222.             if(vw == Business[i][EBusinessVW]) {
  1223.                 return i;
  1224.             }
  1225.         }
  1226.     }
  1227.     return -1;
  1228. }
  1229. YCMD:robbiz(playerid, params[], help) {
  1230.     new biz = getBusinessInside(playerid);
  1231.     if(biz == -1) {
  1232.         biz = getStandingBusiness(playerid, 15.0);
  1233.         if(biz == -1 || (!IsDealership(biz) && !IsFishStore(biz))) {
  1234.             SendClientMessage(playerid, X11_TOMATO_2, "You arn't inside a business");
  1235.             return 1;
  1236.         }
  1237.     }
  1238.     new weapon = GetPlayerWeaponEx(playerid);
  1239.     if(!isDangerousWeapon(weapon)) {
  1240.         SendClientMessage(playerid, X11_TOMATO_2, "You aren't armed!");
  1241.         return 1;
  1242.     }
  1243.     if(GetPVarType(playerid, "BizRobTimer") != PLAYER_VARTYPE_NONE) {
  1244.         SendClientMessage(playerid, X11_TOMATO_2, "You are currently robbing a business");
  1245.         return 1;
  1246.     }
  1247.     new timenow = gettime();
  1248.     if(BIZROB_COOLDOWN-(timenow-Business[biz][EBusinessLastRobbery]) > 0) {
  1249.         SendClientMessage(playerid, X11_TOMATO_2, "This business has been robbed recently, come back later!");
  1250.         return 1;
  1251.     }
  1252.     Business[biz][EBusinessLastRobbery] =  timenow;
  1253.     new biztimer = SetTimerEx("BusinessRob", 300000, false ,"dd", playerid, biz);
  1254.     SetPVarInt(playerid, "BizRobTimer", biztimer);
  1255.     new level = GetPVarInt(playerid, "WantedLevel");
  1256.     level += 6;
  1257.     SetPlayerWantedLevel(playerid, level);
  1258.     SetPVarInt(playerid, "WantedLevel", level);
  1259.     SendCopMessage(X11_BLUE, "|__All Units!__|");
  1260.     format(tempstr, sizeof(tempstr), "Armed robbery at %s!", Business[biz][EBusinessName]);
  1261.     SendCopMessage(COLOR_LIGHTRED, tempstr);
  1262.     InsertCrime(playerid, -1, "Armed Robbery");
  1263.     return 1;
  1264. }
  1265. IsRobbingBusines(playerid) {
  1266.     if(GetPVarType(playerid, "BizRobTimer") == PLAYER_VARTYPE_NONE) {
  1267.         return -1;
  1268.     }
  1269.     return GetPVarInt(playerid, "BizRobTimer");
  1270. }
  1271. StopRobBiz(playerid) {
  1272.     new biztimer = IsRobbingBusines(playerid);
  1273.     if(biztimer != -1) {
  1274.         KillTimer(biztimer);
  1275.         DeletePVar(playerid, "BizRobTimer");
  1276.     }
  1277. }
  1278. forward BusinessRob(playerid, biz);
  1279. public BusinessRob(playerid, biz) {
  1280.     new inbiz = getBusinessInside(playerid);
  1281.     if(biz != inbiz) {
  1282.         inbiz = getStandingBusiness(playerid, 55.0);
  1283.         if((!IsDealership(biz)  && !IsDealership(inbiz) && !IsCarRental(biz) && !IsCarRental(inbiz)) || inbiz != biz) {
  1284.             SendClientMessage(playerid, X11_TOMATO_2, "You didn't get any money because you left the business!");
  1285.             return 1;
  1286.         }
  1287.     }
  1288.     if(GetPlayerWeaponEx(playerid) < 22) {
  1289.         SendClientMessage(playerid, COLOR_LIGHTRED, "You need a Gun to Rob Businesses! The Cashier ran off!");
  1290.         return 1;
  1291.     }
  1292.     if(Business[biz][EBusinessTill] < 100) {
  1293.         SendClientMessage(playerid, X11_TOMATO_2, "This business is out of money!");
  1294.         return 1;
  1295.     }
  1296.     new money;
  1297.     new perc;
  1298.     perc = random(10)+1;
  1299.     money = floatround(Business[biz][EBusinessTill] / 200);
  1300.     money = floatround(money * perc);
  1301.     GiveMoneyEx(playerid, money);
  1302.     addToBusinessTill(biz, -money);
  1303.     format(tempstr, sizeof(tempstr), "* You got $%s out of the Robbery!", getNumberString(money));
  1304.     SendClientMessage(playerid, COLOR_LIGHTGREEN, tempstr);
  1305.     DeletePVar(playerid, "BizRobTimer");
  1306.     return 1;
  1307. }
  1308. YCMD:bizbank(playerid, params[], help) {
  1309.     SendClientMessage(playerid, X11_TOMATO_2, "Use /bizdeposit and /bizwithdraw!");
  1310.     return 1;
  1311. }
  1312. YCMD:biztill(playerid, params[], help) {
  1313.     SendClientMessage(playerid, X11_TOMATO_2, "Use /bizdeposit and /bizwithdraw!");
  1314.     return 1;
  1315. }
  1316. YCMD:bizwithdraw(playerid, params[], help) {
  1317.     new amount;
  1318.     new bizid = getBusinessInside(playerid);
  1319.     if(bizid == -1) {
  1320.         bizid = getStandingBusiness(playerid);
  1321.         if(!IsDealership(bizid) && !IsPaintball(bizid) && !IsFishStore(bizid) && !IsCarRental(bizid)) {
  1322.             SendClientMessage(playerid, X11_TOMATO_2, "You arn't inside your business");
  1323.             return 1;
  1324.         }
  1325.     }
  1326.     if((Business[bizid][EBusinessOwner] != GetPVarInt(playerid,"CharID") || Business[bizid][EBusinessOwner] == 0) && Business[bizid][EBusinessExtortionist] != GetPVarInt(playerid,"CharID")) {
  1327.         SendClientMessage(playerid, X11_WHITE, "You don't own this business.");
  1328.         return 1;
  1329.     }
  1330.     if(!sscanf(params,"d",amount)) {
  1331.         if(amount < 1) {
  1332.             SendClientMessage(playerid, X11_TOMATO_2, "Invalid Amount!");
  1333.             return 1;
  1334.         }
  1335.         if(amount > Business[bizid][EBusinessTill]) {
  1336.             SendClientMessage(playerid, X11_TOMATO_2, "There isn't enough money in the till!");
  1337.             return 1;
  1338.         }
  1339.         addToBusinessTill(bizid, -amount);
  1340.         GiveMoneyEx(playerid, amount);
  1341.         SendClientMessage(playerid, COLOR_GREEN, "Amount Withdrawn");
  1342.     } else {
  1343.         format(tempstr, sizeof(tempstr), "Till Amount: %d",Business[bizid][EBusinessTill]);
  1344.         SendClientMessage(playerid, X11_WHITE, tempstr);
  1345.     }
  1346.     return 1;
  1347. }
  1348.  
  1349. YCMD:bizdeposit(playerid, params[], help) {
  1350.     new amount;
  1351.     new bizid = getBusinessInside(playerid);
  1352.     if(bizid == -1) {
  1353.         bizid = getStandingBusiness(playerid);
  1354.         if(!IsDealership(bizid) && !IsPaintball(bizid) && !IsFishStore(bizid) && !IsCarRental(bizid)) {
  1355.             SendClientMessage(playerid, X11_TOMATO_2, "You aren't inside your business");
  1356.             return 1;
  1357.         }
  1358.     }
  1359.     if((Business[bizid][EBusinessOwner] != GetPVarInt(playerid,"CharID") || Business[bizid][EBusinessOwner] == 0) && Business[bizid][EBusinessExtortionist] != GetPVarInt(playerid,"CharID")) {
  1360.         SendClientMessage(playerid, X11_WHITE, "You don't own this business.");
  1361.         return 1;
  1362.     }
  1363.     if(!sscanf(params,"d",amount)) {
  1364.         if(amount < 1 || amount > 5000) {
  1365.             SendClientMessage(playerid, X11_TOMATO_2, "Invalid Amount!");
  1366.             return 1;
  1367.         }
  1368.         if(amount > GetMoneyEx(playerid)) {
  1369.             SendClientMessage(playerid, X11_TOMATO_2, "You don't have enough money!");
  1370.             return 1;
  1371.         }
  1372.         addToBusinessTill(bizid, amount);
  1373.         GiveMoneyEx(playerid, -amount);
  1374.         SendClientMessage(playerid, COLOR_GREEN, "Amount Deposited");
  1375.     }
  1376.     return 1;
  1377. }
  1378. showDealershipMenu(playerid,index) {
  1379.     new temptxt[128];
  1380.     dialogstr[0] = 0;
  1381.     if(Business[index][EBusinessOwner] == 0 || Business[index][EBusinessLocked] == 1) {
  1382.         SendClientMessage(playerid, X11_TOMATO_2, "Sorry we are closed!");
  1383.         return 1;
  1384.     }
  1385.     if(Business[index][EBType] == EBusinessType_D_NormCar) {
  1386.         for(new i=0;i<sizeof(EBDNormalCars);i++) {
  1387.             format(temptxt,sizeof(temptxt),"%s $%s\n",VehiclesName[EBDNormalCars[i][EBCarModelID]-400],getNumberString(EBDNormalCars[i][EBCarPrice]));
  1388.             strcat(dialogstr,temptxt,sizeof(dialogstr));
  1389.         }
  1390.         ShowPlayerDialog(playerid, BIZ_DEALER_DEALERSHIP_MENU, DIALOG_STYLE_LIST, "{00BFFF}Buy a vehicle", dialogstr, "Buy", "Cancel");
  1391.     } else if(Business[index][EBType] == EBusinessType_D_FastCar) {
  1392.         for(new i=0;i<sizeof(EBDFastCars);i++) {
  1393.             format(temptxt,sizeof(temptxt),"%s $%s\n",VehiclesName[EBDFastCars[i][EBCarModelID]-400],getNumberString(EBDFastCars[i][EBCarPrice]));
  1394.             strcat(dialogstr,temptxt,sizeof(dialogstr));
  1395.         }
  1396.         ShowPlayerDialog(playerid, EBusiness_FastCarMenu, DIALOG_STYLE_LIST, "{00BFFF}Buy a vehicle", dialogstr, "Buy", "Cancel");
  1397.     } else if(Business[index][EBType] == EBusinessType_D_Bike) {
  1398.         for(new i=0;i<sizeof(EBDBikes);i++) {
  1399.             format(temptxt,sizeof(temptxt),"%s $%s\n",VehiclesName[EBDBikes[i][EBCarModelID]-400],getNumberString(EBDBikes[i][EBCarPrice]));
  1400.             strcat(dialogstr,temptxt,sizeof(dialogstr));
  1401.         }
  1402.         ShowPlayerDialog(playerid, EBusiness_BikeCarMenu, DIALOG_STYLE_LIST, "{00BFFF}Buy a vehicle", dialogstr, "Buy", "Cancel");
  1403.     } else if(Business[index][EBType] == EBusinessType_D_Boat) {
  1404.         for(new i=0;i<sizeof(EBDBoats);i++) {
  1405.             format(temptxt,sizeof(temptxt),"%s $%s\n",VehiclesName[EBDBoats[i][EBCarModelID]-400],getNumberString(EBDBoats[i][EBCarPrice]));
  1406.             strcat(dialogstr,temptxt,sizeof(dialogstr));
  1407.         }
  1408.         ShowPlayerDialog(playerid, EBusiness_BoatCarMenu, DIALOG_STYLE_LIST, "{00BFFF}Buy a vehicle", dialogstr, "Buy", "Cancel");
  1409.     } else if(Business[index][EBType] == EBusinessType_D_Plane) {
  1410.         for(new i=0;i<sizeof(EBDPlanes);i++) {
  1411.             format(temptxt,sizeof(temptxt),"%s $%s\n",VehiclesName[EBDPlanes[i][EBCarModelID]-400],getNumberString(EBDPlanes[i][EBCarPrice]));
  1412.             strcat(dialogstr,temptxt,sizeof(dialogstr));
  1413.         }
  1414.         ShowPlayerDialog(playerid, EBusiness_PlaneCarMenu, DIALOG_STYLE_LIST, "{00BFFF}Buy a vehicle", dialogstr, "Buy", "Cancel");
  1415.     } else if(Business[index][EBType] == EBusinessType_D_Truck) {
  1416.         for(new i=0;i<sizeof(EBDTrucks);i++) {
  1417.             format(temptxt,sizeof(temptxt),"%s $%s\n",VehiclesName[EBDTrucks[i][EBCarModelID]-400],getNumberString(EBDTrucks[i][EBCarPrice]));
  1418.             strcat(dialogstr,temptxt,sizeof(dialogstr));
  1419.         }
  1420.         ShowPlayerDialog(playerid, EBusiness_TruckCarMenu, DIALOG_STYLE_LIST, "{00BFFF}Buy a vehicle", dialogstr, "Buy", "Cancel");
  1421.     }
  1422.     return 0;
  1423. }
  1424. bOnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  1425.     #pragma unused inputtext
  1426.     switch(dialogid) {
  1427.         case BIZ_DEALER_DEALERSHIP_MENU: {
  1428.             if(!response) {
  1429.                 return 0;
  1430.             }
  1431.             new num = getNumOwnedCars(playerid);
  1432.             if(num >= GetPVarInt(playerid, "MaxCars")) {
  1433.                 SendClientMessage(playerid, X11_TOMATO_2, "You cannot own any more cars");
  1434.                 return 0;
  1435.             }
  1436.             format(tempstr,sizeof(tempstr),"Congratulations! You are now the owner of a %s",VehiclesName[EBDNormalCars[listitem][EBCarModelID]-400]);
  1437.             if(GetMoneyEx(playerid) >= EBDNormalCars[listitem][EBCarPrice]) {
  1438.                 GiveMoneyEx(playerid, -EBDNormalCars[listitem][EBCarPrice]);
  1439.                 SendClientMessage(playerid, COLOR_LIGHTGREEN, tempstr);
  1440.                 new Float:X,Float:Y,Float:Z,Float:A;
  1441.                 GetPlayerPos(playerid, X, Y, Z);
  1442.                 GetPlayerFacingAngle(playerid, A);
  1443.                 new biz = GetPVarInt(playerid, "BuyingBiz");
  1444.                 addToBusinessTill(biz, EBDNormalCars[listitem][EBCarPrice]/4);
  1445.                 addToBusinessProducts(biz, -25);
  1446.                 CreatePlayerCar(playerid, EBDNormalCars[listitem][EBCarModelID], 0, 0, Business[biz][EBusinessExitX],Business[biz][EBusinessExitY],Business[biz][EBusinessExitZ], A, ELockType_Default,1);
  1447.                 DeletePVar(playerid, "BuyingBiz");
  1448.             } else {
  1449.                 SendClientMessage(playerid, X11_RED, "You don't have enough money");
  1450.             }
  1451.         }
  1452.         case EBusiness_247BuyMenu: {
  1453.             if(!response || listitem < 0) {
  1454.                 return 0;
  1455.             }
  1456.             if(Buyable24Items[listitem][EBIType] != EType_NumSelect) {
  1457.                 CallLocalFunction(Buyable24Items[listitem][EBIOnBuyCallback],"dddd",playerid, listitem, GetPVarInt(playerid, "BuyingBiz"),0);
  1458.                 DeletePVar(playerid, "BuyingBiz");
  1459.             } else {
  1460.                 SetPVarInt(playerid, "BuyingItem", listitem);
  1461.                 format(tempstr,sizeof(tempstr),"How many %s's would you like?",Buyable24Items[listitem][EBIDisplayName]);
  1462.                 ShowPlayerDialog(playerid, _:EBusiness_247NumberInput, DIALOG_STYLE_INPUT, "How many?", tempstr,"Ok","Cancel");
  1463.             }
  1464.         }
  1465.         case EBusiness_247NumberInput: {
  1466.             if(!response) {
  1467.                 return 0;
  1468.             }
  1469.             new item = GetPVarInt(playerid, "BuyingItem");
  1470.             new number = strval(inputtext);
  1471.             if(number < 1 || number > 9999) {
  1472.                 format(tempstr,sizeof(tempstr),"How many %s's would you like?",Buyable24Items[item][EBIDisplayName]);
  1473.                 ShowPlayerDialog(playerid, _:EBusiness_247NumberInput, DIALOG_STYLE_INPUT, "How many?", tempstr,"Ok","Cancel");
  1474.                 return 0;
  1475.             }
  1476.             DeletePVar(playerid,"BuyingItem");
  1477.             CallLocalFunction(Buyable24Items[item][EBIOnBuyCallback],"dddd",playerid, item, GetPVarInt(playerid, "BuyingBiz"),number);
  1478.         }
  1479.         case EBusiness_SexBuyMenu: {
  1480.             if(!response) {
  1481.                 return 0;
  1482.             }
  1483.             if(BuyableSexItems[listitem][EBIType] != EType_NumSelect) {
  1484.                 CallLocalFunction(BuyableSexItems[listitem][EBIOnBuyCallback],"dddd",playerid, listitem, GetPVarInt(playerid, "BuyingBiz"),0);
  1485.                 DeletePVar(playerid, "BuyingBiz");
  1486.             } else {
  1487.                 SetPVarInt(playerid, "BuyingItem", listitem);
  1488.                 format(tempstr,sizeof(tempstr),"How many %s's would you like?",BuyableSexItems[listitem][EBIDisplayName]);
  1489.                 ShowPlayerDialog(playerid, _:EBusiness_SexNumberInput, DIALOG_STYLE_INPUT, "How many?", tempstr,"Ok","Cancel");
  1490.             }
  1491.         }
  1492.         case EBusiness_RestaurantMenu: {
  1493.             if(!response) {
  1494.                 return 0;
  1495.             }
  1496.             if(BuyableRestaurantItems[listitem][EBIType] != EType_NumSelect) {
  1497.                 CallLocalFunction(BuyableRestaurantItems[listitem][EBIOnBuyCallback],"dddd",playerid, listitem, GetPVarInt(playerid, "BuyingBiz"),0);
  1498.                 DeletePVar(playerid, "BuyingBiz");
  1499.             }
  1500.         }  
  1501.         case EBusiness_FastFoodMenu: {
  1502.             if(!response) {
  1503.                 return 0;
  1504.             }
  1505.             if(BuyableFastfoodItems[listitem][EBIType] != EType_NumSelect) {
  1506.                 CallLocalFunction(BuyableFastfoodItems[listitem][EBIOnBuyCallback],"dddd",playerid, listitem, GetPVarInt(playerid, "BuyingBiz"),0);
  1507.                 DeletePVar(playerid, "BuyingBiz");
  1508.             }
  1509.         }
  1510.         case EBusiness_SexNumberInput: {
  1511.             new item = GetPVarInt(playerid, "BuyingItem");
  1512.             new number = strval(inputtext);
  1513.             if(number < 1 || number > 9999) {
  1514.                 format(tempstr,sizeof(tempstr),"How many %s's would you like?",BuyableSexItems[listitem][EBIDisplayName]);
  1515.                 ShowPlayerDialog(playerid, _:EBusiness_SexNumberInput, DIALOG_STYLE_INPUT, "How many?", tempstr,"Ok","Cancel");
  1516.                 return 0;
  1517.             }
  1518.             DeletePVar(playerid,"BuyingItem");
  1519.             CallLocalFunction(BuyableSexItems[item][EBIOnBuyCallback],"dddd",playerid, item, GetPVarInt(playerid, "BuyingBiz"),number);
  1520.         }
  1521.         case EBusiness_FastCarMenu: {
  1522.             if(!response) {
  1523.                 return 0;
  1524.             }
  1525.             new num = getNumOwnedCars(playerid);
  1526.             if(num >= GetPVarInt(playerid, "MaxCars")) {
  1527.                 SendClientMessage(playerid, X11_TOMATO_2, "You cannot own any more cars");
  1528.                 return 0;
  1529.             }
  1530.             format(tempstr,sizeof(tempstr),"Congratulations! You are now the owner of a %s",VehiclesName[EBDFastCars[listitem][EBCarModelID]-400]);
  1531.             if(GetMoneyEx(playerid) >= EBDFastCars[listitem][EBCarPrice]) {
  1532.                 GiveMoneyEx(playerid, -EBDFastCars[listitem][EBCarPrice]);
  1533.                 SendClientMessage(playerid, COLOR_LIGHTGREEN, tempstr);
  1534.                 new Float:X,Float:Y,Float:Z,Float:A;
  1535.                 GetPlayerPos(playerid, X, Y, Z);
  1536.                 GetPlayerFacingAngle(playerid, A);
  1537.                 new biz = GetPVarInt(playerid, "BuyingBiz");
  1538.                 addToBusinessTill(biz, floatround(EBDFastCars[listitem][EBCarPrice]/4));
  1539.                 addToBusinessProducts(biz, -25);
  1540.                 CreatePlayerCar(playerid, EBDFastCars[listitem][EBCarModelID], 0, 0, Business[biz][EBusinessExitX],Business[biz][EBusinessExitY],Business[biz][EBusinessExitZ], A, ELockType_Default,1);
  1541.                 DeletePVar(playerid, "BuyingBiz");
  1542.             } else {
  1543.                 SendClientMessage(playerid, X11_RED, "You don't have enough money");
  1544.             }
  1545.         }
  1546.         case EBusiness_BikeCarMenu: {
  1547.             if(!response) {
  1548.                 return 0;
  1549.             }
  1550.             new num = getNumOwnedCars(playerid);
  1551.             if(num >= GetPVarInt(playerid, "MaxCars")) {
  1552.                 SendClientMessage(playerid, X11_TOMATO_2, "You cannot own any more cars");
  1553.                 return 0;
  1554.             }
  1555.             format(tempstr,sizeof(tempstr),"Congratulations! You are now the owner of a %s",VehiclesName[EBDBikes[listitem][EBCarModelID]-400]);
  1556.             if(GetMoneyEx(playerid) >= EBDBikes[listitem][EBCarPrice]) {
  1557.                 GiveMoneyEx(playerid, -EBDBikes[listitem][EBCarPrice]);
  1558.                 SendClientMessage(playerid, COLOR_LIGHTGREEN, tempstr);
  1559.                 new Float:X,Float:Y,Float:Z,Float:A;
  1560.                 GetPlayerPos(playerid, X, Y, Z);
  1561.                 GetPlayerFacingAngle(playerid, A);
  1562.                 new biz = GetPVarInt(playerid, "BuyingBiz");
  1563.                 addToBusinessTill(biz, floatround(EBDBikes[listitem][EBCarPrice]/4));
  1564.                 addToBusinessProducts(biz, -25);
  1565.                 CreatePlayerCar(playerid, EBDBikes[listitem][EBCarModelID], 0, 0, Business[biz][EBusinessExitX],Business[biz][EBusinessExitY],Business[biz][EBusinessExitZ], A, ELockType_Default,1);
  1566.                 DeletePVar(playerid, "BuyingBiz");
  1567.             } else {
  1568.                 SendClientMessage(playerid, X11_RED, "You don't have enough money");
  1569.             }
  1570.  
  1571.         }
  1572.         case EBusiness_BoatCarMenu: {
  1573.             if(!response) {
  1574.                 return 0;
  1575.             }
  1576.             new num = getNumOwnedCars(playerid);
  1577.             if(num >= GetPVarInt(playerid, "MaxCars")) {
  1578.                 SendClientMessage(playerid, X11_TOMATO_2, "You cannot own any more cars");
  1579.                 return 0;
  1580.             }
  1581.             format(tempstr,sizeof(tempstr),"Congratulations! You are now the owner of a %s",VehiclesName[EBDBoats[listitem][EBCarModelID]-400]);
  1582.             if(GetMoneyEx(playerid) >= EBDBoats[listitem][EBCarPrice]) {
  1583.                 GiveMoneyEx(playerid, -EBDBoats[listitem][EBCarPrice]);
  1584.                 SendClientMessage(playerid, COLOR_LIGHTGREEN, tempstr);
  1585.                 new Float:X,Float:Y,Float:Z,Float:A;
  1586.                 GetPlayerPos(playerid, X, Y, Z);
  1587.                 GetPlayerFacingAngle(playerid, A);
  1588.                 new biz = GetPVarInt(playerid, "BuyingBiz");
  1589.                 addToBusinessTill(biz, floatround(EBDBoats[listitem][EBCarPrice]/4));
  1590.                 addToBusinessProducts(biz, -25);
  1591.                 CreatePlayerCar(playerid, EBDBoats[listitem][EBCarModelID], 0, 0, Business[biz][EBusinessExitX],Business[biz][EBusinessExitY],Business[biz][EBusinessExitZ], A, ELockType_Default,1);
  1592.                 DeletePVar(playerid, "BuyingBiz");
  1593.             } else {
  1594.                 SendClientMessage(playerid, X11_RED, "You don't have enough money");
  1595.             }
  1596.  
  1597.         }
  1598.         case EBusiness_PlaneCarMenu: {
  1599.             if(!response) {
  1600.                 return 0;
  1601.             }
  1602.             new num = getNumOwnedCars(playerid);
  1603.             if(num >= GetPVarInt(playerid, "MaxCars")) {
  1604.                 SendClientMessage(playerid, X11_TOMATO_2, "You cannot own any more cars");
  1605.                 return 0;
  1606.             }
  1607.             format(tempstr,sizeof(tempstr),"Congratulations! You are now the owner of a %s",VehiclesName[EBDPlanes[listitem][EBCarModelID]-400]);
  1608.             if(GetMoneyEx(playerid) >= EBDPlanes[listitem][EBCarPrice]) {
  1609.                 GiveMoneyEx(playerid, -EBDPlanes[listitem][EBCarPrice]);
  1610.                 SendClientMessage(playerid, COLOR_LIGHTGREEN, tempstr);
  1611.                 new Float:X,Float:Y,Float:Z,Float:A;
  1612.                 GetPlayerPos(playerid, X, Y, Z);
  1613.                 GetPlayerFacingAngle(playerid, A);
  1614.                 new biz = GetPVarInt(playerid, "BuyingBiz");
  1615.                 addToBusinessTill(biz, floatround(EBDPlanes[listitem][EBCarPrice]/4));
  1616.                 addToBusinessProducts(biz, -25);
  1617.                 CreatePlayerCar(playerid, EBDPlanes[listitem][EBCarModelID], 0, 0, Business[biz][EBusinessExitX],Business[biz][EBusinessExitY],Business[biz][EBusinessExitZ], A, ELockType_Default,1);
  1618.                 DeletePVar(playerid, "BuyingBiz");
  1619.             } else {
  1620.                 SendClientMessage(playerid, X11_RED, "You don't have enough money");
  1621.             }
  1622.  
  1623.         }
  1624.         case EBusiness_TruckCarMenu: {
  1625.             if(!response) {
  1626.                 return 0;
  1627.             }
  1628.             new num = getNumOwnedCars(playerid);
  1629.             if(num >= GetPVarInt(playerid, "MaxCars")) {
  1630.                 SendClientMessage(playerid, X11_TOMATO_2, "You cannot own any more cars");
  1631.                 return 0;
  1632.             }
  1633.             format(tempstr,sizeof(tempstr),"Congratulations! You are now the owner of a %s",VehiclesName[EBDTrucks[listitem][EBCarModelID]-400]);
  1634.             if(GetMoneyEx(playerid) >= EBDTrucks[listitem][EBCarPrice]) {
  1635.                 GiveMoneyEx(playerid, -EBDTrucks[listitem][EBCarPrice]);
  1636.                 SendClientMessage(playerid, COLOR_LIGHTGREEN, tempstr);
  1637.                 new Float:X,Float:Y,Float:Z,Float:A;
  1638.                 GetPlayerPos(playerid, X, Y, Z);
  1639.                 GetPlayerFacingAngle(playerid, A);
  1640.                 new biz = GetPVarInt(playerid, "BuyingBiz");
  1641.                 addToBusinessTill(biz, floatround(EBDTrucks[listitem][EBCarPrice]/12));
  1642.                 addToBusinessProducts(biz, -25);
  1643.                 CreatePlayerCar(playerid, EBDTrucks[listitem][EBCarModelID], 0, 0, Business[biz][EBusinessExitX],Business[biz][EBusinessExitY],Business[biz][EBusinessExitZ], A, ELockType_Default,1);
  1644.                 DeletePVar(playerid, "BuyingBiz");
  1645.             } else {
  1646.                 SendClientMessage(playerid, X11_RED, "You don't have enough money");
  1647.             }
  1648.  
  1649.         }
  1650.         case EBusiness_DrinkMenu: {
  1651.             if(!response) {
  1652.                 return 0;
  1653.             }
  1654.             new biz = getBusinessInside(playerid);
  1655.             if(biz == -1) return 0;
  1656.             if(GetMoneyEx(playerid) < Drinks[listitem][EDrinkPrice]) {
  1657.                 SendClientMessage(playerid, X11_TOMATO_2, "You don't have enough money!");
  1658.                 return 1;
  1659.             }
  1660.             GiveMoneyEx(playerid, -Drinks[listitem][EDrinkPrice]);
  1661.             new Float:HP;
  1662.             GetPlayerHealth(playerid, HP);
  1663.             HP += Drinks[listitem][EDrinkHealthBoost];
  1664.             SetPlayerHealthEx(playerid, HP);
  1665.             addToBusinessTill(biz, floatround(Drinks[listitem][EDrinkPrice]/2));
  1666.             addToBusinessProducts(biz, -1);
  1667.             if(Drinks[listitem][EDrinkSpecialAction] != SPECIAL_ACTION_NONE) {
  1668.                 SetPlayerSpecialAction(playerid, Drinks[listitem][EDrinkSpecialAction]);
  1669.             }
  1670.             format(tempstr, sizeof(tempstr), Drinks[listitem][EDrinkAction], GetPlayerNameEx(playerid, ENameType_RPName));
  1671.             ProxMessage(30.0, playerid, tempstr, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  1672.            
  1673.         }
  1674.         case EBusiness_LockBuy: {
  1675.             if(!response) {
  1676.                 return 0;
  1677.             }
  1678.             if(GetPVarType(playerid, "HoldingLock") != PLAYER_VARTYPE_NONE) {
  1679.                 SendClientMessage(playerid, X11_TOMATO_2, "You already are holding a lock! Do /destroylock to remove it, or use it in a car!");
  1680.                 return 1;
  1681.             }
  1682.             new biz = getBusinessInside(playerid);
  1683.             if(biz == -1) return 0;
  1684.             if(GetMoneyEx(playerid) < BuyableCarLocks[listitem][EBLockPrice]) {
  1685.                 SendClientMessage(playerid, X11_TOMATO_2, "You don't have enough money!");
  1686.                 return 1;
  1687.             }
  1688.             addToBusinessTill(biz, floatround(BuyableCarLocks[listitem][EBLockPrice]/2));
  1689.             addToBusinessProducts(biz, -1);
  1690.             GiveMoneyEx(playerid, -BuyableCarLocks[listitem][EBLockPrice]);
  1691.             SetPVarInt(playerid, "HoldingLock", _:BuyableCarLocks[listitem][EBLockType]);
  1692.             SendClientMessage(playerid, COLOR_LIGHTGREEN, "Congratulations! Go into a car and do /uselock");
  1693.         }
  1694.         case EBusiness_AmmunationMenu: {
  1695.             if(!response) return 0;
  1696.             new biz = getBusinessInside(playerid);
  1697.             if(biz == -1) return 0;
  1698.             new ELicenseFlags:lflags = ELicenseFlags:GetPVarInt(playerid, "LicenseFlags");
  1699.             if(~lflags & ELicense_Gun && BuyableAmmunationGuns[listitem][EBuyableGunNeedLicense]) {
  1700.                 SendClientMessage(playerid, X11_TOMATO_2, "You don't have a weapons license!");
  1701.                 return 1;
  1702.             }
  1703.             if(GetMoneyEx(playerid) < BuyableAmmunationGuns[listitem][EBuyableGunPrice]) {
  1704.                 SendClientMessage(playerid, X11_TOMATO_2, "You don't have enough money!");
  1705.                 return 1;
  1706.             }
  1707.            
  1708.             if(BuyableAmmunationGuns[listitem][EBuyableGunType] == 0) {
  1709.                 if(IsGunBanned(playerid)) {
  1710.                     SendClientMessage(playerid, X11_TOMATO_2, "This player is weapon banned!");
  1711.                     return 1;
  1712.                 }
  1713.                 GivePlayerWeaponEx(playerid,BuyableAmmunationGuns[listitem][EBuyableGunID], -1);
  1714.             } else if(BuyableAmmunationGuns[listitem][EBuyableGunType] == 1) {
  1715.                 new Float:HP;
  1716.                 GetPlayerArmour(playerid, HP);
  1717.                 HP += float(BuyableAmmunationGuns[listitem][EBuyableGunID]);
  1718.                 if(HP > MAX_HEALTH) HP = MAX_HEALTH;
  1719.                 SetPlayerArmourEx(playerid, HP);
  1720.             } else if(BuyableAmmunationGuns[listitem][EBuyableGunType] == 2) {
  1721.                 new Float:HP;
  1722.                 GetPlayerHealth(playerid, HP);
  1723.                 HP += float(BuyableAmmunationGuns[listitem][EBuyableGunID]);
  1724.                 if(HP > MAX_HEALTH) HP = MAX_HEALTH;
  1725.                 SetPlayerHealthEx(playerid, HP);
  1726.             } else if(BuyableAmmunationGuns[listitem][EBuyableGunType] == 3) {
  1727.                 if(GetPVarInt(playerid, "SpecialItem") != -1) {
  1728.                     SendClientMessage(playerid, X11_TOMATO_2, "You are already holding a special item!");
  1729.                     return 1;
  1730.                 }
  1731.                 GivePlayerItem(playerid, BuyableAmmunationGuns[listitem][EBuyableGunID]);
  1732.             }
  1733.             GiveMoneyEx(playerid, -BuyableAmmunationGuns[listitem][EBuyableGunPrice]);
  1734.             addToBusinessTill(biz, floatround(BuyableAmmunationGuns[listitem][EBuyableGunPrice]*0.50));
  1735.             SendClientMessage(playerid, COLOR_LIGHTGREEN, "Congratulations on your purchase");
  1736.         }
  1737.         case EBusiness_LottoChoose: {
  1738.             if(!response) return 0;
  1739.             new biz = getBusinessInside(playerid);
  1740.             if(biz == -1) return 0;
  1741.             switch(listitem) {
  1742.                 case 0: {
  1743.                     if(GetMoneyEx(playerid) < 100) {
  1744.                         SendClientMessage(playerid, X11_TOMATO_2, "Not enough money!");
  1745.                         return 1;
  1746.                     }
  1747.                     GiveMoneyEx(playerid, -100);
  1748.                     addToBusinessTill(biz, 100);
  1749.                     new number = giveRandomLottoNumber(playerid);
  1750.                     format(query, sizeof(query), "* Your lotto number is: %d, you have a chance of winning the $%s jackpot!",number,getNumberString(getLottoFunds()));
  1751.                     SendClientMessage(playerid, X11_YELLOW, query);
  1752.                     adjustLottoFunds(5000); //add 5000 every time someone buys a ticket
  1753.                     HintMessage(playerid, COLOR_LIGHTGREEN, "Do /lottoinfo to see lottery info, and /trashlotto to trash your ticket");
  1754.                     return 1;
  1755.                 }
  1756.                 case 1: {
  1757.                     ShowPlayerDialog(playerid, EBusiness_EnterLottoNumber,DIALOG_STYLE_INPUT, "Enter Desired Number", "Enter the lottery number you would like.", "Buy", "Cancel");
  1758.                     return 1;
  1759.                 }
  1760.             }
  1761.             return 1;
  1762.         }
  1763.         case EBusiness_EnterLottoNumber: {
  1764.             if(!response) return 0;
  1765.             new biz = getBusinessInside(playerid);
  1766.             if(biz == -1) return 0;
  1767.             if(GetMoneyEx(playerid) < 250) {
  1768.                 SendClientMessage(playerid, X11_TOMATO_2, "Not enough money!");
  1769.                 return 1;
  1770.             }
  1771.             GiveMoneyEx(playerid, -250);
  1772.             addToBusinessTill(biz, 250);
  1773.             adjustLottoFunds(5000); //add 5000 every time someone buys a ticket
  1774.             new number = strval(inputtext);
  1775.             if(isLottoNumberAcceptable(number)) {
  1776.                 setPlayerLottoTicket(playerid, number);
  1777.                 format(query, sizeof(query), "* Your lotto number is: %d, you have a chance of winning the $%s jackpot!",number,getNumberString(getLottoFunds()));
  1778.                 SendClientMessage(playerid, X11_YELLOW, query);
  1779.             } else {
  1780.                 SendClientMessage(playerid, X11_TOMATO_2, "This lotto number is not acceptable! Try a different number!");
  1781.                 format(query, sizeof(query), "* The lotto number must be above 1, and below %s",getNumberString(getLottoMax()));
  1782.                 SendClientMessage(playerid, COLOR_LIGHTGREEN, query);
  1783.             }
  1784.             HintMessage(playerid, COLOR_LIGHTGREEN, "Do /lottoinfo to see lottery info, and /trashlotto to trash your ticket");
  1785.             return 1;
  1786.         }
  1787.         case EBusiness_FishStoreMenu: {
  1788.             if(!response || listitem < 0) {
  1789.                 return 0;
  1790.             }
  1791.             if(BuyableFishStoreItems[listitem][EBIType] != EType_NumSelect) {
  1792.                 CallLocalFunction(BuyableFishStoreItems[listitem][EBIOnBuyCallback],"dddd",playerid, listitem, GetPVarInt(playerid, "BuyingBiz"),0);
  1793.                 DeletePVar(playerid, "BuyingBiz");
  1794.             }
  1795.         }
  1796.         case EBusiness_FishSell: {
  1797.             if(!response || listitem < 0) return 0;
  1798.             new fishname[64];
  1799.             new weight, value, slot;
  1800.             new ELicenseFlags:lflags = ELicenseFlags:GetPVarInt(playerid, "LicenseFlags");
  1801.             if(~lflags & ELicense_Fishing) {
  1802.                 SendClientMessage(playerid, X11_TOMATO_2, "Sorry, you do not have a fishing license!");
  1803.                 return 1;
  1804.             }
  1805.             for(new i=0;i<MAX_HOLDABLE_FISH;i++) {
  1806.                 GetFishInfoAt(playerid, fishname, sizeof(fishname), i, weight, value);
  1807.                 if(value != 0) {
  1808.                     if(slot == listitem) {
  1809.                         GiveMoneyEx(playerid, value);
  1810.                         RemoveFishAt(playerid, i);
  1811.                         format(query, sizeof(query), "You sold your %s for $%s",fishname,getNumberString(value));
  1812.                         SendClientMessage(playerid, COLOR_LIGHTBLUE, query);
  1813.                         return 1;
  1814.                     }
  1815.                     slot++;
  1816.                 }
  1817.             }
  1818.             return 1;
  1819.         }
  1820.         case EBusiness_RentalMenu: {
  1821.             if(!response || listitem < 0) return 0;
  1822.             if(listitem >= sizeof(RentableCars)) {
  1823.                 new caridx = listitem - sizeof(RentableCars);
  1824.                 DestroyPlayerRentCar(playerid, caridx);
  1825.                 SendClientMessage(playerid, X11_TOMATO_2, "* You have returned your rented vehicle.");
  1826.                 return 1;
  1827.             }
  1828.             new price, model;
  1829.             new ELicenseFlags:lflags = ELicenseFlags:GetPVarInt(playerid, "LicenseFlags");
  1830.             if(IsAFlyingVehicle(model)) {
  1831.                 if(~lflags & ELicense_Flying) {
  1832.                     SendClientMessage(playerid, X11_TOMATO_2, "Sorry, you don't have your flying license!");
  1833.                     return 1;
  1834.                 }
  1835.             } else {
  1836.                 if(~lflags & ELicense_Drivers) {
  1837.                     SendClientMessage(playerid, X11_TOMATO_2, "Sorry, you don't have your drivers license!");
  1838.                     return 1;
  1839.                 }
  1840.             }
  1841.             new biz = GetPVarInt(playerid, "BuyingBiz");
  1842.             model = RentableCars[listitem][ECarRental_ModelID];
  1843.             price = RentableCars[listitem][ECarRental_HourlyRate];
  1844.             if(GetMoneyEx(playerid) < price) {
  1845.                 SendClientMessage(playerid, X11_TOMATO_2, "You don't have enough money");
  1846.                 return 1;
  1847.             }
  1848.             GiveMoneyEx(playerid, -price);
  1849.             addToBusinessTill(biz, price);
  1850.             CreatePlayerRentCar(playerid, model, Business[biz][EBusinessExitX],Business[biz][EBusinessExitY],Business[biz][EBusinessExitZ]);
  1851.             DeletePVar(playerid, "BuyingBiz");
  1852.         }
  1853.     }
  1854.     return 1;
  1855. }
  1856. YCMD:destroylock(playerid, params[], help) {
  1857.     if(GetPVarType(playerid, "HoldingLock") != PLAYER_VARTYPE_NONE) {
  1858.         DeletePVar(playerid, "HoldingLock");
  1859.         SendClientMessage(playerid, COLOR_LIGHTGREEN, "Lock Deleted!");
  1860.     } else {
  1861.         SendClientMessage(playerid, X11_TOMATO_2, "You don't even own a lock!");
  1862.     }
  1863.     return 1;
  1864. }
  1865. addToBusinessTill(id, amount) {
  1866.     if(amount > 5000) amount = 5000;
  1867.     query[0] = 0;//[128];
  1868.     Business[id][EBusinessTill] += amount;
  1869.     format(query,sizeof(query),"UPDATE `business` SET `till` = %d WHERE `id` = %d",Business[id][EBusinessTill],Business[id][EBusinessID]);
  1870.     mysql_function_query(g_mysql_handle, query, true, "EmptyCallback", "");
  1871. }
  1872. addToBusinessProducts(id, amount) {
  1873.     query[0] = 0;//[128];
  1874.     Business[id][EBusinessProducts] += amount;
  1875.     format(query,sizeof(query),"UPDATE `business` SET `products` = %d WHERE `id` = %d",Business[id][EBusinessProducts],Business[id][EBusinessID]);
  1876.     mysql_function_query(g_mysql_handle, query, true, "EmptyCallback", "");
  1877. }
  1878. public On247ItemBuy(playerid, itemid, biz, total) {
  1879.     new flags = GetPVarInt(playerid, "UserFlags");
  1880.     if(Buyable24Items[itemid][EBIType] != EType_NumSelect) {
  1881.         if(Buyable24Items[itemid][EBIPrice] > GetMoneyEx(playerid)) {
  1882.             SendClientMessage(playerid, X11_RED3, "You don't have enough cash");
  1883.             return 0;
  1884.         }
  1885.     }
  1886.     #define CheckItem(%1,%2) if(!strcmp(Buyable24Items[itemid][EBIDisplayName],%1)) { \
  1887.         if(~flags & %2) { \
  1888.             flags |= %2; \
  1889.             GiveMoneyEx(playerid, -Buyable24Items[itemid][EBIPrice]); \
  1890.         } else { \
  1891.             format(tempstr, sizeof(tempstr),"You already have a %s",Buyable24Items[itemid][EBIDisplayName]); \
  1892.             SendClientMessage(playerid, X11_GREEN2, tempstr); \
  1893.             return 1;\
  1894.         } \
  1895.     }
  1896.    
  1897.     #define CheckItemInt(%1,%2) if(!strcmp(Buyable24Items[itemid][EBIDisplayName],%1)) { \
  1898.         if(GetPVarInt(playerid, %2) == 0) { \
  1899.             SetPVarInt(playerid, %2, 1); \
  1900.             GiveMoneyEx(playerid, -Buyable24Items[itemid][EBIPrice]); \
  1901.         } else { \
  1902.             format(tempstr, sizeof(tempstr),"You already have a %s",Buyable24Items[itemid][EBIDisplayName]); \
  1903.             SendClientMessage(playerid, X11_GREEN2, tempstr); \
  1904.             return 1;\
  1905.         } \
  1906.     }
  1907.    
  1908.     #define CheckNumberedItem(%1,%2)\
  1909.     if(!strcmp(Buyable24Items[itemid][EBIDisplayName],%1)) { \
  1910.         if(floatround(Buyable24Items[itemid][EBIPrice]*total) > GetMoneyEx(playerid)) { \
  1911.             SendClientMessage(playerid, X11_RED3, "You don't have enough cash"); \
  1912.             return 0; \
  1913.         } \
  1914.         GiveMoneyEx(playerid, floatround(-Buyable24Items[itemid][EBIPrice]*total)); \
  1915.         numitems = GetPVarInt(playerid, %2)+total; \
  1916.         SetPVarInt(playerid,%2,numitems); \
  1917.     }
  1918.    
  1919.     CheckItem("GPS",EUFHasGPS)
  1920.     CheckItem("Dice",EUFHasDice)
  1921.     CheckItem("MP3 Player", EUFHasMP3Player)
  1922.     CheckItem("Walkie Talkie",EUFHasWalkieTalkie)
  1923.     CheckItem("Phone Book",EUFHasPhoneBook)
  1924.     CheckItemInt("Cell Phone", "phone")
  1925.    
  1926.     if(!strcmp(Buyable24Items[itemid][EBIDisplayName],"Mask")) {
  1927.         if(GetPVarInt(playerid, "ConnectTime") < 60 || GetPVarInt(playerid, "Level") < 3) {
  1928.             SendClientMessage(playerid, X11_TOMATO_2, "You need 60 playing hours and level 3 to use this!");
  1929.             return 1;
  1930.         }
  1931.         if(~flags & EUFHasMask) {
  1932.             flags |= EUFHasMask;
  1933.             GiveMoneyEx(playerid, -Buyable24Items[itemid][EBIPrice]);
  1934.         } else {
  1935.             format(tempstr, sizeof(tempstr),"You already have a %s",Buyable24Items[itemid][EBIDisplayName]);
  1936.             SendClientMessage(playerid, X11_GREEN2, tempstr);
  1937.             return 1;
  1938.         }
  1939.     }
  1940.     if(!strcmp(Buyable24Items[itemid][EBIDisplayName],"Camera")) {
  1941.         new weapon, ammo;
  1942.         GetPlayerWeaponDataEx(playerid, 9, weapon, ammo);
  1943.         if(weapon != 43 && weapon != 0) {
  1944.             SendClientMessage(playerid, X11_TOMATO_2, "You are currently holding a weapon in that slot, you cannot use this.");
  1945.             return 1;
  1946.         }
  1947.         GivePlayerWeaponEx(playerid, 43, -1);
  1948.         GiveMoneyEx(playerid, -Buyable24Items[itemid][EBIPrice]);
  1949.         return 1;
  1950.     }
  1951.     if(!strcmp(Buyable24Items[itemid][EBIDisplayName],"Shovel")) {
  1952.         new weapon, ammo;
  1953.         GetPlayerWeaponDataEx(playerid, 1, weapon, ammo);
  1954.         if(weapon != 6 && weapon != 0) {
  1955.             SendClientMessage(playerid, X11_TOMATO_2, "You are currently holding a weapon in that slot, you cannot use this.");
  1956.             return 1;
  1957.         }
  1958.         GivePlayerWeaponEx(playerid, 6, -1);
  1959.         GiveMoneyEx(playerid, -Buyable24Items[itemid][EBIPrice]);
  1960.         return 1;
  1961.     }
  1962.     if(!strcmp(Buyable24Items[itemid][EBIDisplayName],"Flowers")) {
  1963.         new weapon, ammo;
  1964.         GetPlayerWeaponDataEx(playerid, 10, weapon, ammo);
  1965.         if(weapon != 14 && weapon != 0) {
  1966.             SendClientMessage(playerid, X11_TOMATO_2, "You are currently holding a weapon in that slot, you cannot use this.");
  1967.             return 1;
  1968.         }
  1969.         GivePlayerWeaponEx(playerid, 14, -1);
  1970.         GiveMoneyEx(playerid, -Buyable24Items[itemid][EBIPrice]);
  1971.         return 1;
  1972.     }
  1973.     if(!strcmp(Buyable24Items[itemid][EBIDisplayName],"Pool Cue")) {
  1974.         new weapon, ammo;
  1975.         GetPlayerWeaponDataEx(playerid, 1, weapon, ammo);
  1976.         if(weapon != 7 && weapon != 0) {
  1977.             SendClientMessage(playerid, X11_TOMATO_2, "You are currently holding a weapon in that slot, you cannot use this.");
  1978.             return 1;
  1979.         }
  1980.         GivePlayerWeaponEx(playerid, 7, -1);
  1981.         GiveMoneyEx(playerid, -Buyable24Items[itemid][EBIPrice]);
  1982.         return 1;
  1983.     }
  1984.     if(!strcmp(Buyable24Items[itemid][EBIDisplayName],"Golf Club")) {
  1985.         new weapon, ammo;
  1986.         GetPlayerWeaponDataEx(playerid, 1, weapon, ammo);
  1987.         if(weapon !=  2 && weapon != 0) {
  1988.             SendClientMessage(playerid, X11_TOMATO_2, "You are currently holding a weapon in that slot, you cannot use this.");
  1989.             return 1;
  1990.         }
  1991.         GivePlayerWeaponEx(playerid, 2, -1);
  1992.         GiveMoneyEx(playerid, -Buyable24Items[itemid][EBIPrice]);
  1993.         return 1;
  1994.     }
  1995.     if(!strcmp(Buyable24Items[itemid][EBIDisplayName],"Cane")) {
  1996.         new weapon, ammo;
  1997.         GetPlayerWeaponDataEx(playerid, 10, weapon, ammo);
  1998.         if(weapon != 15 && weapon != 0) {
  1999.             SendClientMessage(playerid, X11_TOMATO_2, "You are currently holding a weapon in that slot, you cannot use this.");
  2000.             return 1;
  2001.         }
  2002.         GivePlayerWeaponEx(playerid, 15, -1);
  2003.         GiveMoneyEx(playerid, -Buyable24Items[itemid][EBIPrice]);
  2004.         return 1;
  2005.     }
  2006.     if(!strcmp(Buyable24Items[itemid][EBIDisplayName],"Spray Can")) {
  2007.         new weapon, ammo;
  2008.         GetPlayerWeaponDataEx(playerid, 10, weapon, ammo);
  2009.         if(weapon != 41 && weapon != 0) {
  2010.             SendClientMessage(playerid, X11_TOMATO_2, "You are currently holding a weapon in that slot, you cannot use this.");
  2011.             return 1;
  2012.         }
  2013.         GivePlayerWeaponEx(playerid, 41, -1);
  2014.         GiveMoneyEx(playerid, -Buyable24Items[itemid][EBIPrice]);
  2015.         return 1;
  2016.     }
  2017.     new numitems;
  2018.     if(total != 0) {
  2019.         CheckNumberedItem("Vehicle Lock Picks","VehLockpicks")
  2020.         CheckNumberedItem("Vehicle Tracer","VehTracers")
  2021.         CheckNumberedItem("Cigars","Cigars")
  2022.         CheckNumberedItem("Fertilizer","NumFertilizer")
  2023.         CheckNumberedItem("Gas Can","GasCans")
  2024.         format(tempstr,sizeof(tempstr),"Congratulations, you now own %s %s",getNumberString(numitems) ,Buyable24Items[itemid][EBIDisplayName]);
  2025.     } else {
  2026.         format(tempstr,sizeof(tempstr),"Congratulations, you now own a %s",Buyable24Items[itemid][EBIDisplayName]);
  2027.     }
  2028.     addToBusinessTill(biz, floatround(Buyable24Items[itemid][EBIPrice]/2));
  2029.     SendClientMessage(playerid, X11_GREEN2, tempstr);
  2030.     SetPVarInt(playerid, "UserFlags", flags);
  2031.     #undef CheckNumberedItem
  2032.     #undef CheckItemInt
  2033.     #undef CheckItem
  2034.     return 0;
  2035. }
  2036. YCMD:tracecar(playerid, params[], help) {
  2037.     if(help) {
  2038.         SendClientMessage(playerid, X11_WHITE, "Used for finding your car");
  2039.         return 1;
  2040.     }
  2041.     new numowned = getNumOwnedCars(playerid);
  2042.     if(numowned == 0) {
  2043.         SendClientMessage(playerid, X11_TOMATO_2, "You don't have any cars!");
  2044.         return 1;
  2045.     }
  2046.     new numtracers = GetPVarInt(playerid, "VehTracers");
  2047.     if(numtracers < 1) {
  2048.         SendClientMessage(playerid, X11_TOMATO_2, "You don't have a vehicle tracer!");
  2049.         return 1;
  2050.     }
  2051.     new index;
  2052.     if(!sscanf(params,"d",index)) {
  2053.         if(index < 1 || index > numowned) {
  2054.             SendClientMessage(playerid, X11_TOMATO_2, "You don't have that many cars!");
  2055.             return 1;
  2056.         }
  2057.         new Float:X, Float:Y, Float:Z;
  2058.         new carid = findPlayerCar(playerid, --index);
  2059.         if(carid == -1 || GetVehicleVirtualWorld(carid) != 0) {
  2060.             SendClientMessage(playerid, X11_TOMATO_2, "Vehicle not found!");
  2061.             return 1;
  2062.         }
  2063.         GetVehiclePos(carid, X, Y, Z);
  2064.         SetPlayerCheckpoint(playerid, X, Y, Z, 3.0);
  2065.         SendClientMessage(playerid, COLOR_LIGHTGREEN, "The spot is now marked on your radar");
  2066.         HintMessage(playerid, COLOR_LIGHTGREEN, "Do /killcheckpoint to remove the checkpoint from your radar");
  2067.         SetPVarInt(playerid, "VehTracers", numtracers-1);
  2068.     } else {
  2069.         format(tempstr, sizeof(tempstr), "USAGE: /tracecar [1-%d]",numowned);
  2070.         SendClientMessage(playerid, X11_WHITE, tempstr);
  2071.     }
  2072.     return 1;
  2073. }
  2074. public OnSexItemBuy(playerid, itemid, biz, total) {
  2075.     #define CheckNumberedItem(%1,%2) if(!strcmp(Buyable24Items[itemid][EBIDisplayName],%1)) { \
  2076.         if(floatround(Buyable24Items[itemid][EBIPrice]*total) > GetMoneyEx(playerid)) { \
  2077.             SendClientMessage(playerid, X11_RED3, "You don't have enough cash"); \
  2078.             return 0; \
  2079.         } \
  2080.         GiveMoneyEx(playerid, floatround(-Buyable24Items[itemid][EBIPrice]*total)); \
  2081.         numitems = GetPVarInt(playerid, %2)+total; \
  2082.         SetPVarInt(playerid,%2,numitems); \
  2083.     }
  2084.     new flags = GetPVarInt(playerid, "UserFlags");
  2085.     if(BuyableSexItems[itemid][EBIType] != EType_NumSelect) {
  2086.         if(BuyableSexItems[itemid][EBIPrice] > GetMoneyEx(playerid)) {
  2087.             SendClientMessage(playerid, X11_RED3, "You don't have enough cash");
  2088.             return 0;
  2089.         }
  2090.     }
  2091.     if(!strcmp(BuyableSexItems[itemid][EBIDisplayName],"Purple Dildo"))
  2092.     {
  2093.         GivePlayerWeaponEx(playerid, 10, -1);
  2094.         GiveMoneyEx(playerid, -BuyableSexItems[itemid][EBIPrice]);
  2095.     }
  2096.     if(!strcmp(BuyableSexItems[itemid][EBIDisplayName],"Dildo"))
  2097.     {
  2098.         GivePlayerWeaponEx(playerid, 11, -1);
  2099.         GiveMoneyEx(playerid, -BuyableSexItems[itemid][EBIPrice]);
  2100.     }
  2101.     if(!strcmp(BuyableSexItems[itemid][EBIDisplayName],"Small Vibrator"))
  2102.     {
  2103.         GivePlayerWeaponEx(playerid, 12, -1);
  2104.         GiveMoneyEx(playerid, -BuyableSexItems[itemid][EBIPrice]);
  2105.     }
  2106.     if(!strcmp(BuyableSexItems[itemid][EBIDisplayName],"Vibrator"))
  2107.     {
  2108.         GivePlayerWeaponEx(playerid, 13, -1);
  2109.         GiveMoneyEx(playerid, -BuyableSexItems[itemid][EBIPrice]);
  2110.     }
  2111.     addToBusinessTill(biz, floatround(BuyableSexItems[itemid][EBIPrice]/2));
  2112.     new numitems;
  2113.     if(total != 0) {   
  2114.         CheckNumberedItem("Condoms", "condoms")
  2115.         format(tempstr,sizeof(tempstr),"Congratulations, you now own %s %s",getNumberString(numitems) ,BuyableSexItems[itemid][EBIDisplayName]);
  2116.     } else {
  2117.         format(tempstr,sizeof(tempstr),"Congratulations, you now own a %s",BuyableSexItems[itemid][EBIDisplayName]);
  2118.     }
  2119.     #undef CheckNumberedItem
  2120.     SendClientMessage(playerid, X11_GREEN2, tempstr);
  2121.     SetPVarInt(playerid, "UserFlags", flags);
  2122.     return 0;
  2123. }
  2124. public Generate247PhoneNumber(playerid, itemid, biz, total) {
  2125.     if(GetMoneyEx(playerid) < Buyable24Items[itemid][EBIPrice]) {
  2126.         SendClientMessage(playerid, X11_TOMATO_2, "You don't have enough money for this!");
  2127.         return 1;
  2128.     }
  2129.     GiveMoneyEx(playerid, -Buyable24Items[itemid][EBIPrice]);
  2130.     mysql_function_query(g_mysql_handle, "SELECT sub.random_number FROM (SELECT FLOOR(10000 + RAND() * 899999) AS random_number) sub WHERE sub.random_number NOT IN (SELECT `phonenumber` FROM `characters`) LIMIT 1", true, "OnGeneratePhoneNumber", "d",playerid);
  2131.     return 1;
  2132. }
  2133. public OnGeneratePhoneNumber(playerid) {
  2134.     new rows,fields,id;
  2135.     cache_get_data(rows,fields);
  2136.     if(rows > 0) {
  2137.         new data[16];
  2138.         cache_get_row(0, 0, data);
  2139.         id = strval(data);
  2140.         format(tempstr, sizeof(tempstr), "Your Phone Number is now: %d",id);
  2141.         SetPVarInt(playerid, "PhoneNumber", id);
  2142.         SendClientMessage(playerid, X11_WHITE, tempstr);
  2143.         format(tempstr,sizeof(tempstr), "UPDATE `characters` SET `phonenumber` = %d WHERE `id` = %d",id,GetPVarInt(playerid,"CharID"));
  2144.         mysql_function_query(g_mysql_handle, tempstr, true, "EmptyCallback", "");
  2145.     } else {
  2146.         SendClientMessage(playerid, X11_RED3, "Warning: Could not generate phone number, contact an admin!");
  2147.     }
  2148.     return 0;
  2149. }
  2150. forward OnRestaurantBuy(playerid, itemid, biz, total);
  2151. public OnRestaurantBuy(playerid, itemid, biz, total) {
  2152.     if(BuyableRestaurantItems[itemid][EBIType] != EType_NumSelect) {
  2153.         if(BuyableRestaurantItems[itemid][EBIPrice] > GetMoneyEx(playerid)) {
  2154.             SendClientMessage(playerid, X11_RED3, "You don't have enough cash");
  2155.             return 0;
  2156.         }
  2157.     }
  2158.     new Float:hp;
  2159.     GetPlayerHealth(playerid, hp);
  2160.     if(itemid == 0) {
  2161.         hp += 25.0;
  2162.     } else if(itemid == 1) {
  2163.         hp += 35.0;
  2164.     } else if(itemid == 2) {
  2165.         hp += 55.0;
  2166.     }
  2167.     format(tempstr, sizeof(tempstr), "* %s buys some %s",GetPlayerNameEx(playerid, ENameType_RPName), BuyableRestaurantItems[itemid][EBIDisplayName]);
  2168.     ProxMessage(30.0, playerid, tempstr, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  2169.     GiveMoneyEx(playerid, -BuyableRestaurantItems[itemid][EBIPrice]);
  2170.     addToBusinessTill(biz, floatround(BuyableRestaurantItems[itemid][EBIPrice]/2));
  2171.     SetPlayerHealthEx(playerid, hp);
  2172.     new boost = GetHungerLevel(playerid)+50;
  2173.     if(boost > 100) boost = 100;
  2174.     SetPlayerHunger(playerid, boost);
  2175.     return 0;
  2176. }
  2177. forward OnFishBuy(playerid, itemid, biz, total);
  2178. public OnFishBuy(playerid, itemid, biz, total) {
  2179.     if(BuyableFishStoreItems[itemid][EBIType] != EType_NumSelect) {
  2180.         if(BuyableFishStoreItems[itemid][EBIPrice] > GetMoneyEx(playerid)) {
  2181.             SendClientMessage(playerid, X11_RED3, "You don't have enough cash");
  2182.             return 0;
  2183.         }
  2184.     }
  2185.     new Float:hp;
  2186.     GetPlayerHealth(playerid, hp);
  2187.     if(itemid == 0) {
  2188.         hp += 10.0;
  2189.     } else if(itemid == 1) {
  2190.         hp += 15.0;
  2191.     } else if(itemid == 2) {
  2192.         hp += 25.0;
  2193.     } else if(itemid == 3) {
  2194.         hp += 30.0;
  2195.     }
  2196.     format(tempstr, sizeof(tempstr), "* %s buys some %s",GetPlayerNameEx(playerid, ENameType_RPName), BuyableFishStoreItems[itemid][EBIDisplayName]);
  2197.     ProxMessage(30.0, playerid, tempstr, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  2198.     GiveMoneyEx(playerid, -BuyableFishStoreItems[itemid][EBIPrice]);
  2199.     addToBusinessTill(biz, floatround(BuyableFishStoreItems[itemid][EBIPrice]/2));
  2200.     SetPlayerHealthEx(playerid, hp);
  2201.     new boost = GetHungerLevel(playerid)+50;
  2202.     if(boost > 100) boost = 100;
  2203.     SetPlayerHunger(playerid, boost);
  2204.     return 0;
  2205. }
  2206. forward OnFastFoodBuy(playerid, itemid, biz, total);
  2207. public OnFastFoodBuy(playerid, itemid, biz, total) {
  2208.     if(BuyableFastfoodItems[itemid][EBIType] != EType_NumSelect) {
  2209.         if(BuyableFastfoodItems[itemid][EBIPrice] > GetMoneyEx(playerid)) {
  2210.             SendClientMessage(playerid, X11_RED3, "You don't have enough cash");
  2211.             return 0;
  2212.         }
  2213.     }
  2214.     new Float:hp;
  2215.     GetPlayerHealth(playerid, hp);
  2216.     if(itemid == 0) {
  2217.         hp += 10.0;
  2218.     } else if(itemid == 1) {
  2219.         hp += 15.0;
  2220.     } else if(itemid == 2) {
  2221.         hp += 25.0;
  2222.     } else if(itemid == 3) {
  2223.         hp += 30.0;
  2224.     } else if(itemid == 4) {
  2225.         hp += 35.0;
  2226.     }
  2227.     format(tempstr, sizeof(tempstr), "* %s buys some %s",GetPlayerNameEx(playerid, ENameType_RPName), BuyableFastfoodItems[itemid][EBIDisplayName]);
  2228.     ProxMessage(30.0, playerid, tempstr, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  2229.     GiveMoneyEx(playerid, -BuyableFastfoodItems[itemid][EBIPrice]);
  2230.     addToBusinessTill(biz, floatround(BuyableFastfoodItems[itemid][EBIPrice]/2));
  2231.     SetPlayerHealthEx(playerid, hp);
  2232.     new boost = GetHungerLevel(playerid)+50;
  2233.     if(boost > 100) boost = 100;
  2234.     SetPlayerHunger(playerid, boost);
  2235.     return 0;
  2236. }
  2237. IsDealership(bizid) {
  2238.     if(bizid != -1 && (Business[bizid][EBType] == EBusinessType_D_NormCar || Business[bizid][EBType] == EBusinessType_D_FastCar || Business[bizid][EBType] == EBusinessType_D_Boat || Business[bizid][EBType] == EBusinessType_D_Bike || Business[bizid][EBType] == EBusinessType_D_Plane || Business[bizid][EBType] == EBusinessType_D_Truck)) {
  2239.         return 1;
  2240.     }
  2241.     return 0;
  2242. }
  2243. IsCarRental(bizid) {
  2244.     if(bizid != -1 && (Business[bizid][EBType] == EBusinessType_VehicleRental)) {
  2245.         return 1;
  2246.     }
  2247.     return 0;
  2248. }
  2249. IsFishStore(bizid) {
  2250.  
  2251.     if(bizid != -1 && (Business[bizid][EBType] == EBusinessType_FishStore)) {
  2252.         return 1;
  2253.     }
  2254.     return 0;
  2255. }
  2256. IsFurnitureStore(bizid) {
  2257.     if(bizid != -1 && (Business[bizid][EBType] == EBusinessType_FurnitureStore)) {
  2258.         return 1;
  2259.     }
  2260.     return 0;
  2261. }
  2262. IsPaintball(bizid) {
  2263.     if(bizid != -1 && (Business[bizid][EBType] == EBusinessType_PaintBall)) {
  2264.         return 1;
  2265.     }
  2266.     return 0;
  2267.  }
  2268. IsAtBar(playerid) {
  2269.     if(IsPlayerInRangeOfPoint(playerid, 15.0,1207.23, -29.32, 1000.95) || IsPlayerInRangeOfPoint(playerid, 15.0,756.68, 1441.08, 1102.70) || IsPlayerInRangeOfPoint(playerid, 5.0,1214.61, -13.33, 1000.92) || IsPlayerInRangeOfPoint(playerid, 5.0,968.49, -46.56, 1001.11) || IsPlayerInRangeOfPoint(playerid, 5.0,1415.65, -1489.09, 20.43))
  2270.     {
  2271.         return 1;
  2272.     }
  2273.     else if(IsPlayerInRangeOfPoint(playerid, 15.0,-2658.95, 1410.31, 910.17) || IsPlayerInRangeOfPoint(playerid, 15.0,499.96, -20.35, 1000.67) || IsPlayerInRangeOfPoint(playerid, 5.0,495.55, -76.03, 998.75) || IsPlayerInRangeOfPoint(playerid, 5.0,-224.78, 1404.99, 27.77) || IsPlayerInRangeOfPoint(playerid, 5.0, 238.67, 112.34, 1013.85))
  2274.     {
  2275.         return 1;
  2276.     } else if(IsPlayerInRangeOfPoint(playerid, 15.0,681.12, -453.83, -25.62)) {
  2277.         return 1;
  2278.     }
  2279.     return 0;
  2280. }
  2281. YCMD:drink(playerid, params[], help) {
  2282.     if(!IsAtBar(playerid)) {
  2283.         SendClientMessage(playerid, X11_TOMATO_2, "You aren't at a bar!");
  2284.         return 1;
  2285.     }
  2286.     dialogstr[0] = 0;
  2287.     tempstr[0] = 0;
  2288.     for(new i=0;i<sizeof(Drinks);i++) {
  2289.         format(tempstr, sizeof(tempstr), "%s - $%s\n",Drinks[i][EDrinkName],getNumberString(Drinks[i][EDrinkPrice]));
  2290.         strcat(dialogstr, tempstr, sizeof(dialogstr));
  2291.     }
  2292.    
  2293.     ShowPlayerDialog(playerid, EBusiness_DrinkMenu, DIALOG_STYLE_LIST, "{00BFFF}Drink Menu", dialogstr,"Buy","Cancel");
  2294.     return 1;
  2295. }
  2296. YCMD:givebiz(playerid, params[], help) {
  2297.     if(help) {
  2298.         SendClientMessage(playerid, X11_WHITE, "Used for selling your house");
  2299.         return 1;
  2300.     }
  2301.     new index = getStandingBusiness(playerid);
  2302.     if(index == -1) {
  2303.         SendClientMessage(playerid, X11_WHITE, "You must be standing at a business");
  2304.         return 1;
  2305.     }
  2306.     if(!isBizAdmin(playerid) && (Business[index][EBusinessOwner] != GetPVarInt(playerid,"CharID") || Business[index][EBusinessOwner] == 0)) {
  2307.         SendClientMessage(playerid, X11_WHITE, "You don't own this business.");
  2308.         return 1;
  2309.     }
  2310.     new user;
  2311.     if(!sscanf(params, "k<playerLookup>", user)) {
  2312.         if(!IsPlayerConnectEx(user)) {
  2313.             SendClientMessage(playerid, X11_TOMATO_2, "User not found");
  2314.             return 1;
  2315.         }
  2316.         new Float:X, Float:Y, Float:Z;
  2317.         GetPlayerPos(user, X, Y, Z);
  2318.         if(!IsPlayerInRangeOfPoint(playerid, 5.0, X, Y, Z)) {
  2319.             SendClientMessage(playerid, X11_TOMATO_2, "This person is too far away!");
  2320.             return 1;
  2321.         }
  2322.         SendClientMessage(playerid, COLOR_LIGHTGREEN, "* Business Given");
  2323.         SendClientMessage(user, COLOR_LIGHTGREEN, "* Business Recieved");
  2324.         setBusinessOwner(index, GetPVarInt(user, "CharID"));
  2325.     } else {
  2326.         SendClientMessage(playerid, X11_WHITE, "USAGE: /givehouse [playerid/name]");
  2327.     }
  2328.     return 1;
  2329. }
  2330.  
  2331. forward ShowVehicleLockBuy(playerid, itemid, biz, total);
  2332. public ShowVehicleLockBuy(playerid, itemid, biz, total) {
  2333.     dialogstr[0] = 0;
  2334.     tempstr[0] = 0;
  2335.     for(new i=0;i<sizeof(BuyableCarLocks);i++) {
  2336.         format(tempstr, sizeof(tempstr), "%s - $%s\n",LockName(BuyableCarLocks[i][EBLockType]),getNumberString(BuyableCarLocks[i][EBLockPrice]));
  2337.         strcat(dialogstr, tempstr, sizeof(dialogstr));
  2338.     }
  2339.     ShowPlayerDialog(playerid, EBusiness_LockBuy, DIALOG_STYLE_LIST, "{00BFFF}Vehicle Lock Menu", dialogstr,"Buy","Cancel");   
  2340. }
  2341. forward ShowLotteryTicketBuy(playerid, itemid, biz, total);
  2342. public ShowLotteryTicketBuy(playerid, itemid, biz, total) {
  2343.     if(getPlayerLottoTicket(playerid) != 0) {
  2344.         SendClientMessage(playerid, X11_TOMATO_2, "You already have a lottery ticket!");
  2345.         return 0;
  2346.     }
  2347.     dialogstr[0] = 0;
  2348.     tempstr[0] = 0;
  2349.     strcat(dialogstr, "Buy Ticket (Random Number assigned) - $100\n", sizeof(dialogstr));
  2350.     strcat(dialogstr, "Buy Ticket (Choose Number) - $250\n", sizeof(dialogstr));
  2351.     ShowPlayerDialog(playerid, EBusiness_LottoChoose, DIALOG_STYLE_LIST, "{00BFFF}Lotto Menu", dialogstr,"Buy","Cancel");  
  2352.     return 1;
  2353. }
  2354. forward ShowSellFishMenu(playerid, itemid, biz, total);
  2355. public ShowSellFishMenu(playerid, itemid, biz, total) {
  2356.     dialogstr[0] = 0;
  2357.     tempstr[0] = 0;
  2358.     new fishname[64];
  2359.     new weight, value;
  2360.     for(new slot = 0;slot<MAX_HOLDABLE_FISH;slot++) {
  2361.         GetFishInfoAt(playerid, fishname, sizeof(fishname), slot, weight, value);
  2362.         if(value != 0) {
  2363.             format(tempstr, sizeof(tempstr), "Sell %s - $%s\n",fishname, getNumberString(value));
  2364.             strcat(dialogstr, tempstr, sizeof(dialogstr));
  2365.         }
  2366.     }
  2367.     ShowPlayerDialog(playerid, EBusiness_FishSell, DIALOG_STYLE_LIST, "{00BFFF}Fish Sell Menu", dialogstr,"Sell","Cancel");
  2368. }
  2369. setExtortionist(biz, sqlid) {
  2370.     format(query, sizeof(query), "UPDATE `business` SET `extortion` = %d WHERE `id` = %d",sqlid,Business[biz][EBusinessID]);
  2371.     mysql_function_query(g_mysql_handle, query, true, "onBusinessUpdate", "d",biz);
  2372. }
  2373. setBusinessName(biz, name[]) {
  2374.     new name_esc[(64*2)+1];
  2375.     mysql_real_escape_string(name, name_esc);
  2376.     format(query, sizeof(query), "UPDATE `business` SET `name` = \"%s\" WHERE `id` = %d",name_esc,Business[biz][EBusinessID]);
  2377.     mysql_function_query(g_mysql_handle, query, true, "onBusinessUpdate", "d",biz);
  2378. }
  2379.  
  2380. getModelValue(model) {
  2381.     new i;
  2382.     for(i=0;i<sizeof(EBDNormalCars);i++) {
  2383.         if(EBDNormalCars[i][EBCarModelID] == model) {
  2384.             return EBDNormalCars[i][EBCarPrice];
  2385.         }
  2386.     }
  2387.     for(i=0;i<sizeof(EBDFastCars);i++) {
  2388.         if(EBDFastCars[i][EBCarModelID] == model) {
  2389.             return EBDFastCars[i][EBCarPrice];
  2390.         }
  2391.     }
  2392.     for(i=0;i<sizeof(EBDBikes);i++) {
  2393.         if(EBDBikes[i][EBCarModelID] == model) {
  2394.             return EBDBikes[i][EBCarPrice];
  2395.         }
  2396.     }
  2397.     for(i=0;i<sizeof(EBDTrucks);i++) {
  2398.         if(EBDTrucks[i][EBCarModelID] == model) {
  2399.             return EBDTrucks[i][EBCarPrice];
  2400.         }
  2401.     }
  2402.     for(i=0;i<sizeof(EBDBoats);i++) {
  2403.         if(EBDBoats[i][EBCarModelID] == model) {
  2404.             return EBDBoats[i][EBCarPrice];
  2405.         }
  2406.     }
  2407.     for(i=0;i<sizeof(EBDPlanes);i++) {
  2408.         if(EBDPlanes[i][EBCarModelID] == model) {
  2409.             return EBDPlanes[i][EBCarPrice];
  2410.         }
  2411.     }
  2412.     return 0;
  2413. }
  2414. sellInactiveBusinesses() {
  2415.     mysql_function_query(g_mysql_handle, "SELECT `business`.`id` FROM `business` INNER JOIN `characters` ON `business`.`owner` = `characters`.`id`  INNER JOIN `accounts` ON `characters`.`accountid` = `accounts`.`id` WHERE `business`.`owner` != 0 AND `accounts`.`lastlogin` < DATE_SUB(CURDATE(),INTERVAL 2 WEEK)", true, "OnCheckInactiveBusinesses", "");   
  2416.    
  2417.     mysql_function_query(g_mysql_handle, "SELECT `h`.`id` FROM `business`  AS `h` LEFT JOIN `characters` AS `c` ON `c`.`id` = `h`.`owner` WHERE `c`.`username` IS NULL AND `h`.`owner` != 0", true, "OnCheckInactiveBusinesses", "");
  2418. }
  2419. forward OnCheckInactiveBusinesses();
  2420. public OnCheckInactiveBusinesses() {
  2421.     new rows, fields;
  2422.     new id, id_string[128];
  2423.     cache_get_data(rows, fields);
  2424.     for(new i=0;i<rows;i++) {
  2425.         cache_get_row(i, 0, id_string);
  2426.         id = strval(id_string);
  2427.         new hid = findBizBySQLID(id);
  2428.         if(hid != -1) {
  2429.             setBusinessOwner(hid, 0);
  2430.         }
  2431.     }
  2432. }
  2433. findBizBySQLID(sqlid) {
  2434.     for(new i=0;i<MAX_BUSINESS;i++) {
  2435.         if(Business[i][EBusinessID] == sqlid) {
  2436.             return i;
  2437.         }
  2438.     }
  2439.     return -1;
  2440. }
  2441.  
  2442. GetTotalBusinessValue(playerid) {
  2443.     new charid = GetPVarInt(playerid,"CharID");
  2444.     new value;
  2445.     for(new i=0;i<MAX_BUSINESS;i++) {
  2446.         if(Business[i][EBusinessOwner] == charid) {
  2447.             value += Business[i][EBusinessPrice];
  2448.             value += Business[i][EBusinessTill];
  2449.         }
  2450.     }
  2451.     return value;
  2452. }
  2453.  
  2454. GetRentModelPrice(model) {
  2455.     for(new i=0;i<sizeof(RentableCars);i++) {
  2456.         if(RentableCars[i][ECarRental_ModelID] == model) {
  2457.             return RentableCars[i][ECarRental_HourlyRate];
  2458.         }
  2459.     }
  2460.     return 0;
  2461. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement