Killtransfer by selling in the npc (need only little fix)

12/02/2014 20:32 Lordritter#1
Trigger

PHP Code:
USE [PS_GameData]
GO
/****** Object:  Trigger [dbo].[Killtransfer]    Script Date: 02.12.2014 19:32:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER TRIGGER 
[dbo].[Killtransfer]
on [PS_GameData].[dbo].[Chars]
for 
insert
as


DECLARE
@
ActionType tinyint,
@
AT int,
@
UserUID int,
@
ItemID int,
@
K1 int


/*    
Action_Trigger_v2.sql    RELEASE: 2014-10-13

Scripted by blabla
Made for: blabla / Elitepvpers
*/

-- ActionType114 Get Killtransfer by Selling Item to NPC
-- ActionType112 Get Killtransfer by using it
SET 
@AT 114

SET 
@ItemID = (SELECT Value2 FROM PS_GameLog.dbo.Actionlog)
SET @ActionType = (SELECT ActionType FROM PS_GameLog.dbo.Actionlog)
-- -------------------------------------------------

IF ( @
ActionType = @AT )
BEGIN
-- -----------------------------------------

-- 
Killtransfer

IF (@ItemID 100239)
BEGIN 
SET 
@UserUID = (SELECT UserUID FROM PS_GameLog.dbo.Actionlog)

UPDATE PS_GameData.dbo.Chars
SET K1 
= (SELECT top 5 K1 FROM [PS_GameData].[dbo].[Chars]
ORDER BY K1 DESC)
WHERE UserUID = @UserUID
END

-- -----------------------------------------
End 
PHP Code:
USE [PS_GameLog]
GO
/****** Object:  Trigger [dbo].[Killtransfer]    Script Date: 02.12.2014 20:35:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER TRIGGER 
[dbo].[Killtransfer]
on [PS_GameLog].[dbo].[ActionLog]
for 
insert
as


DECLARE
@
ActionType tinyint,
@
AT int,
@
UserUID int,
@
ItemID int,
@
K1 int


/*    
Action_Trigger_v2.sql    RELEASE: 2014-10-13

Scripted by blabla
Made for: blabla / Elitepvpers
*/

-- ActionType114 Get Killtransfer by Selling Item to NPC
-- ActionType112 Get Killtransfer by using it
SET 
@AT 114

SET 
@ItemID = (SELECT Value2 FROM PS_GameLog.dbo.Actionlog)
SET @ActionType = (SELECT ActionType FROM PS_GameLog.dbo.Actionlog)
-- -------------------------------------------------

IF ( @
ActionType = @AT )
BEGIN
-- -----------------------------------------

-- 
Killtransfer

IF (@ItemID 100239)
BEGIN 
SET 
@UserUID = (SELECT UserUID FROM inserted)

UPDATE PS_GameData.dbo.Chars
SET K1 
= (SELECT top 5 K1 FROM [PS_GameData].[dbo].[Chars]
ORDER BY K1 DESC)
WHERE UserUID = @UserUID
END

-- -----------------------------------------
End 
Dont know whats wrong. Its dont work. I hope anyone can help me.
12/02/2014 23:46 killer2p#2
Well have you tried just doing it like ap coin
12/03/2014 00:06 wallerus#3
You could probably rewrite it and put it into usp_Insert_Action_Log_E with all the other ActionLog code such as DP coins, seems like a better fit to me. Rewriting it to fit there would be really simple as it's just changing a couple of the lines.

Also, I think it might not work because you have to actually be logged in to sell your item to an NPC but you need to be logged out (of the char at least) to update it's kills in the database (i'm pretty certain about that).

If the last part holds true then your script would be redundant and wouldn't work, you'd sell the item, it would change the kills in the database but most likely when you logout of the char it reupdates back to the last value. I haven't actually tested it but that's what is in my head.

It would work better as a script from a website where you're not actually logged in the character/account for it.
12/03/2014 13:11 Lordritter#4
Its work guys. I found it what gave error. Change the top 5 to top 1. Its work 100%. Need only to relogg
12/03/2014 21:34 SnickQ#5
Thanks Lordritter :)
But this should be
Code:
WHERE UserUID = @UserUID and del='0' and level >31
12/05/2014 14:07 Lordritter#6
snick check my private messages pls xD
04/11/2015 18:57 Cansas59#7
can you explain the fix lordritter?what sniq means?
04/12/2015 16:46 SnickQ#8
Idk Cansas where you have problem, but i gussing you not read carefully

