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!

Add Item to NPC

Junior Spellweaver
Joined
Sep 13, 2011
Messages
100
Reaction score
110
Well, here is the query, just fill out the Data you need.
You can add the same by my small n00b program :)
There is an example inside so you will know how it works.

Program(client side):
Hean - Add Item to NPC - RaGEZONE Forums






MSSQL Query:
PHP:
USE SRO_VT_SHARD_INIT
GO
DECLARE @ID int
DECLARE @CodeName varchar(129)
DECLARE @DescSTRID varchar(129)
DECLARE @File varchar(129)
DECLARE @Price int
DECLARE @Slot tinyint
DECLARE @TAB varchar(129)
DECLARE @Data int
--- Set Variables
SET @ID = 84037
SET @CodeName = 'ITEM_ETC_ARCHEMY_MAGICSTONE_STR_08'
SET @DescSTRID = 'SN_ITEM_ETC_ARCHEMY_MAGICSTONE_STR_TT_DESC'
SET @File = 'item\etc\archemy_magicstone_str.ddj'
SET @Price = 9000000
SET @Slot = 11
SET @TAB = 'STORE_KT_ACCESSORY_TAB3'
SET @Data = 0

SET IDENTITY_INSERT _RefPackageItem ON

INSERT _RefPackageItem 
(
[Service],
Country,
ID,
CodeName128,
SaleTag,
ExpandTerm,
NameStrID,
DescStrID,
AssocFileIcon,
Param1,
Param1_Desc128,
Param2,
Param2_Desc128,
Param3,
Param3_Desc128,
Param4,
Param4_Desc128) 

VALUES 
( 1, 15, @ID,'PACKAGE_' + @CodeName, 0, 'EXPAND_TERM_ALL', 'SN_' + @CodeName, @DescSTRID, @File, -1, 'xxx', -1, 'xxx', -1, 'xxx', -1, 'xxx')
SET IDENTITY_INSERT _RefPackageItem OFF
INSERT _RefScrapOfPackageItem 
(
Service,
Country,
RefPackageItemCodeName,
RefItemCodeName,
OptLevel,
Variance,
Data,
MagParamNum,
MagParam1,
MagParam2,
MagParam3,
MagParam4,
MagParam5,
MagParam6,
MagParam7,
MagParam8,
MagParam9,
MagParam10,
MagParam11,
MagParam12,
Param1,
Param1_Desc128,
Param2,
Param2_Desc128,
Param3,
Param3_Desc128,
Param4,
Param4_Desc128
) 

VALUES 
(1, 15, 'PACKAGE_' + @CodeName, @CodeName, 0, 0,	@Data,	0,	0,	0,	0,	0,	0,	0,	0,	0,	0,	0,	0,	0,	-1,	'xxx',	-1,	'xxx',	-1,	'xxx',	-1,	'xxx' )

INSERT _RefPricePolicyOfItem 
(
Service,
Country,
RefPackageItemCodeName,
PaymentDevice,
PreviousCost,
Cost,
Param1,
Param1_Desc128,
Param2,
Param2_Desc128,
Param3,
Param3_Desc128,
Param4,
Param4_Desc128
) 

VALUES 
(1,	15,	'PACKAGE_' + @CodeName,	1,	0,	@Price,	-1,	'xxx',	-1,	'xxx',	-1,	'xxx',	-1,	'xxx')

INSERT _RefShopGoods
(
Service,
Country,
RefTabCodeName,
RefPackageItemCodeName,
SlotIndex,
Param1,
Param1_Desc128,
Param2,
Param2_Desc128,
Param3,
Param3_Desc128,
Param4,
Param4_Desc128
) 

VALUES 
(1,	15,	@TAB,'PACKAGE_' + @CodeName, @Slot,	-1,	'xxx',	-1,	'xxx',	-1,	'xxx',	-1,	'xxx')
 
Experienced Elementalist
Joined
Sep 27, 2011
Messages
285
Reaction score
229
Re: [Release] Add Item to NPC

