Advertisement
Guest User

ShopSystem.cs

a guest
Aug 6th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.97 KB | None | 0 0
  1. function serverCmdBBBR_RequestShopData(%client)
  2. {
  3.     %BBB = BBB_System;
  4.     for(%i = 0; %i < %BBB.totalEquipment; %i++)
  5.     {
  6.         %itemData = %BBB.equipmentList[%i]; //Just dump onto em all the new information they could ever want.
  7.         if(%client.player.role $= %itemData.alliance)
  8.             commandToClient(%client,'BBBR_ReceiveShopData',%itemData.id,%itemData.color);
  9.     }
  10. }
  11. function GameConnection::ShopMessage(%client,%msg) //Rather not copy paste this code everywhere. again.
  12. {
  13.     %client.chatMessage("\c4Shop\c6:" SPC %msg);
  14. }
  15. function serverCmdBBBRShop(%client,%id,%confirm)
  16. {
  17.     if(isObject(%player = %client.player))
  18.     {
  19.         %BBB = BBB_System;
  20.         if(%id $= "") //Give a list to the poor children who cannot afford a free GUI
  21.         {
  22.             %client.ShopMessage("You may purchase the following equipment as a(n)" SPC %player.getFormattedRole() @ "\c6:");
  23.             %total = 0;
  24.             for(%i = 0; %i<%BBB.totalEquipment; %i++)
  25.             {
  26.                 %item = BBB_System.equipmentList[%i];
  27.                 if(%item.alliance $= %player.role)
  28.                 {
  29.                     %total ++;
  30.                     %assembleMessage = "\c7[\c4"@%item.id@"\c7]"; //Sets up id...
  31.                     %assembleMessage = %assembleMessage @ BBB_System.RoleColor[%player.role] SPC %item.name; //Sets the name allong with color...
  32.                     %assembleMessage = %assembleMessage SPC "\c6-" SPC %item.desc; //And adds a description. Yay.
  33.                     %client.ShopMessage(%assembleMessage);
  34.                 }
  35.             }
  36.             if(%total == 0)
  37.                 %client.ShopMessage("You can get nothing! Good day sir!");
  38.             else
  39.                 %client.ShopMessage("Type \"/BBBRShop \c4TheIdLocatedInCyan\c6 Yes\" in chat to confirm your purchase.");
  40.         }
  41.         else if(%confirm $= "Yes") //Great scott they've actually purchased it!
  42.         {
  43.             serverCmdBBBR_ProcessShopRequest(%client,%id,false,true);
  44.         }
  45.     }
  46.     else
  47.         %client.ShopMessage("\c0ERROR: Ghosts do not possess enough real limbs to handle the current wares for sale.");
  48. }
  49. function serverCmdBBBR_ProcessShopRequest(%client,%id,%check,%skipCustoms)
  50. {
  51.     if(isObject(%player = %client.player)) //We don't want to operate on something that's dead...
  52.     {
  53.         %itemData = BBB_System.equipmentListById[%id]; //Pulls out item data for use.
  54.         if(!isObject(%itemData))
  55.             %client.ShopMessage("\c0ERROR: The equipment you are trying to purchase doesn't exist.");
  56.         if((%player.prevItemId $= %id && !%check) || %skipCustoms)
  57.         {
  58.             if(%player.credits >= %itemData.cost)
  59.             {
  60.                 if(%player.role $= %itemData.alliance)
  61.                 {
  62.                     %brokenTwig = false;
  63.                     for(%i = 0; %i < %player.purchasedEquipment; %i++)
  64.                     {
  65.                         %word = getWord(%player.equipmentList,%i);
  66.                         if(getWord(%player.equipmentList,%i) $= %id)
  67.                             %brokenTwig = true;
  68.                     }
  69.                     if(!%brokenTwig)
  70.                     {
  71.                         if(%itemData.type $= "Item")
  72.                         {
  73.                             if(%player.tool[%itemData.slot] == 0)
  74.                             {
  75.                                 %item = %itemData.data;
  76.                                 %client.player.tool[%itemData.slot] = nameToID(%item);
  77.                                 messageClient(%client,'MsgItemPickup','',%itemData.slot,nameToID(%item));
  78.                             }
  79.                             else
  80.                             {
  81.                                 %client.ShopMessage("\c0ERROR: There is no space for this equipment in slot #" @ (%itemData.slot + 1) SPC ".");
  82.                                 return;
  83.                             }
  84.                         }
  85.                         else
  86.                             %client.call(%itemData.data);
  87.                         if(%itemData.buyOnce)
  88.                         {
  89.                             commandToClient(%client,'BBBR_disableButton',%itemData.id);
  90.                             if(%player.equipmentList $= "")
  91.                                 %player.equipmentList = %itemData.id;
  92.                             else
  93.                                 %player.equipmentList = %player.equipmentList SPC %id;
  94.                             %player.purchasedEquipment ++;
  95.                         }
  96.                         %player.credits -= %itemData.cost;
  97.                     }
  98.                     else
  99.                         %client.ShopMessage("\c0ERROR: You've already purchased this and cannot purchase it again.");
  100.                 }
  101.                 else
  102.                     %client.ShopMessage("\c0ERROR: This equipment is not available for you!");
  103.             }
  104.             else
  105.                 %client.ShopMessage("\c0ERROR: Not enough credits.");
  106.         }
  107.         else
  108.         {
  109.             %player.prevItemId = %id;
  110.             commandToClient(%client,'BBBR_RecieveItemData',%itemData.name,%itemData.desc);
  111.         }
  112.     }
  113.     else
  114.         %client.ShopMessage("\c0ERROR: You don't even exist. Idiot.");
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement