· 8 years ago · Nov 17, 2017, 03:14 AM
1ندخل على الموضع
2
3اولا
4Ù‡Ù†ÙØªØ
5
6Player
7
8public int Sentagain { get; set; }
9 public DateTime MerchantDay;
10 public DateTime MerchantDate;
11 public int Merchant { get; set; }
12
13
14كده تمام
15هنروØ
16على
17
18Database
19
20 ونعمل مل٠جديد باسم
21
22MerchantTable.cs
23
24 ÙˆÙ†ØØ· ده Ùيه
25
26namespace ConquerUnion.Network
27{
28 using ConquerUnion.Client;
29 using ConquerUnion.Database;
30 using ConquerUnion.Network.GamePackets;
31 using System;
32 using System.Drawing;
33
34 public class MerchantTable
35 {
36 public static System.Collections.Generic.Dictionary<uint, MerchantInfo> MerchantCharacters = new System.Collections.Generic.Dictionary<uint, MerchantInfo>();
37 public static void CancelMerch(GameState client)
38 {
39 if (client.Player.Merchant > 0)
40 {
41 MySqlCommand command = new MySqlCommand(MySqlCommandType.DELETE);
42 command.Delete("merchant", "UID", (long)client.Player.UID).Execute();
43 }
44 else
45 {
46 client.Send(new MsgTalk("You already not merchant!", Color.Red, 0x7d5));
47 }
48 }
49
50 public static void InsertMerch(GameState client)
51 {
52 if (client.Player.Merchant == 0)
53 {
54 client.Player.MerchantDate = DateTime.Now;
55 client.Player.Merchant = 1;
56 MySqlCommand command = new MySqlCommand(MySqlCommandType.INSERT);
57 command.Insert("merchant").Insert("UID", (long)client.Account.EntityID).Insert("Merchant", (long)client.Player.Merchant).Insert("Date", client.Player.MerchantDate.Ticks).Execute();
58 }
59 else
60 {
61 client.Send(new MsgTalk("You already merchant!", Color.Red, 0x7d5));
62 }
63 }
64
65 public static void LoadMerchant(GameState client)
66 {
67 MySqlCommand command = new MySqlCommand(MySqlCommandType.SELECT);
68 command.Select("merchant").Where("UID", (long)client.Player.UID);
69 MySqlReader reader = new MySqlReader(command);
70 while (reader.Read())
71 {
72 client.Player.Merchant = reader.ReadUInt16("Merchant");
73 client.Player.MerchantDate = DateTime.FromBinary(reader.ReadInt64("Date"));
74 if ((DateTime.Now > client.Player.MerchantDate.AddDays(5.0)) && (client.Player.Merchant == 1))
75 {
76 client.Player.Merchant = 0xff;
77 UpdateMerchant(client);
78 }
79 MerchantInfo info = new MerchantInfo
80 {
81 UID = client.Player.UID,
82
83 };
84 if (!MerchantCharacters.ContainsKey(info.UID))
85 {
86 MerchantCharacters.Add(info.UID, info);
87 }
88 }
89 reader.Close();
90 }
91
92 public static void UpdateMerchant(GameState client)
93 {
94 client.Player.Merchant = 0xff;
95 MySqlCommand command = new MySqlCommand(MySqlCommandType.SELECT);
96 command.Select("merchant").Where("UID", (long)client.Player.UID).Set("Merchant", (long)0xffL).Set("Date", (long)0L).Execute();
97 }
98 }
99 public class MerchantInfo
100 {
101 public ulong Experience;
102 public byte Level;
103 public uint UID;
104 }
105}
106
107
108تمام كده
109Ù‡Ù†Ø±ÙˆØ Ø¹Ù„Ù‰
110
111EntityTable
112
113 وهندور على
114
115CloudSaintsTable.Reset(client);
116
117 ÙˆÙ†ØØ· ده ØªØØªÙ‡
118
119Network.MerchantTable.LoadMerchant(client);
120
121 تمام Ù†Ø±ÙˆØ Ø¨Ù‚Ø§ على
122
123MsgInteract.cs
124
125 وندور على
126
127public static void Process(byte[] packet, Client.GameState client)
128
129 هنشيله كله ÙˆÙ‡Ù†ØØ¯ ده
130
131 public static void Process(byte[] packet, Client.GameState client)
132 {
133
134 if (client.Action == 2)
135 {
136 client.LastAttack = Time32.Now;
137 MsgInteract attack = new MsgInteract(false);
138 attack.Deserialize(packet);
139 HandleAttack(attack, client);
140 client.Player.SpiritFocus = false;
141 switch (BitConverter.ToUInt32(packet, 20 + 4))
142 {
143 case 40:
144 client.Player.Merchant = 0xff;
145 client.Player.Update(0x26, (byte)0xff, false);
146 client.Send(packet);
147 break;
148
149 case 41:
150 client.Player.Update(0x26, (byte)0, false);
151 MerchantTable.CancelMerch(client);
152 client.Send(packet);
153 break;
154 }
155 }
156 if (client.Player.ContainsFlag((ulong)MsgUpdate.Flags.Intensify))
157 {
158 client.Player.RemoveFlag((ulong)MsgUpdate.Flags.Intensify);
159 client.Player.IntensifyPercent = 0;
160 }
161 }
162
163 تمام Ù†Ø±ÙˆØ Ø¨Ù‚Ø§ على
164
165GeneralData.cs
166
167
168وبعدين
169هندور على
170
171 public static void LoginMessages(GameState client)
172
173 ÙˆÙ†ØØ¯ ده ØªØØªÙ‡Ø§
174
175 #region Merchant
176 if (MerchantTable.MerchantCharacters.ContainsKey(client.Player.UID))
177 {
178 client.Player.Sentagain = 1;
179 client.Player.MerchantDay = DateTime.Now;
180 client.Send(new MsgAction(true)
181 {
182 UID = client.Player.UID,
183 ID = MsgAction.Mode.OpenCustom,
184 dwParam = MsgAction.CustomCommands.MerchantApply
185 });
186 }
187 #endregion
188
189
190تمام قوى
191هندور على
192ده
193
194client.Player.Update((byte)MsgUpdate.Merchant, 255, false);
195
196هتلقيه مرتين او تلاته هنمسØÙ‡
197ولو ملقتهوش عادى
198بعدين
199Ù‡Ù†ÙØªØ
200
201Npcs.cs
202
203 ونضي٠ده
204 #region Merchant
205 case 1880:
206 switch (npcRequest.OptionID)
207 {
208 case 0:
209 if ((client.Player.Merchant != 0) && (client.Player.Merchant == 1))
210 {
211 dialog.Text("Your Merchant application is being proceseed. Please wait for 5 days. All of your equipment and items are not protected by the foribiden sale system in the game,");
212 dialog.Text("And Avengers is not resposible for any loss relates");
213 dialog.Text("click the cancel button to reset your merchant account to be normal. A Normal account will be protected by all the trading protection measures in case of equipment loss resulted from accounts being hacked.");
214 dialog.Option("Cancel my application", 2);
215 dialog.Option("Let me think it over.", 0xff);
216 dialog.Avatar(10);
217 dialog.Send();
218 }
219 dialog.Text("A merchant account is for any who frequenly engages in commercial activities");
220 dialog.Text("A merchant account is not protected by the virtuall property protection meassures.");
221 dialog.Text("So Avengers Digital will not be resposible for any loss relates.");
222 dialog.Text("ou may choose to be a merchant account instantly on your first login or manually apply for it in future.");
223 dialog.Text("It takes us 5 days to censor your manual application. You can reset it to be a normal account at any time. Are you reasy to be a merchant?");
224 dialog.Option("I want to be a merchant.", 1);
225 dialog.Option("Let me think it over.", 0xff);
226 dialog.Avatar(10);
227 dialog.Send();
228 break;
229
230 case 1:
231 client.Player.Update(0x26, (byte)1, false);
232 MerchantTable.InsertMerch(client);
233 client.Player.Sentagain = 1;
234 client.Player.MerchantDay = DateTime.Now;
235 client.Send(new MsgAction(true)
236 {
237 UID = client.Player.UID,
238 ID = MsgAction.Mode.OpenCustom,
239 dwParam = MsgAction.CustomCommands.MerchantApply
240 });
241 dialog.Text("You have now applied for merchant. Your application has been sent and it is required a 5 Day wait time period");
242 dialog.Option("Alright, Thank you.", 0xff);
243 dialog.Avatar(10);
244 dialog.Send();
245 break;
246
247 case 2:
248 case 3:
249 client.Player.Update(0x26, (byte)0, false);
250 MerchantTable.CancelMerch(client);
251 client.Player.Merchant = 0;
252 client.Player.Sentagain = 0;
253
254 client.Send(new MsgAction(true)
255 {
256 UID = client.Player.UID,
257 ID = MsgAction.Mode.OpenCustom,
258 dwParam = 1208
259 });
260 dialog.Text("You are currently not a merchant and your Equipment and items are now protected by Our Sale / Trade Protection system.");
261 dialog.Option("Alright, Thank you.", 0xff);
262 dialog.Avatar(10);
263 dialog.Send();
264 break;
265 }
266 return;
267
268
269 #endregion
270كده ÙÙ„ يا ØµØØ¨Ù‰
271ÙˆÙ‡Ù†Ø±ÙØ¹ ده على النÙÙ‰ كات
272
273
274/*
275Navicat MySQL Data Transfer
276
277Source Server : localhost_3306
278Source Server Version : 50045
279Source Host : localhost:3306
280Source Database : cq1
281
282Target Server Type : MYSQL
283Target Server Version : 50045
284File Encoding : 65001
285
286Date: 2017-11-17 05:11:54
287*/
288
289SET FOREIGN_KEY_CHECKS=0;
290
291-- ----------------------------
292-- Table structure for `merchant`
293-- ----------------------------
294DROP TABLE IF EXISTS `merchant`;
295CREATE TABLE `merchant` (
296 `UID` bigint(36) unsigned NOT NULL default '0',
297 `Merchant` bigint(36) unsigned default '0',
298 `Date` bigint(16) default NULL COMMENT '\r\n',
299 PRIMARY KEY (`UID`)
300) ENGINE=MyISAM DEFAULT CHARSET=utf8;
301
302-- ----------------------------
303-- Records of merchant
304-- ----------------------------
305INSERT INTO `merchant` VALUES ('1000001', '1', '636464914161341892');