[SQL] Kill Fetch [KillEvent/Points/Survival]

03/20/2015 21:18 ​Exo#1
PHP Code:
CREATE PROCEDURE Exo_KillFetch
-- =============================================
-- 
Author:        <Exo>
-- 
Create date: <13.5.2014>
-- 
Description:    <KillFetch>
-- =============================================
  @
CharID INT, 
  @
Desc   VARCHAR(512),
  @
strPos VARCHAR(64)
AS
BEGIN SET NOCOUNT ON;
--
//---------------------------------------------------------------
  
DECLARE
        @
KillerName   VARCHAR(max),
        @
KillerID     INT,
        @
JobType      VARCHAR(max),
        @
StartPos     TINYINT
--//---------------------------------------------------------------    

  
SELECT @StartPos   = (SELECT CHARINDEX('(',@desc)) + 1
  SELECT 
@KillerName = (SELECT SUBSTRING(@Desc, @StartPos, CHARINDEX(')', @Desc, @StartPos) - @StartPos))
  
SELECT @KillerID   = (SELECT CharID FROM Fayox_Shard.._Char WHERE CharName16 = @KillerName)
--
//---------------------------------------------------------------
    
SELECT @JobType = CASE
           
WHEN   (@desc LIKE '%My: Trader%') 
               OR (@
desc LIKE '%My: Robber%')
               OR (@
desc LIKE '%My: Hunter%')
                    
THEN 'Job'
         
WHEN (@desc LIKE '%Murderer%')  
                    
THEN 'Murder'
           
ELSE 'Free'
                  
END
--//---------------------------------------------------------------
BEGIN TRANSACTION     
--ADD your event conditions here example:
--IF (@
strPos = '0x0000')
     --
BEGIN
        
-- Give silk
     
--END

  INSERT Fayox_Log
.._KillLogs VALUES (@KillerID,@CharID,@strPos,@JobType)
COMMIT TRANSACTION
END 
To run this procedure, go to your _AddLogChar SP and add this:
PHP Code:
IF (@EventID = 20)
BEGIN
EXEC Exo_KillFetch 
@CharID,@Desc,@strPos
END 
03/20/2015 21:47 Justin1337*#2
Nice brother, thanks a lot. =)
03/20/2015 21:48 zizoelnigm#3
there is some thing wrong in this Query
03/20/2015 21:49 ​Exo#4
Quote:
Originally Posted by zizoelnigm View Post
there is some thing wrong in this Query
which is?
03/20/2015 23:58 X-Vortex#5
Nice Work Keep It Up ^_^
03/21/2015 02:35 geomangy#6
I Like Your Way Of Coding.
03/21/2015 11:48 _0x0000#7
thx you :)
03/21/2015 12:15 ​Exo#8
PS: Play with the trans as you like, hint: characters killed by mobs will be added and the KillerID will be null, you can skip that, just add you condition.
03/21/2015 15:10 leader*#9
Nice Job ! ;)
03/22/2015 12:39 Syloxx#10
Code:
	IF	 @EventID = 19
	AND	(@Desc LIKE '/[My: Robber, %, no freebattle team/] /[His(%): Trader, %, no freebattle team/]' ESCAPE '/'
	OR	 @Desc LIKE '/[My: Trader, %, no freebattle team/] /[His(%): Robber, %, no freebattle team/]' ESCAPE '/'
	OR	 @Desc LIKE '/[My: Hunter, %, no freebattle team/] /[His(%): Robber, %, no freebattle team/]' ESCAPE '/'
	OR	 @Desc LIKE '/[My: Robber, %, no freebattle team/] /[His(%): Hunter, %, no freebattle team/]' ESCAPE '/')
Code:
SELECT	@KillerName = SUBSTRING(@Desc, (CHARINDEX('[His(', @Desc) +5), (CHARINDEX('): ', @Desc) - (CHARINDEX('[His(', @Desc) +5)))
i made mine like 1 or 2 years ago but its still faster then this...

feel free to use it
03/22/2015 12:49 ​Exo#11
^ Because I fetch other kills? Actually all of them, and you jut fetch the job kills.

Also you have less conditions, even if it would be faster it wouldn't be more than 10ms or smth, nothing major there.
03/22/2015 13:11 Syloxx#12
just add some more OR @Desc LIKE '' and you are ready to go
03/22/2015 13:20 ​Exo#13
Whatever...
03/24/2015 12:31 raptter#14
can u tell me how it start or where's the time to edit it i don't know how to start it :D
03/24/2015 12:49 ​Exo#15
Quote:
Originally Posted by raptter View Post
can u tell me how it start or where's the time to edit it i don't know how to start it :D
PHP Code:
IF (@EventID = 20)
BEGIN
EXEC Exo_KillFetch 
@CharID,@Desc,@strPos
END