That's not strictly true. The code needs to fall through each case and check its value before deciding whether or not to execute it's contents. It will though, stop falling through each after executing your code when you put a break in there. To the machine though, the difference between using a switch and if/else statements is negligibleQuote:
Switches are quicker and less resource using since they don't carry out each argument, they go straight to the case.
I agree with the fact that switches are more cleaner in a script. I allways use switches in my scripts, and only use if/else statements if the varible's im using are say 2 or below.Quote:
The real difference between the two is from the programmers point of view. swicthes are more self-descriptive when used properly. It's easier to read and follow through compared with if/elses. It's easier to write the code as a switch, and mainly, it's much easier to maintain (ie, by changing values, adding additional cases etc).
For you code it is only Client Sided that way to make it so other players will see it you would have to add something like thisQuote:
Here`s a very minor release, a GM-Broadcast-thing command. I know that it`s not much but I just started working on the source XD.
@announce command
// change the color if you wish
Usage : @announce Your~text~goes~here
foreach (GameClient Cli in Kernel.GamePool.Values)
{ Cli.Send(new MessagePacket(Message, Client.Entity.Name, 0xFFFFFFF, MessagePacket.Center)); }
Quote:
case "@announce":
{
string msg = args[1];
string Message = msg.Replace("~", " ");
Client.Send(new MessagePacket(Message, 0x00FF0000, MessagePacket.Center));
break;
}
case "@announce":
{
string Message = args[1];
for(int x = 2; x < args.Lenght; x ++)
Message += args[x];
foreach (GameClient Cli in Kernel.GamePool.Values)
{ Cli.Send(new MessagePacket(Message, Client.Entity.Name, 0xFFFFFFF, MessagePacket.Center)); }
break;
}
#region Proficiency
case "@prof":
{
Client.SetProficiency(new Proficiency(ushort.Parse(args[1]), ushort.Parse(args[2]), 0);
break;
}
#endregion
public bool SetProficiency(Proficiency prof)
{
lock(Proficiencys)
{
if(Proficiencys.ContainsKey(prof.ID)
Proficiencys[prof.ID] = prof;
else
Proficiencys.Add(prof.ID, prof);
Send(prof.Serialize());
}
}
public Dictionary<ushort, Proficiency> Proficiency = new Dictinary<ushort, Proficiency>(50);