Alright so I have this in game command so here it is
internal class GambleCommand : Command
{
public GambleCommand()
: base("roll", 3)
{
}
protected override bool Process(Player player, RealmTime time, string[] args)
{
try
{
if (args.Length == 1)
{
int num = int.Parse(args[0]);
Random rnd = new Random();
string pl = player.Name;
string rand = rnd.Next(0, num).ToString();
if (num < 0)
{
rand = rnd.Next(num, 0).ToString();
}
foreach (Client i in player.Manager.Clients.Values)
{
i.SendPacket(new TextPacket
{
BubbleTime = 0,
Stars = -1,
Name = pl,
Text = "rolled a " + rand + " out of " + num + "."
});
}
}
}
catch
{
Random rnd = new Random();
string pl = player.Name;
string rand = rnd.Next(0, 100).ToString();
foreach (Client i in player.Manager.Clients.Values)
{
i.SendPacket(new TextPacket
{
BubbleTime = 0,
Stars = -1,
Name = pl,
Text = "rolled a " + rand
});
}
}
return true;
}
}
Everything here works fine except for the part that says
if (num < 0)
{
rand = rnd.Next(num, 0).ToString();
}
Basically what this should do is change places from (0, num) num being the maximum number to (num, 0) if the number you choose is a negative. As of right now when I put a negative it goes to default 0-100 which is the catch statement. Please help me asap! Thanks, Dante.
Aucun commentaire:
Enregistrer un commentaire