[Euphoria Dev Team Release] Level-up Stone

11/12/2013 18:30 nubness#1
Hello everyone,

As someone seemed interested in a level-up rune/stone in [Only registered and activated users can see links. Click Here To Register...], I decided to do more than just give a simple reply, and make a whole release out of it.

The Level-up rune will be based on the game logs, which will record whenever someone consumes the item.

Here's a table which I decided to bring as an example.

UserIDUserUIDCharIDCharNameActionTypeValue2Text1Text2
ciochris19Turbo112100001Etain Potionuse_item

ActionType = 112 stands for an item disappearing from the inventory, it's Text2 property telling us how exactly the item disappeared, in our case being use_item, which makes you understand that the item was consumed. As you might have already guessed, this log occurred when I consumed an Etain Potion.

I don't know for which reason, but this gets recorded in the logs only if the consumed item is of Type = 100, which means your Level-Up rune must have Type = 100.

Another thing to notice is that the level of a character is a property stored in the server's memory while the account is online, so no matter what you do in the database, the character's level doesn't change as long as it is online.

First of all, we need to create a table which will store the logs for the LevelUp runes.

Code:
USE [PS_GameLog]
GO

/****** Object:  Table [dbo].[LevelUpRuneLog]    Script Date: 11/12/2013 19:23:59 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[LevelUpRuneLog](
	[RowID] [int] IDENTITY(1,1) NOT NULL,
	[UserUID] [int] NOT NULL,
	[CharID] [int] NOT NULL,
	[Done] [bit] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[RowID] 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
Next thing to do is make the usp_Insert_Action_Log_E procedure insert the information in our newly created table. For that, you need to paste the following code snippet in the usp_Insert_Action_Log_E procedure.

Code:
IF @ActionType = 112 AND @Text2 = 'use_item' AND @Value2 = 100001
BEGIN
	
	INSERT INTO LevelUpRuneLog VALUES (@UserUID, @CharID, 0)
	
END
The last thing to do is add another block of code to the PS_UserData.dbo.usp_Try_GameLogout_R procedure, which is triggered when the account is logged off.

Code:
DECLARE @CharID INT

WHILE (SELECT COUNT(UserUID) FROM PS_GameLog.dbo.LevelUpRuneLog WHERE UserUID = @UserUID AND Done = 0) > 0
BEGIN
	
	SET @CharID = (SELECT TOP 1 CharID FROM PS_GameLog.dbo.LevelUpRuneLog WHERE UserUID = @UserUID AND Done = 0)
	
	UPDATE PS_GameData.dbo.Chars
	SET Level += 1
	WHERE CharID = @CharID
	
	UPDATE PS_GameLog.dbo.LevelUpRuneLog
	SET Done = 1
	WHERE CharID = @CharID
	
END
That's pretty much it. You can of course customize it if you want it to do more stuff, that's all up to you.

Enjoy !
11/13/2013 07:54 nic0y0525#2
will it work in League of shaiya?

<-- i'm just a noob..sorry for this question
11/13/2013 09:08 erickreq#3
thanks for collection
11/13/2013 14:08 andr3y_you96#4
Quote:
Originally Posted by nic0y0525 View Post
will it work in League of shaiya?

<-- i'm just a noob..sorry for this question
If the adm add this on his server yes it will work
11/15/2013 07:13 elliuspluss#5
to paste into the table PS_UserData.dbo.usp_Try_GameLogout_R produces the following error:
Quote:
Mens 137, Level 15, State 1, Procedure usp_Try_GameLogout_R, Line 75
Must declare the scalar variable "@ CharID".
Mens 102, Level 15, State 1, Procedure usp_Try_GameLogout_R, Line 78
Incorrect syntax near '+'.
Mens 137, Level 15, State 2, Procedure usp_Try_GameLogout_R, Line 83
Must declare the scalar variable "@ CharID".
where am I wrong?
11/15/2013 09:15 nubness#6
I was hoping for you to at least read the error text and try to understand it.

Add
Code:
DECLARE @CharID INT
before the WHILE loop in usp_Try_GameLogout_R.

And also, for fuck's sake, read the errors, they state it too damn clearly that you had to declare a variable named @CharID, having the INT datatype, because that's what a CharID is in the Chars table.

P.S. SQL Server 2005 is gay, that's the reason for your 2nd error still occurring.
11/15/2013 13:11 Lordblubb#7
It wont works for me. I Use SQL 2008 R2 and when i use the Etain potion, and relog (out of game and log in again) Then i look in the dbo.LevelUpRuneLog and then it say me As Done = False, but in the SQL Querys on top of you (nubness) it says when Done = 0 its not be successed and when Done = 1 it works with +1 lvl... But when i want to delete the "False" and write "1" or "0" it cant be accepted from SQL..

Can you help me? Forgot i anything? pls help...
11/15/2013 14:23 andr3y_you96#8
you can change the table here
Code:
[Done] [bit] NOT NULL,
to this
Code:
[Done] [int] NOT NULL,
11/15/2013 15:13 nubness#9
The value of the bit field is either 0 or 1. The text representations are False for 0 and True for 1, what's so complicated about this ?
11/15/2013 17:54 sominus#10
This is a little off topic here:
How many of these additions to usp_Insert_Action_Log_E (plus all the needed tables for each), you think we could add, before it start to produce some Load on the server? I mean, a server with ppl heavily farming all day and producing huge Logs. (I've tried blocking the 'mob damage' logs but since they're useful to quickly find GRB Reset, I've enabled them again).
11/15/2013 19:02 nubness#11
Any dedicated server will handle the load no matter how many of these IFs you have. Take my advice, use ELSE statements as well.
As an example, if you do like I used to do by filtering all the important logs in separate tables for faster processing in the future:
Code:
IF @ActionType = 103
BEGIN
-- some bullshit here
END
IF @ActionType = 104
BEGIN
-- some other bullshit here
END
IF @ActionType = 107
BEGIN
-- some other bullshit here
END
IF @ActionType = 108
BEGIN
-- some other bullshit here
END
Code:
IF @ActionType = 103
BEGIN
-- some bullshit here
END
ELSE IF @ActionType = 104
BEGIN
-- some other bullshit here
END
ELSE IF @ActionType = 107
BEGIN
-- some other bullshit here
END
ELSE IF @ActionType = 108
BEGIN
-- some other bullshit here
END
The second part, the one containing ELSE statements, will save resources because if the first IF statement returns true, the ELSE statements will be skipped, whereas in the first one, even if the first IF statement returns true, it will still run through the next ones.

Again, modern hosts can support such load without much trouble. Still, personally, if I see a chance to reduce CPU usage even by 0.001%, I won't hesitate to do that, assuming it doesn't cut off performance of course.
11/15/2013 19:14 Lordblubb#12
Okay 0 =False and 1=True, but why it dont work, when i drunk ingame the Etain Potion, relog and iam not lvl 2? Ive made all what you tell us whith the scripts.. it wont work..

Help me pls
11/15/2013 19:35 nubness#13
Re-read the tutorial and check your database to see if it matches.
03/15/2014 05:47 GM.Triest#14
P.S
To prevent someone from going a higher level than your server is set to, put this somewhere in usp_Try_GameLogout_R


I'll now stop spamming old threads QQ
04/08/2014 09:50 Lordblubb#15
Thanks GM.Triest.
But another way to make the Level-Up-Stone more attractiv and prevent that anyone is leveling over the Max. Level cap is to change it in dbo.ups.TryGameLogout_R the old script to this

DECLARE @CharID INT

WHILE (SELECT COUNT(UserUID) FROM PS_GameLog.dbo.LevelUpRuneLog WHERE UserUID = @UserUID AND Done = 0) > 0
BEGIN

SET @CharID = (SELECT TOP 1 CharID FROM PS_GameLog.dbo.LevelUpRuneLog WHERE UserUID = @UserUID AND Done = 0)

UPDATE PS_GameData.dbo.Chars
SET Level = 90
WHERE CharID = @CharID

UPDATE PS_GameLog.dbo.LevelUpRuneLog
SET Done = 1
WHERE CharID = @CharID

END



*Aswell now you level to level 90 when you use this Level-UP-Stone, which prevent of getting higher as allowed. Everytime u use the Stone you will set up to 90, and not from 1 to 2. I think its much better! But, Nubness, Thanks For your Nice idea with the Level-Up-Stone! Your a Shaiya-Dev-God i think!!!

;)