Register for your free account! | Forgot your password?

You last visited: Today at 11:52

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

Advertisement



Achievement System

Discussion on Achievement System within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Feb 2009
Posts: 262
Received Thanks: 161
Achievement System

I wrote just a few flags , you can write rest of them


Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Project_Terror.Role
{
    public class Achievement : ServerSocket.Packet
    {
        public const ushort 
            Place_a_piece_of_furniture_in_your_house = 0,
            House_L1 = 1,
            House_L2 = 2,
            House_L3 = 3,
            House_L4 = 4,
            Have_at_least_3_million_silver_on_hand = 5,
            EquipMount = 6,
            EquipLevler12Mount = 7,
            VirtuteforMeteor = 9,
            BreedANewMount = 11,
            DyeYouHaire = 12,
            ChangeYouHaireStyle = 13,
            Change_the_color_of_your_clothes = 14,
            ChangeYouAvatar = 15,
            UsedTheGuildPortal = 16,
            Receive_a_treasure_from_the_Lottery = 17,
            SummonGuard = 18,
            Answer_at_least_5_questions_correctly_in_the_Quiz_Show = 19,
            DanceInMarket = 20,
            House_L5 = 21,
            AddFriend = 22;




        private Role.IMapObj Object;

        private CMD.BitVector BitVector32;
        public Achievement(Role.IMapObj _obj)
            : base(76, true)
        {
            Object = _obj;

            WriteUshort(68, 0);
            WriteUshort((ushort)CMD.GamePackets.Achievement, 2);
            WriteUint(Object.UID, 8);

            BitVector32 = new CMD.BitVector(32 * 13);

            WriteUint(13, 12);//count int[]
        }

        public void AddFlag(int flag)
        {
            BitVector32.Add(flag);

            ShowScreen(flag);

            Send();

        }
        public void Send()
        {
            for (byte x = 0; x < BitVector32.bits.Length; x++)
                WriteUint(BitVector32.bits[x], (ushort)(16 + 4 * x));
            Object.Enqueue(this.ToArray());
        }
           private void ShowScreen(int flag)
        {
            uint FRAG_ID = (uint)(10100 + (uint)(100 * (byte)(flag / 32)) + (byte)(flag % 32) + 1); 

            using (ServerSocket.Packet send_me = new ServerSocket.Packet(28, true))
            {
                send_me.WriteUshort(20, 0);
                send_me.WriteUshort((ushort)CMD.GamePackets.Achievement, 2);
                send_me.WriteUshort(2, 4);//type
                send_me.WriteUint(Object.UID, 8);
                send_me.WriteUint(FRAG_ID, 12);
                Object.Enqueue(send_me.ToArray());
            }
        }
        public override string ToString()
        {
            string line = "";
            foreach (uint bits in BitVector32.bits)
                line += bits.ToString() + "#";
            return line;
        }

        public byte[] ViewOpen()
        {
           byte[] packet = ToArray().ToArray();
            packet[4] = 1;
            return packet;
        }

        public void Load(string bas_line)
        {
           if (bas_line.Length == 0) return;
            string[] line = bas_line.Split('#');
            for(byte x =0; x< 13; x++)
                BitVector32.bits[x] = uint.Parse(line[x]);
        }
    }
}
Code:
 public class BitVector
    {
        public uint[] bits;

        public int Size { get { return 32 * bits.Length; } }

        public BitVector(int BitCount)
        {
            int sections = BitCount / 32;
            bits = new uint[sections];
        }

        public void Add(int index)
        {
            int idx = index / 32;
            uint bites = (uint)(1 << (index % 32));
            bits[idx] |= bites;
        }
        public void Remove(int index)
        {
            int idx = index / 32;
            uint bites = (uint)(1 << (index % 32));
            bits[idx] &= ~bites;
        }
        public bool Contain(int index)
        {
            int idx = index / 32;
            uint bites = (uint)(1 << (index % 32));
            return ((bits[idx] & bites) == bites);
        }
    }
For Viewer player

In packethandler, with id 1136

change them for your source

Code:
 public class Achievement
    {
        public void Execute(Client.IClient client, ServerSocket.Packet packet)
        {
            switch (packet.ToArray()[4])
            {
                case 1:
                    {
                        Client.GameClient obj;
                        if (CMD.Src.Online.TryGetValue(packet.ReadUint(8), out obj))
                        {
                            client.Enqueue(obj.Player.MyAchievement.ViewOpen());
                        }
                        break;
                    }
            }
        }
    }
Attached Images
File Type: jpg poza1.jpg (431.3 KB, 279 views)
File Type: jpg poza2.jpg (376.4 KB, 213 views)
Attached Files
File Type: txt Achievement.txt (28.6 KB, 124 views)
teroareboss1 is offline  
Thanks
2 Users
Old 02/17/2013, 01:24   #2
 
nTL3fTy's Avatar
 
elite*gold: 0
Join Date: Jun 2005
Posts: 692
Received Thanks: 353
You obviously have no idea what you're doing. This packet contains a bit array for the achievement flags. The value at offset 12 is the size of the bit array (in integers). Try again.
nTL3fTy is offline  
Thanks
1 User
Old 02/17/2013, 04:53   #3
 
elite*gold: 0
Join Date: Feb 2009
Posts: 262
Received Thanks: 161
Quote:
Originally Posted by nTL3fTy View Post
You obviously have no idea what you're doing. This packet contains a bit array for the achievement flags. The value at offset 12 is the size of the bit array (in integers). Try again.
You right. Thanks
teroareboss1 is offline  
Old 02/18/2013, 09:09   #4
 
abdoumatrix's Avatar
 
elite*gold: 0
Join Date: Jul 2008
Posts: 874
Received Thanks: 239
Great one.
Ty for share
abdoumatrix is offline  
Reply


Similar Threads Similar Threads
What is Achievement System?
01/27/2024 - Metin2 Private Server - 3 Replies
Hi, As the title tells, my question is what is that achievement system? What is it for? I've seen threads about it but they all are non english and couldn't understand anything from translation, can somebody explain to me what is that system but in english please?
Achievement System
02/16/2013 - CrossFire - 14 Replies
Hallo Com, habe ein bisschen Erklärung notwendig wegen dem Achievement System... (ps. habe die dual d.e. valentine in cf eu ) also: -bleiben die achievements immer? oder nur für dieses event? -werden die fortschritte bei den achievements wieder gelöscht nach einiger zeit? -was bringen die achievements genau? auf welche lohnt es sich zu spielen?
Achievement System DL
01/25/2013 - Metin2 Private Server - 3 Replies
darf man ja nicht :S #cls request
Achievement System
02/23/2012 - Metin2 Private Server - 4 Replies
Joar mir fehlen 2 Datein und zwar achievement_small.dds achievement_small.sub Könnte die jemand hochladen bitte?
achievement system.quest
11/18/2011 - Metin2 Private Server - 6 Replies
Hey Leute. Hat jemand einen quest wo man die Punkte die man bekommen hat gegen Sachen eintauschen kann?



All times are GMT +1. The time now is 11:57.


Powered by vBulletin®
Copyright ©2000 - 2026, 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 ©2026 elitepvpers All Rights Reserved.