Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Shaiya > Shaiya Private Server > Shaiya PServer Development
You last visited: Today at 22:48

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

Advertisement



[RELEASE] Usefull SQL statements - for GM's

Discussion on [RELEASE] Usefull SQL statements - for GM's 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: 644
[RELEASE] Usefull SQL statements - for GM's

This one lists all items that can drop from any particular monster. The one I post here will return MobName, ItemName, Grade, DropChance. You can add more if you want to.

To make it work type the monster name between the percent signs (red colour). It doesn't have to be the full name. Partial names will work too, i.e. '%Ruined Wolf%', '%Cryptic%':

Code:
    DECLARE @MobName varchar(60);
    
    SET @MobName = [COLOR=Red]'%%'[/COLOR];

    SELECT M.MobName, I.ItemName, MI.Grade, MI.DropRate
    FROM PS_GameDefs.dbo.Mobs AS M INNER JOIN PS_GameDefs.dbo.MobItems AS MI
    ON M.MobID = MI.MobID AND MI.Grade<>0 LEFT OUTER JOIN PS_GameDefs.dbo.Items AS I
    ON MI.Grade = I.Grade
    WHERE M.MobName LIKE @MobName
    ORDER BY I.Grade, I.ItemName;
To get more detailed results simply add the column names you want to be returned with proper alias in-front of it.



SQL Version of Deleting Player


This is one heck of a statement if you ask me, but I didn't want to start another thread. This is a complete procedure to wipe existence of any player from a server. It only needs a CharName, then it goes by itself acquiring all the necessary data. Read the comments when you are lost. Post any errors if you get them.


There's a lot of recurring DELETE and (CharID IN (SELECT CharID FROM @del_chars)) statements. I didn't know how to replace the latter. I hope someone with more knowledge and experience can optimize the procedure.


List players equipped items


I created this procedure to check player's equipment, what lapis is linked and how much it adds to basic status points. I had my doubts about some people 'cheating' their way to become stronger. I think I found myself in error, anyway it is still useful if you want to allow players to use it.

What it does:
- selects all equipped items the player has,
- ignores items in inventory (for now),
- checks what lapis is linked,
- and which stats and by how much it increases,
- sums it up with basic stats and prints everything.

I couldn't come up with any use for this procedure when it turned out to be useless. Then I thought you can actually integrate it with a website and allow players to list their equipment. Might be hard on the DB side though. Still it is worth considering.

Procedure:


New Version

Version II of the above procedure. It does the same thing but is entirely different. You can integrate it with your website as the results are sent to PHP or whatever you are using. I am planing to write a PHP website which will sort all the information.

To remind beginners. It is up to you to implement it. I will not provide any assistance in doing so.

I tested the procedure and it works. It works with PHP as well. I was able to receive, switch between results and print the data. I haven't noticed any errors, but if you get one post it here. Any optimizations are welcome.


Procedure Ver.2
ProfNerwosol is offline  
Thanks
16 Users
Old 01/07/2011, 22:35   #2
 
[GM]Father's Avatar
 
elite*gold: 0
Join Date: Aug 2010
Posts: 136
Received Thanks: 343
If you changed the Set to

Code:
SET @MobName = [COLOR="Red"]'%%'[/COLOR];
and the Where to

Code:
WHERE M.MobName like @MobName
Or (with the original SET)
Code:
where MobName like '%@MobName%'
(Abrasive suggested this might work)


Will it find partial mob names?

I'm not currently at home so I couldn't test it.

I usually search for partial mob names because I can never remember the full thing, and sometimes it is hard to get the exact name, like CTI.

Also, if you can do partial names, it would make it more robust.
[GM]Father is offline  
Thanks
2 Users
Old 01/07/2011, 23:32   #3
 
ProfNerwosol's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 449
Received Thanks: 644
Didn't think of that. Added.
ProfNerwosol is offline  
Old 01/07/2011, 23:45   #4
 
Bаne's Avatar
 
elite*gold: 0
Join Date: Mar 2010
Posts: 2,334
Received Thanks: 1,777
# added to my collection of guides.^^
Bаne is offline  
Old 01/08/2011, 12:54   #5
 
ProfNerwosol's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 449
Received Thanks: 644
Added something new.
ProfNerwosol is offline  
Thanks
1 User
Old 01/09/2011, 01:27   #6
 
[GM]Father's Avatar
 
elite*gold: 0
Join Date: Aug 2010
Posts: 136
Received Thanks: 343
Quote:
Originally Posted by ProfNerwosol View Post
There's a lot of recurring DELETE and (CharID IN (SELECT CharID FROM @del_chars)) statements. I didn't know how to replace the latter. I hope someone with more knowledge and experience can optimize the procedure.
Abrasive can probably do it, he is much better at writing queries than I am. I'm only good at finding exploits

