本文整理匯總了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;
}