public static int HasItem(int index, int itemNum) { int i = 0; // Check for subscript out of range if (C_Player.IsPlaying(index) == false || itemNum <= 0 || itemNum > Constants.MAX_ITEMS) { return(0); } for (i = 1; i <= Constants.MAX_INV; i++) { // Check to see if the player has the item if (C_Player.GetPlayerInvItemNum(index, i) == itemNum) { if (Types.Item[itemNum].Type == (byte)Enums.ItemType.Currency || Types.Item[itemNum].Stackable == 1) { return(C_Player.GetPlayerInvItemValue(index, i)); } else { return(1); } return(0); } } return(0); }
internal static void SendDropItem(int invNum, int amount) { ByteStream buffer = new ByteStream(4); if (System.Convert.ToBoolean(C_Banks.InBank != 0 || C_Shops.InShop != 0)) { return; } // do basic checks if (invNum < 1 || invNum > Constants.MAX_INV) { return; } if (C_Variables.PlayerInv[invNum].Num <1 || C_Variables.PlayerInv[invNum].Num> Constants.MAX_ITEMS) { return; } if (Types.Item[C_Player.GetPlayerInvItemNum(C_Variables.Myindex, invNum)].Type == (byte)Enums.ItemType.Currency || Types.Item[C_Player.GetPlayerInvItemNum(C_Variables.Myindex, invNum)].Stackable == 1) { if (amount < 1 || amount > C_Variables.PlayerInv[invNum].Value) { return; } } buffer.WriteInt32((System.Int32)Packets.ClientPackets.CMapDropItem); buffer.WriteInt32(invNum); buffer.WriteInt32(amount); C_NetworkConfig.Socket.SendData(buffer.Data, buffer.Head); buffer.Dispose(); }
public static void DrawTrade() { int i = 0; int x = 0; int y = 0; int itemnum = 0; int itempic = 0; string amount = ""; Rectangle rec = new Rectangle(); Rectangle recPos = new Rectangle(); SFML.Graphics.Color colour = new SFML.Graphics.Color(); amount = System.Convert.ToString(0); colour = SFML.Graphics.Color.White; if (!C_Variables.InGame) { return; } //first render panel C_Graphics.RenderSprite(C_Graphics.TradePanelSprite, C_Graphics.GameWindow, C_UpdateUI.TradeWindowX, C_UpdateUI.TradeWindowY, 0, 0, C_Graphics.TradePanelGfxInfo.Width, C_Graphics.TradePanelGfxInfo.Height); //Headertext C_Text.DrawText(C_UpdateUI.TradeWindowX + 70, C_UpdateUI.TradeWindowY + 6, "Your Offer", SFML.Graphics.Color.White, SFML.Graphics.Color.Black, C_Graphics.GameWindow, (byte)15); C_Text.DrawText(C_UpdateUI.TradeWindowX + 260, C_UpdateUI.TradeWindowY + 6, C_UpdateUI.Tradername + "'s Offer.", SFML.Graphics.Color.White, SFML.Graphics.Color.Black, C_Graphics.GameWindow, (byte)15); for (i = 1; i <= Constants.MAX_INV; i++) { // blt your own offer itemnum = C_Player.GetPlayerInvItemNum(C_Variables.Myindex, TradeYourOffer[i].Num); if (itemnum > 0 && itemnum <= Constants.MAX_ITEMS) { itempic = Types.Item[itemnum].Pic; if (itempic > 0 && itempic <= C_Graphics.NumItems) { if (C_Graphics.ItemsGfxInfo[itempic].IsLoaded == false) { C_Graphics.LoadTexture(itempic, (byte)4); } //seeying we still use it, lets update timer ref var with_1 = ref C_Graphics.ItemsGfxInfo[itempic]; with_1.TextureTimer = C_General.GetTickCount() + 100000; rec.Y = 0; rec.Height = C_Constants.PicY; rec.X = 0; rec.Width = C_Constants.PicX; recPos.Y = C_UpdateUI.TradeWindowY + C_UpdateUI.OurTradeY + C_UpdateUI.InvTop + ((C_UpdateUI.InvOffsetY + 32) * ((i - 1) / C_UpdateUI.InvColumns)); recPos.Height = C_Constants.PicY; recPos.X = C_UpdateUI.TradeWindowX + C_UpdateUI.OurTradeX + C_UpdateUI.InvLeft + ((C_UpdateUI.InvOffsetX + 32) * ((i - 1) % C_UpdateUI.InvColumns)); recPos.Width = C_Constants.PicX; C_Graphics.RenderSprite(C_Graphics.ItemsSprite[itempic], C_Graphics.GameWindow, recPos.X, recPos.Y, rec.X, rec.Y, rec.Width, rec.Height); // If item is a stack - draw the amount you have if (TradeYourOffer[i].Value >= 1) { y = recPos.Top + 22; x = recPos.Left - 4; // Draw currency but with k, m, b etc. using a convertion function if (double.Parse(amount) < 1000000) { colour = SFML.Graphics.Color.White; } else if (double.Parse(amount) > 1000000 && long.Parse(amount) < 10000000) { colour = SFML.Graphics.Color.Yellow; } else if (double.Parse(amount) > 10000000) { colour = SFML.Graphics.Color.Green; } amount = System.Convert.ToString(TradeYourOffer[i].Value); C_Text.DrawText(x, y, C_GameLogic.ConvertCurrency(System.Convert.ToInt32(amount)), colour, SFML.Graphics.Color.Black, C_Graphics.GameWindow); } } } }