Register for your free account! | Forgot your password?

Go Back   elitepvpers › MMORPGs › Shaiya › Shaiya Private Server › Shaiya PServer Development
You last visited: Today at 07:11

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

Advertisement



[RELEASE] UM Resurrection script - SQL version

Discussion on [RELEASE] UM Resurrection script - SQL version within the Shaiya PServer Development forum part of the Shaiya Private Server category.

Reply
 
Old   #1
 
ProfNerwosol's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 449
Received Thanks: 648
[RELEASE] UM Resurrection script - SQL version

This is my UM resurrection procedure. I believe my first version was posted here somewhere, but it's gone within the new posts.

This procedure will resurrect all dead Ultimate Mode characters on the server. It does not restore any particular character and thus is not recommender to be used by players. It is best to run it once during maintenance.

It takes into account:
- players who lost all characters,
- a player who changed faction after loosing or deleting all characters,
- no free slots,
- restores characters to guilds and corrects number of members,
- prints result table with all considered for resurrection characters and the status of the process (resurrected, no?, in guild?, etc.).

The procedure was tested by Shaiya Dev Forum members and since they didn't report any issues I assume it is fully functional. It works for me as well.

If by any chance you get any errors, post them here. I almost forgot. Read the comments when you get lost. They're here to help you.

EDITED: IMPORTANT!
Run this before you use the procedure. Abrasive suggested me to create separate table with all possible slots to speed up searching for first available one.


PROCEDURE:

Credits (people who helped me develop my work):
Abrasive, LilProHaker, EarthCrush and other Dev's on Shaiya Dev Forum whos names I don't recall SORRY GUYS! .
ProfNerwosol is offline  
Thanks
14 Users
Old   #2
 
elite*gold: 0
Join Date: Aug 2009
Posts: 13
Received Thanks: 4
I ran the Procedure and got this :
I didnt changed anything and besides i am pretty new into SQL queries and i have no idea if anything should be changed or not.
darkmanx1986 is offline  
Old   #3
 
ProfNerwosol's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 449
Received Thanks: 648
Quote:
Originally Posted by darkmanx1986 View Post
I ran the Procedure and got this :
I didnt changed anything and besides i am pretty new into SQL queries and i have no idea if anything should be changed or not.
I forgot to remove one tiny bit of code. Here's where you find it:

Code:
IF @@CURSOR_ROWS = 0
	begin
		PRINT 'No one died so far.'
		CLOSE dead_um
		DEALLOCATE dead_um		
		return [B]@ret;[/B]
	end
See the return @ret; ? Just remove @ret and it will work fine.

Seems not that many people used the procedure, if it took so much time to find a simple error. I was hoping it's going to be useful, I spent a lot of time writing it.
ProfNerwosol is offline  
Thanks
8 Users
Old   #4
 
elite*gold: 0
Join Date: Aug 2015
Posts: 1
Received Thanks: 0
This is going to sound like a stupid question, but how do you run this file? It saves as .txt with ANSI encoding.
C.v.B12 is offline  
Old   #5
 
momocruz's Avatar
 
elite*gold: 0
Join Date: Sep 2011
Posts: 390
Received Thanks: 377
I banging my head and lose my mind
momocruz is offline  
Thanks
2 Users
Old   #6
 
Trayne01's Avatar
 
elite*gold: 0
Join Date: Feb 2015
Posts: 473
Received Thanks: 1,117
Quote:
Originally Posted by JohnHeatz
So, to fix this problem you need to go to your SQL Server Management Studio, login to the database and click on the "New Query" Button:


Quote:
Originally Posted by JohnHeatz
Then you need to Copy/Paste this Query in there:
PHP Code:
USE [PS_GameData]
GO