Quote:
Originally Posted by ProfNerwosol View Post
This is one heck of a statement if you ask me, but I didn't want to start another thread. This is a complete procedure to wipe existence of any player from a server. It only needs a CharName, then it goes by itself acquiring all the necessary data. Read the comments when you are lost. Post any errors if you get them.
I think it would be safer supplying the UserUID or UserID.
But, if you still what to do it based on character name, you should add a check to see if that character has not been deleted. I believe it is possible to have two characters in the database with the same name, only one of them will be active however.

I think the way it stands, it could accidently grab the UserUID of somebody that had that char name and deleted the character, then proceed to delete all his data.

I didn't see where this deleted your friend list as well as take your characters off of anybody that friended you. (This sounds really complex).

Abrasive and I were talking and thought it would be good to add a 'BEGIN TRAN'/'ROLLBACK' to this also. That way if any part had an error it wouldn't fragment the data.
[GM]Father is offline  
Thanks
1 User
Old 01/09/2011, 17:26   #7
 
ProfNerwosol's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 449
Received Thanks: 644
There would be a problem with UserID or UserUID. You don't normally know them when you are in game. However it can be easily changed and the procedure made available to players who want to delete their account. UserUID or UserID would be known then.

You might be right with the two char names in DB. I think the server doesn't include deleted chars in check for duplicate names. I'll add check for it.

EDIT:
Added TRY...CATCH to test for errors and TRANSACTION.

Deleting friend list and those chars from others friend lists was easier than I thought. CharID's of friends are stored in one table so basically you need to delete every record with your CharID and every record where your CharID appears in FriendID column.
ProfNerwosol is offline  
Old 01/10/2011, 01:34   #8
 
taurian83's Avatar
 
elite*gold: 0
Join Date: Jun 2010
Posts: 84
Received Thanks: 65
Very nice addition. Certainly makes the process much quicker, as well as easier to keep db's clean and minimal. Thank you.
taurian83 is offline  
Old 01/11/2011, 22:33   #9
 
ProfNerwosol's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 449
Received Thanks: 644
Another addition to first post.
ProfNerwosol is offline  
Thanks
1 User
Old 01/12/2011, 14:00   #10
 
elite*gold: 0
Join Date: Aug 2010
Posts: 241
Received Thanks: 254
In the Player equipments SQL I got an small error
Code:
Cursorfetch: The number of variables declared in the INTO list must match that of selected columns.
To avoid this just remove the calls to I.Itemname near cursor declaration, and also from fetch next statement. To get the itemname use the ItemID and get from items table seperatly.
zargon05 is offline  
Thanks
1 User
Old 01/12/2011, 14:34   #11
 
ProfNerwosol's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 449
Received Thanks: 644
Quote:
Originally Posted by zargon05 View Post
In the Player equipments SQL I got an small error
Code:
Cursorfetch: The number of variables declared in the INTO list must match that of selected columns.
To avoid this just remove the calls to I.Itemname near cursor declaration, and also from fetch next statement. To get the itemname use the ItemID and get from items table seperatly.
You got the error because I didn't add variable @ItemName to the FETCH inside the loop. No need to remove I.ItemName from cursor declaration. I used JOIN to limit the number of queries.
ProfNerwosol is offline  
Old 01/12/2011, 14:59   #12
 
elite*gold: 0
Join Date: Aug 2010
Posts: 241
Received Thanks: 254
Ok ty, fixed.

Here I modifiedt so instead just displaying the charitems table, It displays the entire item list in tabular form.

