本文整理汇总了C#中PacketIn类的典型用法代码示例。如果您正苦于以下问题:C# PacketIn类的具体用法?C# PacketIn怎么用?C# PacketIn使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PacketIn类属于命名空间,在下文中一共展示了PacketIn类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BuyNpcItem
public static void BuyNpcItem(Client client, PacketIn packet)
{
int npcWorldId = (int)packet.ReadUInt32();
byte v1 = packet.ReadByte();
byte amount = packet.ReadByte();
int totalPrice = 0;
ushort[] items = new ushort[amount];
ushort[] amounts = new ushort[amount];
for(int i=0;i<amount;i++)
{
items[i] = packet.ReadUShort();
amounts[i] = packet.ReadUShort();
// TODO, calculate correct price
totalPrice += 100 * amounts[i];
}
// TODO, add geon amount check
for(int i=0;i<amount;i++)
{
// should be items, not player items
PlayerItem item = PlayerItem.Get((int)items[i]);
client.Character.Player.Inventory.Items.Add(item);
// update AddToInventory with generic item-object
client.Send(new Packets.AddToInventory((int)items[i],(int)amounts[i]),"Buy Item");
// update amout of geons !
}
}
开发者ID:KalOnline,项目名称:KaLua,代码行数:30,代码来源:PT_Npc.cs
示例2: DropItem
public static void DropItem(Client client, PacketIn packet)
{
int IID = (int)packet.ReadUInt32();
PlayerItem pItem = PlayerItem.GetItem(IID);
int quantity = (int)packet.ReadUInt32();
//check if the item exists
if (pItem == null)
{
Hackshield.AddOffense(client, OffenseSeverity.IncorrectPacketDetails);
return;
}
//check if player owns the item
if (pItem.PID != client.Character.Player.PID)
{
Hackshield.AddOffense(client, OffenseSeverity.IncorrectPacketDetails);
return;
}
CodeHandler handler = CodeManager.GetHandler(pItem.Item.Code);
handler.Drop(pItem, quantity, client.Character, client);
}
开发者ID:BeshoyFD,项目名称:kalsharp,代码行数:25,代码来源:PT_Item.cs
示例3: HandlePacket
public int HandlePacket(BaseClient client, PacketIn packet)
{
LobbyClient cclient = client as LobbyClient;
byte slotId = packet.GetUint8();
Character Info = cclient.Characters.Get(slotId);
MySqlCommand cmd = new MySqlCommand("DELETE FROM `clientstatus` WHERE `name` = @name", Connection.Instance);
try
{
cmd.Prepare();
cmd.Parameters.AddWithValue("@name", Info.Name);
cmd.ExecuteNonQuery();
}
catch (MySqlException) { }
finally { cmd.Dispose(); }
PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CHARACTER_INFO);
if (Info == null) Out.WriteUInt32Reverse((uint)ResponseCodes.RC_FAILED);
else
{
Out.WriteUInt32Reverse((uint)ResponseCodes.RC_SUCCESS);
Out.WriteByte(Info.Slot);
Out.WriteByte(Info.Gender);
Out.WriteUInt32Reverse(Info.Playtime);
Out.WriteUInt32Reverse(Info.Rank);
Out.WriteByte(Info.Threat);
Out.WriteUInt32Reverse(Info.Money);
Out.WriteParsedString("APB-EMU", 60);
byte[] Custom = Info.getCustom();
Out.Write(Custom, 0, Custom.Length);
}
cclient.Send(Out);
return 0;
}
开发者ID:harleyknd1,项目名称:rAPB,代码行数:32,代码来源:ASK_CHARACTER_INFO.cs
示例4: EndPlayerMove
public static void EndPlayerMove(Client client, PacketIn packet)
{
sbyte dx = packet.ReadSByte();
sbyte dy = packet.ReadSByte();
sbyte dz = packet.ReadSByte();
client.Character.MoveEnd(dx, dy, dz);
}
开发者ID:BeshoyFD,项目名称:kalsharp,代码行数:7,代码来源:PT_Movement.cs
示例5: HandlePacket
public int HandlePacket(BaseClient client, PacketIn packet)
{
LobbyClient cclient = (LobbyClient)client;
Byte slotId = packet.GetUint8();
Character character = cclient.Characters.Get(slotId);
if (character == null) Log.Error(cclient.Account.Email, "Wrong slot specified!");
World.World info = null;
lock (Program.worldListener.Worlds)
{
Program.worldListener.Worlds.TryGetValue(character.WorldId, out info);
}
PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_WORLD_ENTER);
if (info == null) Out.WriteUInt32Reverse(1);
else
{
info.Send(new AccountEnter(cclient.Account.Id, character.Id, cclient.SessionId));
Out.WriteUInt32Reverse((uint)ResponseCodes.RC_SUCCESS);
Out.WriteByte(info.IP1);
Out.WriteByte(info.IP2);
Out.WriteByte(info.IP3);
Out.WriteByte(info.IP4);
Out.WriteUInt16Reverse((UInt16)info.Port);
Out.WriteInt64Reverse(TCPManager.GetTimeStamp());
}
cclient.Send(Out);
return 0;
}
开发者ID:harleyknd1,项目名称:rAPB,代码行数:27,代码来源:ASK_WORLD_ENTER.cs
示例6: HandlePacket
public int HandlePacket(BaseClient client, PacketIn packet)
{
LobbyClient cclient = (LobbyClient)client;
Byte slotId = packet.GetUint8();
CharacterEntry character = Databases.CharacterTable.SingleOrDefault(c => c.AccountIndex == cclient.Account.Index && c.Slot == slotId);
if (character.Index < 1) Log.Error(cclient.Account.Username, "Wrong slot specified!");
World.World info = null;
lock (Program.worldListener.Worlds)
{
Program.worldListener.Worlds.TryGetValue((uint)character.World, out info);
}
PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_WORLD_ENTER);
if (info == null) Out.WriteUInt32Reverse(1);
else
{
info.Send(new AccountEnter((uint)cclient.Account.Index, (uint)character.Index, cclient.SessionId));
Out.WriteUInt32Reverse((uint)ResponseCodes.RC_SUCCESS);
Out.WriteByte(info.IP1);
Out.WriteByte(info.IP2);
Out.WriteByte(info.IP3);
Out.WriteByte(info.IP4);
Out.WriteUInt16Reverse((UInt16)info.Port);
Out.WriteInt64Reverse(TCPManager.GetTimeStamp());
}
cclient.Send(Out);
return 0;
}
开发者ID:fiki574,项目名称:rAPB,代码行数:27,代码来源:ASK_WORLD_ENTER.cs
示例7: HandlePacket
public int HandlePacket(BaseClient client, PacketIn packet)
{
LobbyClient cclient = client as LobbyClient;
UInt32 WorldUid = packet.GetUint32Reversed();
string Name = packet.GetParsedString();
PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CHARACTER_NAME_CHECK);
if (Databases.CharacterTable.Count(c => c.Name == Name) == 0)
{
cclient.Pending = new CharacterEntry();
cclient.Pending.Index = Databases.CharacterTable.GenerateIndex();
cclient.Pending.AccountIndex = cclient.Account.Index;
cclient.Pending.Name = Name;
cclient.Pending.World = (int)WorldUid;
cclient.Pending.Rank = 1;
cclient.Pending.Money = 0;
cclient.Pending.Threat = 1;
cclient.Pending.Playtime = 0;
cclient.Pending.Clan = "APB-EMU";
cclient.Pending.IsOnline = 0;
cclient.Pending.DistrictID = 0;
cclient.Pending.DistrictType = 0;
cclient.Pending.LFG = 0;
cclient.Pending.IsGroupPublic = 0;
cclient.Pending.GroupInvite = 0;
cclient.Pending.GroupStatus = 0;
Out.WriteUInt32Reverse((uint)ResponseCodes.RC_SUCCESS);
}
else
{
cclient.Pending = default(CharacterEntry);
Out.WriteUInt32Reverse((uint)ResponseCodes.RC_CHARACTER_NAME_CHECK_IN_USE);
}
cclient.Send(Out);
return 0;
}
开发者ID:fiki574,项目名称:rAPB,代码行数:35,代码来源:ASK_CHARACTER_NAME_CHECK.cs
示例8: DropItem
public static void DropItem(Client client, PacketIn packet)
{
int itemId = (int)packet.ReadUInt32();
PlayerItem item = PlayerItem.Get(itemId);
int quantity = (int)packet.ReadUInt32();
if(item == null) {
ServerConsole.WriteLine(
"Player #{0} attempted to drop non-existant item #{1} !",
client.Character.Player.PlayerId,
itemId
);
return;
}
if(item.PlayerId != client.Character.Player.PlayerId) {
ServerConsole.WriteLine(
"Player #{0} attempted to drop item that belongs to #{1}!",
client.Character.Player.PlayerId,
item.PlayerId
);
return;
}
uint worldId = World.NewId();
Server.WorldDrops[worldId] = new Drop(item,client.Character,quantity,worldId);
client.Send(new Packets.SpawnDrop(Server.WorldDrops[worldId]),"Spawn Drop");
client.Send(new Packets.RemoveFromInventory(item.ItemId,quantity),"Update Inventory");
client.Character.Player.Inventory.Items.Remove(item);
}
开发者ID:KalOnline,项目名称:KaLua,代码行数:31,代码来源:PT_Item.cs
示例9: LearnSkill
public static void LearnSkill(Client client, PacketIn packet)
{
byte skillId = packet.ReadByte();
if(client.Character.Player.SkillPoints >= 1)
{
if(!client.Character.Skills.ContainsKey(skillId))
{
using(ISession session = Server.Factory.OpenSession())
{
PlayerSkill skill = new PlayerSkill();
skill.Level = 1;
skill.PlayerId = client.Character.Player.PlayerId;
skill.SkillIndex = (int)skillId;
client.Character.Skills[skillId] = skill;
client.Send(new Packets.SkillSet(skillId,(byte)1));
using(ITransaction transaction = session.BeginTransaction())
{
session.Save(skill);
transaction.Commit();
}
}
client.Character.Player.SkillPoints--;
client.Send(new Packets.ValueChange(0x18,(byte)client.Character.Player.SkillPoints));
}
}
}
开发者ID:KalOnline,项目名称:KaLua,代码行数:28,代码来源:PT_Skill.cs
示例10: EquipItem
public static void EquipItem(Client client, PacketIn packet)
{
int itemId = (int)packet.ReadUInt32();
PlayerItem item = PlayerItem.Get(itemId);
if(item == null) {
ServerConsole.WriteLine(
System.Drawing.Color.Red,
"Player #{0} attempted to equip non-existant item!",
client.Character.Player.PlayerId
);
return;
}
if(item.PlayerId != client.Character.Player.PlayerId) {
ServerConsole.WriteLine(System.Drawing.Color.Red,
"Player #{0} attempted to equip item that belongs to #{1}!",
client.Character.Player.PlayerId,
item.PlayerId
);
return;
}
if(!item.Wearable) {
ServerConsole.WriteLine(
System.Drawing.Color.Red,
"Player #{0} attempted to equip non-equipable item #{1}!",
item.PlayerId,item.ItemId
);
return;
}
PlayerItem.Equip(item);
client.Send(new Packets.EquipItem(item),"Equip Item");
}
开发者ID:KalOnline,项目名称:KaLua,代码行数:31,代码来源:PT_Item.cs
示例11: HandlePacket
public int HandlePacket(BaseClient client, PacketIn packet)
{
LobbyClient cclient = client as LobbyClient;
byte[] clientModulus = new byte[64];
for (int i = 0; i < 64; ++i) clientModulus[i] = packet.GetUint8();
cclient.clientModulus = new FrameWork.NetWork.Crypto.BigInteger(1, clientModulus);
UInt16 unk = packet.GetUint16();
byte[] Proof = new byte[20];
for (int i = 0; i < 20; ++i) Proof[i] = packet.GetUint8();
cclient.Proof = Proof;
if (IsBanned(cclient))
{
ANS_LOGIN_FAILED.Send(cclient, (int)ResponseCodes.RC_LOGIN_ACCOUNT_BLOCKED);
cclient.Disconnect();
}
else
{
if (IsValid(cclient))
{
ANS_LOGIN_SUCCES.Send(cclient);
cclient.ECrypt = new TCP.Encryption(cclient.SessionId);
ANS_CHARACTER_INFO.Send(cclient);
}
else
{
ANS_LOGIN_FAILED.Send(cclient, (int)ResponseCodes.RC_LOGIN_INVALID_ACCOUNT);
cclient.Disconnect();
}
}
return 0;
}
开发者ID:fiki574,项目名称:rAPB,代码行数:31,代码来源:LOGIN_PROOF.cs
示例12: HandlePacket
public int HandlePacket(BaseClient client, PacketIn packet)
{
WorldClient cclient = (WorldClient)client;
UInt32 code = packet.GetUint32();
cclient.Send(new ANS_DISTRICT_RESERVE(code, packet.GetUint32(), cclient.Character.LFG, cclient));
return 0;
}
开发者ID:fiki574,项目名称:rAPB,代码行数:7,代码来源:ASK_DISTRICT_RESERVE.cs
示例13: Login
public static void Login(Client client, PacketIn packet)
{
string user = packet.ReadString();
string pass = packet.ReadString();
ServerConsole.WriteLine("Login request from {0} on ip {1}.", MessageLevel.Message, user, client.IP.ToString());
client.UserLogin(user, pass);
}
开发者ID:BeshoyFD,项目名称:kalsharp,代码行数:7,代码来源:PT_Login.cs
示例14: HandlePacket
public int HandlePacket(BaseClient client, PacketIn packet)
{
WorldClient cclient = (WorldClient)client;
PacketOut Out = new PacketOut((UInt32)Opcodes.LFG);
if (cclient.LFG == 0)
{
MySqlCommand cmd = new MySqlCommand("UPDATE `clientstatus` SET `lfg` = 1 WHERE `name` = @name", WorldServer.Database.Connection.Instance);
try
{
cmd.Prepare();
cmd.Parameters.AddWithValue("@name", cclient.Name);
cmd.ExecuteNonQuery();
}
catch (MySqlException e) { FrameWork.Logger.Log.Error("MySQL", e.ToString()); }
finally { cmd.Dispose(); }
cclient.LFG = 1;
Out.WriteByte(1);
}
else if (cclient.LFG == 1)
{
MySqlCommand cmd = new MySqlCommand("UPDATE `clientstatus` SET `lfg` = 0 WHERE `name` = @name", WorldServer.Database.Connection.Instance);
try
{
cmd.Prepare();
cmd.Parameters.AddWithValue("@name", cclient.Name);
cmd.ExecuteNonQuery();
}
catch (MySqlException e) { FrameWork.Logger.Log.Error("MySQL", e.ToString()); }
finally { cmd.Dispose(); }
cclient.LFG = 0;
Out.WriteByte(0);
}
cclient.Send(Out);
return 0;
}
开发者ID:harleyknd1,项目名称:rAPB,代码行数:35,代码来源:LFG.cs
示例15: SkillRequest
public static void SkillRequest(Client client,PacketIn packet)
{
byte skillId = packet.ReadByte();
uint playerId = packet.ReadUInt32();
client.SkillHandler.Request(skillId,playerId);
client.Send(new Packets.SkillExecute(client.Character,skillId,1));
}
开发者ID:KalOnline,项目名称:KaLua,代码行数:9,代码来源:PT_Skill.cs
示例16: HandlePacket
public int HandlePacket(BaseClient client, PacketIn packet)
{
LobbyClient cclient = client as LobbyClient;
cclient.Characters.Delete(packet.GetUint8());
PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CHARACTER_DELETE);
Out.WriteUInt32Reverse((uint)ResponseCodes.RC_SUCCESS);
cclient.Send(Out);
return 0;
}
开发者ID:harleyknd1,项目名称:rAPB,代码行数:9,代码来源:ASK_CHARACTER_DELETE.cs
示例17: Decrypt
public PacketIn Decrypt(PacketIn packet)
{
byte[] data = packet.ToArray();
decryption.Process(data, 4, data.Length - 4);
PacketIn result = new PacketIn(data, 0, data.Length);
result.Size = result.GetUint32Reversed();
result.Opcode = result.GetUint32Reversed();
Log.Info("[CLIENT POST-ENCRYPT]", this.DumpData(data));
return result;
}
开发者ID:fiki574,项目名称:rAPB,代码行数:10,代码来源:Encryption.cs
示例18: PlayerChange
public static void PlayerChange(Client client, PacketIn packet)
{
byte b = packet.ReadByte();
if(b == 1) {
client.Send(new Packets.AcceptChange());
client.UnspawnPlayer();
client.SendPlayerList();
return;
}
}
开发者ID:BeshoyFD,项目名称:kalsharp,代码行数:10,代码来源:PT_Character.cs
示例19: HandlePacket
public int HandlePacket(BaseClient client, PacketIn packet)
{
WorldClient cclient = (WorldClient)client;
UInt32 whisperuid = packet.GetUint32Reversed();
String charname = packet.GetParsedString();
String message = packet.GetParsedString();
(client as WorldClient).Send(new ANS_CHAT_WHISPER(cclient, whisperuid, charname, message));
//cclient.Send(new CHAT_WHISPER(cclient.CharacterId, 1, message));
return 0;
}
开发者ID:fiki574,项目名称:rAPB,代码行数:10,代码来源:ASK_CHAT_WHISPER.cs
示例20: NpcTalk
public static void NpcTalk(Client client, PacketIn packet)
{
Npc npc = Server.WorldNPCs[packet.ReadUInt32()];
if(npc != null)
{
if(npc.Talk != 0) {
//ServerConsole.WriteLine("Talking with npc #{0} returning Talk #{1}",npc.NpcId,npc.Talk);
client.Send(new Packets.OpenDialog(npc.Talk));
}
}
}
开发者ID:KalOnline,项目名称:KaLua,代码行数:11,代码来源:PT_Npc.cs
注:本文中的PacketIn类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论