iMaikel

[FilterScript] Business System

Jun 26th, 2020 (edited)
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 43.19 KB | None | 0 0
  1. Commands:
  2. admin:
  3. /createbiz - creates the bizz
  4. /deletebiz - deletes the bizz
  5. /gotobiz - go to any bizz
  6. /asellbizz - sells any bizz
  7. /bused - see the bizz info
  8. /bedit - edit the bizz info
  9.  
  10. players:
  11. /enter - enters
  12. /exit - exits
  13. /sellbiztomarket - sells a bizz
  14. /buybiz - buys a bizz
  15. /lockb - locking the bizz
  16. /buyproducts - buying bizz's products
  17. /vault - checking bizz's vault
  18. /bizzhelp - showing the business system help
  19.  
  20. known bug(s):
  21. /lockb is bugged atm, something is wrong with the values
  22. /buyproducts is absolutely bugged, you may remove it as I cannot really fix it.
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31. // This is a comment
  32. // uncomment the line below if you want to write a filterscript
  33. //#define FILTERSCRIPT
  34.  
  35. #include <a_samp>
  36. #include <ZCMD>
  37. #include <dini>
  38. #include <dudb>
  39. #include <dutils>
  40. #include <YSI\y_ini>
  41. #include <streamer>
  42. #include <sscanf2>
  43. #include <foreach>
  44.  
  45. #pragma tabsize 0
  46. #define FILTERSCRIPT
  47. // Color Defines
  48. #define COLOR_WHITE 0xFFFFFFFF
  49. #define COLOR_FADE1 0xE6E6E6E6
  50. #define COLOR_PM1 0xA65FC7FF
  51. #define COLOR_PM2 0xD35FC7FF
  52. #define COLOR_FADE2 0xC8C8C8C8
  53. #define COLOR_FADE3 0xAAAAAAAA
  54. #define COLOR_FADE4 0x8C8C8C8C
  55. #define COLOR_FADE5 0x6E6E6E6E
  56. #define COLOR_OOC 0xE0FFFFFF
  57. #define COLOR_GREY 0xAFAFAFFF
  58. #define COLOR_LIGHTGREEN 0xADFF2FFF
  59. #define COLOR_LIGHTRED 0xFF6347FF
  60. #define COLOR_DARKRED 0xAA3333FF
  61. #define COLOR_RED 0xFF0606FF
  62. #define COLOR_LIGHTBLUE 0x33CCFFFF
  63. #define COLOR_GREEN 0x33AA33FF
  64. #define COLOR_YELLOW 0xFFFF00FF
  65. #define COLOR_PURPLE 0xC2A2DAFF
  66. #define COLOR_ORANGE 0xFF9900FF
  67. #define COLOR_REPORT 0xFFFF91FF
  68. #define COLOR_RADIO 0x8D8DFFFF
  69. #define COLOR_DEPTRADIO 0xFFD700FF
  70. #define COLOR_BLUE 0x2641FEFF
  71. #define COLOR_MEDIC 0xFF8282FF
  72. #define COLOR_NEWBIE 0x7DAEFFFF
  73. #define COLOR_LIME 0x00FF00FF
  74. #define COLOR_NEWS 0x049C7100
  75. #define COLOR_CYAN 0x01FCFFFF
  76. #define COLOR_VIP 0xC93CCEFF
  77. #define COLOR_GOLD 0xFFD700FF
  78.  
  79. // Biz Defines
  80. #define MAX_BIZ 201
  81. #define COE "{F07B0F}"
  82. #define CWE "{FFFFFF}"
  83. #define CGE "{2A8A07}"
  84.  
  85. enum pInfo
  86. {
  87.     pAdmin,
  88.     pCash,
  89.     pBiz,
  90.     pMaskOn,
  91.     pHideOn,
  92.     pVBiz
  93. };
  94. new PlayerInfo[MAX_PLAYERS][pInfo];
  95.  
  96. enum bizInfo
  97. {
  98.     bType,
  99.     bStatus,
  100.     bOwner[32],
  101.     Float:bX,
  102.     Float:bY,
  103.     Float:bZ,
  104.     bPickup,
  105.     bMoney,
  106.     bProducts,
  107.     Text3D:bText,
  108.     bSold,
  109.     bLevel,
  110.     bPrice,
  111.     bAP
  112. }
  113. new BizInfo[MAX_BIZ][bizInfo];
  114.  
  115. public OnFilterScriptInit()
  116. {
  117.     LoadBiz();
  118.     print("\n--------------------------------------");
  119.     print(" Business System By EquinoX/Flaken");
  120.     print("--------------------------------------\n");
  121.     return 1;
  122. }
  123.  
  124. public OnFilterScriptExit()
  125. {
  126.     SaveBiz();
  127.     return 1;
  128. }
  129. stock CheckFiles()
  130. {
  131.     if(!dini_Exists("businesses.cfg")) dini_Create("businesses.cfg");
  132.     return 1;
  133. }
  134. stock LoadBiz()
  135. {
  136.     if(!fexist("businesses.cfg")) fcreate("businesses.cfg");
  137.     new binfo[12][32];
  138.     new string[256];
  139.     new File:file = fopen("businesses.cfg", io_read);
  140.     if(file)
  141.     {
  142.         new idx = 1;
  143.         while(idx < MAX_BIZ)
  144.         {
  145.             fread(file, string);
  146.             split(string, binfo, '|');
  147.             BizInfo[idx][bType] = strval(binfo[0]);
  148.             BizInfo[idx][bStatus] = strval(binfo[1]);
  149.             format(BizInfo[idx][bOwner], 32, "%s", binfo[2]);
  150.             BizInfo[idx][bX] = floatstr(binfo[3]);
  151.             BizInfo[idx][bY] = floatstr(binfo[4]);
  152.             BizInfo[idx][bZ] = floatstr(binfo[5]);
  153.             BizInfo[idx][bMoney] = strval(binfo[6]);
  154.             BizInfo[idx][bProducts] = strval(binfo[7]);
  155.             BizInfo[idx][bSold] = strval(binfo[8]);
  156.             BizInfo[idx][bLevel] = strval(binfo[9]);
  157.             BizInfo[idx][bPrice] = strval(binfo[10]);
  158.             BizInfo[idx][bAP] = strval(binfo[11]);
  159.             if(BizInfo[idx][bType]) // If Business is owned
  160.             {
  161.                 BizInfo[idx][bPickup] = CreateDynamicPickup(1272, 1, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ], 0);
  162.                 if(!strcmp("The State", BizInfo[idx][bOwner])) format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: For Sale\nPrice: $%d", idx, RBT(idx), BizInfo[idx][bOwner], BizInfo[idx][bPrice]);
  163.                 //else format(string, sizeof(string), "ID: %d\n%s\nOwner: %s\nStatus: %s", idx, RBT(idx), BizInfo[idx][bOwner], RBS(idx));
  164.                 else format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: %s", idx, RBT(idx), BizInfo[idx][bOwner], RBS(idx));
  165.                 BizInfo[idx][bText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]+0.3, 15);
  166.             }
  167.             idx++;
  168.         }
  169.     }
  170.     print("Businesses loaded successfully.");
  171.     return 1;
  172. }
  173.  
  174. stock SaveBiz()
  175. {
  176.     if(!fexist("businesses.cfg")) fcreate("businesses.cfg");
  177.     new idx = 1, File:file;
  178.     new string[256];
  179.     while(idx < MAX_BIZ)
  180.     {
  181.         format(string, sizeof(string), "%d|%d|%s|%f|%f|%f|%d|%d|%d|%d|%d|%d\r\n", BizInfo[idx][bType], BizInfo[idx][bStatus], BizInfo[idx][bOwner], BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ], BizInfo[idx][bMoney], BizInfo[idx][bProducts], BizInfo[idx][bSold], BizInfo[idx][bLevel], BizInfo[idx][bPrice], BizInfo[idx][bAP]);
  182.         if(idx == 1)
  183.         {
  184.             file = fopen("businesses.cfg", io_write);
  185.         }
  186.         else
  187.         {
  188.             file = fopen("businesses.cfg", io_append);
  189.         }
  190.         fwrite(file, string);
  191.         fclose(file);
  192.         idx++;
  193.     }
  194.     print("Businesses saved successfully.");
  195. }
  196. public OnPlayerConnect( playerid )
  197. {
  198. SendClientMessage(playerid, COLOR_GREY,"This server is using Flaken's business system!");
  199. return 1;
  200. }
  201.  
  202. CMD:createbiz(playerid, params[])
  203. {
  204.     new type, string[128];
  205.     if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  206.     if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  207. //    if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
  208.     if(sscanf(params, "i", type))
  209.     {
  210.         SendClientMessage(playerid, COLOR_WHITE, "USAGE: /createbiz [type]");
  211.         SendClientMessage(playerid, COLOR_GREY, "TYPES: 1) 24/7 | 2) Clothes Shop | 3) Ammunation | 4) Club | 5) Advertisement Agency | 6) Fast Food | 7) Casino");
  212.         return 1;
  213.     }
  214.     if(type < 1 || type > 7) return SendClientMessage(playerid, COLOR_GREY, "Businesses are between 1 and 7.");
  215.     for(new idx=1; idx<MAX_BIZ; idx++)
  216.     {
  217.         if(!BizInfo[idx][bType])
  218.         {
  219.             //g_bizRobber[idx] = -1;
  220.             // Getting Business Setup
  221.             new Float:X, Float:Y, Float:Z;
  222.             GetPlayerPos(playerid, X, Y, Z);
  223.             // Making Business
  224.             BizInfo[idx][bType] = type;
  225.             BizInfo[idx][bStatus] = 0;
  226.             format(BizInfo[idx][bOwner], 32, "The State");
  227.             BizInfo[idx][bX] = X;
  228.             BizInfo[idx][bY] = Y;
  229.             BizInfo[idx][bZ] = Z;
  230.             BizInfo[idx][bMoney] = 0;
  231.             BizInfo[idx][bProducts] = 0;
  232.             BizInfo[idx][bSold] = 0;
  233.             BizInfo[idx][bLevel] = 1;
  234.             BizInfo[idx][bPrice] = 500000;
  235.             BizInfo[idx][bPickup] = CreateDynamicPickup(1272, 1, X, Y, Z, 0);
  236.             format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: For Sale\nPrice: $%d", idx, RBT(idx), BizInfo[idx][bOwner], BizInfo[idx][bPrice]);
  237.             BizInfo[idx][bText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, X, Y, Z, 15);
  238.             format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has created business ID %d.", RPN(playerid), idx);
  239.             //SendAdminMessage(COLOR_DARKRED, 1, string);
  240.             Log("logs/business.log", string);
  241.             idx = MAX_BIZ;
  242.         }
  243.     }
  244.     return 1;
  245. }
  246.  
  247. CMD:deletebiz(playerid, params[])
  248. {
  249.     new id, string[128];
  250.     if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  251.     if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  252. //    if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
  253.     if(sscanf(params, "i", id)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /deletebiz [bizid]");
  254.     if(!BizInfo[id][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
  255.     foreach(Player, i)
  256.     {
  257.         if(IsPlayerConnected(i) && PlayerInfo[i][pBiz] == id)
  258.         {
  259.             PlayerInfo[playerid][pBiz] = 0;
  260.             format(string, sizeof(string), " Adminstrator %s has deleted your business.", RPN(playerid));
  261.             SendClientMessage(i, COLOR_WHITE, string);
  262.         }
  263.     }
  264.     if(!strcmp("The State", BizInfo[id][bOwner]))
  265.     {
  266.         format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has deleted business ID %d.", RPN(playerid), id);
  267.     }
  268.     else
  269.     {
  270.         format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has deleted %s's business. (ID %d)", RPN(playerid), BizInfo[id][bOwner], id);
  271.     }
  272.     //SendAdminMessage(COLOR_DARKRED, 1, string);
  273.     Log("logs/business.log", string);
  274.     BizInfo[id][bType] = 0;
  275.     BizInfo[id][bStatus] = 0;
  276.     format(BizInfo[id][bOwner], 32, "");
  277.     BizInfo[id][bX] = 0;
  278.     BizInfo[id][bY] = 0;
  279.     BizInfo[id][bZ] = 0;
  280.     BizInfo[id][bMoney] = 0;
  281.     BizInfo[id][bProducts] = 0;
  282.     DestroyDynamicPickup(BizInfo[id][bPickup]);
  283.     DestroyDynamic3DTextLabel(BizInfo[id][bText]);
  284.     return 1;
  285. }
  286. CMD:bizhelp(playerid, params[])
  287. {
  288.     if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  289.     SendClientMessage(playerid, COLOR_YELLOW, "BUSINESS: {FFFFFF}/buybiz");
  290.     if(PlayerInfo[playerid][pBiz] || PlayerInfo[playerid][pVBiz]) SendClientMessage(playerid, COLOR_YELLOW, "BUSINESS OWNER: {FFFFFF}/vault /lock /buyproducts /sellbiztomarket");
  291.     return 1;
  292. }
  293. CMD:vault(playerid, params[])
  294. {
  295.     new value, string[128];
  296.     new idx = PlayerInfo[playerid][pBiz];
  297.     if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  298.     if(!PlayerInfo[playerid][pBiz] && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a busines.");
  299.     if(GetPlayerVirtualWorld(playerid)-100 != idx && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your business.");
  300.     if(GetPlayerVirtualWorld(playerid)-100 != idx && PlayerInfo[playerid][pVBiz])
  301.     {
  302.         idx = PlayerInfo[playerid][pVBiz];
  303.         if(GetPlayerVirtualWorld(playerid)-100 != idx) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your business.");
  304.     }
  305.     if(sscanf(params, "s[32]", params))
  306.     {
  307.         SendClientMessage(playerid, COLOR_WHITE, "USAGE: /vault [option]");
  308.         SendClientMessage(playerid, COLOR_GREY, "OPTIONS: withdraw | deposit");
  309.         return 1;
  310.     }
  311.     if(!strcmp(params, "withdraw", false, 8))
  312.     {
  313.         if(sscanf(params, "s[32]i", params, value))
  314.         {
  315.             SendClientMessage(playerid, COLOR_WHITE, "USAGE: /vault withdraw [amount]");
  316.             format(string, sizeof(string), "Current Vault Money: $%d", BizInfo[idx][bMoney]);
  317.             SendClientMessage(playerid, COLOR_GREY, string);
  318.             return 1;
  319.         }
  320.         if(value > BizInfo[idx][bMoney]) return SendClientMessage(playerid, COLOR_GREY, "You don't have this much money in your business vault.");
  321.         BizInfo[idx][bMoney] -= value;
  322.         GivePlayerCash(playerid, value);
  323.         format(string, sizeof(string), "* %s has withdrawn money from their business vault.", RPN(playerid));
  324.         SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  325.         format(string, sizeof(string), " You have withdrawn $%d from your business vault, amount left: $%d", value, BizInfo[idx][bMoney]);
  326.         SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
  327.     }
  328.     else if(!strcmp(params, "deposit", false, 7))
  329.     {
  330.         if(sscanf(params, "s[32]i", params, value))
  331.         {
  332.             SendClientMessage(playerid, COLOR_WHITE, "USAGE: /vault deposit [amount]");
  333.             format(string, sizeof(string), "Current Vault Money: $%d", BizInfo[idx][bMoney]);
  334.             SendClientMessage(playerid, COLOR_GREY, string);
  335.             return 1;
  336.         }
  337.         if(value > PlayerInfo[playerid][pCash]) return SendClientMessage(playerid, COLOR_GREY, "You don't have this much money on you.");
  338.         BizInfo[idx][bMoney] += value;
  339.         GivePlayerCash(playerid, -value);
  340.         format(string, sizeof(string), "* %s has deposited money to their business vault.", RPN(playerid));
  341.         SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  342.         format(string, sizeof(string), " You have deposited $%d to your business vault, current amount: $%d", value, BizInfo[idx][bMoney]);
  343.         SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
  344.     }
  345.     return 1;
  346. }
  347. /*CMD:buyproducts(playerid, params[])
  348. {
  349.     new amount, price, string[128];
  350.     new idx = PlayerInfo[playerid][pBiz];
  351.     if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  352.     if(!PlayerInfo[playerid][pBiz] && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a business.");
  353.     if(GetPlayerVirtualWorld(playerid)-100 != idx && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your business.");
  354.     if(GetPlayerVirtualWorld(playerid)-100 != idx && PlayerInfo[playerid][pVBiz])
  355.     {
  356.         idx = PlayerInfo[playerid][pVBiz];
  357.         if(GetPlayerVirtualWorld(playerid)-100 != idx) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your business.");
  358.     }
  359.     if(sscanf(params, "i", amount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /buyproducts [amount]");
  360.     if(amount < 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid products amount.");
  361.     if(Products < amount)
  362.     {
  363.         format(string, sizeof(string), "The products dropoff currently has %d products only.", Products);
  364.         SendClientMessage(playerid, COLOR_GREY, string);
  365.         return 1;
  366.     }
  367.     price = amount*20;
  368.     if(PlayerInfo[playerid][pCash] < price)
  369.     {
  370.         format(string, sizeof(string), "You don't have that much money on you. ($%d)", price);
  371.         SendClientMessage(playerid, COLOR_GREY, string);
  372.         return 1;
  373.     }
  374.     if(BizInfo[idx][bProducts]+amount > 500) return SendClientMessage(playerid, COLOR_GREY, "Your business can't hold that much products.");
  375.     GivePlayerCash(playerid, -price);
  376.     BizInfo[idx][bProducts] += amount;
  377.     Products -= amount;
  378.     format(string, sizeof(string), "* %s has purchased %d products for $%d.", RPN(playerid), amount, price);
  379.     SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  380.     format(string, sizeof(string), "Packages Dropoff\n{FFFF00}/deliverpackages to deliver crates\nAvailable Products: %d/20000", Products);
  381.     UpdateDynamic3DTextLabelText(ProductsText, COLOR_RED, string);
  382.     return 1;
  383. }*/
  384. /*CMD:lockb(playerid, params[])
  385. {
  386.     new string[128], idx, done, lockdone;
  387.     if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  388.     if(PlayerInfo[playerid][pBiz])
  389.     {
  390.         if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[PlayerInfo[playerid][pBiz]][bX], BizInfo[PlayerInfo[playerid][pBiz]][bY], BizInfo[PlayerInfo[playerid][pBiz]][bZ]))
  391.         {
  392.             if(!BizInfo[PlayerInfo[playerid][pBiz]][bStatus])
  393.             {
  394.                 BizInfo[PlayerInfo[playerid][pBiz]][bStatus] = 1;
  395.                 format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: %s", PlayerInfo[playerid][pBiz], RBT(PlayerInfo[playerid][pBiz]), BizInfo[PlayerInfo[playerid][pBiz]][bOwner], RBS(PlayerInfo[playerid][pBiz]));
  396.                 UpdateDynamic3DTextLabelText(BizInfo[PlayerInfo[playerid][pBiz]][bText], COLOR_WHITE, string);
  397.                 format(string, sizeof(string), "* %s takes out their business keys and unlocks it.", RPN(playerid));
  398.                 SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  399.                 GameTextForPlayer(playerid, "~g~Business Unlocked", 3500, 3);
  400.             }
  401.             else if(BizInfo[PlayerInfo[playerid][pBiz]][bStatus])
  402.             {
  403.                 BizInfo[PlayerInfo[playerid][pBiz]][bStatus] = 0;
  404.                 format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: %s", PlayerInfo[playerid][pBiz], RBT(PlayerInfo[playerid][pBiz]), BizInfo[PlayerInfo[playerid][pBiz]][bOwner], RBS(PlayerInfo[playerid][pBiz]));
  405.                 UpdateDynamic3DTextLabelText(BizInfo[PlayerInfo[playerid][pBiz]][bText], COLOR_WHITE, string);
  406.                 format(string, sizeof(string), "* %s takes out their business keys and locks it.", RPN(playerid));
  407.                 SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  408.                 GameTextForPlayer(playerid, "~r~Business Locked", 3500, 3);
  409.    }
  410.             done = 1;
  411.             lockdone = 1;
  412.             }
  413.         }
  414.         return 1;
  415.     }*/
  416. CMD:buybiz(playerid, params[])
  417. {
  418.     new string[128], done;
  419.     if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  420.     if(PlayerInfo[playerid][pBiz] == 1) return SendClientMessage(playerid, COLOR_GREY, "You already own a businesses.");
  421.     //if(PlayerInfo[playerid][pBiz] && PlayerInfo[playerid][pVIP] < 4) return SendClientMessage(playerid, COLOR_GREY, "You already own a business.");
  422.     for(new idx=1; idx<MAX_BIZ; idx++)
  423.     {
  424.         if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
  425.         {
  426.             if(!strcmp("The State", BizInfo[idx][bOwner], false))
  427.             {
  428.                 if(GetPlayerMoney(playerid) < BizInfo[idx][bPrice]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this business.");
  429.                 {
  430.                 GivePlayerCash(playerid, -BizInfo[idx][bPrice]);
  431.                 if(PlayerInfo[playerid][pBiz]) PlayerInfo[playerid][pVBiz] = idx;
  432.                 else PlayerInfo[playerid][pBiz] = idx;
  433.                 format(BizInfo[idx][bOwner], 32, "%s", RPNU(playerid));
  434.                 format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: %s", idx, RBT(idx), BizInfo[idx][bOwner], RBS(idx));
  435.                 UpdateDynamic3DTextLabelText(BizInfo[idx][bText], COLOR_WHITE, string);
  436.                 SendClientMessage(playerid, COLOR_GREEN, " You have successfully bought a business.");
  437.                 SendClientMessage(playerid, COLOR_WHITE, " Type /bizhelp to view your business commands.");
  438.                 BizInfo[idx][bProducts] = 99999;
  439.                 format(string, sizeof(string), "%s has bought business id %d.", RPN(playerid), idx);
  440.                 Log("logs/business.log", string);
  441.                 idx = MAX_BIZ;
  442.                 done = 1;
  443.             }
  444.             if(idx == MAX_BIZ-1 && !done)
  445.             {
  446.                 SendClientMessage(playerid, COLOR_GREY, "This business is owned by someone else.");
  447.             }
  448.         }
  449.         if(idx == MAX_BIZ-1 && !done)
  450.         {
  451.             SendClientMessage(playerid, COLOR_GREY, "You are not near a buyable business.");
  452.         }
  453.     }
  454. }
  455.     return 1;
  456. }
  457.  
  458.  
  459.  
  460. CMD:sellbiztomarket(playerid, params[])
  461. {
  462.     new string[128];
  463.     if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  464.     if(!PlayerInfo[playerid][pBiz] && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a business.");
  465.     if(sscanf(params, "s[8]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sellbiztomarket confirm");
  466.     if(!strcmp(params, "confirm", true))
  467.     {
  468.         new done;
  469.         if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[PlayerInfo[playerid][pBiz]][bX], BizInfo[PlayerInfo[playerid][pBiz]][bY], BizInfo[PlayerInfo[playerid][pBiz]][bZ]))
  470.         {
  471.             GivePlayerCash(playerid, (75*BizInfo[PlayerInfo[playerid][pBiz]][bPrice])/100);
  472.             BizInfo[PlayerInfo[playerid][pBiz]][bStatus] = 0;
  473.             format(BizInfo[PlayerInfo[playerid][pBiz]][bOwner], 32, "The State");
  474.             format(string, sizeof(string), "[Business ID:% d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: For Sale\nPrice: $%d", PlayerInfo[playerid][pBiz], RBT(PlayerInfo[playerid][pBiz]), BizInfo[PlayerInfo[playerid][pBiz]][bOwner], BizInfo[PlayerInfo[playerid][pBiz]][bPrice]);
  475.             UpdateDynamic3DTextLabelText(BizInfo[PlayerInfo[playerid][pBiz]][bText], COLOR_WHITE, string);
  476.             SendClientMessage(playerid, COLOR_GREEN, " You have successfully sold your business to The State. (75 percent of original price was paid back)");
  477.             format(string, sizeof(string), "%s has sold business id %d to the market.", RPN(playerid), PlayerInfo[playerid][pBiz]);
  478.             Log("logs/business.log", string);
  479.             PlayerInfo[playerid][pBiz] = 0;
  480.             done = 1;
  481.         }
  482.         if(!done)
  483.         {
  484.             new idx = PlayerInfo[playerid][pVBiz];
  485.             if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
  486.             {
  487.                 GivePlayerCash(playerid, (75*BizInfo[idx][bPrice])/100);
  488.                 BizInfo[idx][bStatus] = 0;
  489.                 format(BizInfo[idx][bOwner], 32, "The State");
  490.                 format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: For Sale\nPrice: $%d", idx, RBT(idx), BizInfo[idx][bOwner], BizInfo[idx][bPrice]);
  491.                 UpdateDynamic3DTextLabelText(BizInfo[idx][bText], COLOR_WHITE, string);
  492.                 SendClientMessage(playerid, COLOR_GREEN, " You have successfully sold your business to The State. (75 percent of original price was paid back)");
  493.                 format(string, sizeof(string), "%s has sold business id %d to the market.", RPN(playerid), idx);
  494.                 Log("logs/business.log", string);
  495.                 PlayerInfo[playerid][pVBiz] = 0;
  496.                 done = 1;
  497.             }
  498.         }
  499.         if(!done)
  500.         {
  501.             SendClientMessage(playerid, COLOR_GREY, "You are not near your business.");
  502.             return 1;
  503.         }
  504.     }
  505.     return 1;
  506. }
  507. CMD:enter(playerid, params[])
  508. {
  509.     new string[128];
  510.     for(new idx=1; idx<MAX_BIZ; idx++)
  511.     {
  512.         if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
  513.         {
  514.             if(!BizInfo[idx][bStatus] && PlayerInfo[playerid][pBiz] != idx && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "This business is closed.");
  515.             if(BizInfo[idx][bType] == 1) // 24/7 Business
  516.             {
  517.                 format(string, sizeof(string), "* %s pushes the door and enters the shop.", RPN(playerid));
  518.                 SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  519.                 SetPlayerPos(playerid, -27.3025,-57.6649,1003.5469);
  520.                 SetPlayerFacingAngle(playerid, 357.5915);
  521.                 SetCameraBehindPlayer(playerid);
  522.                 SetPlayerInterior(playerid, 6);
  523.                 SetPlayerVirtualWorld(playerid, idx+100);
  524.                 format(string, sizeof(string), "** Welcome to %s's 24/7 Market (( /list & /buy )) **", BizInfo[idx][bOwner]);
  525.                 SendClientMessage(playerid, COLOR_ORANGE, string);
  526.                 return 1;
  527.             }
  528.             else if(BizInfo[idx][bType] == 2) // Clothes Shop Business
  529.             {
  530.                 format(string, sizeof(string), "* %s pushes the door and enters the shop.", RPN(playerid));
  531.                 SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  532.                 SetPlayerPos(playerid, 207.0638,-139.9965,1003.5078);
  533.                 SetPlayerFacingAngle(playerid, 356.3849);
  534.                 SetCameraBehindPlayer(playerid);
  535.                 SetPlayerInterior(playerid, 3);
  536.                 SetPlayerVirtualWorld(playerid, idx+100);
  537.                 format(string, sizeof(string), "** Welcome to %s's Clothes Shop (( /buyclothes(old) & /buytoys )) **", BizInfo[idx][bOwner]);
  538.                 SendClientMessage(playerid, COLOR_ORANGE, string);
  539.                 return 1;
  540.             }
  541.             else if(BizInfo[idx][bType] == 3) // Ammunation Business
  542.             {
  543.                 format(string, sizeof(string), "* %s pushes the door and enters the shop.", RPN(playerid));
  544.                 SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  545.                 SetPlayerPos(playerid, 285.8044,-85.9956,1001.5229);
  546.                 SetPlayerFacingAngle(playerid, 358.9898);
  547.                 SetCameraBehindPlayer(playerid);
  548.                 SetPlayerInterior(playerid, 4);
  549.                 SetPlayerVirtualWorld(playerid, idx+100);
  550.                 format(string, sizeof(string), "** Welcome to %s's Ammunation (( /list & /buy /buyweapon )) **", BizInfo[idx][bOwner]);
  551.                 SendClientMessage(playerid, COLOR_ORANGE, string);
  552.                 return 1;
  553.             }
  554.             else if(BizInfo[idx][bType] == 4) // Club Business
  555.             {
  556.                 format(string, sizeof(string), "* %s pushes the door and enters the shop.", RPN(playerid));
  557.                 SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  558.                 SetPlayerPos(playerid, 493.4252,-24.3061,1000.6797);
  559.                 SetPlayerFacingAngle(playerid, 0.2432);
  560.                 SetCameraBehindPlayer(playerid);
  561.                 SetPlayerInterior(playerid, 17);
  562.                 SetPlayerVirtualWorld(playerid, idx+100);
  563.                 format(string, sizeof(string), "** Welcome to %s's Club (( /list & /buy )) **", BizInfo[idx][bOwner]);
  564.                 SendClientMessage(playerid, COLOR_ORANGE, string);
  565.                 return 1;
  566.             }
  567.             else if(BizInfo[idx][bType] == 5) // Advertisement Agency
  568.             {
  569.                 format(string, sizeof(string), "* %s pushes the door and enters the shop.", RPN(playerid));
  570.                 SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  571.                 SetPlayerPos(playerid, 834.1631,7.4883,1004.1797);
  572.                 SetPlayerFacingAngle(playerid, 86.7239);
  573.                 SetCameraBehindPlayer(playerid);
  574.                 SetPlayerInterior(playerid, 3);
  575.                 SetPlayerVirtualWorld(playerid, idx+100);
  576.                 format(string, sizeof(string), "** Welcome to %s's Advertisement Agency (( /ad )) **", BizInfo[idx][bOwner]);
  577.                 SendClientMessage(playerid, COLOR_ORANGE, string);
  578.                 return 1;
  579.             }
  580.             else if(BizInfo[idx][bType] == 6) // Fast Food
  581.             {
  582.                 format(string, sizeof(string), "* %s pushes the door and enters the shop.", RPN(playerid));
  583.                 SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  584.                 SetPlayerPos(playerid, 372.3830,-133.2579,1001.4922);
  585.                 SetPlayerFacingAngle(playerid, 0.4216);
  586.                 SetCameraBehindPlayer(playerid);
  587.                 SetPlayerInterior(playerid, 5);
  588.                 SetPlayerVirtualWorld(playerid, idx+100);
  589.                 format(string, sizeof(string), "** Welcome to %s's Fast Food (( /list /buy )) **", BizInfo[idx][bOwner]);
  590.                 SendClientMessage(playerid, COLOR_ORANGE, string);
  591.                 return 1;
  592.             }
  593.             else if(BizInfo[idx][bType] == 7) // Casino
  594.             {
  595.                 format(string, sizeof(string), "* %s pushes the door and enters the casino.", RPN(playerid));
  596.                 SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  597.                 SetPlayerPos(playerid, 2233.8032,1712.2303,1011.7632);
  598.                 SetPlayerFacingAngle(playerid, 0.4216);
  599.                 SetCameraBehindPlayer(playerid);
  600.                 SetPlayerInterior(playerid, 1);
  601.                 SetPlayerVirtualWorld(playerid, idx+100);
  602.                 format(string, sizeof(string), "** Welcome to %s's Casino (( /list /buy )) **", BizInfo[idx][bOwner]);
  603.                 SendClientMessage(playerid, COLOR_ORANGE, string);
  604.                 return 1;
  605.             }
  606.         }
  607.     }
  608.     return 1;
  609. }
  610. CMD:exit(playerid, params[])
  611. {
  612.     new done, string[128];
  613.     if(IsPlayerInRangeOfPoint(playerid, 5, 2233.8032,1712.2303,1011.7632) || IsPlayerInRangeOfPoint(playerid, 2, -27.3025,-57.6649,1003.5469) || IsPlayerInRangeOfPoint(playerid, 2, 207.0638,-139.9965,1003.5078) || IsPlayerInRangeOfPoint(playerid, 2, 285.8044,-85.9956,1001.5229) || IsPlayerInRangeOfPoint(playerid, 2, 493.4252,-24.3061,1000.6797) || IsPlayerInRangeOfPoint(playerid, 2, 834.1631,7.4883,1004.1797) || IsPlayerInRangeOfPoint(playerid, 2, 372.3830,-133.2579,1001.4922))
  614.     {
  615.         new idx;
  616.         idx = GetPlayerVirtualWorld(playerid)-100;
  617.         if(!done && idx < MAX_BIZ && BizInfo[idx][bType])
  618.         {
  619.             if(BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ])
  620.             {
  621.                 idx = GetPlayerVirtualWorld(playerid)-100;
  622.                 if(!done && idx < MAX_BIZ && BizInfo[idx][bType])
  623.                 {
  624.                     SetPlayerPos(playerid, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]);
  625.                     SetPlayerInterior(playerid, 0);
  626.                     SetPlayerVirtualWorld(playerid, 0);
  627.                 }
  628.                 done = 1;
  629.                 return 1;
  630.             }
  631.             format(string, sizeof(string), "* %s pushes the door and exits the shop.", RPN(playerid));
  632.             if(PlayerInfo[playerid][pMaskOn] == 1)
  633.             {
  634.                 format(string, sizeof(string), "* Stranger pushes the door and exits the shop.");
  635.             }
  636.             else
  637.             {
  638.                 format(string, sizeof(string), "* %s pushes the door and exits the shop.", RPN(playerid));
  639.             }
  640.             SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  641.             SetPlayerPos(playerid, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]);
  642.             SetPlayerInterior(playerid, 0);
  643.             SetPlayerVirtualWorld(playerid, 0);
  644.         }
  645.         done = 1;
  646.     }
  647.     return 1;
  648. }
  649. CMD:bused(playerid, params[])
  650. {
  651.     new string[128];
  652.     if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  653.     if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  654. //    if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
  655.     SendClientMessage(playerid, COLOR_ORANGE, "[Used Businesses]:");
  656.     for(new idx=1; idx<MAX_BIZ; idx++)
  657.     {
  658.         if(BizInfo[idx][bType])
  659.         {
  660.             format(string, sizeof(string), "ID: %d | Type: %s | Level: %d | Price: $%d | Products: %d | Vault: $%d | Owner: %s", idx, RBT(idx), BizInfo[idx][bLevel], BizInfo[idx][bPrice],BizInfo[idx][bProducts], BizInfo[idx][bMoney], BizInfo[idx][bOwner]);
  661.             SendClientMessage(playerid, COLOR_ORANGE, string);
  662.         }
  663.     }
  664.     return 1;
  665. }
  666. CMD:bedit(playerid, params[])
  667. {
  668.     new bizid, string[128], input;
  669.     if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  670.     if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not an authorized to use this command.");
  671. //    if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
  672.     if(sscanf(params, "s[32]", params))
  673.     {
  674.         SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit [option] [bizid]");
  675.         SendClientMessage(playerid, COLOR_GREY, "OPTIONS: location | price | level | products | vault | truckers");
  676.         return 1;
  677.     }
  678.     if(!strcmp(params, "location", true, 8))
  679.     {
  680.         if(sscanf(params, "s[32]i", params, bizid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit location [bizid]");
  681.         new idx=bizid;
  682.         if(!BizInfo[bizid][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
  683.         GetPlayerPos(playerid, BizInfo[bizid][bX], BizInfo[bizid][bY], BizInfo[bizid][bZ]);
  684.         DestroyDynamicPickup(BizInfo[bizid][bPickup]);
  685.         BizInfo[bizid][bPickup] = CreateDynamicPickup(1272, 1, BizInfo[bizid][bX], BizInfo[bizid][bY], BizInfo[bizid][bZ], 0);
  686.         DestroyDynamic3DTextLabel(BizInfo[bizid][bText]);
  687.         if(!strcmp("The State", BizInfo[idx][bOwner])) format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: For Sale\nPrice: $%d", idx, RBT(idx), BizInfo[idx][bOwner], BizInfo[idx][bPrice]);
  688.         else format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: %s", idx, RBT(idx), BizInfo[idx][bOwner], RBS(idx));
  689.         BizInfo[bizid][bText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, BizInfo[bizid][bX], BizInfo[bizid][bY], BizInfo[bizid][bZ]+0.3, 15);
  690.         format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has changed business ID %d's location.", NORPN(playerid), bizid);
  691.         //SendAdminMessage(COLOR_DARKRED, 1, string);
  692.         Log("logs/business.log", string);
  693.     }
  694.     else if(!strcmp(params, "price", true, 5))
  695.     {
  696.         if(sscanf(params, "s[32]ii", params, bizid, input)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit price [bizid] [price]");
  697.         if(!BizInfo[bizid][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
  698.         if(strcmp("The State", BizInfo[bizid][bOwner])) return SendClientMessage(playerid, COLOR_GREY, "You can't edit the price of owned businesses.");
  699.         BizInfo[bizid][bPrice] = input;
  700.         format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: For Sale\nPrice: $%d", bizid, RBT(bizid), BizInfo[bizid][bOwner], BizInfo[bizid][bPrice]);
  701.         UpdateDynamic3DTextLabelText(BizInfo[bizid][bText], COLOR_WHITE, string);
  702.         format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has set business ID %d's price to $%d.", NORPN(playerid), bizid, input);
  703.         //SendAdminMessage(COLOR_DARKRED, 1, string);
  704.         Log("logs/business.log", string);
  705.     }
  706.     else if(!strcmp(params, "level", true, 5))
  707.     {
  708.         // L1: 0 | L2: 100 | L3: 300 | L4: 700 | L5: 1200
  709.         if(sscanf(params, "s[32]ii", params, bizid, input)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit level [bizid] [level]");
  710.         if(!BizInfo[bizid][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
  711.         if(input < 0 || input > 5) return SendClientMessage(playerid, COLOR_GREY, "Levels are between 1 and 5.");
  712.         BizInfo[bizid][bLevel] = input;
  713.         if(input == 1) BizInfo[bizid][bSold] = 0;
  714.         if(input == 2) BizInfo[bizid][bSold] = 100;
  715.         if(input == 3) BizInfo[bizid][bSold] = 300;
  716.         if(input == 4) BizInfo[bizid][bSold] = 700;
  717.         if(input == 5) BizInfo[bizid][bSold] = 1200;
  718.         format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has set business ID %d's level to %d.", NORPN(playerid), bizid, input);
  719.         //SendAdminMessage(COLOR_DARKRED, 1, string);
  720.         Log("logs/business.log", string);
  721.     }
  722.     else if(!strcmp(params, "products", true, 8))
  723.     {
  724.         if(sscanf(params, "s[32]ii", params, bizid, input)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit products [bizid] [amount]");
  725.         if(!BizInfo[bizid][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
  726.         if(input < 0) return SendClientMessage(playerid, COLOR_GREY, "Products can't be negative.");
  727.         BizInfo[bizid][bProducts] = input;
  728.         format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has set business ID %d's products to %d.", NORPN(playerid), bizid, input);
  729.         //SendAdminMessage(COLOR_DARKRED, 1, string);
  730.         Log("logs/business.log", string);
  731.     }
  732.     else if(!strcmp(params, "vault", true, 5))
  733.     {
  734.         if(sscanf(params, "s[32]ii", params, bizid, input)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit vault [bizid] [amount]");
  735.         if(!BizInfo[bizid][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
  736.         if(input < 0) return SendClientMessage(playerid, COLOR_GREY, "Vault money can't be negative.");
  737.         BizInfo[bizid][bMoney] = input;
  738.         format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has set business ID %d's vault money to $%d.", NORPN(playerid), bizid, input);
  739.         //SendAdminMessage(COLOR_DARKRED, 1, string);
  740.         Log("logs/business.log", string);
  741.     }
  742.     else if(!strcmp(params, "truckers", true, 8))
  743.     {
  744.         if(sscanf(params, "s[32]ii", params, bizid, input)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit truckers [bizid] [type] (1=Accepting | 2=NotAccepting");
  745.         if(!BizInfo[bizid][bAP])
  746.         {
  747.             BizInfo[bizid][bAP] = 1;
  748.             format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has set business ID %d to accept truckers.", NORPN(playerid), bizid);
  749.             //SendAdminMessage(COLOR_DARKRED, 1, string);
  750.             Log("logs/business.log", string);
  751.         }
  752.         else
  753.         {
  754.             BizInfo[bizid][bAP] = 0;
  755.             format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has set business ID %d to NOT accept truckers.", NORPN(playerid), bizid);
  756.             //SendAdminMessage(COLOR_DARKRED, 1, string);
  757.             Log("logs/business.log", string);
  758.         }
  759.     }
  760.     return 1;
  761. }
  762. CMD:gotobiz(playerid, params[])
  763. {
  764.     new idx, string[128];
  765.     if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  766.     if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not an authorized to use this command.");
  767. //    if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
  768.     if(sscanf(params, "i", idx)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gotobiz [bizid]");
  769.     if(!BizInfo[idx][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
  770.     SetPlayerVirtualWorld(playerid, 0);
  771.     SetPlayerInterior(playerid, 0);
  772.     SetPlayerPos(playerid, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]);
  773.     format(string, sizeof(string), " You have teleported to business ID %d.", idx);
  774.     SendClientMessage(playerid, COLOR_WHITE, string);
  775.     return 1;
  776. }
  777.  
  778. CMD:asellbiz(playerid, params[])
  779. {
  780.     new bizid, string[128];
  781.     if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  782.     if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not an authorized to use this command.");
  783. //    if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
  784.     if(sscanf(params, "i", bizid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /asellbiz [bizid]");
  785.     if(!BizInfo[bizid][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
  786.     if(!strcmp("The State", BizInfo[bizid][bOwner], true)) return SendClientMessage(playerid, COLOR_GREY, "This business is not owned by anybody.");
  787.     foreach(Player, i)
  788.     {
  789.         if(IsPlayerConnected(i) && PlayerInfo[i][pBiz] == bizid)
  790.         {
  791.             PlayerInfo[i][pBiz] = 0;
  792.             format(string, sizeof(string), " Administrator %s has sold your business.", RPN(playerid));
  793.             SendClientMessage(i, COLOR_WHITE, string);
  794.         }
  795.     }
  796.     format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has sold %s's business. (ID %d)", RPN(playerid), BizInfo[bizid][bOwner], bizid);
  797.     //SendAdminMessage(COLOR_DARKRED, 1, string);
  798.     Log("logs/business.log", string);
  799.     BizInfo[bizid][bStatus] = 0;
  800.     format(BizInfo[bizid][bOwner], 32, "The State");
  801.     format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: For Sale\nPrice: $%d", bizid, RBT(bizid), BizInfo[bizid][bOwner], BizInfo[bizid][bPrice]);
  802.     UpdateDynamic3DTextLabelText(BizInfo[bizid][bText], COLOR_WHITE, string);
  803.     return 1;
  804. }
  805. stock GivePlayerCash(playerid, money)
  806. {
  807.     SetPVarInt(playerid, "Cash", GetPVarInt(playerid, "Cash")+money);
  808.     GivePlayerMoney(playerid, money);
  809.     return 1;
  810. }
  811. stock fcreate(filename[])
  812. {
  813.     if (fexist(filename)) return false;
  814.     new File:fhnd;
  815.     fhnd=fopen(filename,io_write);
  816.     if (fhnd) {
  817.         fclose(fhnd);
  818.         return true;
  819.     }
  820.     return false;
  821. }
  822. stock RBT(bizid)
  823. {
  824.     new string[24];
  825.     if(!BizInfo[bizid][bType]) format(string, sizeof(string), "None");
  826.     else if(BizInfo[bizid][bType] == 1) format(string, sizeof(string), "24/7 Market");
  827.     else if(BizInfo[bizid][bType] == 2) format(string, sizeof(string), "Clothes Shop");
  828.     else if(BizInfo[bizid][bType] == 3) format(string, sizeof(string), "Ammunation");
  829.     else if(BizInfo[bizid][bType] == 4) format(string, sizeof(string), "Club");
  830.     //else if(BizInfo[bizid][bType] == 5) format(string, sizeof(string), "Advertisement Agency");
  831.     else if(BizInfo[bizid][bType] == 5) format(string, sizeof(string), "Adv. Agency");
  832.     else if(BizInfo[bizid][bType] == 6) format(string, sizeof(string), "Fast Food");
  833.     else if(BizInfo[bizid][bType] == 7) format(string, sizeof(string), "Casino");
  834.     return string;
  835. }
  836. stock RHS(bizid)
  837. {
  838.     new string[16];
  839.     if(!HouseInfo[bizid][hStatus]) format(string, sizeof(string), "Closed");
  840.     else if(HouseInfo[bizid][hStatus]) format(string, sizeof(string), "Open");
  841.     return string;
  842. }
  843.  
  844. stock RBS(bizid)
  845. {
  846.     new string[16];
  847.     if(!BizInfo[bizid][bStatus]) format(string, sizeof(string), "Closed");
  848.     else if(BizInfo[bizid][bStatus]) format(string, sizeof(string), "Open");
  849.     return string;
  850. }
  851.  
  852. stock RPBP(playerid)
  853. {
  854.     new string[32];
  855.     if(!PlayerInfo[playerid][pBiz]) format(string, sizeof(string), "None");
  856.     else if(PlayerInfo[playerid][pBiz]) format(string, sizeof(string), "%d", BizInfo[PlayerInfo[playerid][pBiz]][bProducts]);
  857.     return string;
  858. }
  859. stock RPN(playerid)
  860. {
  861.     new string[25];
  862.     if(PlayerInfo[playerid][pMaskOn] == 0)format(string, sizeof(string), "%s", RemoveUnderScore(playerid));
  863.     else if(PlayerInfo[playerid][pMaskOn] == 1)format(string, sizeof(string), "Stranger");
  864.     return string;
  865. }
  866. stock Log(sz_fileName[], sz_input[]) {
  867.  
  868.     new sz_logEntry[156], i_dateTime[2][3], File: fileHandle = fopen(sz_fileName, io_append);
  869.     gettime(i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2]);
  870.     getdate(i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2]);
  871.     format(sz_logEntry, sizeof(sz_logEntry), "[%i/%i/%i - %i:%i:%i] %s\r\n", i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2], i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2], sz_input);
  872.     fwrite(fileHandle, sz_logEntry);
  873.     return fclose(fileHandle);
  874. }
  875. stock SendNearbyMessage(playerid, Float:radius, string[], col1, col2, col3, col4, col5)
  876. {
  877.     new Float:x, Float:y, Float:z;
  878.     GetPlayerPos(playerid, x, y, z);
  879.     new Float:ix, Float:iy, Float:iz;
  880.     new Float:cx, Float:cy, Float:cz;
  881.     foreach(Player, i)
  882.     {
  883.         if(IsPlayerConnected(i))
  884.         {
  885.             if(GetPlayerInterior(playerid) == GetPlayerInterior(i) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
  886.             {
  887.                 GetPlayerPos(i, ix, iy, iz);
  888.                 cx = (x - ix);
  889.                 cy = (y - iy);
  890.                 cz = (z - iz);
  891.                 if(((cx < radius/16) && (cx > -radius/16)) && ((cy < radius/16) && (cy > -radius/16)) && ((cz < radius/16) && (cz > -radius/16)))
  892.                 {
  893.                     SendClientMessage(i, col1, string);
  894.                 }
  895.                 else if(((cx < radius/8) && (cx > -radius/8)) && ((cy < radius/8) && (cy > -radius/8)) && ((cz < radius/8) && (cz > -radius/8)))
  896.                 {
  897.                     SendClientMessage(i, col2, string);
  898.                 }
  899.                 else if(((cx < radius/4) && (cx > -radius/4)) && ((cy < radius/4) && (cy > -radius/4)) && ((cz < radius/4) && (cz > -radius/4)))
  900.                 {
  901.                     SendClientMessage(i, col3, string);
  902.                 }
  903.                 else if(((cx < radius/2) && (cx > -radius/2)) && ((cy < radius/2) && (cy > -radius/2)) && ((cz < radius/2) && (cz > -radius/2)))
  904.                 {
  905.                     SendClientMessage(i, col4, string);
  906.                 }
  907.                 else if(((cx < radius) && (cx > -radius)) && ((cy < radius) && (cy > -radius)) && ((cz < radius) && (cz > -radius)))
  908.                 {
  909.                     SendClientMessage(i, col5, string);
  910.                 }
  911.             }
  912.         }
  913.     }
  914.     return 1;
  915. }
  916. stock RPNU(playerid)
  917. {
  918.     new name[MAX_PLAYER_NAME];
  919.     GetPlayerName(playerid, name, sizeof(name));
  920.     return name;
  921. }
  922. stock NORPN(playerid)
  923. {
  924.     new astring[25];
  925.     if(PlayerInfo[playerid][pHideOn] == 0)format(astring, sizeof(astring), "%s", RemoveUnderScore(playerid));
  926.     else if(PlayerInfo[playerid][pHideOn] == 1)format(astring, sizeof(astring), "Anon");
  927.     return astring;
  928. }
  929. stock RemoveUnderScore(playerid)
  930. {
  931.     new name[MAX_PLAYER_NAME];
  932.     GetPlayerName(playerid,name,sizeof(name));
  933.     for(new i = 0; i < MAX_PLAYER_NAME; i++)
  934.     {
  935.         if(name[i] == '_') name[i] = ' ';
  936.     }
  937.     return name;
  938. }
  939. stock split(const strsrc[], strdest[][], delimiter)
  940. {
  941.     new i, li;
  942.     new aNum;
  943.     new len;
  944.     while(i <= strlen(strsrc))
  945.     {
  946.         if(strsrc[i] == delimiter || i == strlen(strsrc))
  947.         {
  948.             len = strmid(strdest[aNum], strsrc, li, i, 128);
  949.             strdest[aNum][len] = 0;
  950.             li = i+1;
  951.             aNum++;
  952.         }
  953.         i++;
  954.     }
  955.     return 1;
  956. }
Add Comment
Please, Sign In to add comment