本文整理汇总了C#中System.IO.BinaryWriter.WriteVarUInt32方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryWriter.WriteVarUInt32方法的具体用法?C# BinaryWriter.WriteVarUInt32怎么用?C# BinaryWriter.WriteVarUInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.BinaryWriter
的用法示例。
在下文中一共展示了BinaryWriter.WriteVarUInt32方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: doProcess
public override bool doProcess(string[] args)
{
if (this.client.playerData.freeFuel)
{
client.sendCommandMessage("Sorry, you have already received free starter fuel on this server.");
return false;
}
else if (!StarryboundServer.config.freeFuelForNewPlayers)
{
client.sendCommandMessage("Sorry, this server does not provide free starter fuel.");
return false;
}
MemoryStream packet = new MemoryStream();
BinaryWriter packetWrite = new BinaryWriter(packet);
packetWrite.WriteStarString("solariumore");
packetWrite.WriteVarUInt32(31); // Seems like it always gives 1 less than the amount entered, so we need 31 to give 30.
packetWrite.Write((byte)0); //0 length Star::Variant
client.sendClientPacket(Packet.GiveItem, packet.ToArray());
client.sendCommandMessage("You have received 30 Solarium Ore as free starter fuel!");
this.client.playerData.freeFuel = true;
Users.SaveUser(this.client.playerData);
return true;
}
示例2: doProcess
public override bool doProcess(string[] args)
{
if (player.receivedStarterKit)
{
client.sendCommandMessage("You have already received your starting items.");
return false;
}
if (StarryboundServer.config.starterItems == null || StarryboundServer.config.starterItems.Length <= 0)
{
client.sendCommandMessage("Sorry! This server does not provide any starting items.");
return false;
}
int awardedItems = 0;
foreach (string item in StarryboundServer.config.starterItems)
{
if (String.IsNullOrEmpty(item) || String.IsNullOrWhiteSpace(item))
{
continue;
}
string name;
uint amount;
if (item.Contains('*'))
{
name = item.Split('*')[0];
amount = uint.Parse(item.Split('*')[1]);
if (amount <= 0) { continue; }
}
else
{
name = item;
amount = 1;
}
MemoryStream packet = new MemoryStream();
BinaryWriter packetWrite = new BinaryWriter(packet);
packetWrite.WriteStarString(name);
packetWrite.WriteVarUInt32(amount+1);
packetWrite.Write((byte)0);
client.sendClientPacket(Packet.GiveItem, packet.ToArray());
awardedItems++;
}
if (awardedItems == 0)
{
client.sendCommandMessage("Sorry! This server does not provide any starting items.");
return false;
}
client.sendCommandMessage("You have been given a few starting items to help you on your journey. Good luck!");
this.client.playerData.receivedStarterKit = true;
Users.SaveUser(this.client.playerData);
return true;
}
示例3: onSend
public override void onSend()
{
MemoryStream packet = new MemoryStream();
BinaryWriter packetWrite = new BinaryWriter(packet);
packetWrite.Write(false);
packetWrite.WriteVarUInt32(0);
packetWrite.WriteStarString((string)tmpArray["rejectReason"]);
this.mClient.sendClientPacket(Packet.ConnectResponse, packet.ToArray());
}
示例4: doProcess
public override bool doProcess(string[] args)
{
if (!hasPermission()) { permissionError(); return false; }
if (args.Length < 2) { showHelpText(); return false; }
string item = args[0];
uint count = Convert.ToUInt32(args[1]) + 1;
if (String.IsNullOrEmpty(item) || count < 1) { showHelpText(); return false; }
MemoryStream packet = new MemoryStream();
BinaryWriter packetWrite = new BinaryWriter(packet);
packetWrite.WriteStarString(item);
packetWrite.WriteVarUInt32(count);
packetWrite.Write((byte)0); //0 length Star::Variant
client.sendClientPacket(Packet.GiveItem, packet.ToArray());
client.sendCommandMessage("Gave you " + (count - 1) + " " + item);
return true;
}