[Release] Fix OwnerCharID in _CharCOS

09/04/2014 16:39 Syloxx#1
The column OwnerCharID in _CharCOS is only used for Transport & Ride Pets.
All other pets use OwnerCharID = 0
This Stored Procedure will solve the problem for you.

Info: If you put the pet into the Storage OwnerCharID will stay, if u want to fix that write your own Query for this

PHP Code:
USE SRO_VT_SHARD
GO

ALTER PROCEDURE 
[dbo].[_ChangeCOSState]
@
COSID                INT,
@
State                INT
AS
--
//////////_ChangeCOSState Fix V1.1 By Syloxx\\\\\\\\\
    
DECLARE @ItemID    INT,
            @
CharID    INT
            
    
IF @State 3
        BEGIN
            SELECT        
@ItemID IT.ID64
            FROM        _Items IT
            INNER JOIN    _RefObjCommon ROC
            ON            ROC
.ID IT.RefItemID
            WHERE        ROC
.TypeID2 2
            
AND            ROC.TypeID3 1
            
AND            IT.Data = @COSID
            
            SELECT        
@CharID CharID
            FROM        _Inventory
            WHERE        ItemID 
= @ItemID
            
            
IF EXISTS (SELECT @CharID FROM _CharCOS WHERE OwnerCharID = @CharID AND ID = @COSID)
                
BEGIN
                    UPDATE    _CharCOS
                    SET        State 
3
                    WHERE    ID 
= @COSID
                END
            
ELSE
                
BEGIN
                    UPDATE    _CharCOS
                    SET        State 
3,
                            
OwnerCharID = @CharID
                    WHERE    ID 
= @COSID
                END
        END
    
ELSE
        
BEGIN
                UPDATE    _CharCOS
                SET        State 
= @State
                WHERE    ID 
= @COSID
        END
        
    
IF @@ERROR <> OR @@ROWCOUNT =0
        BEGIN
            
RETURN -1
        END
    
    
RETURN 
Download attached file for better formatting
09/06/2014 01:53 Grav!ty™#2
helpful thx
09/09/2014 01:33 asanoftw#3
thanks.
09/16/2014 04:46 _Joe#4
thanks bro <3 :* that's really useful i had this bug on my servers long time ago and i couldn't fix it , finally you helped me .
09/16/2014 04:46 _Joe#5
thanks bro <3 :* that's really useful i had this bug on my servers long time ago and i couldn't fix it , finally you helped me .
02/27/2015 20:25 blapanda#6
-
02/27/2015 22:57 Aaron*#7
Great one syloxx ! thanks for sharing it ^^
02/27/2015 23:15 Syloxx#8
you can optimize this query by creating a custom table and insert ItemID + COS_ID into that
the gameserver send this values only to one procedure... "_AddNewCOS"
table hit on _Items every time is pretty slow...

just modify the procedure to insert the values to the custom table and on _ChangeCOSState hit the custom table instead of the _Items table
02/28/2015 02:44 Royalblade*#9
Syloxx, you've shown this to me before. But I forgot why it's useful again. Wanna fresh me up?

The ownercharid isn't ever needed by the GS. There's no point in getting it and putting it in there for self convenience is there?
02/28/2015 08:15 Syloxx#10
its just usefull if you wanna create a query / procedure which requires the CharID for a pet. I don't need it aswell but ppl asked me for it so... why not?
02/28/2015 11:46 blapanda#11
It can become handy, if you are e.g. changing the lvl system and inserting some quests unlocking further leveling process of your growth pets.
02/28/2015 17:57 bestprem#12
useful thx Syloxx
09/01/2019 09:01 sonzenbi#13
I get this error after using proc
[Only registered and activated users can see links. Click Here To Register...]
or it is a coincidence ...
09/01/2019 15:40 MeGaMaX#14
Quote:
Originally Posted by sonzenbi View Post
I get this error after using proc
[Only registered and activated users can see links. Click Here To Register...]
or it is a coincidence ...
It is not a coincidence, thats because this fix makes the gameserver think that the pet you tried to use is a trade pet. Furthermore to fix this problem, update that table with a NULL OwnerID again for every pet types, EXCEPT the trade pets.

PS: OwnerCharID was left empty on purpose by joymax because its only used for trade pets.

Note: Dont ever treat it as a fix. This will bug your server more.
09/01/2019 17:05 thebigbody#15
Quote:
Originally Posted by MeGaMaX. View Post
It is not a coincidence, thats because this fix makes the gameserver think that the pet you tried to use is a trade pet. Furthermore to fix this problem, update that table with a NULL OwnerID again for every pet types, EXCEPT the trade pets.

PS: OwnerCharID was left empty on purpose by joymax because its only used for trade pets.

Note: Dont ever treat it as a fix. This will bug your server more.
i have this same issue without making the procedure above