You cud add a retrieval for every Table if the item exists there already - otherwise it'll cause error - furthermore you can shorten those 8 variables to 3 in total actually :)

And please change the 'SRO_VT_SHARD_INIT' into 'SRO_VT_SHARD' that's the common name for the DB.

Anyway nice work ^^
 
Skilled Illusionist
Joined
Dec 3, 2011
Messages
318
Reaction score
23
Re: [Release] Add Item to NPC

Wow great job. Do you think this will work with adding white wolf to npc?
 
Junior Spellweaver
Joined
Sep 13, 2011
Messages
100
Reaction score
110
Re: [Release] Add Item to NPC

You cud add a retrieval for every Table if the item exists there already - otherwise it'll cause error - furthermore you can shorten those 8 variables to 3 in total actually :)

And please change the 'SRO_VT_SHARD_INIT' into 'SRO_VT_SHARD' that's the common name for the DB.

Anyway nice work ^^

I'm still a n00b with mssql and don't messed that much with the syntax now. but feel free to edit it :p
 
Newbie Spellweaver
Joined
Jun 17, 2008
Messages
88
Reaction score
21
Re: [Release] Add Item to NPC

Truly nice job Hean
 
Junior Spellweaver
Joined
Sep 13, 2011
Messages
100
Reaction score
110
Re: [Release] Add Item to NPC

Wow great job. Do you think this will work with adding white wolf to npc?

Yeah but at this point you only need to add Refprice and Refshop txt and table :) Because refscrap/package are already definied.
 
Newbie Spellweaver
Joined
Nov 22, 2011
Messages
18
Reaction score
0
Re: [Release] Add Item to NPC

Hean;
Y'know the table editing skill moobs and drop?
 
Experienced Elementalist
Joined
Nov 14, 2011
Messages
260
Reaction score
54
Re: [Release] Add Item to NPC

thxx :)
 
Initiate Mage
Joined
Dec 21, 2011
Messages
4
Reaction score
0
Re: [Release] Add Item to NPC

very nice i was working on something like that but with web application you have to make some validations first (check the item exists and enabled .. calculate the slot automatically ..) but really nice effort thank you
 
Initiate Mage
Joined
Dec 19, 2011
Messages
1
Reaction score
0
Re: [Release] Add Item to NPC

Works fine, but only for the first item.
If i want to add a new item after i closed mssql i got this strange errors:

Meldung 2627, Ebene 14, Status 1, Zeile 21
Violation of PRIMARY KEY constraint 'PK__RefPackageItem'. Cannot insert duplicate key in object 'dbo._RefPackageItem'.
The statement has been terminated.

(1 Zeile(n) betroffen)
Meldung 2627, Ebene 14, Status 1, Zeile 79
Violation of PRIMARY KEY constraint 'PK__RefPricePolicyOfItem'. Cannot insert duplicate key in object 'dbo._RefPricePolicyOfItem'.
The statement has been terminated.

Meldung 2627, Ebene 14, Status 1, Zeile 100
Violation of PRIMARY KEY constraint 'PK__RefShopGoods_renewal'. Cannot insert duplicate key in object 'dbo._RefShopGoods'.
The statement has been terminated.


Any solutions?


edit
omg forgot to count id up -.- :D
 
Last edited:
Junior Spellweaver
Joined
Sep 13, 2011
Messages
100
Reaction score
110
Re: [Release] Add Item to NPC

Works fine, but only for the first item.
If i want to add a new item after i closed mssql i got this strange errors:

Meldung 2627, Ebene 14, Status 1, Zeile 21
Violation of PRIMARY KEY constraint 'PK__RefPackageItem'. Cannot insert duplicate key in object 'dbo._RefPackageItem'.
The statement has been terminated.

(1 Zeile(n) betroffen)
Meldung 2627, Ebene 14, Status 1, Zeile 79
Violation of PRIMARY KEY constraint 'PK__RefPricePolicyOfItem'. Cannot insert duplicate key in object 'dbo._RefPricePolicyOfItem'.
The statement has been terminated.