Code:
USE [PS_GameData]
GO
/****** Object:  StoredProcedure [dbo].[ausp_Check_PlayersEquipment]    Script Date: 06/13/2010 12:24:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Tomasz Wiacek
-- Create date: <Create Date,,>
-- Description:	Lists equipment, lapis linked, current and added status points of a given character.
-- =============================================
CREATE PROCEDURE [dbo].[ausp_Check_PlayersEquipment]
	
	@CharName varchar(50) = '',
	@CharID int = 0
AS
BEGIN
	
	SET NOCOUNT ON;

DECLARE @tempitems TABLE (
ItemName varchar(30),
Gem1 varchar(30),
Gem2 varchar(30),
Gem3 varchar(30),
Gem4 varchar(30),
Gem5 varchar(30),
Gem6 varchar(30) )
    
	-- variables to store Status Points
	-- variables without _p - characters current status points
	-- variables with _p - status points added by lapis
		DECLARE @Str smallint, @Dex smallint, @Rec smallint, @Int smallint, @Wis smallint, @Luc smallint,
				@Str_p smallint, @Dex_p smallint, @Rec_p smallint, @Int_p smallint, @Wis_p smallint, @Luc_p smallint;
	
	-- variables for sp_executesql
		DECLARE @stmt nvarchar(1000), @variables nvarchar(500)
		
	-- these variables with hold lapis name and an item it was linked to	
		DECLARE @ItemName varchar(50), 
				@GemName1 varchar(50),@GemName2 varchar(50),@GemName3 varchar(50),@GemName4 varchar(50),
				@GemName5 varchar(50),@GemName6 varchar(50);
		
	-- variables to hold lapis properties
	-- first set is TypeID selected from PS_GameData.dbo.CharItems
	-- second set (Const***) holds what lapis adds
		DECLARE @Gem1 tinyint,@Gem2 tinyint,@Gem3 tinyint,@Gem4 tinyint,@Gem5 tinyint,@Gem6 tinyint
		DECLARE @ConstStr tinyint, @ConstDex tinyint, @ConstRec tinyint, @ConstInt tinyint, @ConstWis tinyint, 
				@ConstLuc tinyint, @ConstHP tinyint, @ConstMP tinyint, @ConstSP tinyint;
			
		DECLARE @ItemID int			
	
		-- let's prepare statements for sp_executesql procedure
	SET @stmt = N'
			SELECT @GemName=ItemName, @ConstStr=ConstStr, @ConstDex=ConstDex, @ConstRec=ConstRec, @ConstInt=ConstInt, 
			@ConstWis=ConstWis, @ConstLuc=ConstLuc, @ConstHP=ConstHP, @ConstMP=ConstMP, @ConstSP=ConstSP 
			FROM PS_GameDefs.dbo.Items WHERE [Type]=30 AND TypeID=@Gem';
	SET @variables = N'
			@GemName varchar(50) output, @Gem tinyint, @ConstStr tinyint output, @ConstDex tinyint output, 
			@ConstRec tinyint output, @ConstInt tinyint output, @ConstWis tinyint output, @ConstLuc tinyint output, 
			@ConstHP tinyint output, @ConstMP tinyint output, @ConstSP tinyint output';
	
		-- and initialize variables
	SET @Str_p = 0
	SET @Dex_p = 0
	SET @Rec_p = 0
	SET @Int_p = 0
	SET @Wis_p = 0
	SET @Luc_p = 0
	
	IF @CharID = 0
		SELECT @CharID = CharID FROM dbo.Chars WHERE CharName=@CharName;
	ELSE
		SELECT @CharName = CharName FROM dbo.Chars WHERE CharID=@CharID;
	
		-- let see if the character exists and there are no typing errors
	IF @@ROWCOUNT>0
	BEGIN	
			-- setting up a cursor to process characters items (equiped)
		DECLARE item_cursor CURSOR FAST_FORWARD FOR
			SELECT CI.ItemID,CI.ItemName, CI.Gem1, CI.Gem2, CI.Gem3, CI.Gem4, CI.Gem5, CI.Gem6
			FROM dbo.CharItems AS CI INNER JOIN PS_GameDefs.dbo.Items AS I
			ON CI.ItemID = I.ItemID
			WHERE CI.CharID = @CharID AND CI.Bag=0 ORDER BY CI.slot --AND Gem1<>0 AND (Gem2<>0 or Gem3<>0 or Gem4<>0 or Gem5<>0 or Gem6<>0);

		SELECT ItemID, Gem1, Gem2, Gem3, Gem4, Gem5, Gem6
		FROM PS_GameData.dbo.CharItems WHERE CharID=@CharID AND Bag=0
	
			-- initialize cursor and fetch first row
		OPEN item_cursor;
		FETCH NEXT FROM item_cursor INTO
			@ItemID,@Gem1,@Gem2,@Gem3,@Gem4,@Gem5,@Gem6,@ItemName;
	
			-- now let's put it all together and print what items this character has
		PRINT '-----------------------------'				
		PRINT 'Items of: ' + @CharName
		
		WHILE @@FETCH_STATUS = 0
			BEGIN											
				
				PRINT ' '				
				print '----------------------------------------';
				print 'Item name: ' + @ItemName;
				print '----------------------------------------';
				
					-- if this is an old player not all slots can be taken and some lapis might have been extracted
					-- let's make sure we don't process such slots
				if @Gem1 <> 0 
					begin
						exec sp_executesql @stmt,@variables,@GemName1 output, @Gem1, @ConstStr output, 
								@ConstDex output, @ConstRec output, @ConstInt output, @ConstWis output, 
								@ConstLuc output, @ConstHP output, @ConstMP output, @ConstSP output;
						
						print 'Gem1: ' + @GemName1
				
						if @ConstStr <> 0 SET @Str_p = @Str_p + @ConstStr;
						if @ConstDex <> 0 SET @Dex_p = @Dex_p + @ConstDex;
						if @ConstRec <> 0 SET @Rec_p = @Rec_p + @ConstRec;
						if @ConstInt <> 0 SET @Int_p = @Int_p + @ConstInt;
						if @ConstWis <> 0 SET @Wis_p = @Wis_p + @ConstWis;
						if @ConstLuc <> 0 SET @Luc_p = @Luc_p + @ConstLuc;
					end
			
				else
				begin
					SET @GemName1 = ''
				end
				if @Gem2 <> 0
					begin	
						exec sp_executesql @stmt,@variables,@GemName2 output,@Gem2, @ConstStr output, 
								@ConstDex output, @ConstRec output, @ConstInt output, @ConstWis output, 
								@ConstLuc output, @ConstHP output, @ConstMP output, @ConstSP output;
						
						print 'Gem2: ' + @GemName2
						
						if @ConstStr <> 0 SET @Str_p = @Str_p + @ConstStr;
						if @ConstDex <> 0 SET @Dex_p = @Dex_p + @ConstDex;
						if @ConstRec <> 0 SET @Rec_p = @Rec_p + @ConstRec;
						if @ConstInt <> 0 SET @Int_p = @Int_p + @ConstInt;
						if @ConstWis <> 0 SET @Wis_p = @Wis_p + @ConstWis;
						if @ConstLuc <> 0 SET @Luc_p = @Luc_p + @ConstLuc;
					end
			
				else
				begin
					SET @GemName2 = ''
				end	
				if @Gem3 <> 0
					begin
						exec sp_executesql @stmt,@variables,@GemName3 output,@Gem3, @ConstStr output, 
								@ConstDex output, @ConstRec output, @ConstInt output, @ConstWis output, 
								@ConstLuc output, @ConstHP output, @ConstMP output, @ConstSP output;
						
						print 'Gem3: ' + @GemName3
						
						if @ConstStr <> 0 SET @Str_p = @Str_p + @ConstStr;
						if @ConstDex <> 0 SET @Dex_p = @Dex_p + @ConstDex;
						if @ConstRec <> 0 SET @Rec_p = @Rec_p + @ConstRec;
						if @ConstInt <> 0 SET @Int_p = @Int_p + @ConstInt;
						if @ConstWis <> 0 SET @Wis_p = @Wis_p + @ConstWis;
						if @ConstLuc <> 0 SET @Luc_p = @Luc_p + @ConstLuc;
					end
				
				else
				begin
					SET @GemName3 = ''
				end	
				if @Gem4 <> 0
					begin
						exec sp_executesql @stmt,@variables,@GemName4 output,@Gem4, @ConstStr output, 
								@ConstDex output, @ConstRec output, @ConstInt output, @ConstWis output, 
								@ConstLuc output, @ConstHP output, @ConstMP output, @ConstSP output;
						
						print 'Gem4: '+@GemName4
						
						if @ConstStr <> 0 SET @Str_p = @Str_p + @ConstStr;
						if @ConstDex <> 0 SET @Dex_p = @Dex_p + @ConstDex;
						if @ConstRec <> 0 SET @Rec_p = @Rec_p + @ConstRec;
						if @ConstInt <> 0 SET @Int_p = @Int_p + @ConstInt;
						if @ConstWis <> 0 SET @Wis_p = @Wis_p + @ConstWis;
						if @ConstLuc <> 0 SET @Luc_p = @Luc_p + @ConstLuc;
				end
				
				else
				begin
					SET @GemName4 = ''
				end	
				if @Gem5 <> 0
					begin				
						exec sp_executesql @stmt,@variables,@GemName5 output,@Gem5, @ConstStr output, 
								@ConstDex output, @ConstRec output, @ConstInt output, @ConstWis output, 
								@ConstLuc output, @ConstHP output, @ConstMP output, @ConstSP output;
						
						print 'Gem5: '+@GemName5
						
						if @ConstStr <> 0 SET @Str_p = @Str_p + @ConstStr;
						if @ConstDex <> 0 SET @Dex_p = @Dex_p + @ConstDex;
						if @ConstRec <> 0 SET @Rec_p = @Rec_p + @ConstRec;
						if @ConstInt <> 0 SET @Int_p = @Int_p + @ConstInt;
						if @ConstWis <> 0 SET @Wis_p = @Wis_p + @ConstWis;
						if @ConstLuc <> 0 SET @Luc_p = @Luc_p + @ConstLuc;
					end
			
				else
				begin
					SET @GemName5 = ''
				end	
				if @Gem6 <> 0
					begin
						exec sp_executesql @stmt,@variables,@GemName6 output,@Gem6, @ConstStr output, 
								@ConstDex output, @ConstRec output, @ConstInt output, @ConstWis output, 
								@ConstLuc output, @ConstHP output, @ConstMP output, @ConstSP output;
						
						print 'Gem6: ' + @GemName6
						
						if @ConstStr <> 0 SET @Str_p = @Str_p + @ConstStr;
						if @ConstDex <> 0 SET @Dex_p = @Dex_p + @ConstDex;
						if @ConstRec <> 0 SET @Rec_p = @Rec_p + @ConstRec;
						if @ConstInt <> 0 SET @Int_p = @Int_p + @ConstInt;
						if @ConstWis <> 0 SET @Wis_p = @Wis_p + @ConstWis;
						if @ConstLuc <> 0 SET @Luc_p = @Luc_p + @ConstLuc;
					end
				
				else
				begin
					SET @GemName6 = ''
				end
				
				INSERT INTO @tempitems (itemname,gem1,gem2,gem3,gem4,gem5,gem6)
				VALUES (@itemname,@gemname1,@gemname2,@gemname3,@gemname4,@gemname5,@gemname6)
				
					-- get new row from the cursor
				FETCH NEXT FROM item_cursor INTO
					@ItemID,@Gem1,@Gem2,@Gem3,@Gem4,@Gem5,@Gem6,@ItemName
				
			END
		
		 -- the cursor is no longer needed, time to close it and free memory
		CLOSE item_cursor
		DEALLOCATE item_cursor
		
			/* now let's see how many status points the character has */
		SELECT @Str = [Str], @Dex = Dex, @Rec = Rec, @Int = [Int], @Wis = Wis, @Luc = Luc
		FROM dbo.Chars WHERE CharName=@CharName
		
		SELECT * FROM @tempitems

		PRINT '----------------------------------------';
		PRINT 'Players status points: ';			
		PRINT 'Str: ' + cast(@Str AS char(3)) + ' (' + cast(@Str_p as char(3)) + ') = ' + cast(@Str + @Str_p as Char(4))
		PRINT 'Dex: ' + cast(@Dex AS char(3)) + ' (' + cast(@Dex_p as char(3)) + ') = ' + cast(@Dex + @Dex_p as Char(4))
		PRINT 'Rec: ' + cast(@Rec AS char(3)) + ' (' + cast(@Rec_p as char(3)) + ') = ' + cast(@Rec + @Rec_p as Char(4))
		PRINT 'Int: ' + cast(@Int AS char(3)) + ' (' + cast(@Int_p as char(3)) + ') = ' + cast(@Int + @Int_p as Char(4))
		PRINT 'Wis: ' + cast(@Wis AS char(3)) + ' (' + cast(@Wis_p as char(3)) + ') = ' + cast(@Wis + @Wis_p as Char(4))
		PRINT 'Luc: ' + cast(@Luc AS char(3)) + ' (' + cast(@Luc_p as char(3)) + ') = ' + cast(@Luc + @Luc_p as Char(4))
		PRINT '----------------------------------------';		
	END
