Rice emu Shop system source

Results 1 to 1 of 1
  1. #1
    Apprentice ByLeon is offline
    MemberRank
    Jul 2015 Join Date
    20Posts

    Rice emu Shop system source

    Shop buy system minimal fixed source code:

    Server/Packets/Game/Shop.cs

    Code:
    using System;
    using DriftCity.Server.Structures;
    using System.Data.Common;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using DriftCity.Server.Core;
    
    
    namespace DriftCity.Server.Packets.Game
    {
        public static class Shop
        {
    
    
            [DriftCityPacket(405, DriftCityServer.ServerType.Game)]
            public static void BuyItem(DriftCityPacket packet)
            {
                
                int id = packet.Reader.ReadInt32();
                int quantity = packet.Reader.ReadInt32();
    
    
                DbConnection dbconn_d = Database.GetConnection();
                DbCommand items = dbconn_d.CreateCommand();
                items.CommandText = @"SELECT price FROM items WHERE id = '" + id + "'";
    
    
                DbDataReader itemdata = items.ExecuteReader();
                
                if( itemdata.HasRows )
                {
                    while( itemdata.Read() )
                    {
                       // By SdfSdf
                        Log.WriteLine("Shop Buy - ItemID: {0} Quantity: {1} Price: {2}", id, quantity, (itemdata.GetInt32(0)));
    
    
                        var ack = new DriftCityPacket(406);
                        ack.Writer.Write(id);
                        ack.Writer.Write(quantity);
                        ack.Writer.Write(itemdata.GetInt32(0) * quantity);
    
    
                        packet.Sender.Send(ack);
    
    
                        break;
                    }
                }
                else
                {
                    packet.Sender.Error( "Add item id = {0} to the database!", id );
                }
    
    
                itemdata.Close();
            }
        }
    
    
    }
    Credits: By SdfSdf




Advertisement