コード例 #1
0
ファイル: storeManager.cs プロジェクト: habb0/Woodpecker
        /// <summary>
        /// Gets the transactions (credit log) of a user on given user session and sends it to the session's game connection.
        /// </summary>
        /// <param name="Session">The Woodpecker.Sessions.Session object to get the transaction for and to send the message to.</param>
        public void sendTransactions(ref Session Session)
        {
            if (Session.User == null)
            {
                return;
            }

            serverMessage Message  = new serverMessage(209); // "CQ"
            Database      Database = new Database(false, true);

            Database.addParameterWithValue("userid", Session.User.ID);

            Database.Open();
            if (Database.Ready)
            {
                DataTable creditLogData = Database.getTable("SELECT moment,type,activity FROM users_creditlog WHERE userid = @userid LIMIT 50");
                foreach (DataRow dRow in creditLogData.Rows)
                {
                    DateTime Moment = (DateTime)dRow["moment"];
                    Message.appendTabbedValue(Moment.ToString("dd/MM/yyyy"));
                    Message.appendTabbedValue(Moment.ToString("hh:mm"));
                    Message.appendTabbedValue(dRow["activity"].ToString());
                    Message.appendTabbedValue("0");
                    Message.appendTabbedValue("");
                    Message.Append(dRow["type"].ToString());
                    Message.appendChar(13);
                }
            }

            Session.gameConnection.sendMessage(Message);
        }
コード例 #2
0
 /// <summary>
 /// 199 - "CG"
 /// </summary>
 public void MESSAGETOCALLER()
 {
     string[] args = Request.getMixedParameters();
     if (Session.User.hasFuseRight("fuse_receive_calls_for_help"))
     {
         Database Database = new Database(false, false);
         Database.addParameterWithValue("id", args[0]);
         Database.addParameterWithValue("msg", args[1]);
         Database.Open();
         if (Database.Ready)
         {
             DataRow dRow = Database.getRow("SELECT * FROM callforhelp WHERE id = @id");
             if (dRow != null)
             {
                 Session S = Engine.Game.Users.getUserSession(Convert.ToInt32(dRow["uid"]));
                 if (S == null)
                 {
                     return;
                 }
                 serverMessage Message = new serverMessage();
                 Message.Initialize(274);
                 Message.Append(args[1]);
                 Message.appendChar(2);
                 S.gameConnection.sendMessage(Message);
                 Database.runQuery("INSERT INTO callforhelp_msg VALUES ('', @id, @msg, '" + Session.User.ID + "', '" + Session.ipAddress + "', '" + DateTime.Now.ToString() + "')");
             }
         }
     }
 }
コード例 #3
0
        /// <summary>
        /// 86 - "AV"
        /// </summary>
        public void CRYFORHELP()
        {
            string[] args     = Request.getMixedParameters();
            Database Database = new Database(false, false);

            Database.addParameterWithValue("userid", Session.User.ID);
            Database.addParameterWithValue("senderip", Session.ipAddress);
            Database.addParameterWithValue("msg", args[0]);
            Database.addParameterWithValue("roomid", Session.roomID);
            Database.addParameterWithValue("ip", Session.ipAddress);
            Database.addParameterWithValue("sended", DateTime.Now.ToString());
            Database.Open();
            string row  = "";
            string room = "";

            if (Database.Ready)
            {
                Database.runQuery("INSERT INTO callforhelp (id, sended, uid, rid, date, message, send_ip, pickedup, pickedup_person, pickedup_ip, pickedup_date) VALUES ('', @sended, @userid, @roomid, @msg, '" + DateTime.Now.ToString() + "', @senderip, '0', '', '', '')");
                row  = Database.getString("SELECT id FROM `callforhelp` ORDER BY `callforhelp`.`id` DESC LIMIT 1");
                room = Database.getString("SELECT roomname FROM `rooms` WHERE `id` = '" + Session.roomID + "' LIMIT 1");
                Database.Close();
            }

            ArrayList list = Engine.Game.Users.UserFuses("fuse_receive_calls_for_help");

            foreach (int x in list)
            {
                Session S = Engine.Game.Users.getUserSession(x);
                if (S == null)
                {
                    return;
                }
                serverMessage Message = new serverMessage();
                Message.Initialize(148);
                Message.Append(row);
                Message.appendChar(2);
                Message.Append("ISent: ");
                Message.Append(DateTime.Now.ToString());
                Message.appendChar(2);
                Message.Append(Session.User.Username);
                Message.appendChar(2);
                Message.Append(args[0]);
                Message.appendChar(2);
                Message.Append(Specialized.Encoding.wireEncoding.Encode(Session.roomID));
                Message.appendChar(2);
                Message.Append("Room: " + room);
                Message.appendChar(2);
                Message.Append("I");
                Message.appendChar(2);
                Message.Append(Specialized.Encoding.wireEncoding.Encode(Session.roomID));
                S.gameConnection.sendMessage(Message);
            }
        }