/****** Object:  Table [dbo].[Slots]    Script Date: 01/11/2011 22:23:11 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE 
[PS_GameData].[dbo].[Slots](
    [
Slot] [tinyint] NOT NULL,
PRIMARY KEY CLUSTERED 
(
    [
Slot] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) 
ON [PRIMARY]

GO

INSERT INTO 
[PS_GameData].[dbo].[Slots] ([Slot]) VALUES (0)
INSERT INTO [PS_GameData].[dbo].[Slots] ([Slot]) VALUES (1)
INSERT INTO [PS_GameData].[dbo].[Slots] ([Slot]) VALUES (2)
INSERT INTO [PS_GameData].[dbo].[Slots] ([Slot]) VALUES (3)
INSERT INTO [PS_GameData].[dbo].[Slots] ([Slot]) VALUES (4)
GO 
Quote:
Originally Posted by JohnHeatz
Then just Click on "Execute Query" Button


And same for this:

PHP Code:
USE [PS_GameData]
GO
/****** Object:  StoredProcedure [dbo].[ausp_Restore_UM2]    Script Date: 10/11/2010 16:59:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- 
Author:        Tomasz Wiącek
-- Create date: 18.VIII.2010
-- Description:    Restores dead UM characters,
--                
which player did not delete by him/herself
-- =============================================
ALTER PROCEDURE [dbo].[ausp_Restore_UM2]

AS
BEGIN
    
-- SET NOCOUNT ON added to prevent extra result sets from
    
-- interfering with SELECT statements.
    
SET NOCOUNT ON;
    
SET ANSI_NULLS ON;

DECLARE 
dead_um CURSOR FOR 
    
SELECT UserUID,UserID,CharID,Slot,CharName,Family FROM PS_GameData.dbo.Chars WHERE Del=1 AND RemainTime=0;

/* Table to store results of running the procedure, used in PHP to list resurrected characters */
DECLARE @ResultTable TABLE (
    
UserID varchar(40), CharID int NOT NULL PRIMARY KEY CLUSTERED, CharName varchar(50) NOT NULL, 
    
Resurrected varchar(3) NOT NULL, Slot tinyint NULL, NoFreeSlots varchar(3) NULL, FactionChange varchar(3) NULL, 
    
InGuild varchar(3) NULL, GuildReturnedTo varchar(30) NULL);        

DECLARE @
UserUID int
DECLARE @UserID varchar(40)
DECLARE @
CharID int
DECLARE @Slot tinyint
DECLARE @Free_slot tinyint        -- variable to store players first available slot
DECLARE @CharName varchar(50)
DECLARE @
GuildID smallint
DECLARE @GuildName varchar(40)
DECLARE @
Family tinyint            -- used to test for race to avoid having AoL characters at UoF side - glitch in the script if player had only one UM char
DECLARE @Country tinyint

    
-- commonly used SQL queries through the script
    
DECLARE @sql_update_chars1 nvarchar(200)    -- player had only one character which was UM
    
DECLARE @sql_update_chars2 nvarchar(200)    -- used when player has more than 1 character
    
DECLARE @sql_delete nvarchar(200)            -- remove information about characters death
    
DECLARE @sql_update_guild nvarchar(200)
    DECLARE @
sql_update_count nvarchar(200)
    DECLARE @
sql_vars1 nvarchar(50)
    DECLARE @
sql_vars2 nvarchar(50)
    DECLARE @
sql_vars3 nvarchar(50)
    
    
    
SET @sql_update_chars1    = N'UPDATE PS_GameData.dbo.Chars SET Del=0, DeleteDate=NULL, Slot=0 WHERE CharID=@CharID'
    
SET @sql_update_chars2    = N'UPDATE PS_GameData.dbo.Chars SET Del=0, DeleteDate=NULL, Slot=@Free_slot WHERE CharID=@CharID'
    
SET @sql_delete            = N'DELETE FROM PS_GameData.dbo._DeletedChars WHERE CharID=@CharID'
    
SET @sql_vars1            = N'@CharID int'
    
SET @sql_vars3            = N'@Free_slot tinyint, @CharID int'
    
    
SET @sql_update_guild    = N'UPDATE PS_GameData.dbo.GuildChars SET Del=0,LeaveDate=NULL WHERE CharID=@CharID'
    
SET @sql_update_count    = N'UPDATE PS_GameData.dbo.Guilds SET TotalCount=TotalCount+1 WHERE GuildID=@GuildID'
    
SET @sql_vars2            = N'@GuildID smallint'
    

/*********
- Enough of declaring, let's do something with the data.

- Let's open the cursor and start restoring UM's
**********/

OPEN dead_um
FETCH NEXT FROM dead_um INTO
    
@UserUID,@UserID,@CharID,@Slot,@CharName,@Family

IF @@CURSOR_ROWS = 0
    begin
        
PRINT 'No one died so far.'
        
CLOSE dead_um
        DEALLOCATE dead_um        
        
return
    
end
    
WHILE @@FETCH_STATUS=0
    begin                
        
        
IF (SELECT COUNT(*) FROM PS_GameData.dbo.Chars WHERE UserUID=@UserUID AND Del=0)=0
            begin
                
                
PRINT '-------------------------------'
                
PRINT 'Every character associated to - ' + @UserID + ' - account is dead.'
                
PRINT '----------'
                
                
-- let's get that new faction and see if it's the same as the last time
                SELECT 
@Country=Country FROM PS_GameData.dbo.UserMaxGrow WHERE UserUID=@UserUID

                
IF @Country<>2
                    begin
                        
PRINT 'Player chose faction after loosing all characters. Checking whether new characters exist.'
                        
                        
IF EXISTS (SELECT * FROM PS_GameData.dbo.Chars WHERE UserUID=@UserUID AND Del=0)
                            
begin
                                
PRINT 'Player has new characters. Checking faction.'
                                
PRINT '----------'
                                
                                
IF (@Family=0 OR @Family=1) AND @Country<>0
                                    begin
                                        
