Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NPCS
- #region Pole Jugadores
- #region Pole
- case 999:
- {
- dialog.Text("Bienvenido a Pole Jugadores!.");
- dialog.Option("Gracias.", 255);
- dialog.Send();
- break;
- }
- #endregion
- #region Ir a la Pole Jugadores
- case 17042021:
- {
- switch (npcRequest.OptionID)
- {
- case 0:
- {
- dialog.Text("Quieres Ir a la Pole Jugadores?");
- dialog.Option("Quiero Participar!", 8);
- dialog.Option("No Adios!", 255);
- dialog.Send();
- break;
- }
- case 8:
- {
- if (PoleJugadores.IsWar)
- {
- Random R = new Random();
- int Nr = R.Next(2, 8);
- if (Nr == 2) client.Entity.Teleport(3973, 224, 112);
- if (Nr == 3) client.Entity.Teleport(3973, 226, 122);
- if (Nr == 4) client.Entity.Teleport(3973, 227, 139);
- if (Nr == 5) client.Entity.Teleport(3973, 228, 153);
- if (Nr == 6) client.Entity.Teleport(3973, 227, 162);
- if (Nr == 7) client.Entity.Teleport(3973, 229, 178);
- if (Nr == 8) client.Entity.Teleport(3973, 149, 167);
- }
- else
- {
- dialog.Text("La Pole no Esta Encendida.. Regresa mas Tarde.");
- dialog.Option("OK", 255);
- dialog.Send();
- break;
- }
- break;
- }
- }
- break;
- }
- #endregion
- #region Premio Pole Jugadores
- case 17042020:
- {
- switch (npcRequest.OptionID)
- {
- case 0:
- {
- dialog.Text("Hola Quieres Reclamar el Premio De la Pole de Jugadores? .");
- dialog.Option("Si, Soy el Ganador", 1);
- dialog.Option("No Adios!", 255);
- dialog.Send();
- break;
- }
- case 1:
- {
- if (PoleJugadores.KeeperID == client.Entity.UID)
- {
- dialog.Text("Hola, Quieres Reclamar tu Premio?");
- dialog.Option("Si.", 2);
- dialog.Option("Ah, No", 255);
- dialog.Send();
- }
- else
- {
- dialog.Text("Perdon Pero solo el Ganador Puede Reclamar.");
- dialog.Option("Ahh.", 255);
- dialog.Send();
- }
- break;
- }
- case 2:
- {
- if (!PoleJugadores.IsWar)
- {
- if (PoleJugadores.KeeperID != 0)
- {
- if (PoleJugadores.ReclamarPremioPP && client.Entity.UID == PoleJugadores.KeeperID)
- {
- PoleJugadores.ReclamarPremioPP = false;
- PoleJugadores.KeeperID = 0;
- client.Entity.ConquerPoints += 200;
- Kernel.SendWorldMessage(new Network.GamePackets.Message("RECLAMO EL PREMIO POR GANAR LA POLE JUGADORES! ARRODILLENSE ANTE EL.", System.Drawing.Color.White, Network.GamePackets.Message.Center), Program.Values);
- if (client.Entity.ContainsFlag3(Update.Flags3.rygh_hglx))
- { client.MessageBox("Ya Posees Este Grandioso Top "); return; }
- client.Entity.AddTopStatus(Update.Flags3.rygh_hglx, 3, DateTime.Now.AddHours(1));
- }
- else
- {
- dialog.Text("Perdon No Tienes Premios.");
- dialog.Option("OK.", 255);
- dialog.Send();
- break;
- }
- }
- }
- else
- {
- dialog.Text("Oye Oye " + client.Entity.Name + "No Puedes Reclamar si la Pole Aun esta Encendida");
- dialog.Option("OK", 255);
- dialog.Send();
- break;
- }
- break;
- }
- }
- break;
- }
- #endregion
- #endregion
- ================================================================
- Crear una Nueva Clase
- using Sword.Game;
- using Sword.Game.ConquerStructures.Society;
- using Sword.Network.GamePackets;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Sword
- {
- public unsafe class PoleJugadores
- {
- public static SobNpcSpawn Poles;
- public static SafeDictionary<uint, Entity> Scores = new SafeDictionary<uint, Entity>(100);
- public static bool IsWar = false, FirstRound = false;
- public static Time32 ScoreSendStamp, LastWin;
- public static Entity PoleKeeper, CurrentTopLeader;
- private static bool changed = false;
- private static string[] scoreMessages;
- public static DateTime StartTime;
- public static bool ReclamarPremioPP
- {
- get { return Program.Vars["ppclaim"]; }
- set { Program.Vars["ppclaim"] = value; }
- }
- public static uint KeeperID
- {
- get { return Program.Vars["ppkeeperid"]; }
- set { Program.Vars["ppkeeperid"] = value; }
- }
- public static void PoleJugadoresIniciacion()
- {
- var Map = Kernel.Maps[3973];
- Poles = (SobNpcSpawn)Map.Npcs[999];
- }
- public static void Start()
- {
- if (Poles == null) return;
- ReclamarPremioPP = false;
- Scores = new SafeDictionary<uint, Entity>(100);
- StartTime = DateTime.Now;
- Kernel.SendWorldMessage(new Message("Pole Jugadores Comenzo!", System.Drawing.Color.Red, Message.Center), Program.Values);
- FirstRound = true;
- foreach (Entity PlayerScore in Kernel.PlayerPool.Values)
- {
- PlayerScore.PoleJugadoresScore = 0;
- }
- IsWar = true;
- }
- public static void Reset()
- {
- Scores = new SafeDictionary<uint, Entity>(100);
- Poles.Hitpoints = Poles.MaxHitpoints;
- foreach (Entity PlayerScore in Kernel.PlayerPool.Values)
- {
- PlayerScore.PoleJugadoresScore = 0;
- }
- IsWar = true;
- }
- public static void FinishRound()
- {
- LastWin = Time32.Now;
- FirstRound = false;
- SortScores(out PoleKeeper);
- // if (PoleKeeper != null)
- {
- KeeperID = PoleKeeper.UID;
- Kernel.SendWorldMessage(new Message("El Jugador, " + PoleKeeper.Name + ", Esta Dominando La Pole De Jugadores!", System.Drawing.Color.Red, Message.Center), Program.Values);
- if (PoleKeeper.PerdidaPole == 0)
- PoleKeeper.GanadaPole++;
- else
- PoleKeeper.PerdidaPole--;
- Poles.Name = PoleKeeper.Name;
- }
- // Poles.Name = PoleKeeper.Name;
- Poles.Hitpoints = Poles.MaxHitpoints;
- Kernel.SendWorldMessage(Poles, Program.Values, (ushort)3973);
- Reset();
- }
- public static void End()
- {
- if (PoleKeeper != null)
- {
- Kernel.SendWorldMessage(new Message("El Jugador " + PoleKeeper.Name + " Gano La Pole De Jugadores!", System.Drawing.Color.White, Message.Center), Program.Values);
- }
- else
- {
- Kernel.SendWorldMessage(new Message("Pole Jugadores Termino y No Hubo Ganadores!", System.Drawing.Color.Red, Message.Center), Program.Values);
- }
- IsWar = false;
- ReclamarPremioPP = true;
- UpdatePole(Poles);
- }
- public static void AddScore(uint addScore, Entity Player)
- {
- if (Player != null)
- {
- Player.PoleJugadoresScore += addScore;
- changed = true;
- if (!Scores.ContainsKey(Player.UID))
- Scores.Add(Player.UID, Player);
- if ((int)Poles.Hitpoints <= 0)
- {
- FinishRound();
- return;
- }
- }
- }
- public static void SendScores()
- {
- if (scoreMessages == null)
- scoreMessages = new string[0];
- if (Scores.Count == 0)
- return;
- if (changed)
- SortScores(out CurrentTopLeader);
- for (int c = 0; c < scoreMessages.Length; c++)
- {
- Message msg = new Message(scoreMessages[c], System.Drawing.Color.Red,
- c == 0 ? Message.FirstRightCorner : Message.ContinueRightCorner);
- Kernel.SendWorldMessage(msg, Program.Values, (ushort)3973);
- Kernel.SendWorldMessage(msg, Program.Values, (ushort)3973);
- }
- }
- private static void SortScores(out Entity winner)
- {
- winner = null;
- List<string> ret = new List<string>();
- int Place = 0;
- foreach (Entity Player in Scores.Values.OrderByDescending((p) => p.PoleJugadoresScore))
- {
- if (Place == 0)
- winner = Player;
- string str = "No " + (Place + 1).ToString() + ": " + Player.Name + "(" + Player.PoleJugadoresScore + ")";
- ret.Add(str);
- Place++;
- if (Place == 4)
- break;
- }
- changed = false;
- scoreMessages = ret.ToArray();
- }
- private static void UpdatePole(SobNpcSpawn pole)
- {
- new Database.MySqlCommand(Sword.Database.MySqlCommandType.UPDATE)
- .Update("sobnpcs").Set("name", pole.Name).Set("life", Poles.Hitpoints).Where("id", pole.UID).Execute();
- }
- }
- }
- ===========================================================================
- En MsgNpcInfoEx o SobNpcSpawn buscamos "void Die" y Agregamos :
- if (MapID == 3973)//PoleJugadores
- {
- if (UID != 999)
- {
- if (Hitpoints != 0 || Mesh != 251 && Mesh != 281)
- {
- if (Mesh == 241)
- Mesh = (ushort)(250 + Mesh % 10);
- else
- Mesh = (ushort)(280 + Mesh % 10);
- Update upd = new Update(true);
- upd.UID = UID;
- upd.Append(Update.Mesh, Mesh);
- killer.Owner.SendScreen(upd, true);
- Hitpoints = 0;
- }
- Attack attack = new Attack(true);
- attack.Attacker = killer.UID;
- attack.Attacked = UID;
- attack.AttackType = Network.GamePackets.Attack.Kill;
- attack.X = X;
- attack.Y = Y;
- killer.Owner.Send(attack);
- killer.KOCount++;
- }
- }
- ============================================================
- En Kernel.cs Agregamos :
- public static SafeDictionary<uint, Entity> PlayerPool = new SafeDictionary<uint, Entity>(100000);//PoleJugadores
- ===========================================================
- En Program o Server.cs (EN LA PARTE DE CARGA DE LAS COSAS)
- new Game.Map(3973, 3973, Database.DMaps.MapPaths[3973]);//PoleJugadores
- ===========================================================
- En World.cs o Thread.cs (en la parte donde tengan sus eventos pk osea para ir a los eventos) Agregamos
- #region Pole Jugadores
- {
- foreach (var client in Program.Values)
- if (client.Entity.MapID == 6000 || client.Entity.MapID == 6001 || client.Entity.MapID == 6002 || client.Entity.MapID == 6003 || client.Entity.MapID == 6004)
- return;
- if (!PoleJugadores.IsWar)
- {
- if (Now64.Minute == 19 && Now64.Second == 10)
- {
- PoleJugadores.Start();
- foreach (var client in Program.Values)
- client.MessageBox("Pole Jugadores Comenzo Quieres Ir?",
- p => { p.Entity.Teleport(1002, 336, 295); }, null);
- }
- }
- if (PoleJugadores.IsWar)
- {
- if (Time32.Now > PoleJugadores.ScoreSendStamp.AddSeconds(3))
- {
- PoleJugadores.ScoreSendStamp = Time32.Now;
- PoleJugadores.SendScores();
- }
- if (Now64.Minute == 24 && Now64.Second <= 10)
- {
- Kernel.SendWorldMessage(new Network.GamePackets.Message("Faltan 5 Minutos Para que Acabe la Pole De Jugadores, Apresurate y Mata a los Noobs.", System.Drawing.Color.White, Network.GamePackets.Message.Center), Program.Values);
- }
- }
- if (PoleJugadores.IsWar)
- {
- if (Now64.Minute == 30 && Now64.Second == 10)
- {
- PoleJugadores.End();
- }
- if (Now64.Minute == 30 && Now64.Second == 15)
- {
- foreach (var client in Program.Values)
- {
- client.Entity.Teleport(1002, 300, 240);
- }
- }
- }
- }
- #endregion
- =======================================================
- Entity.cs // Player.cs
- public uint PoleJugadoresScore,PerdidaPole,GanadaPole;
- ======================================================
- Handler.cs buscamos void ReceiveAttack --> HAY 2 RECEIVE, DEBEMOS IR AL QUE TENGA SOBNPCSPAWN O MSGNPCINFOEX y Agregamos :
- VER IMAGEN : https://prnt.sc/107z8la
- if (attacker.MapID == 3973)//Pole Jugadore
- {
- if (attacked.UID == 999)
- {
- if (attacked.Hitpoints <= damage)
- attacked.Hitpoints = 0;
- PoleJugadores.AddScore(damage, attacker);
- attacker.PoleJugadoresScore += damage;
- }
- }
- Luego Buscamos bool CanAttack lo mismo que arriba la parte de sobnpcspawn o MsgNpcInfoEx
- if (attacker.MapID == 3973)//Pole Jugadores
- {
- if (!PoleJugadores.IsWar)
- {
- if (attacked.UID == 999)
- {
- return false;
- }
- }
- }
- if (attacker.MapID == 3973)//Pole Jugadores
- {
- if (!PoleJugadores.IsWar)
- {
- if (PoleJugadores.Poles != null)
- if (attacked.UID == PoleJugadores.Poles.UID)
- return false;
- }
- if (PoleJugadores.PoleKeeper != null)
- {
- }
- }
- ======================================================
- Ahora vamos a Navicat -> Nuestra Base de Datos del Server -> Buscamos y Abrimos la Tabla llamada sobnpcs
- https://prnt.sc/107zcz0 -> Ver Imagen para que sepan en que lado debe ir cada cosa.
- 999 POLEJUGADORES 10 1137 3973 138 166 16000000 16000000 0 17 1 0
- Agregamos manualmente en ORDEN ese codigo.
- =====================================================
- POSIBLES ERRORES:
- Entity -> Player
- SobNpcSpawn -> MsgNpcInfoEx
- Program.Values -> Server.Values
- Message -> MsgTalk
- Time32 -> Time64
- new Attack = new MsgInteract ((si hay mas errores de Attack, lo cambian a MsgInteract)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement