Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- step 1:
- open GameServer Project Add New Class name it : Rankings.cs
- then add this code to your class
- **/
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using COServer.Client;
- using COServer;
- using COServer.Database;
- using Extensions;
- namespace COServer
- {
- class Rankings
- {
- public static Dictionary<uint, Entities> Ranklist = new Dictionary<uint, Entities>();
- public class Entities
- {
- public uint UID;
- public string Name = "";
- public ushort Level;
- public long Money;
- public ulong Donation;
- public uint ConquerPoints;
- public byte VipLevel;
- public byte Class;
- public ushort Face;
- }
- public static void Update(GameClient client)
- {
- if (!Ranklist.ContainsKey(client.Player.UID))
- {
- Entities players = new Entities();
- players.UID = client.Player.UID;
- players.Name = client.Player.Name;
- Ranklist.Add(players.UID, players);
- }
- else
- {
- Refresh(client);
- }
- }
- public static void check(GameClient client)
- {
- using (var command = new MySqlCommand(MySqlCommandType.SELECT))
- {
- command.Select("Rankings").Where("UID", client.Player.UID);
- using ( var reader = new MySqlReader(command, true))
- {
- if (!reader.Read())
- {
- using (var cmd = new MySqlCommand(MySqlCommandType.INSERT))
- {
- cmd.Insert("Rankings")
- .Insert("UID", client.Player.UID)
- .Insert("Name", client.Player.Name)
- .Execute();
- }
- }
- }
- }
- }
- public static void Refresh(GameClient client)
- {
- if (Ranklist.ContainsKey(client.Player.UID))
- {
- var Player = Ranklist[client.Player.UID];
- Player.Level = client.Player.Level;
- Player.Money = client.Player.Money;
- Player.Donation = client.Player.Nobility.Donation;
- Player.ConquerPoints = client.Player.ConquerPoints;
- Player.VipLevel = client.Player.VipLevel;
- Player.Class = client.Player.Class;
- Player.Face = client.Player.Face;
- using (var cmd = new MySqlCommand(MySqlCommandType.UPDATE))
- {
- cmd.Update("Rankings")
- .Set("Level", Player.Level)
- .Set("Gold", Player.Money)
- .Set("Donation", Player.Donation)
- .Set("cps", Player.ConquerPoints)
- .Set("VIPLevel", Player.VipLevel)
- .Set("Class", Player.Class)
- .Set("Face", Player.Face)
- .Where("UID", Player.UID)
- .Execute();
- }
- }
- }
- public static void Load()
- {
- using (var command = new MySqlCommand(MySqlCommandType.SELECT))
- {
- command.Select("Rankings").Where("UID", 0, true);
- using (var reader = new MySqlReader(command))
- {
- while (reader.Read())
- {
- Entities players = new Entities();
- players.UID = reader.ReadUInt32("UID");
- players.Name = reader.ReadString("Name");
- players.Level = reader.ReadByte("Level");
- players.Money = reader.ReadInt64("Gold");
- players.ConquerPoints = reader.ReadUInt32("cps");
- players.VipLevel = reader.ReadByte("VIPLevel");
- players.Class = reader.ReadByte("Class");
- if (!Ranklist.ContainsKey(players.UID))
- {
- Ranklist.Add(players.UID,players);
- }
- }
- }
- }
- }
- public static void Save()
- {
- foreach (var player in Rankings.Ranklist.Values)
- {
- using (var cmd = new MySqlCommand(MySqlCommandType.UPDATE))
- {
- cmd.Update("Rankings")
- .Set("Level", player.Level)
- .Set("Gold", player.Money)
- .Set("Donation", player.Donation)
- .Set("cps", player.ConquerPoints)
- .Set("VIPLevel", player.VipLevel)
- .Set("Class", player.Class)
- .Where("UID", player.UID)
- .Execute();
- }
- }
- }
- }
- }
- }
- /////////////////////////////////////////////////////////
- ///////////////////////////////////////////
- ///////////////////////////////
- ///////////////////
- /**
- step 2:
- goto class Server.cs
- search for : IniFile.Write<uint>("Config", "Day", ResetServerDay);
- add this code after it
- **/
- Save(new Action(Rankings.Save));
- ////////////////////////////////////////////////////////
- /**
- step 3:
- in the same class srech for :
- Shops.ShopFile.Load();
- and add this code after
- **/
- Rankings.Load();
- //////////////////////////////////////////////////////
- /**
- step 4:
- goto MsgLoginClient.cs
- search for : Playeracc.WriteName(client);
- you will found 2 result of this line
- after each line of them add this code:
- **/
- Rankings.check(client);
- ////////////////////////////////////////////////////////
- /**
- step 5:
- goto Program.cs
- search for this void :
- public static void SaveDBPayers(Extensions.Time32 clock)
- then inside this void you will found this if condaition :
- ##########################################################################################
- if ((user.ClientFlag & Client.ServerFlag.LoginFull) == Client.ServerFlag.LoginFull)` #
- { #
- user.ClientFlag |= Client.ServerFlag.QueuesSave; #
- Database.ServerDatabase.LoginQueue.TryEnqueue(user); #
- #
- } #
- ##########################################################################################
- after this if condaition brackets we will add this code :
- ########################
- #Rankings.Update(user);#
- ########################
- to be like this code
- ##########################################################################################
- if ((user.ClientFlag & Client.ServerFlag.LoginFull) == Client.ServerFlag.LoginFull)` #
- { #
- user.ClientFlag |= Client.ServerFlag.QueuesSave; #
- Database.ServerDatabase.LoginQueue.TryEnqueue(user); #
- #
- } #
- Rankings.Update(user); #
- ##########################################################################################
- **/
- /////////////////////////////////////////////
- /**
- step 6:
- goto navicat then right click on ur dbname then -> Console
- and copy this code to ur db console
- **/
- -- ----------------------------
- -- Table structure for rankings
- -- ----------------------------
- DROP TABLE IF EXISTS `rankings`;
- CREATE TABLE `rankings` (
- `UID` bigint(16) UNSIGNED NULL DEFAULT NULL,
- `Name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
- `Level` bigint(16) NULL DEFAULT NULL,
- `Gold` bigint(18) UNSIGNED NULL DEFAULT NULL,
- `Donation` bigint(25) UNSIGNED NULL DEFAULT NULL,
- `cps` bigint(18) UNSIGNED NULL DEFAULT 0,
- `VIPLevel` tinyint(5) UNSIGNED NOT NULL,
- `Class` bigint(16) NULL DEFAULT NULL,
- `Face` int(5) UNSIGNED NULL DEFAULT NULL
- ) ENGINE = MyISAM CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;
- /////////////////////////////////////////////////////////////////
- /**
- ##################################################################################################
- this code for Conquer Developers Facebook Group: https://www.facebook.com/groups/cocoders/
- By : Salem Ahmed
- Use It To Read And write ranks in mysql db and pass data to Web Page
- ##################################################################################################
- **/
Advertisement
Add Comment
Please, Sign In to add comment