Some Help ?

12/05/2010 22:25 PuN|SheR#1
Hello!

I Don't Wanna Be Leecher and ask gimme this gimme this but I Have One Question, and I Hope you will help me.. Its about my Pserver... I Would Like To Add Some NPC Which will give super +12 items 2sct with super gems.. But as i can see, on my Character.cs , only its declared additem as (ITEMID,Plus) CODE:

Code:
public void[B] AddItem[/B]([I]uint ID, byte Plus[/I])
this is what i got into characters.cs :
Quote:
public void AddItem(uint ID, byte Plus)
{
Item I = new Item();
I.Plus = Plus;
I.ID = ID;
I.UID = (uint)Rnd.Next(10000000);
I.MaxDur = I.DBInfo.Durability;
I.CurDur = I.MaxDur;

if (I.UID == 0)
{
I.UID = (uint)Rnd.Next(10000000);
}

Inventory.Add(I);
MyClient.AddSend(Packets.AddItem(I, 0));
}

So I Know How To Make a NPC Which Gives Super Items +12 but no clue how should I Public AddItem(uint ID,byte Plus,byte soc1,byte soc2) cause I'm not that good "Coder" !
Here is the NPC Code For +12 Items
Code:

Code:
#region MyNpc7
case 412345:
                                {
                                    if (Control == 0)
                                    {
                                        GC.AddSend(Packets.NPCSay("Hello, Welcome To Your God ! I Will Give You Free Items If You Are 70lvl +"));
                                        GC.AddSend(Packets.NPCLink("Cool let me in.", 1));
                                        GC.AddSend(Packets.NPCLink("Haa Ok Then", 255));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());
                                    }
                                    if (Control == 1)
                                    {
                                        GC.AddSend(Packets.NPCSay("I can gift you with some gear of specified profesion"));
                                        GC.AddSend(Packets.NPCLink("FireTao L70 pack", 2));
                                        GC.AddSend(Packets.NPCLink("WaterTao L70 pack", 3));
                                        GC.AddSend(Packets.NPCLink("Warrior L70 pack", 4));
                                        GC.AddSend(Packets.NPCLink("Trojan L70 pack", 5));
                                        GC.AddSend(Packets.NPCLink("Archer L70 pack", 6));
                                        GC.AddSend(Packets.NPCLink("Ninja L70 pack", 7));
                                        GC.AddSend(Packets.NPCLink("Weps pack L70", 8));
                                        GC.AddSend(Packets.NPCLink("No, thanks.", 255));
                                        GC.AddSend(Packets.NPCSetFace(15));
                                        GC.AddSend(Packets.NPCFinish());
                                    }

                                    else if (GC.MyChar.Level <= 0)
                                    {
                                        GC.AddSend(Packets.NPCSay("Welcome To My Seller But ur not lvl 70 yet!"));
                                        GC.AddSend(Packets.NPCLink("Damn.", 255));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());
                                    }

                                    if (Control == 2)
                                    {


                                        GC.MyChar.AddItem(134069, 12); //Robe
                                        GC.MyChar.AddItem(117069, 12); //Earring
                                        GC.MyChar.AddItem(152129, 12); //brac
                                        GC.MyChar.AddItem(121129, 12); //Bag
                                        GC.MyChar.AddItem(160139, 12); //boots
                                        GC.MyChar.AddItem(202009, 12); //Star
                                        GC.MyChar.AddItem(201009, 12); //Fan
                                        GC.AddSend(Packets.NPCSay("Here you are."));
                                        GC.AddSend(Packets.NPCLink("Thanks.", 255));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());

                                    }
                                    if (Control == 3)
                                    {
                                        GC.MyChar.AddItem(134069, 12); //Robe
                                        GC.MyChar.AddItem(117069, 12); //Earring
                                        GC.MyChar.AddItem(152129, 12); //brac
                                        GC.MyChar.AddItem(121129, 12); //Bag
                                        GC.MyChar.AddItem(160139, 12); //boots
                                        GC.MyChar.AddItem(202009, 12); //Star
                                        GC.MyChar.AddItem(201009, 12); //Fan
                                        GC.AddSend(Packets.NPCSay("Here you are."));
                                        GC.AddSend(Packets.NPCLink("Thanks.", 255));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());
                                    }

                                    if (Control == 4)
                                    {
                                        GC.MyChar.AddItem(131069, 12); //Robe
                                        GC.MyChar.AddItem(117069, 12); //Earring
                                        GC.MyChar.AddItem(120129, 12); //Neck
                                        GC.MyChar.AddItem(150139, 12); //Ring
                                        GC.MyChar.AddItem(160139, 12); //boots
                                        GC.MyChar.AddItem(202009, 12); //Star
                                        GC.MyChar.AddItem(201009, 12); //Fan
                                        GC.AddSend(Packets.NPCSay("Here you are."));
                                        GC.AddSend(Packets.NPCLink("Thanks.", 255));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());
                                    }
                                    else if (Control == 5)
                                    {
                                        GC.MyChar.AddItem(130069, 12); //Robe
                                        GC.MyChar.AddItem(117069, 12); //Earring
                                        GC.MyChar.AddItem(120129, 12); //Neck
                                        GC.MyChar.AddItem(150139, 12); //Ring
                                        GC.MyChar.AddItem(160139, 12); //boots
                                        GC.MyChar.AddItem(202009, 12); //Star
                                        GC.MyChar.AddItem(201009, 12); //Fan
                                        GC.AddSend(Packets.NPCSay("Here you are."));
                                        GC.AddSend(Packets.NPCLink("Thanks.", 255));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());
                                    }
                                    else if (Control == 6)
                                    {
                                        GC.MyChar.AddItem(133049, 12); //Robe
                                        GC.MyChar.AddItem(117069, 12); //Earring
                                        GC.MyChar.AddItem(120129, 12); //Neck
                                        GC.MyChar.AddItem(150139, 12); //Ring
                                        GC.MyChar.AddItem(160139, 12); //boots
                                        GC.MyChar.AddItem(202009, 12); //Star
                                        GC.MyChar.AddItem(201009, 12); //Fan
                                        GC.AddSend(Packets.NPCSay("Here you are."));
                                        GC.AddSend(Packets.NPCLink("Thanks.", 255));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());
                                        GC.AddSend(Packets.NPCSay("Here you are."));
                                        GC.AddSend(Packets.NPCLink("Thanks.", 255));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());
                                    }
                                    else if (Control == 7)
                                    {
                                        GC.MyChar.AddItem(135069, 12); //Robe
                                        GC.MyChar.AddItem(112069, 12); //Earring
                                        GC.MyChar.AddItem(120129, 12); //Neck
                                        GC.MyChar.AddItem(150139, 12); //Ring
                                        GC.MyChar.AddItem(160139, 12); //boots
                                        GC.MyChar.AddItem(202009, 12); //Star
                                        GC.MyChar.AddItem(201009, 12); //Fan
                                        GC.AddSend(Packets.NPCSay("Here you are."));
                                        GC.AddSend(Packets.NPCLink("Thanks.", 255));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());

                                    }
                                    else if (Control == 8)
                                    {
                                        GC.MyChar.AddItem(421139, 12); //BS
                                        GC.MyChar.AddItem(420139, 12); //S
                                        GC.MyChar.AddItem(410139, 12); //B
                                        GC.MyChar.AddItem(480139, 12); //C
                                        GC.MyChar.AddItem(561139, 12); //W
                                        GC.MyChar.AddItem(560139, 12); //SP
                                        GC.MyChar.AddItem(601139, 12); //k
                                        GC.MyChar.AddItem(500129, 12); //Bo
                                        GC.AddSend(Packets.NPCSay("Here you are."));
                                        GC.AddSend(Packets.NPCLink("Thanks.", 255));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());

                                    }

                                    break;
                                }
                            #endregion
