Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Creas Nueva Clase Activist
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using COServer.Database;
- namespace COServer.Game
- {
- public class Activists
- {
- public static uint R1Points, R2Points, R3Points, R4Points, R5Points;
- public static string R1Name, R2Name, R3Name, R4Name, R5Name;
- public static void READ()
- {
- using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("activists"))
- using (var reader = new MySqlReader(cmd))
- {
- while (reader.Read())
- {
- R1Points = reader.ReadUInt32("R1Points");
- R2Points = reader.ReadUInt32("R2Points");
- R3Points = reader.ReadUInt32("R3Points");
- R4Points = reader.ReadUInt32("R4Points");
- R5Points = reader.ReadUInt32("R5Points");
- R1Name = reader.ReadString("R1Name");
- R2Name = reader.ReadString("R2Name");
- R3Name = reader.ReadString("R3Name");
- R4Name = reader.ReadString("R4Name");
- R5Name = reader.ReadString("R5Name");
- }
- }
- Console.WriteLine("Systems QuestsServer Players Done!.");
- }
- public static void RESTART()
- {
- using (var cmd = new MySqlCommand(MySqlCommandType.UPDATE).Update("activists"))
- {
- cmd.Set("R1Points", 0).Set("R1Name", "[Empty]")
- .Set("R2Points", 0).Set("R2Name", "[Empty]")
- .Set("R3Points", 0).Set("R3Name", "[Empty]")
- .Set("R4Points", 0).Set("R4Name", "[Empty]")
- .Set("R5Points", 0).Set("R5Name", "[Empty]");
- cmd.Execute();
- }
- using (var cmd = new MySqlCommand(MySqlCommandType.UPDATE).Update("entities"))
- {
- cmd.Set("Activists", 0);
- cmd.Execute();
- }
- Network.GamePackets.Message.WorldMessage("Activists System Restarted.");
- }
- public static void SAVE()
- {
- COServer.Database.MySqlCommand cmd = new COServer.Database.MySqlCommand(COServer.Database.MySqlCommandType.UPDATE);
- cmd.Update("activists")
- .Set("R1Points", R1Points).Set("R1Name", R1Name)
- .Set("R2Points", R2Points).Set("R2Name", R2Name)
- .Set("R3Points", R3Points).Set("R3Name", R3Name)
- .Set("R4Points", R4Points).Set("R4Name", R4Name)
- .Set("R5Points", R5Points).Set("R5Name", R5Name);
- cmd.Execute();
- }
- }
- }
- ============================================
- En PacketHandler.cs
- Agregamos :
- #region Activists
- public static ConcurrentDictionary<string, byte[]> ActivistsAllowance = new ConcurrentDictionary<string, byte[]>();
- public static object ActivistsSyncRoot = new object();
- public static void AddActivists(GameClient client)//Caso de error cambias a GameState
- {
- if (!ActivistsAllowance.ContainsKey(client.Socket.IP))
- ActivistsAllowance.Add(client.Socket.IP, new byte[3]);
- lock (ActivistsSyncRoot)
- {
- byte[] data = ActivistsAllowance[client.Socket.IP];
- for (int i = 0; i < data.Length; i++)
- {
- if (data[i] == 0)
- {
- client.AllowedActivists = true;
- client.AllowedActivistsIndex = i;
- data[i] = 1;
- }
- }
- }
- }
- public static void RemoveActivists(GameClient client)
- {
- if (client.AllowedActivists)
- {
- lock (ActivistsSyncRoot)
- {
- byte[] data = ActivistsAllowance[client.Socket.IP];
- data[client.AllowedActivistsIndex] = 0;
- }
- }
- }
- #endregion
- Buscamos : void DoLogin(GameClient client) y Agregamos :
- AddActivists(client);
- ==========================================
- en GameState // GameClient Agregamos :
- public bool AllowedActivists;
- Buscamos : void Disconnect(bool save = true) y Agregamos :
- GeneralData.RemoveActivists(this);//PacketHandler en tu Caso
- ==========================================
- En World.cs en la Parte de CharactersCallBack Agregamos :
- #region Activists
- if (DateTime.Now.DayOfWeek != DayOfWeek.Friday)
- {
- //Check & Set.
- uint myPoints = client.Player.Activists;//Player por Entity cualquier cosa..
- string myName = client.Player.Name;
- //Rank[1]
- if (myPoints > Activists.R1Points && myName != Activists.R1Name)
- {
- if (Activists.R2Points < Activists.R1Points) Activists.R2Name = Activists.R1Name; Activists.R2Points = Activists.R1Points;
- Activists.R1Name = myName; Activists.R1Points = myPoints; Activists.SAVE();
- }
- //Rank[2]
- if (myPoints > Activists.R2Points && myName != Activists.R1Name && myName != Activists.R2Name)
- {
- if (Activists.R3Points < Activists.R2Points) Activists.R3Name = Activists.R2Name; Activists.R3Points = Activists.R2Points;
- Activists.R2Name = myName; Activists.R2Points = myPoints; Activists.SAVE();
- }
- //Rank[3]
- if (myPoints > Activists.R3Points && myName != Activists.R1Name && myName != Activists.R2Name && myName != Activists.R3Name)
- {
- if (Activists.R4Points < Activists.R3Points) Activists.R4Name = Activists.R3Name; Activists.R4Points = Activists.R3Points;
- Activists.R3Points = myPoints; Activists.R3Name = myName; Activists.SAVE();
- }
- //Rank[4]
- if (myPoints > Activists.R4Points && myName != Activists.R1Name && myName != Activists.R2Name && myName != Activists.R3Name && myName != Activists.R4Name)
- {
- if (Activists.R5Points < Activists.R4Points) Activists.R5Name = Activists.R4Name; Activists.R5Points = Activists.R4Points;
- Activists.R4Points = myPoints; Activists.R4Name = myName; Activists.SAVE();
- }
- //Rank[5]
- if (myPoints > Activists.R5Points && myName != Activists.R1Name && myName != Activists.R2Name && myName != Activists.R3Name && myName != Activists.R4Name && myName != Activists.R5Name)
- {
- Activists.R5Points = myPoints; Activists.R5Name = myName; Activists.SAVE();
- }
- //Update
- //1
- if (myName == Activists.R1Name && myPoints != Activists.R1Points)
- {
- Activists.R1Points = myPoints;
- }
- //2
- if (myName == Activists.R2Name && myPoints != Activists.R2Points)
- {
- Activists.R2Points = myPoints; Activists.SAVE();
- }
- //3
- if (myName == Activists.R3Name && myPoints != Activists.R3Points)
- {
- Activists.R3Points = myPoints; Activists.SAVE();
- }
- //4
- if (myName == Activists.R4Name && myPoints != Activists.R4Points)
- {
- Activists.R4Points = myPoints; Activists.SAVE();
- }
- //5
- if (myName == Activists.R5Name && myPoints != Activists.R5Points)
- {
- Activists.R5Points = myPoints; Activists.SAVE();
- }
- #region Activists Points
- if (client.AllowedActivists)
- {
- if (Now32 > client.LastActivists.AddMinutes(1))
- {
- client.Player.Activists += 1;
- client.LastActivists = Time32.Now;
- }
- }
- #endregion
- }
- //1
- if (Activists.R2Name == Activists.R1Name) { Activists.R2Name = ""; Activists.R2Points = 0; Activists.SAVE(); }
- if (Activists.R3Name == Activists.R1Name) { Activists.R3Name = ""; Activists.R3Points = 0; Activists.SAVE(); }
- if (Activists.R4Name == Activists.R1Name) { Activists.R4Name = ""; Activists.R4Points = 0; Activists.SAVE(); }
- if (Activists.R5Name == Activists.R1Name) { Activists.R5Name = ""; Activists.R5Points = 0; Activists.SAVE(); }
- //2
- if (Activists.R3Name == Activists.R2Name) { Activists.R3Name = ""; Activists.R3Points = 0; Activists.SAVE(); }
- if (Activists.R4Name == Activists.R2Name) { Activists.R4Name = ""; Activists.R4Points = 0; Activists.SAVE(); }
- if (Activists.R5Name == Activists.R2Name) { Activists.R5Name = ""; Activists.R5Points = 0; Activists.SAVE(); }
- //3
- if (Activists.R4Name == Activists.R3Name) { Activists.R4Name = ""; Activists.R4Points = 0; Activists.SAVE(); }
- if (Activists.R5Name == Activists.R3Name) { Activists.R5Name = ""; Activists.R5Points = 0; Activists.SAVE(); }
- //4
- if (Activists.R5Name == Activists.R4Name) { Activists.R5Name = ""; Activists.R5Points = 0; Activists.SAVE(); }
- if (DateTime.Now.DayOfWeek == DayOfWeek.Friday && Now64.Hour == 23 && Now64.Minute == 59 && Now64.Second == 10)
- {
- #warning IMPORTANTE ACA SE RESETEA !!!
- Activists.RESTART();
- }
- #endregion
- ==================================================
- En Player/Entity.cs Agregamos :
- public uint Activists
- {
- get
- {
- return _Activists;
- }
- set
- {
- if (value <= 0)
- value = 0;
- _Activists = value;
- Database.EntityTable.UpdateActivists(this.Owner);
- }
- }
- ===================================================
- En EntityTable Agregamos :
- public static void UpdateActivists(Client.GameClient client)
- {
- UpdateData(client, "Activists", client.Player.Activists);
- }
- Busamos LoadEntity(Client y Agregamos :
- client.Player.Activists = reader.ReadUInt32("Activists");
- ====================================================
- En Npcs.cs al Final o donde quieras agregas el Npc :
- #region Activists Commander
- case 45235:
- {
- dialog.Avatar(219);
- uint myPoints = client.Player.Activists;
- string myName = client.Player.Name;
- switch (npcRequest.OptionID)
- {
- case 0:
- {
- if (DateTime.Now.DayOfWeek == DayOfWeek.Friday && !GuildWar.IsWar)
- {
- if (myName == Activists.R1Name || myName == Activists.R2Name || myName == Activists.R3Name || myName == Activists.R4Name || myName == Activists.R5Name)
- {
- dialog.Option("[HOT] Reward.", 4);
- dialog.Option("Not~now.", 255);
- dialog.Send();
- }
- else
- {
- dialog.Text("You're not from our heroes, be much active to get ranked like them");
- dialog.Option("I~will.", 255);
- dialog.Send();
- }
- }
- else
- {
- dialog.Text("Hi " + client.Player.Name + ", Commander of the activists here. I can tell you some info if you like. First tell me what you want to know.");
- dialog.Option("Who is the first five activists.", 1);
- dialog.Option("What about this event.", 2);
- dialog.Option("How can I be of 5 activists.", 3);
- dialog.Option("Check my points.", 5);
- dialog.Option("Bye.", 255);
- dialog.Send();
- }
- break;
- }
- case 1:
- {
- dialog.Text("The first five activists Is: \n[1] Is --> (" + Activists.R1Name + ") Points: " + Activists.R1Points + " ,Reward: 100,000,000 CPs\n[2] Is --> (" + Activists.R2Name + ") Points: " + Activists.R2Points + " ,Reward: 90,000,000 CPs.");
- dialog.Text("\n[3] Is --> (" + Activists.R3Name + ") Points: " + Activists.R3Points + " ,Reward: 80,000,000 CPs.\n[4] Is --> (" + Activists.R4Name + ") Points: " + Activists.R4Points + " ,Reward: 70,000,000 CPs.\n[5] Is --> (" + Activists.R5Name + ") Points: " + Activists.R5Points + " ,Reward: 60,000,000 CPs.");
- dialog.Option("Thanks", 255);
- break;
- }
- case 2:
- {
- dialog.Text("This event is Consists of 5 ranking, and each rank do choose a player owns much number of activists points.\n");
- dialog.Text("Every minute a player gets 1 activists point.\nAll players can get the prize every Friday after GuildWar.");
- dialog.Option("Thanks", 255);
- break;
- }
- case 3:
- {
- dialog.Text("You must be constantly online so you get the maximum number of points to be one of the five ranking.");
- dialog.Option("Thanks", 255);
- break;
- }
- case 5:
- {
- dialog.Text("Hi Mr " + client.Player.Name + ", All of your points is: " + client.Player.Activists + "");
- break;
- }
- case 4:
- {
- if (myName == Activists.R1Name)
- {
- dialog.Text("Hi Mr: (" + myName + ") You are rank [1] this week, Your reward is 100,000,000 CPs. Just press claim to get it.");
- dialog.Option("Claim.", 6);
- dialog.Option("Not~now.", 255);
- }
- if (myName == Activists.R2Name)
- {
- dialog.Text("Hi Mr: (" + myName + ") You are rank [2] this week, Your reward is 90,000,000 CPs. Just press claim to get it.");
- dialog.Option("Claim.", 6);
- dialog.Option("Not~now.", 255);
- }
- if (myName == Activists.R3Name)
- {
- dialog.Text("Hi Mr: (" + myName + ") You are rank [3] this week, Your reward is 80,000,000 CPs. Just press claim to get it.");
- dialog.Option("Claim.", 6);
- dialog.Option("Not~now.", 255);
- }
- if (myName == Activists.R4Name)
- {
- dialog.Text("Hi Mr: (" + myName + ") You are rank [4] this week, Your reward is 70,000,000 CPs. Just press claim to get it.");
- dialog.Option("Claim.", 6);
- dialog.Option("Not~now.", 255);
- }
- if (myName == Activists.R5Name)
- {
- dialog.Text("Hi Mr: (" + myName + ") You are rank [5] this week, Your reward is 60,000,000 CPs. Just press claim to get it.");
- dialog.Option("Claim.", 6);
- dialog.Option("Not~now.", 255);
- }
- break;
- }
- case 6:
- {
- if (myName == Activists.R1Name)
- {
- Activists.R1Name = "[Its Done.]";
- Activists.R1Points = 0;
- client.Player.ConquerPoints += 5000;
- client.Player.AddTopStatus(Update.Flags.WeeklyPKChampion, DateTime.Now.AddDays(7));
- client.Player.AddTopStatus(Update.Flags.MonthlyPKChampion, DateTime.Now.AddDays(7));
- Message.WorldMessage("Congratulations " + myName + " He received his prize from Activists Event this weak.");
- }
- if (myName == Activists.R2Name)
- {
- Activists.R2Name = "[Its Done.]";
- Activists.R2Points = 0;
- client.Player.ConquerPoints += 5000;
- Message.WorldMessage("Congratulations " + myName + " He received his prize from Activists Event this weak.");
- }
- if (myName == Activists.R3Name)
- {
- Activists.R3Name = "[Its Done.]";
- Activists.R3Points = 0;
- client.Player.ConquerPoints += 5000;
- Message.WorldMessage("Congratulations " + myName + " He received his prize from Activists Event this weak.");
- }
- if (myName == Activists.R4Name)
- {
- Activists.R4Name = "[Its Done.]";
- Activists.R4Points = 0;
- client.Player.ConquerPoints += 5000;
- Message.WorldMessage("Congratulations " + myName + " He received his prize from Activists Event this weak.");
- }
- if (myName == Activists.R5Name)
- {
- Activists.R5Name = "[Its Done.]";
- Activists.R5Points = 0;
- client.Player.ConquerPoints += 5000;
- Message.WorldMessage("Congratulations " + myName + " He received his prize from Activists Event this weak.");
- }
- break;
- }
- }
- break;
- }
- #endregion
- =========================
- En Navicat -> Console Pegas el siguiente code
- -- ----------------------------
- -- Table structure for activists
- -- ----------------------------
- DROP TABLE IF EXISTS `activists`;
- CREATE TABLE `activists` (
- `R1Name` varchar(255) NOT NULL default '',
- `R1Points` bigint(16) NOT NULL default '0',
- `R2Name` varchar(255) default NULL,
- `R2Points` bigint(16) NOT NULL default '0',
- `R3Name` varchar(255) default NULL,
- `R3Points` bigint(16) NOT NULL default '0',
- `R4Name` varchar(255) default NULL,
- `R4Points` bigint(16) NOT NULL default '0',
- `R5Name` varchar(255) default NULL,
- `R5Points` bigint(16) NOT NULL default '0',
- PRIMARY KEY (`R1Name`)
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
- En entities
- activist bigint 255
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement