Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Fix multiple vault bug

Newbie Spellweaver
Joined
Aug 15, 2006
Messages
20
Reaction score
0
While testing the server files (996x 8-15 release)..
found vault bug when typing /keep <negative number> (ex. /keep -999).

With this, all can have more than the number of vault
(ex. WareHouseNum = 3) u specified in gamserver.ini .

Say, for WareHouseNum=3..
Players can select vault 0 to 3 but cant access vault 4 up.
Unfortunately, players can access vault -1 to -999 above if they type
/keep -1 to /keep -999 above which in turn creating huge number
of vaults for each account.

I cross examined the extra warehouse procedures and come up with
a simple fix below (correct me if I'm wrong or got better idea):

Just edit the following Stored Procedures like so:

For WHS_SELECT:
Code:
CREATE       proc WHS_SELECT 
@op int,
@Accountid varchar(10)
as
set nocount on
declare @aid varchar(10)
 ,@cknum int
if @op=1 begin --读取ID,检查仓库是否存在
 SELECT @aid=AccountID,@cknum=NeedExtCK FROM warehouse WHERE AccountID=@accountid
 if @cknum is null begin  --打开主仓库
  INSERT INTO warehouse (AccountID, Items, Money, EndUseDate, DbVersion) 
   VALUES (@accountid,cast(REPLICATE(char(0xff),1200) as varbinary(1200))
    ,0, getdate(), 1)
  Select @accountid AS AccountID
 end else begin
  Update warehouse Set ExtCKNum=NeedExtCK WHERE AccountID=@accountid
  if  @cknum[COLOR=red]<[/COLOR]=0
   Select @aid AS AccountID
  else begin
   if not EXISTS (select AccountID FROM ExtWareHouse WHERE AccountID=@accountid and Number=@cknum) begin
    INSERT INTO ExtWarehouse (AccountID,Number,Items, Money, EndUseDate, DbVersion) 
     VALUES (@accountid,@cknum,cast(REPLICATE(char(0xff),1200) as varbinary(1200))
      ,0, getdate(), 1)
   end
   Select @accountid AS AccountID
  end
 end
end else if @op=2 begin
 SELECT @cknum=ExtCKNum FROM warehouse WHERE AccountID=@accountid
        if @cknum[COLOR=red]<[/COLOR]=0 begin
  SELECT Items from warehouse where AccountID=@accountid
       end
 else begin
  SELECT Items from ExtWareHouse WHERE AccountID=@Accountid AND Number=@cknum
             end
end else begin
 SELECT @cknum=ExtCKNum FROM warehouse WHERE AccountID=@accountid
 if @cknum[COLOR=red]<[/COLOR]=0
  SELECT Money, DbVersion, pw from warehouse where AccountID=@accountid
 else
  SELECT Money, DbVersion, pw from ExtWareHouse where AccountID=@accountid AND Number=@cknum
end
set nocount off
GO

For WHS_UPD_Items:
Code:
CREATE    proc WHS_UPD_Items 
@items varchar(2500),
@Accountid varchar(10)
as
set nocount on
declare @cknum int
SELECT @cknum=ExtCKNum FROM warehouse WHERE AccountID=@accountid
if @cknum[COLOR=red]<[/COLOR]=0 --主仓库
 UPDATE warehouse set Items=cast(@items as varbinary(1200))
   where AccountID=@accountid
else
 UPDATE ExtWareHouse set Items=cast(@items as varbinary(1200))
  where AccountID=@accountid AND Number=@cknum
--waitfor delay '00:00:10'
set nocount off
GO

For WHS_UPD_MnyPwDbv:
Code:
CREATE      proc WHS_UPD_MnyPwDbv
@mny int,
@pw int,
@dbv int,
@Accountid varchar(10)
as
set nocount on
declare @cknum int
SELECT @cknum=ExtCKNum FROM warehouse WHERE AccountID=@accountid
if @cknum[COLOR=red]<[/COLOR]=0 begin --主仓库
 if @pw=0
  UPDATE warehouse set Money=@mny,pw=@pw,DbVersion=@dbv
    where AccountID=@accountid
 else
  UPDATE warehouse set Money=@mny,pw=@pw,lastpw=@pw,DbVersion=@dbv
    where AccountID=@accountid
 UPDATE ExtWareHouse set pw=@pw where AccountID=@accountid
end else begin
 UPDATE ExtWareHouse set Money=@mny,pw=@pw,DbVersion=@dbv
  where AccountID=@accountid AND Number=@cknum
 UPDATE ExtWareHouse set pw=@pw where AccountID=@accountid
 if @pw=0
  UPDATE WareHouse set pw=@pw where AccountID=@accountid
 else
  UPDATE WareHouse set pw=@pw,lastpw=@pw where AccountID=@accountid
end
--waitfor delay '00:00:10'
set nocount off
GO

For WHS_UPD_Money:

Code:
CREATE    proc WHS_UPD_Money
@mny int,
@Accountid varchar(10)
as
set nocount on
declare @cknum int
SELECT @cknum=ExtCKNum FROM warehouse WHERE AccountID=@accountid
if @cknum[COLOR=red]<[/COLOR]=0 --主仓库
 UPDATE warehouse set Money=@mny
   where AccountID=@accountid
else
 UPDATE ExtWareHouse set Money=@mny
  where AccountID=@accountid AND Number=@cknum
--waitfor delay '00:00:10'
set nocount off
GO

What the changes do?
Whenever a player tries to type /keep <negative number>..
He will be redirected to vault 0 (normal vault).

NOTE: If u have better FIX please post here.

I hope this helps. :)
 
Last edited:
Newbie Spellweaver
Joined
Jul 14, 2005
Messages
19
Reaction score
3
thanks m8, good work. :clap_1: i guess im not a good tester cuz i didn't noticed that :hang:
 
Newbie Spellweaver
Joined
Jan 5, 2006
Messages
62
Reaction score
0
hi good work.
I didn't tryed that.
but there is a simple change.
Let me tell how these new vaults work. in the procedures.

WHS_UPD_Money This don't work. You can delete it because its not executed.
WHS_UPD_MnyPwDbv this change the money, pass of vault and version of vault. and its only executed when you close the vault.
WHS_UPD_Items this save the items. so when you close the vault it executes this to save the items.
WHS_SELECT this is executed when you Open the vault. it says the Items, money, pass and version.

And final. You only need to change this procedure to fix the bug.
WHS_SELECT_UP
this is executed when you type /keep
So if you change the info when it start you correct all the bug.

ALTER proc WHS_SELECT_UP
@num int,
@Name varchar(10)
as
set nocount on
declare @aid varchar(10)
declare @cknum int
If @num>0 begin
SELECT @aid=AccountID FROM Character WHERE Name=@Name
SELECT @cknum=NeedExtCK FROM warehouse WHERE AccountID=@aid
if @cknum is null begin -- Opens Vault
INSERT INTO warehouse (AccountID, Items, Money, EndUseDate, DbVersion)
VALUES (@aid,cast(REPLICATE(char(0xff),1200) as varbinary(1200))
,0, getdate(), 2)
end
Update warehouse Set NeedExtCK=@num WHERE AccountID=@aid
Select @num AS NeedExtCK
end

I hope it help.
 
Initiate Mage
Joined
Oct 17, 2005
Messages
4
Reaction score
0
I did all that , and now nobody can open the vault 0, that was the main one, I have had to return to put like was because with those fix baul 0 cannot be opened, that I can do? thanks
 
Newbie Spellweaver
Joined
Jan 5, 2006
Messages
62
Reaction score
0
I did all that , and now nobody can open the vault 0, that was the main one, I have had to return to put like was because with those fix baul 0 cannot be opened, that I can do? thanks

yeah you are right. ^^

just put it like this

ALTER proc WHS_SELECT_UP
@num int,
@Name varchar(10)
as
set nocount on
declare @aid varchar(10)
declare @cknum int
If @num>=0 begin

SELECT @aid=AccountID FROM Character WHERE Name=@Name
SELECT @cknum=NeedExtCK FROM warehouse WHERE AccountID=@aid
if @cknum is null begin -- Opens Vault
INSERT INTO warehouse (AccountID, Items, Money, EndUseDate, DbVersion)
VALUES (@aid,cast(REPLICATE(char(0xff),1200) as varbinary(1200))
,0, getdate(), 2)
end
Update warehouse Set NeedExtCK=@num WHERE AccountID=@aid
Select @num AS NeedExtCK
end

Put it > or =
because 0 is not included in >

thx for noticed that =)
 
Newbie Spellweaver
Joined
Aug 15, 2006
Messages
20
Reaction score
0
Hi mig :)

Nice fix but if u want flexibility & more option, my fix comes in handy when combine with urs..

If u change the following:

In ur fix change @num>=0 to @num>=1 ..
In my fix change @cknum<=0 to @cknum<=1 ..

The result will be, if u type /keep 1 = normal vault (not /keep 0), /keep 2 = 2nd vault.
This makes it easier for the players to understand which vault they are into (minimize confusion).
And of course, WareHouseNum = 2 in gameserver.ini would now mean TOTAL VAULTS and
not just ADDITIONAL/EXTRA VAULTS.
If u have existing 'Number' values (ex. Number=1) in extwarehouse table,
just update the value to +1 (ex. Number=1 will now be Number=2 since 1 is reserved for ur normal vault)

:smile:

EDIT:
Or u can just ignore the WHS_SELECT_UP fix and
just apply my fix + mod so that /keep 0 will still redirect u to ur normal vault.
 
Last edited:
Newbie Spellweaver
Joined
Jan 5, 2006
Messages
62
Reaction score
0
Hi mig :)

Nice fix but if u want flexibility & more option, my fix comes in handy when combine with urs..

If u change the following:

In ur fix change @num>=0 to @num>=1 ..
In my fix change @cknum<=0 to @cknum<=1 ..

The result will be, if u type /keep 1 = normal vault (not /keep 0), /keep 2 = 2nd vault.
This makes it easier for the players to understand which vault they are into (minimize confusion).
And of course, WareHouseNum = 2 in gameserver.ini would now mean TOTAL VAULTS and
not just ADDITIONAL/EXTRA VAULTS.
If u have existing 'Number' values (ex. Number=1) in extwarehouse table,
just update the value to +1 (ex. Number=1 will now be Number=2 since 1 is reserved for ur normal vault)

:smile:

EDIT:
Or u can just ignore the WHS_SELECT_UP fix and
just apply my fix + mod so that /keep 0 will still redirect u to ur normal vault.

There is much ways to edit this. and configure what ever you like.
The way you are saying maybe you come to have some problems. the new players in the server. if they open the vault before they type /keep any. the result will be.
They will store in vault 0. them they type /keep 1. and it will open a new vault. so items in 0 will be lost.

For me i prefere to set /keep 0 to the normal vault. them 4 adictional vaults.
So they actualy have 5 vaults.
Them they type /keep 5. and OMG guild vault. ^^

Like i say you can do everything with these scripts.
 
Newbie Spellweaver
Joined
Aug 15, 2006
Messages
20
Reaction score
0
The way you are saying maybe you come to have some problems. the new players in the server. if they open the vault before they type /keep any. the result will be.
They will store in vault 0. them they type /keep 1. and it will open a new vault. so items in 0 will be lost.

Hehe i dont know about u mate, but it's obvious in the script that scenario
wont happen, and to confirm it i tested in all possible ways but what u said
never happened.

Anyways, thanks for comment. :)
 
Newbie Spellweaver
Joined
Aug 15, 2006
Messages
20
Reaction score
0
Yes that's why i never said edit only WHS_SELECT_UP

Nice fix but if u want flexibility & more option, my fix comes in handy when combine with urs..

If u change the following:

In ur fix change @num>=0 to @num>=1 ..
In my fix change @cknum<=0 to @cknum<=1 ..

Just want to make that clear :)
Well, enough said, ur fix is cool but i just post my own in case someone
ever need to modify the way i did.

Cya.
 
Back
Top