[Release] Extremely basic (but working/bugless) C# Source

04/26/2009 19:36 kinshi88#76
Quote:
Originally Posted by alexbigfoot View Post
why would I? I mean its not a big difference. It works the same...
anyway as you wish
Switches are quicker and less resource using since they don't carry out each argument, they go straight to the case.
04/26/2009 23:31 unknownone#77
Quote:
Originally Posted by kinshi88 View Post
Switches are quicker and less resource using since they don't carry out each argument, they go straight to the case.
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 negligible

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).
04/27/2009 00:27 Ultimatum#78
Quote:
Originally Posted by unknownone View Post
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).
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.

Also theres another point about switches. If you do use switches the compiler will optimize it to a look up table, and with if/else statements cannot. The only downside to switches is the fact that you can't use a single varible to define as the case. You have to use the constant value.
04/27/2009 00:44 LordSesshomaru#79
Quote:
Originally Posted by ElDeRnEcRo View Post
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
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 this

Code:
foreach (GameClient Cli in Kernel.GamePool.Values)
                            { Cli.Send(new MessagePacket(Message, Client.Entity.Name, 0xFFFFFFF, MessagePacket.Center)); }
Thanks to Alexbigfoot for that one
04/27/2009 10:47 alexbigfoot#80
Quote:
Originally Posted by ElDeRnEcRo View Post
case "@announce":
{
string msg = args[1];
string Message = msg.Replace("~", " ");
Client.Send(new MessagePacket(Message, 0x00FF0000, MessagePacket.Center));
break;
}
Code:
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;
}
^ The code I use in my server.
04/28/2009 02:51 kinshi88#81
Here's my noobie attacking.
Its not finished yet, but I guess its a start.
If anyone wants to help me improve/finish it, that would be great =P
04/30/2009 23:59 kinshi88#82
Quote:
Originally Posted by felipeboladao View Post
InfamousNoone, To make the Sell Shop and Shopping Mall ,i need of?

Tranks ;D
case 1009 in the Packet Processor.
Use ItemUsagePacket.BuyFromNPC.

Attached is the script to buy items from NPCs
05/04/2009 23:38 kinshi88#83
#Thread Cleaned

(It may look like I'm triple posting, but technically I'm not..)
05/05/2009 14:31 taushif#84
Yo can someone help me?
I'm trying to add prof's i saw Alex's Prof class and I downloaded Tao's 3.1 Rev.
I see that Alex's prof class looks like the ProfPacket class from Tao's 3.1 Rev.
But I don't really know how to use Tao's class I think its sorta same as Alex's
I guess: ProfPacket club = new ProfPacket(); club.ID = 480; club.Level = 19; club.Experience = 192321; Client.Send(club.Serialize());

Thats how I think its used, but I need a bit more info :P
Where do I need to code something that will add the prof to the client?
Like when i use @prof 480 20 it has to give me prof level 20 of Club :P
I have a feeling its done with Client.Send(club.Serialize()); but I dont really know.

Uhm about saving in in the database I think I need to make an Array of Prof's
like its done with Items and then make a folder like Inventory but then I name it Profiency. And loading it from the database is sorta same as loading Inventory I think?

Please help me
Thnx in advance,
Taus
05/05/2009 16:55 alexbigfoot#85
this goes to commands class:
Code:
#region Proficiency
case "@prof":
{
Client.SetProficiency(new Proficiency(ushort.Parse(args[1]), ushort.Parse(args[2]), 0);
break;
}
#endregion
But be sure you`ve got in your gameclient class SetProficiency(Proficiency prof)

if you dont use this:
Code:
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());
}
}
Also you may need the proficiencys dictionary.
Code:
public Dictionary<ushort, Proficiency> Proficiency = new Dictinary<ushort, Proficiency>(50);
Usage: @prof 480 20

You`ve got to do the save part by your own. Good luck!
05/05/2009 22:05 tao4229#86
If you just use my rev it has a method called Client.LearnProf, which either updates or completely learns a proficiency.
05/06/2009 17:47 taushif#87
Thnx very much for responding and for ur information both Alex and tao.
I got another question :P If i use the command @prof 480 2 or any numer :P it doesn't show anything in the prof list in the client. I think its because there isn't coded which Prof ID is which Prof like Prof 480 is club and it doesn't do anything I think. If its true what I say can you tell me where to code that and maybe give me 1 example how you coded 1 prof? I learned Java and thats very similar to C++ so its not hard to understand code for me :P
05/06/2009 23:54 hok30#88
Quote:
Originally Posted by taushif View Post
I learned Java and thats very similar to C++ so its not hard to understand code for me :P
That's good, but this is C#.

btw, I hate Java. And JavaScript. and HTML. If that even counts as a scripting language.
05/07/2009 00:33 PeTe Ninja#89
ooo wonder when rev4 will come out lol..Im having trouble with rev3 :(
05/07/2009 01:36 kinshi88#90
Quote:
Originally Posted by PeTe Ninja View Post
ooo wonder when rev4 will come out lol..Im having trouble with rev3 :(
Won't be one (at least not from Hybrid).
Hybrid has stopped development on this.