So AnyONe Knows How To Do This?

Sorry For Bothering you :bandit:
12/05/2010 22:36 bone-you#2
Make a new function that does what you want, or modify existing function to support your params.
12/05/2010 22:42 PuN|SheR#3
Quote:
Originally Posted by bone-you View Post
Make a new function that does what you want, or modify existing function to support your params.
Yea,Thats what im talkin' in my thread.. I Could'nt do that,could you give me some example how should new function look? Cause i guess im not that good at C# , must to read some more tuts... :)
12/05/2010 23:48 .Beatz#4
I.Socket = Socket;
I.Socket2 = Socket2;

Something along the lines of that, I dont know how your source is set up to handle the sockets so that is just a guess, but you can work of that.
Code:
public void AddItem(uint ID, byte Plus, byte Bless, byte Enchant, bool Free, byte Socket)
        {
            ItemType I = new ItemType();
            I.Plus = Plus;
            I.ID = ID;
            I.Bless = Bless;
            I.FreeItem = Free;
            I.Enchant = Enchant;
            I.UID = (uint)Rnd.Next(10000000);
            I.MaxDur = I.DBInfo.Durability;
            I.CurDur = I.MaxDur;
            I.Socket = I.Socket;

            if (I.UID == 0)
            {
                I.UID = (uint)Rnd.Next(10000000);
            }

            Inventory.Add(I);
            Client.Send(ConquerPacket.AddItem(I, 0));
        }