PRINT 'Faction is not the same. Was Alliance of Light is Union of Fury. Character not resurrected.';
                                        
                                        
INSERT INTO @ResultTable 
                                            
(UserID, CharID, CharName, Resurrected, NoFreeSlots, FactionChange) 
                                        
VALUES
                                            
(@UserID, @CharID, @CharName, 'no', 'no', 'yes');
                                        
                                        
FETCH NEXT FROM dead_um INTO
                                            
@UserUID,@UserID,@CharID,@Slot,@CharName,@Family;
                                        
                                        CONTINUE;
                                    
end
                                
ELSE IF (@Family=2 OR @Family=3) AND @Country<>1
                                    begin
                                        
PRINT 'Faction is not the same. Was Union of Fury is Alliance of Light. Character not resurrected.';
                                        
INSERT INTO @ResultTable
                                            
(UserID, CharID, CharName, Resurrected, NoFreeSlots, FactionChange) 
                                        
VALUES
                                            
(@UserID, @CharID, @CharName, 'no', 'no', 'yes');
                                        
                                        
FETCH NEXT FROM dead_um INTO
                                            
@UserUID,@UserID,@CharID,@Slot,@CharName,@Family;
                                        
                                        CONTINUE;                                        
                                    
end                                                                
                            end
                        
ELSE
                            
begin
                                
PRINT 'No new characters detected. Proceeding with standard routine.'
                                
PRINT '----------'
                            
end                        
                    end                
                
                exec sp_executesql 
@sql_update_chars1, @sql_vars1, @CharID    -- restore UM
                exec sp_executesql 
@sql_delete, @sql_vars1, @CharID            -- remove entry about deleted UM from _DeletedChars table
                
                
                
-- Character restored to Slot 0.
                INSERT INTO 
@ResultTable 
                    
(UserID, CharID, CharName, Resurrected, Slot) 
                
VALUES
                    
(@UserID, @CharID, @CharName, 'yes', 0);
                
                    -- 
verify whether character belonged to guild
                SELECT 
@GuildID = GC.GuildID, @GuildName = G.GuildName 
                FROM PS_GameData
.dbo.GuildChars AS GC INNER JOIN PS_GameData.dbo.Guilds AS G
                ON GC
.GuildID = G.GuildID
                WHERE GC
.CharID=@CharID AND GC.LeaveDate IS NULL AND GC.Del=1
                
                
IF (@GuildID <> 0 AND @GuildID IS NOT NULL)
                    
begin
                        exec sp_executesql 
@sql_update_guild, @sql_vars1, @CharID
                        exec sp_executesql 
@sql_update_count, @sql_vars2, @GuildID                                                                                                                        
                        
-- Character restored to guild.
                        
UPDATE @ResultTable SET InGuild='yes',GuildReturnedTo=@GuildName WHERE CharID=@CharID
                    end
                
ELSE
                    
begin                        
                        
-- Character was not in guild.
                        
UPDATE @ResultTable SET InGuild='no' WHERE CharID=@CharID
                    end                            
            end
            
/* Do nothing when player has no available slots. */
        
ELSE IF (SELECT COUNT(Slot) FROM PS_GameData.dbo.Chars WHERE UserUID=@UserUID AND Del=0)=5
            begin
                
                
-- No free slots to restore character.
                
INSERT INTO @ResultTable 
                    
(UserID, CharID, CharName, Resurrected, NoFreeSlots) 
                
VALUES
                    
(@UserID, @CharID, @CharName, 'no', 'yes');
                
                
FETCH NEXT FROM dead_um INTO
                    
@UserUID,@UserID,@CharID,@Slot,@CharName,@Family                                                                                                        
                
CONTINUE;
            
end
            
/* Run when player has free slots and at least one character remaining on the account */
        
ELSE    
            
begin                
                SET 
@Free_Slot = (SELECT MIN(Slots.Slot) FROM
                         
(SELECT Slot FROM PS_GameData.dbo.Slots) AS Slots
                         LEFT JOIN
                         
(SELECT C.Slot
                         FROM PS_userdata
.dbo.Users_Master AS UM
                         INNER JOIN PS_GameData
.dbo.Chars AS C ON C.UserUID = UM.UserUID
                         WHERE UM
.UserUID = @UserUID
                         
AND C.Del = 0) AS Chars ON Chars.Slot = Slots.Slot
                         WHERE Chars
.Slot IS NULL);
                
                
exec sp_executesql @sql_update_chars2, @sql_vars3, @Free_slot, @CharID    -- restore UM
                exec sp_executesql 
@sql_delete, @sql_vars1, @CharID                        -- remove entry about deleted UM from _DeletedChars table
                
                
-- Character restored.
                
INSERT INTO @ResultTable 
                    
(UserID, CharID, CharName, Resurrected, Slot) 
                