Code:
UPDATE PS_GameData.dbo.Chars
SET K1 = (SELECT top 1 K1 FROM [PS_GameData].[dbo].[Chars]
ORDER BY K1 DESC)
WHERE UserUID = @UserUID
04/12/2015 21:18 _Diavolino_#9
need to add again something,

-> the reset point of base
-> reset kill rank

because without these 2, same the toon at '0' kill will still get the bonification of Vet manager from rank precedent.
And in more again, the update of the rest of character. because the proper sense if i don't do mistake, is to Add the kill of all the character to 1, the seller of the special rune...
So without to update the rank K1 of each character... will be some problem i think ^^

Kind Regards,
04/13/2015 00:37 SnickQ#10
Code:
Declare @Slot1 int =(Select top 1 k1 From PS_GameData.dbo.chars where UserID =@UserrID and slot ='0')
Declare @Slot2 int =(Select top 1 k1 From PS_GameData.dbo.chars where UserID =@UserrID and slot ='1')
Declare @Slot3 int =(Select top 1 k1 From PS_GameData.dbo.chars where UserID =@UserrID and slot ='2')
Declare @Slot4 int =(Select top 1 k1 From PS_GameData.dbo.chars where UserID =@UserrID and slot ='3')
Declare @Slot5 int =(Select top 1 k1 From PS_GameData.dbo.chars where UserID =@UserrID and slot ='4')
Declare @Toon1 int =(Select top 1 CharID From PS_GameData.dbo.chars where UserID =@UserrID and slot ='0')
Declare @Toon2 int =(Select top 1 CharID From PS_GameData.dbo.chars where UserID =@UserrID and slot ='1')
Declare @Toon3 int =(Select top 1 CharID From PS_GameData.dbo.chars where UserID =@UserrID and slot ='2')
Declare @Toon4 int =(Select top 1 CharID From PS_GameData.dbo.chars where UserID =@UserrID and slot ='3')
Declare @Toon5 int =(Select top 1 CharID From PS_GameData.dbo.chars where UserID =@UserrID and slot ='4')
DECLARE @Slocik tinyint =(Select top 1 Slot from PS_gamedata.dbo.chars where CharID = @CharID)

update PS_GameData.dbo.chars
Set K1 =k1+ @Slot1
Where CharID=@CharID and Slot=@Slocik and @Slot1 IS NOT NULL

update PS_GameData.dbo.chars
Set K1 =k1+  @Slot2
Where CharID=@CharID and Slot=@Slocik and @Slot2 IS NOT NULL

update PS_GameData.dbo.chars
Set K1 =k1+  @Slot3
Where CharID=@CharID and Slot=@Slocik and @Slot3 IS NOT NULL

update PS_GameData.dbo.chars
Set K1 =k1+  @Slot4
Where CharID=@CharID and Slot=@Slocik and @Slot4 IS NOT NULL

update PS_GameData.dbo.chars
Set K1 =k1+  @Slot5
Where CharID=@CharID and Slot=@Slocik  and @Slot5 IS NOT NULL

update PS_GameData.dbo.chars
Set K1 = '0'
Where CharID=@Toon1

update PS_GameData.dbo.chars
Set K1 = '0'
Where CharID=@Toon2

update PS_GameData.dbo.chars
Set K1 = '0'
Where CharID=@Toon3

update PS_GameData.dbo.chars
Set K1 = '0'
Where CharID=@Toon4

update PS_GameData.dbo.chars
Set K1 = '0'
Where CharID=@Toon5

update PS_GameData.dbo.chars
Set K1 =k1+ @Slot1
Where CharID=@CharID and Slot=@Slocik and @Slot1 IS NOT NULL

update PS_GameData.dbo.chars
Set K1 =k1+  @Slot2
Where CharID=@CharID and Slot=@Slocik and @Slot2 IS NOT NULL

update PS_GameData.dbo.chars
Set K1 =k1+  @Slot3
Where CharID=@CharID and Slot=@Slocik and @Slot3 IS NOT NULL

update PS_GameData.dbo.chars
Set K1 =k1+  @Slot4
Where CharID=@CharID and Slot=@Slocik and @Slot4 IS NOT NULL

update PS_GameData.dbo.chars
Set K1 =k1+  @Slot5
Where CharID=@CharID and Slot=@Slocik  and @Slot5 IS NOT NULL
That should update kills with 1+1
04/17/2015 15:08 beetols#11
Quote:
Originally Posted by SnickQ View Post
That should update kills with 1+1
and what happen if there is a death character? miss

Code:
AND Del = 0
04/17/2015 17:58 SkuulCandy#12
Quote:
Originally Posted by SnickQ View Post
That should update kills with 1+1
Why update kills 1+1 ?