Meldung 2627, Ebene 14, Status 1, Zeile 100
Violation of PRIMARY KEY constraint 'PK__RefShopGoods_renewal'. Cannot insert duplicate key in object 'dbo._RefShopGoods'.
The statement has been terminated.


Any solutions?


edit
omg forgot to count id up -.- :D

Also check if that item exist bevore. Maybe if someone knows mssql more then me smthing like
if (CodeName128 = exist) execute code

or something like that.
 
Experienced Elementalist
Joined
Sep 27, 2011
Messages
285
Reaction score
229
Re: [Release] Add Item to NPC

PHP:
USE SRO_VT_SHARD /* ITEMS TO NPC FOR GOLD by Caipi */
Declare @ItemID int
Declare @yourPrice int
Declare @WhichTAB varchar(74)



SET @ItemID = 23							/* The Item ID of the Item you want to add to the NPC*/ --## <--
SET @yourPrice = 5000						/* The price per Unit */ --## <--
SET @WhichTAB = 'STORE_CH_POTION_TAB1'		/* To which Tab at which NPC you want to add the Item*/



/* Codename instead of the ID */ 
Declare @CodeName varchar (74) SET @CodeName = (SELECT CodeName128 FROM _RefObjCommon WHERE ID = @ItemID)

/* Which Itemdata.txt is affected in the Media.pk2*/
Declare @newItemID varchar(5)
Declare @lastPrice varchar(25) SET @lastPrice = (SELECT Price FROM _RefObjCommon WHERE ID = @ItemID)
Declare @yourPriceCHAR varchar(25) SET @yourPriceCHAR = @yourPrice
IF (@ItemID < 5000) SET @newItemID = 5000
else if (@ItemID < 10000) SET @newItemID = 10000
else if (@ItemID < 15000) SET @newItemID = 15000
else if (@ItemID < 20000) SET @newItemID = 20000
else if (@ItemID < 25000) SET @newItemID = 25000
else if (@ItemID < 30000) SET @newItemID = 30000
else if (@ItemID < 35000) SET @newItemID = 35000
else if (@ItemID < 40000) SET @newItemID = 40000
else SET @newItemID = 45000
print ''
print @CodeName + ' from Media\server_dep\silkroad\textdata\itemdata_'+@newItemID+'.txt'
print 'Change the current Price of '+@lastPrice+' to '+@yourPriceCHAR+' at the itemdata_'+@newItemID+'. (For the visual Price ingame)'
/*END which Itemdata.txr*/

/*for _RefObjCommon Price*/
UPDATE _RefObjCommon SET Price = @yourPrice WHERE ID = @ItemID

/* for _RefPackageItem */
IF EXISTS (SELECT CodeName128 FROM _RefPackageItem WHERE CodeName128 = 'Package_'+@CodeName)
	BEGIN
		print 'Already added @ RefPackageItem/.txt!'
	END