ELSE
	BEGIN					
		PRINT 'Character ' + @CharName + ' does not exists.'
	END	

END
zargon05 is offline  
Old 01/12/2011, 18:02   #13
 
ProfNerwosol's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 449
Received Thanks: 644
How will you go about adding the players status information to the table or are you planing not to? I was thinking to do it this way but couldn't come up with any idea how to combine everything in one table.

Btw, minor bug in CURSOR declaration "CI.ItemName" should be "I.ItemName" or you'll get an error. Plus remember to add @ItemName to FETCH's. There are two of them. One is right under whole CURSOR thing and the other is at the end of WHILE loop.
ProfNerwosol is offline  
Old 01/13/2011, 00:05   #14
 
ProfNerwosol's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 449
Received Thanks: 644
*BUMP*

Added another version of equipment listing procedure.
ProfNerwosol is offline  
Old 01/13/2011, 14:13   #15
 
elite*gold: 0
Join Date: Aug 2010
Posts: 241
Received Thanks: 254
o.O sorry I posted a untested version instead of the one in my DB. I never intented to add a seperate table for stats but here is one anyway. The last row of the items table is used for stats
Code:
USE [PS_GameData]
GO
/****** Object:  StoredProcedure [dbo].[ausp_Check_PlayersEquipment]    Script Date: 01/13/2011 19:04:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Tomasz Wiacek
-- Create date: <Create Date,,>
-- Description:	Lists equipment, lapis linked, current and added status points of a given character.
-- =============================================
CREATE PROCEDURE [dbo].[ausp_Check_PlayersEquipment]
	
	@CharName varchar(50) = '',
	@CharID int = 0
AS
BEGIN
	
	SET NOCOUNT ON;

DECLARE @tempitems TABLE (
ItemName varchar(50),
Gem1 varchar(50),
Gem2 varchar(50),
Gem3 varchar(50),
Gem4 varchar(50),
Gem5 varchar(50),
Gem6 varchar(50) )
    
	-- variables to store Status Points
	-- variables without _p - characters current status points
	-- variables with _p - status points added by lapis
		DECLARE @Str smallint, @Dex smallint, @Rec smallint, @Int smallint, @Wis smallint, @Luc smallint,
				@Str_p smallint, @Dex_p smallint, @Rec_p smallint, @Int_p smallint, @Wis_p smallint, @Luc_p smallint;
	
	-- variables for sp_executesql
		DECLARE @stmt nvarchar(1000), @variables nvarchar(500)
		
	-- these variables with hold lapis name and an item it was linked to	
		DECLARE @ItemName varchar(50), 
				@GemName1 varchar(50),@GemName2 varchar(50),@GemName3 varchar(50),@GemName4 varchar(50),
				@GemName5 varchar(50),@GemName6 varchar(50);
		
	-- variables to hold lapis properties
	-- first set is TypeID selected from PS_GameData.dbo.CharItems
	-- second set (Const***) holds what lapis adds
		DECLARE @Gem1 tinyint,@Gem2 tinyint,@Gem3 tinyint,@Gem4 tinyint,@Gem5 tinyint,@Gem6 tinyint
		DECLARE @ConstStr tinyint, @ConstDex tinyint, @ConstRec tinyint, @ConstInt tinyint, @ConstWis tinyint, 
				@ConstLuc tinyint, @ConstHP tinyint, @ConstMP tinyint, @ConstSP tinyint;
			
		DECLARE @ItemID int			
	
		-- let's prepare statements for sp_executesql procedure
	SET @stmt = N'
			SELECT @GemName=ItemName, @ConstStr=ConstStr, @ConstDex=ConstDex, @ConstRec=ConstRec, @ConstInt=ConstInt, 
			@ConstWis=ConstWis, @ConstLuc=ConstLuc, @ConstHP=ConstHP, @ConstMP=ConstMP, @ConstSP=ConstSP 
			FROM PS_GameDefs.dbo.Items WHERE [Type]=30 AND TypeID=@Gem';
	SET @variables = N'
			@GemName varchar(50) output, @Gem tinyint, @ConstStr tinyint output, @ConstDex tinyint output, 
			@ConstRec tinyint output, @ConstInt tinyint output, @ConstWis tinyint output, @ConstLuc tinyint output, 
			@ConstHP tinyint output, @ConstMP tinyint output, @ConstSP tinyint output';
	
		-- and initialize variables
	SET @Str_p = 0
	SET @Dex_p = 0
	SET @Rec_p = 0
	SET @Int_p = 0
	SET @Wis_p = 0
	SET @Luc_p = 0
	
	IF @CharID = 0
		SELECT @CharID = CharID FROM dbo.Chars WHERE CharName=@CharName;
	ELSE
		SELECT @CharName = CharName FROM dbo.Chars WHERE CharID=@CharID;
	
		-- let see if the character exists and there are no typing errors
	IF @@ROWCOUNT>0
	BEGIN	
			-- setting up a cursor to process characters items (equiped)
		DECLARE item_cursor CURSOR FAST_FORWARD FOR
			SELECT CI.ItemID,I.ItemName, CI.Gem1, CI.Gem2, CI.Gem3, CI.Gem4, CI.Gem5, CI.Gem6
			FROM dbo.CharItems AS CI INNER JOIN PS_GameDefs.dbo.Items AS I
			ON CI.ItemID = I.ItemID
			WHERE CI.CharID = @CharID AND CI.Bag=0 ORDER BY CI.slot --AND Gem1<>0 AND (Gem2<>0 or Gem3<>0 or Gem4<>0 or Gem5<>0 or Gem6<>0);
	
			-- initialize cursor and fetch first row
		OPEN item_cursor;
		FETCH NEXT FROM item_cursor INTO
			@ItemID,@ItemName,@Gem1,@Gem2,@Gem3,@Gem4,@Gem5,@Gem6;
	
			-- now let's put it all together and print what items this character has
		PRINT '-----------------------------'				
		PRINT 'Items of: ' + @CharName
		
		WHILE @@FETCH_STATUS = 0
			BEGIN											
				
				--SELECT @ItemName=Itemname from PS_GameDefs.dbo.items where itemid=@itemid
				PRINT ' '
								
				print '----------------------------------------';
				print 'Item name: ' + @ItemName;
				print '----------------------------------------';
				
					-- if this is an old player not all slots can be taken and some lapis might have been extracted
					-- let's make sure we don't process such slots
				if @Gem1 <> 0 
					begin
						exec sp_executesql @stmt,@variables,@GemName1 output, @Gem1, @ConstStr output, 
								@ConstDex output, @ConstRec output, @ConstInt output, @ConstWis output, 
								@ConstLuc output, @ConstHP output, @ConstMP output, @ConstSP output;
						
						print 'Gem1: ' + @GemName1
				
						if @ConstStr <> 0 SET @Str_p = @Str_p + @ConstStr;
						if @ConstDex <> 0 SET @Dex_p = @Dex_p + @ConstDex;
						if @ConstRec <> 0 SET @Rec_p = @Rec_p + @ConstRec;
						if @ConstInt <> 0 SET @Int_p = @Int_p + @ConstInt;
						if @ConstWis <> 0 SET @Wis_p = @Wis_p + @ConstWis;
						if @ConstLuc <> 0 SET @Luc_p = @Luc_p + @ConstLuc;
					end
			
				else
				begin
					SET @GemName1 = ''
				end
				if @Gem2 <> 0
					begin	
						exec sp_executesql @stmt,@variables,@GemName2 output,@Gem2, @ConstStr output, 
								@ConstDex output, @ConstRec output, @ConstInt output, @ConstWis output, 
								@ConstLuc output, @ConstHP output, @ConstMP output, @ConstSP output;
						
						print 'Gem2: ' + @GemName2
						
						if @ConstStr <> 0 SET @Str_p = @Str_p + @ConstStr;
						if @ConstDex <> 0 SET @Dex_p = @Dex_p + @ConstDex;
						if @ConstRec <> 0 SET @Rec_p = @Rec_p + @ConstRec;
						if @ConstInt <> 0 SET @Int_p = @Int_p + @ConstInt;
						if @ConstWis <> 0 SET @Wis_p = @Wis_p + @ConstWis;
						if @ConstLuc <> 0 SET @Luc_p = @Luc_p + @ConstLuc;
					end
			
				else
				begin
					SET @GemName2 = ''
				end	
				if @Gem3 <> 0
					begin
						exec sp_executesql @stmt,@variables,@GemName3 output,@Gem3, @ConstStr output, 
								@ConstDex output, @ConstRec output, @ConstInt output, @ConstWis output, 
								@ConstLuc output, @ConstHP output, @ConstMP output, @ConstSP output;
						
						print 'Gem3: ' + @GemName3
						
						if @ConstStr <> 0 SET @Str_p = @Str_p + @ConstStr;
						if @ConstDex <> 0 SET @Dex_p = @Dex_p + @ConstDex;
						if @ConstRec <> 0 SET @Rec_p = @Rec_p + @ConstRec;
						if @ConstInt <> 0 SET @Int_p = @Int_p + @ConstInt;
						if @ConstWis <> 0 SET @Wis_p = @Wis_p + @ConstWis;
						if @ConstLuc <> 0 SET @Luc_p = @Luc_p + @ConstLuc;
					end
				
				else
				begin
					SET @GemName3 = ''
				end	
				if @Gem4 <> 0
					begin
						exec sp_executesql @stmt,@variables,@GemName4 output,@Gem4, @ConstStr output, 
								@ConstDex output, @ConstRec output, @ConstInt output, @ConstWis output, 
								@ConstLuc output, @ConstHP output, @ConstMP output, @ConstSP output;
						
						print 'Gem4: '+@GemName4
						
						if @ConstStr <> 0 SET @Str_p = @Str_p + @ConstStr;
						if @ConstDex <> 0 SET @Dex_p = @Dex_p + @ConstDex;
						if @ConstRec <> 0 SET @Rec_p = @Rec_p + @ConstRec;
						if @ConstInt <> 0 SET @Int_p = @Int_p + @ConstInt;
						if @ConstWis <> 0 SET @Wis_p = @Wis_p + @ConstWis;
						if @ConstLuc <> 0 SET @Luc_p = @Luc_p + @ConstLuc;
				end
				
				else
				begin
					SET @GemName4 = ''
				end	
				if @Gem5 <> 0
					begin				
						exec sp_executesql @stmt,@variables,@GemName5 output,@Gem5, @ConstStr output, 
								@ConstDex output, @ConstRec output, @ConstInt output, @ConstWis output, 
								@ConstLuc output, @ConstHP output, @ConstMP output, @ConstSP output;
						
						print 'Gem5: '+@GemName5
						
						if @ConstStr <> 0 SET @Str_p = @Str_p + @ConstStr;
						if @ConstDex <> 0 SET @Dex_p = @Dex_p + @ConstDex;
						if @ConstRec <> 0 SET @Rec_p = @Rec_p + @ConstRec;
						if @ConstInt <> 0 SET @Int_p = @Int_p + @ConstInt;
						if @ConstWis <> 0 SET @Wis_p = @Wis_p + @ConstWis;
						if @ConstLuc <> 0 SET @Luc_p = @Luc_p + @ConstLuc;
					end
			
				else
				begin
					SET @GemName5 = ''
				end	
				if @Gem6 <> 0
					begin
						exec sp_executesql @stmt,@variables,@GemName6 output,@Gem6, @ConstStr output, 
								@ConstDex output, @ConstRec output, @ConstInt output, @ConstWis output, 
								@ConstLuc output, @ConstHP output, @ConstMP output, @ConstSP output;
						
						print 'Gem6: ' + @GemName6
						
						if @ConstStr <> 0 SET @Str_p = @Str_p + @ConstStr;
						if @ConstDex <> 0 SET @Dex_p = @Dex_p + @ConstDex;
						if @ConstRec <> 0 SET @Rec_p = @Rec_p + @ConstRec;
						if @ConstInt <> 0 SET @Int_p = @Int_p + @ConstInt;
						if @ConstWis <> 0 SET @Wis_p = @Wis_p + @ConstWis;
						if @ConstLuc <> 0 SET @Luc_p = @Luc_p + @ConstLuc;
					end
				
				else
				begin
					SET @GemName6 = ''
				end
				INSERT INTO @tempitems (itemname,gem1,gem2,gem3,gem4,gem5,gem6)
				VALUES (@itemname,@gemname1,@gemname2,@gemname3,@gemname4,@gemname5,@gemname6)
				
					-- get new row from the cursor
				FETCH NEXT FROM item_cursor INTO
					@ItemID,@ItemName,@Gem1,@Gem2,@Gem3,@Gem4,@Gem5,@Gem6
				
			END
		
		 -- the cursor is no longer needed, time to close it and free memory
		CLOSE item_cursor
		DEALLOCATE item_cursor
		
			/* now let's see how many status points the character has */
		SELECT @Str = [Str], @Dex = Dex, @Rec = Rec, @Int = [Int], @Wis = Wis, @Luc = Luc
		FROM dbo.Chars WHERE CharName=@CharName

		INSERT INTO @tempitems (itemname,gem1,gem2,gem3,gem4,gem5,gem6)
		VALUES ('Stats',
			cast(@Str as char(4))+'+'+cast(@Str_p as char(4)),
			cast(@Dex as char(4))+'+'+cast(@Dex_p as char(4)),
			cast(@Rec as char(4))+'+'+cast(@Rec_p as char(4)),
			cast(@Int as char(4))+'+'+cast(@Int_p as char(4)),
			cast(@Wis as char(4))+'+'+cast(@Wis_p as char(4)),
			cast(@Luc as char(4))+'+'+cast(@Luc_p as char(4)))

		SELECT * FROM @tempitems

		PRINT '----------------------------------------';
		PRINT 'Players status points: ';			
		PRINT 'Str: ' + cast(@Str AS char(3)) + ' (' + cast(@Str_p as char(3)) + ') = ' + cast(@Str + @Str_p as Char(4))
		PRINT 'Dex: ' + cast(@Dex AS char(3)) + ' (' + cast(@Dex_p as char(3)) + ') = ' + cast(@Dex + @Dex_p as Char(4))
		PRINT 'Rec: ' + cast(@Rec AS char(3)) + ' (' + cast(@Rec_p as char(3)) + ') = ' + cast(@Rec + @Rec_p as Char(4))
		PRINT 'Int: ' + cast(@Int AS char(3)) + ' (' + cast(@Int_p as char(3)) + ') = ' + cast(@Int + @Int_p as Char(4))
		PRINT 'Wis: ' + cast(@Wis AS char(3)) + ' (' + cast(@Wis_p as char(3)) + ') = ' + cast(@Wis + @Wis_p as Char(4))
		PRINT 'Luc: ' + cast(@Luc AS char(3)) + ' (' + cast(@Luc_p as char(3)) + ') = ' + cast(@Luc + @Luc_p as Char(4))
		PRINT '----------------------------------------';		
	END
ELSE
	BEGIN					
		PRINT 'Character ' + @CharName + ' does not exists.'
	END	

END
zargon05 is offline  
Reply


Similar Threads Similar Threads
[Release] Some Usefull Tools
12/23/2014 - Aion Guides & Strategies - 8 Replies
Well, i see there is not much traffic going here , and anyway there aren't a lot of releases for aion.so i guess those will help you a bit. All credits go to the releasers. Make Max level 60 (34.87 KB) Multiupload.com - upload your files to multiple file hosting sites! Fixed Gatherable Templates (6.34 KB) Multiupload.com - upload your files to multiple file hosting sites!
[RELEASE] Usefull Server Scripts
03/02/2010 - EO PServer Guides & Releases - 9 Replies
Hey everyone as there isnt many admin type releases i thought id put some up to help out the newer server developers out there. here is a list of the scripts to follow: Palladin Potion Soul bug fix, Set players gear to full bonus, Bot jail a player, Open all totems, Staff ep and pp award, banned player and cheat log table' (php web page for it soon)



All times are GMT +2. The time now is 22:48.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

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