VALUES
                    
(@UserID, @CharID, @CharName, 'yes', @Free_Slot);                
                
                    -- 
verify whether character belonged to guild 
                    
-- aquire guild ID the character belonged to
                SELECT 
@GuildID = GC.GuildID, @GuildName = G.GuildName 
                FROM PS_GameData
.dbo.GuildChars AS GC INNER JOIN PS_GameData.dbo.Guilds AS G
                ON GC
.GuildID = G.GuildID
                WHERE GC
.CharID=@CharID AND GC.LeaveDate IS NULL AND GC.Del=1
                
                
IF (@GuildID <> 0 AND @GuildID IS NOT NULL)
                    
begin
                        exec sp_executesql 
@sql_update_guild, @sql_vars1, @CharID
                        exec sp_executesql 
@sql_update_count, @sql_vars2, @GuildID                                                                                                                        
                        
-- Character restored to guild.
                        
UPDATE @ResultTable SET InGuild='yes',GuildReturnedTo=@GuildName WHERE CharID=@CharID
                    end
                
ELSE
                    
begin                        
                        
-- Character was not in guild.
                        
UPDATE @ResultTable SET InGuild='no' WHERE CharID=@CharID
                    end
            end
        
        FETCH NEXT FROM dead_um INTO
            
@UserUID,@UserID,@CharID,@Slot,@CharName,@Family        
    end

CLOSE dead_um
DEALLOCATE dead_um

SELECT UserID
, CharID, CharName, Resurrected, Slot, NoFreeSlots, FactionChange, InGuild, GuildReturnedTo FROM @ResultTable

END 
Trayne01 is offline  
Thanks
2 Users
Old   #7
 
momocruz's Avatar
 
elite*gold: 0
Join Date: Sep 2011
Posts: 390
Received Thanks: 377
Trayne

Why you don't let " Pseudo DEV " use search Button to learn by himself , they are to many private server online and many newbee DEV open server , for me only 6 server deserve to be online

-Sanctuary Shaiya
-Official Shaiya Exile pserver
-Shaiya Invasion
-Spectral Shaiya
-Masacre Official
-Shaiya Legacy

This is only Real DEV i see and work good , and don't need help to have server

I hope Juuf TEAM going to do something amazing here

But helping people don't know how to open server on Local with ZERO bug it's loosing time to Upgrade yours servers

Let this people learn alone , using BRAIN.exe and making error to upgrade knowledge by himself


Sorry for you to read this but i think i'm not alone to think that
momocruz is offline  
Thanks
2 Users
Old   #8
 
Trayne01's Avatar
 
elite*gold: 0
Join Date: Feb 2015
Posts: 473
Received Thanks: 1,117
Simply because 4 years ago, I asked the same stupid question, and someone helped me, and now I'm in the team which you quoted.. but i hope that next time he will search by him self, thats the best way to learn.

And yes I agree with you, some servers should not exist... ephemeral server are destroying our community
Trayne01 is offline  
Thanks
4 Users
Old   #9
 
elite*gold: 0
Join Date: Jul 2017
Posts: 12
Received Thanks: 0
Quote:
Msg 208, Level 16, State 6, Procedure ausp_Restore_UM2, Line 226
Invalid object name 'dbo.ausp_Restore_UM2'.
I have error while executing those sql queries.
meroy2147 is offline  
Reply


Similar Threads Similar Threads
[RELEASE] Safe Toon Resurrection (SQL)
10/23/2017 - Shaiya PServer Guides & Releases - 9 Replies
Following in Prof recent footsteps of releasing useful scripts, here is one for safely resurrecting a single toon to a location in which a second death wont occur upon logging the toon. USE DECLARE @User varchar(12), @Char varchar(30), @Slot tinyint, @Country tinyint, @Family tinyint,
Tantra ResurrecTioN On
07/15/2010 - Foreign Games - 0 Replies
Rates : ResuExp : 300x ResuGold : 40x ResuPoints : 30x Pag Y Reg : tresu.sytes.net tresu.sytes.net/sec/registro
[Release]EasyMetin2(Lonely) DE Version Released!!!(Levelbot) NEUE VERSION
04/10/2010 - Metin2 Hacks, Bots, Cheats, Exploits & Macros - 12 Replies
poly was here
Looking for script/program for skill resurrection
08/09/2008 - Silkroad Online - 0 Replies
Im looking for script/program who can say me how many cruset hearts and gold i need to turn my.. like lvl 90 FF mastery turn to 0 lvl -_- or maybe there is some number i can count it ? i know that by cruset hearts i get only 80% invested SP, and i know how to count it (lol its easy), but how about gold ? how much gold i need to get lvl 90 mastery full skilled to 0 ? And im writing about skill resurrection quest not IM item to skill resurrection



All times are GMT +2. The time now is 07:11.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.