ELSE BEGIN
Declare @SN varchar(74) SET @SN = (SELECT NameStrID128 FROM _RefObjCommon WHERE ID = @ItemID)
Declare @DESC varchar(74) SET @Desc = (SELECT DescStrID128 FROM _RefObjCommon WHERE ID = @ItemID)
Declare @DDJ varchar(74) SET @DDJ = (SELECT AssocFileIcon128 FROM _RefObjCommon WHERE ID = @ItemID)
INSERT INTO _RefPackageItem (Service,Country,CodeName128,SaleTag,ExpandTerm,NameStrID,DescStrID,AssocFileIcon,Param1,Param1_Desc128,Param2,Param2_Desc128,Param3,Param3_Desc128,Param4,Param4_Desc128) 
VALUES (1,15,'PACKAGE_'+@CodeName,0,'EXPAND_TERM_ALL',@SN,@Desc,@DDJ,-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx')
Declare @TOPID varchar (10) SET @TOPID = (SELECT MAX(ID) FROM _RefPackageItem)
print ''
print 'Add the following line @ refpackageitem.txt'
print '1	15	'+@TOPID+'	PACKAGE_'+@CodeName+'	0	EXPAND_TERM_ALL	'+@SN+'	'+@DESC+'	'+@DDJ+'	-1	xxx	-1	xxx	-1	xxx	-1	xxx'
print ''
END

/* for _RefPricePolicyOfItem */
IF EXISTS (SELECT RefPackageItemCodeName FROM _RefPricePolicyOfItem WHERE RefPackageItemCodeName = 'Package_'+@CodeName AND PaymentDevice = 1 AND Cost = @yourPrice)
	BEGIN
		print 'Already added @ RefPricePolicyOfItem/.txt!'
	END
ELSE BEGIN
INSERT INTO _RefPricePolicyOfItem (Service,Country,RefPackageItemCodeName,PaymentDevice,PreviousCost,Cost,Param1,Param1_Desc128,Param2,Param2_Desc128,Param3,Param3_Desc128,Param4,Param4_Desc128)
VALUES (1,15,'PACKAGE_'+@CodeName,1,0,@yourPrice,-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx')
Declare @NEWPRICE varchar(15) SET @NEWPRICE = @yourPrice
print ''
print 'Add the following line @ refpricepolicyofitem.txt'
print '1	15	PACKAGE_'+@CodeName+'	1	0	'+@NEWPRICE+'	-1	xxx	-1	xxx	-1	xxx	-1	xxx'
print ''
END

/* for _RefShopGoods */
IF EXISTS (SELECT RefPackageItemCodeName FROM _RefShopGoods WHERE RefPackageItemCodeName = 'Package_'+@CodeName AND RefTabCodeName = @WhichTAB)
	BEGIN
		print 'Already added @ RefShopGoods/.txt!'
	END
ELSE BEGIN
Declare @newSLOTINDEX varchar(15) SET @newSLOTINDEX = (SELECT MAX(SlotIndex) FROM _RefShopGoods WHERE RefTabCodeName = @WhichTAB)+1
INSERT INTO _RefShopGoods (Service,Country,RefTabCodeName,RefPackageItemCodeName,SlotIndex,Param1,Param1_Desc128,Param2,Param2_Desc128,Param3,Param3_Desc128,Param4,Param4_Desc128)
VALUES (1,15,@WhichTAB,'PACKAGE_'+@CodeName,@newSLOTINDEX,-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx')
print ''
print 'Add the following line @ refshopgoods.txt'
print '1	15	'+@WhichTAB+'	'+'PACKAGE_'+@CodeName+'	'+@newSLOTINDEX+'	-1	xxx	-1	xxx	-1	xxx	-1	xxx'
print ''
END

/* for _RefScrapOfPackageItem */
IF EXISTS (SELECT RefPackageItemCodeName FROM _RefScrapOfPackageItem WHERE RefPackageItemCodeName = 'Package_'+@CodeName AND RefItemCodeName = @CodeName)
	BEGIN
		print 'Already added @ RefScrapOfPackageItem/.txt!'
	END
ELSE BEGIN
INSERT INTO _RefScrapOfPackageItem (Service,Country,RefPackageItemCodeName,RefItemCodeName,OptLevel,Variance,Data,MagParamNum,MagParam1,MagParam2,MagParam3,MagParam4,MagParam5,MagParam6,MagParam7,MagParam8,MagParam9,MagParam10,MagParam11,MagParam12,Param1,Param1_Desc128,Param2,Param2_Desc128,Param3,Param3_Desc128,Param4,Param4_Desc128)
VALUES (1,15,'PACKAGE_'+@CodeName,@CodeName,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx')
Declare @ScrapIndex varchar(15)
SET @ScrapIndex = (SELECT MAX([Index]) FROM _RefScrapOfPackageItem WHERE RefItemCodeName = @CodeName)
print ''
print 'Add the following line @ refscrapofpackageitem.txt'
print '1	15	'+'PACKAGE_'+@CodeName+'	'+@CodeName+'	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	-1	xxx	-1	xxx	-1	xxx	-1	xxx	'+@ScrapIndex
print ''
END
print ''
print ''
print 'Done!'
 
Back
Top