Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

SQL - PK and Heroes store unlimited.

Junior Spellweaver
Joined
Nov 24, 2013
Messages
178
Reaction score
28
Copy/Paste Español

Hola muchachos, la idea de este sistema es poder almacenar el PK mas alla del "99" o "-1" que esta permitido en las versiones viejas (nose si aun se presenta este problemaMatias65 - SQL - PK and Heroes store unlimited. - RaGEZONE Forums en versiones nuevas), ademas como plus le agregamos para que guarde valores en 2 columnas mas llamadas PkMensual y PkSemanal.

El sistema lo probe muy a grandes rasgos, nunca con un servidor online, en el caso de los pks no me preocupa el funcionamiento, es un 99% seguro que funcione como se espera, pero en el caso de los heroes podria llegar a variar, bueno, sin mas rodeos, les dejo los pasos a seguir.

Primero que nada, todo se realiza a traves del "Analizador de Consultas" y tienen que seleccionar la db en la cual van a correr las consultas (yo seleccione "MuOnline" porque es una db con la que pruebo estas pequeñeces)


Matias65 - SQL - PK and Heroes store unlimited. - RaGEZONE Forums



1- Crear las tablas en la base de datos:

Code:
USE MuOnline
ALTER TABLE dbo.[Character] add PkTotal int not null default 0
ALTER TABLE dbo.[Character] add PkMensual int not null default 0
ALTER TABLE dbo.[Character] add PkSemanal int not null default 0


2- Creamos el trigger:

Code:
CREATE TRIGGER [dbo].[RankingPK] ON [dbo].[Character]
FOR Update
AS
BEGIN


SET NOCOUNT ON;


-- =============================================
-- Author:   <kind>
-- Create date: <09/07/2015>
-- Description:   <Obtiene los valores de PkCount y los guarda en otras columnas>
-- =============================================


DECLARE [USER=162874]account[/USER]id varchar(10)
DECLARE [USER=833731]Rank[/USER]new int
DECLARE [USER=833731]Rank[/USER]old int
DECLARE [USER=833731]Rank[/USER]dif int
DECLARE [USER=1333344765]name[/USER] varchar(10)


SELECT [USER=833731]Rank[/USER]new = PkCount, [USER=1333344765]name[/USER] = Name, [USER=162874]account[/USER]id = AccountID FROM INSERTED
SELECT [USER=833731]Rank[/USER]old = PkCount, [USER=1333344765]name[/USER] = Name, [USER=162874]account[/USER]id = AccountID FROM DELETED
END
IF  [USER=833731]Rank[/USER]new != [USER=833731]Rank[/USER]old)
BEGIN
SET [USER=833731]Rank[/USER]dif =  [USER=833731]Rank[/USER]new - [USER=833731]Rank[/USER]old
UPDATE  Character SET PkTotal = PkTotal + [USER=833731]Rank[/USER]dif, PkSemanal = PkSemanal +  [USER=833731]Rank[/USER]dif, PkMensual = PkMensual + [USER=833731]Rank[/USER]dif WHERE Name = [USER=1333344765]name[/USER]
IF [USER=833731]Rank[/USER]new = -3
BEGIN
UPDATE character SET PkCount = 0 WHERE Name = [USER=1333344765]name[/USER]
END
IF [USER=833731]Rank[/USER]new = 100
BEGIN
UPDATE character SET PkCount = 0 WHERE Name = [USER=1333344765]name[/USER]
END
END

Solamente eso es necesario para aumentar el limite de kills almacenadas en la db, basicamente lo que hace el script es tomar los valores del PkCount ni bien se actualiza la tabla, y los agrega a las tablas creadas (PkTotal,PkMensual y PkSemanal). En el caso de que el personaje sea Heroe y tenga ya "-3" (el limite que se guarda), vuelve el valor de PkCount a 0, para poder seguir almacenando los kills de los heroes.


Para verificar que el script funciona basta con editar el PkCount de algun personaje, o entrar al juego y matar a alguien:

Code:
UPDATE Character SET PkCount = 3 WHERE Name = 'NombrePj'


Y luego la siguiente para ver si sumo o no los kills :

Code:
SELECT TOP 10 Name,PkTotal,PkSemanal,PkMensual FROM Character ORDER BY PkTotal DESC


Para mostrarlos despues en la pagina web, basta alterar todos los campos donde figure PkCount por PkTotal. Ya si quieren crear un sistema de rankings mensuales y semanales tendran que crear tareas que se ejecuten mensualmente/semanalmente borrando los valores de las tablas PkMensual y PkTotal.


Si se lo piensan llevar a otro foro, por favor respeten creditos.

CREDITOS :

kind

English :

Hello boys, the idea of this system is to store the PK beyond the "99" or "-1" that is allowed in older versions (nose if even this problem is presented in new versions), plus as a bonus we added to to save values in 2 columns and more calls PkMensual PkSemanal.

The system will probe very broadly ever with an online server, in the case of pks'm not worried about the operation, it is 99% sure that it works as expected, but in the case of the heroes could vary, well, without further ado, I leave the steps.

First of all, everything is done through the "Query Analyzer" and have to select the db which will run queries (I choose "MuOnline" because it is a db with which I try these little)

Only it is necessary to increase the limit stored in the db kills, basically what the script is taking PkCount values as soon as the table is updated, and added to the created tables (PkTotal, PkMensual and PkSemanal). In the case of the character is the hero and has already "-3" (the limit that is stored), returns the value of PkCount to 0, to continue storing the kills of heroes.





To show later on the website, simply alter all fields where PkCount by PkTotal figure. And if they want to create a system of monthly and weekly rankings will have to create jobs running monthly / weekly erasing values and PkTotal PkMensual tables.

Google Traslate.



 
Back
Top