btw cant remember if its a byte or w/e so that will do for now lol
12/06/2010 00:01 PuN|SheR#5
My Source is kinda different.. Cant Make it like it needs.... Im gooonna attach it here,writing from my notebook so sorry if i make some grammar mistakes !
12/06/2010 01:06 Syst3m_W1z4rd#6
Code:
public void AddItem(uint ID, byte Plus, byte Bless, byte Enchant, byte Soc1, byte Soc2)
{
Item I = new Item();
I.Plus = Plus;
I.ID = ID;
I.Bless = Bless;
I.Enchant = Enchant;
I.Soc1 = (Item.Gem)Soc1;
I.Soc2 = (Item.Gem)Soc2;
I.UID = (uint)Rnd.Next(10000000);
I.MaxDur = I.DBInfo.Durability;
I.CurDur = I.MaxDur;

if (I.UID == 0)
{
I.UID = (uint)Rnd.Next(10000000);
}

Inventory.Add(I);
MyClient.AddSend(Packets.AddItem(I, 0));
}
12/06/2010 09:32 PuN|SheR#7
Oh Thanks Alot.. Btw, someone have ID's from AllGems?

EDIT:

Can someone help me about something? I wanna make, on each killed birdman player who killed the birdman get 50cp's , and for Turtledoves 25cps.. Can someone tell me how :)?
12/06/2010 10:27 Syst3m_W1z4rd#8
Right click Item.Gem.
And click Go to defination.

Then you have all the ids :)
12/06/2010 10:49 pro4never#9
For cps from monster just go to where final monster death is (should be something like kill( or w/e) and run your calculation on how you want to award cp. Personally I prefer random chance + difference in player/mob levels but if you want just standard rate across a certain mob you could do something like..

switch(Monster.Name)
{
case "Birdmen":
Client.Cps+= 50;
break;
default:
Client.Cps += 10;
break;
}

or w/e you wanted.
12/06/2010 11:38 PuN|SheR#10
Quote:
Originally Posted by pro4never View Post
For cps from monster just go to where final monster death is (should be something like kill( or w/e) and run your calculation on how you want to award cp. Personally I prefer random chance + difference in player/mob levels but if you want just standard rate across a certain mob you could do something like..

switch(Monster.Name)
{
case "Birdmen":
Client.Cps+= 50;
break;
default:
Client.Cps += 10;
break;
}

or w/e you wanted.
Oh.. It should be something like this,but my source is kinda different... With If(MyMath.Sucess) or w/e ! Should i upload my source?
12/06/2010 11:51 bone-you#11
Quote:
Originally Posted by pro4never View Post
For cps from monster just go to where final monster death is (should be something like kill( or w/e) and run your calculation on how you want to award cp. Personally I prefer random chance + difference in player/mob levels but if you want just standard rate across a certain mob you could do something like..

switch(Monster.Name)
{
case "Birdmen":
Client.Cps+= 50;
break;
default:
Client.Cps += 10;
break;
}

or w/e you wanted.
BAD. Do it by id, not by strings. Little things like that is why most servers nowadays can't handle more than 10 people. Each action someone takes invokes like 100000 memory operations and 500 functions.
12/06/2010 12:40 Syst3m_W1z4rd#12
Quote:
Originally Posted by bone-you View Post
BAD. Do it by id, not by strings. Little things like that is why most servers nowadays can't handle more than 10 people. Each action someone takes invokes like 100000 memory operations and 500 functions.
like?
Code:
switch(Monster.ID)
{
    case 0001:
    Client.Cps+= 50;
    break;
    
    default: 
    Client.Cps += 10;
    break;
}
12/06/2010 14:02 bone-you#13
Quote:
Originally Posted by 1337 H4X0R View Post
like?
Code:
switch(Monster.ID)
{
    case 0001:
    Client.Cps+= 50;
    break;
    
    default: 
    Client.Cps += 10;
    break;
}
Must better. Indexes are far faster than string lookups.

Integers are just (does x = y). String lookups are (string compare x and y). Imagine that in a switch with tons of cases.
12/06/2010 15:29 _Emme_#14
I remember reading a long time ago about this topic just to clarify it all, strings are nearly ten times slower than indexes. So yeah, use them as little as possible =p
12/06/2010 18:45 PuN|SheR#15
Let Me Upload you the MOB.CS ,and someone who will have time, would change something in it! If you need something else exsept mob.cs , just REPLY! I Can't make it work :S
Uploaded Mob.cs and Character.cs ! Please modify them if you have some time :)

Edit: Bone-You, and Emme Coder, You're right, reading indexes is faster than reading strings :)