[Release]ItemSocket

03/15/2012 17:04 coreymills#1
this is for albetros source Version 5518


in PacketHandler(Packets/PacketHandler) look for
Code:
#region 1009: item usage/ping
                        case 1009:
paste this in the switch statment:
Code:
#region Socket Equipment (market)
                                    case ItemAction.SocketEquipment:
                                        {
                                            if (!user.Inventory.ContainsKey(item.Id))
                                                return;
                                            Structures.ItemInfo toUpgrade = user.Inventory[item.Id];
                                            if (toUpgrade.Gem1 == 0 && toUpgrade.Gem2 == 0)
                                            {
                                                if (!user.HasItem(1088000))
                                                {
                                                    user.SendMessage("SYSTEM", user.Name, "You must have at least one DragonBall!", uint.MaxValue, ChatType.MessageBox);
                                                    return;
                                                }
                                                if (toUpgrade.StaticID < 410003 || toUpgrade.StaticID > 610439)
                                                {
                                                    user.RemoveItem(1088000, 12);
                                                }
                                                else
                                                {
                                                    user.RemoveItem(1088000, 1);
                                                }
                                                toUpgrade.Gem1 = 255;
                                                Database.ModifyItem(toUpgrade.Gem1, "Soc1", toUpgrade.UniqueID);
                                                user.Inventory[toUpgrade.UniqueID] = toUpgrade;
                                                user.Send(Packet.ItemInfoPacket.Create(toUpgrade, 3));
                                                user.SendMessage("SYSTEM", user.Name, "You have added your first socket successfully!", uint.MaxValue, ChatType.MessageBox);
                                            }
                                            else if (toUpgrade.Gem2 == 0)
                                            {
                                                switch(toUpgrade.Gem2)
                                                {
                                                    case 0:
                                                        {
                                                            if (toUpgrade.StaticID < 410003 || toUpgrade.StaticID > 610439 || user.HasItem(1200005, 1))
                                                            {
                                                                user.RemoveItem(1200005, 1);
                                                            }
                                                            break;
                                                        }
                                                    case 1:
                                                        {
                                                            if (toUpgrade.StaticID < 410003 || toUpgrade.StaticID > 610439 || user.HasItem(1200006, 7))
                                                            {
                                                                user.RemoveItem(1200006, 7);
                                                            }
                                                            break;
                                                        }
                                                    default:
                                                        {
                                                            if (toUpgrade.StaticID > 410002 || toUpgrade.StaticID < 610440)
                                                            {
                                                                user.RemoveItem(1088000, 5);
                                                            }
                                                            break;
                                                        }
                                                }
                                                toUpgrade.Gem2 = 255;
                                                Database.ModifyItem(toUpgrade.Gem2, "Soc2", toUpgrade.UniqueID);
                                                user.Inventory[toUpgrade.UniqueID] = toUpgrade;
                                                user.Send(Packet.ItemInfoPacket.Create(toUpgrade, 3));
                                                user.SendMessage("SYSTEM", user.Name, "You have added a second socket successfully!", uint.MaxValue, ChatType.MessageBox);
                                            }
                                            else
                                            {
                                                user.SendMessage("SYSTEM", user.Name, "This item already has dual sockets!", uint.MaxValue, ChatType.MessageBox);
                                                return;
                                            }

                                            user.Send(item);
                                            break;
                                        }
                                    #endregion
03/15/2012 20:45 Spirited#2
Looks good to me. You don't need to send the player's name though. All you need is "SYSTEM" and "ALL". It won't send it to all of the players. It's meant to generalize a message (just in case if you wanted to send it to multiple players). That way you could also make the messages predefined packets (to improve the function's performance). I'd also get rid of that switch statement. Switches are good for 5 or more cases (roughly if I could take a guess). An "if-else if-else" structure would be better there. As I said though, looks good. Good job.
03/16/2012 03:01 ×Holo#3
Glad that you finally got it done :]
03/16/2012 14:27 coreymills#4
Quote:
Originally Posted by Fаng View Post
Looks good to me. You don't need to send the player's name though. All you need is "SYSTEM" and "ALL". It won't send it to all of the players. It's meant to generalize a message (just in case if you wanted to send it to multiple players). That way you could also make the messages predefined packets (to improve the function's performance). I'd also get rid of that switch statement. Switches are good for 5 or more cases (roughly if I could take a guess). An "if-else if-else" structure would be better there. As I said though, looks good. Good job.
i tryed a if else statment but i couldnt get it to work as there was 3 things that needed to be put into account weapon socking then the first socket for items which is 12 dbs and the second socket which needed the tough drill/star drill but i couldnt figure out how to get it to produce a star drill and not give a socket with the way i had the code wrote.

and as for the message i didnt put that there it was already in the code i just added the switch statment to it

thanks XHolo took me awhile but i got it working