Register for your free account! | Forgot your password?

You last visited: Today at 17:11

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Release]ItemSocket

Discussion on [Release]ItemSocket within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.

Reply
 
Old   #1
 
coreymills's Avatar
 
elite*gold: 0
Join Date: Mar 2008
Posts: 555
Received Thanks: 99
[Release]ItemSocket

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
coreymills is offline  
Thanks
3 Users
Old 03/15/2012, 20:45   #2
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
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.
Spirited is offline  
Thanks
1 User
Old 03/16/2012, 03:01   #3
 
×Holo's Avatar
 
elite*gold: 0
Join Date: Mar 2012
Posts: 286
Received Thanks: 71
Glad that you finally got it done :]
×Holo is offline  
Thanks
1 User
Old 03/16/2012, 14:27   #4
 
coreymills's Avatar
 
elite*gold: 0
Join Date: Mar 2008
Posts: 555
Received Thanks: 99
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
coreymills is offline  
Reply




All times are GMT +1. The time now is 17:12.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.