コード例 #4
0
        /// <summary>
        /// Modifies the hand page index with a given mode and sends the current hand page of this user.
        /// </summary>
        /// <param name="szMode">'How-to' modify the hand page index.</param>
        public void sendHandStrip(string szMode)
        {
            if (this.itemStripHandler != null)
            {
                this.itemStripHandler.changeHandStripPage(szMode); // Switch!

                serverMessage Message = new serverMessage(140);    // "BL"
                Message.Append(this.itemStripHandler.getHandItemCasts());
                Message.appendChar(13);
                Message.Append(this.itemStripHandler.handItemCount);

                this.gameConnection.sendMessage(Message);
            }
        }
コード例 #5
0
        /// <summary>
        /// 48 - "@p"
        /// </summary>
        public void PICK_CRYFORHELP()
        {
            string[] args = Request.getMixedParameters();
            if (Session.User.hasFuseRight("fuse_receive_calls_for_help"))
            {
                string   username = Session.User.Username;
                Database Database = new Database(false, false);
                Database.addParameterWithValue("id", args[0]);
                Database.Open();
                if (Database.Ready)
                {
                    DataRow dRow = Database.getRow("SELECT * FROM callforhelp WHERE id = @id");
                    if (dRow != null)
                    {
                        string room = Database.getString("SELECT roomname FROM `rooms` WHERE `id` = '" + dRow["rid"] + "' LIMIT 1");
                        if (dRow["pickedup"].ToString() == "1")
                        {
                            Response.Initialize(139);
                            Response.Append("This call has already been picked up by " + Engine.Game.Users.getUsername(Convert.ToInt32(dRow["pickedup_person"])) + ".");
                            sendResponse();
                        }
                        else
                        {
                            Database.runQuery("UPDATE callforhelp SET pickedup = '1', pickedup_person = '" + Session.User.ID + "', pickedup_ip = '" + Session.ipAddress + "', pickedup_date = '" + DateTime.Now.ToString() + "' WHERE id = @id");

                            ArrayList list = Engine.Game.Users.UserFuses("fuse_receive_calls_for_help");
                            foreach (int x in list)
                            {
                                Session S = Engine.Game.Users.getUserSession(x);
                                if (S == null)
                                {
                                    return;
                                }
                                serverMessage Message = new serverMessage();
                                Message.Initialize(148);
                                Message.Append(args[0]);
                                Message.appendChar(2);
                                Message.Append("IPicked up on: ");
                                Message.Append(DateTime.Now.ToString());
                                Message.appendChar(2);
                                Message.Append(Session.User.Username);
                                Message.appendChar(2);
                                Message.Append(dRow["message"].ToString());
                                Message.appendChar(2);
                                Message.Append(Specialized.Encoding.wireEncoding.Encode(Convert.ToInt32(dRow["rid"])));
                                Message.appendChar(2);
                                Message.Append("(Picked up by " + username + ") Room: " + room);
                                Message.appendChar(2);
                                Message.Append("I");
                                Message.appendChar(2);
                                Message.Append(Specialized.Encoding.wireEncoding.Encode(Convert.ToInt32(dRow["rid"])));
                                sendResponse();
                                S.gameConnection.sendMessage(Message);
                            }
                        }
                    }

                    Database.Close();
                }
            }
        }