Add Item to NPC Query

12/23/2011 00:23 IceAmStiel#1
if someone needs it, use it - will faster many things up :) and you'll get punished for sloppy done work in the past.

PHP Code:
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!' 
12/30/2011 16:05 BestOnWorld#2
thanks ^^
02/28/2012 17:55 vantuto#3
THANK YOU VERY MUCH
04/15/2012 11:28 ZiCo*#4
Works perfectly in microsoft sql 2005 but not mssql 2008 r2
it give an error that it can't add null some where in refpackageitem & refscrapofpackageitem

Regards
08/20/2012 13:08 Pati1992#5
which lines i need to change ? i changed in first line to SRO_VT_SHARD_INIT ...
line 8-10 i changed for my item,price,npc... what i need change else ?
09/26/2012 17:40 mmmhhh#6
thx bro
11/23/2012 15:47 gman2233#7
yesterday i was trying to add a vehicle to the stable tab one

so i tried it i put

item ID 22720 (Unicorn)
price 5000
shop tab Shop_CH_STABLE_TAB1 or what ever it was

i execute the query runs fine no errors
i change the media files like i am told to by the query

but when i go to start my server up
all modules work except Game_server
it shows
"
Connected to Shard_manager
Connected to DB
Connected to farm
"
then i just closes
no message or anything

this really pissed me off because after working for like an hour figuring stuff out i just ended up having to restore to a clean database :mad::mad:

so i thought maybe it was because of sloppy work, so i redid all initial work on DB added user ids privileged Ip .. ETC

and backed up the data base

checked if it worked, it did Game server ran fine

then i redid the add item to just one store and i got the same problem. If anyone has any idea whats going on please help me
06/05/2014 16:35 marwanayman19#8
the price 5000 is what gold silk or coins
and if I want change the type of it I edit refpricepolicy or what
07/19/2014 03:31 asanoftw#9
n11
07/26/2014 04:05 GM Offander#10
how i can find media file witch Query edit them ?
08/01/2014 19:49 JoyGaming#11
thanks :)
08/14/2014 20:20 pompapage#12
thanks
10/18/2014 09:48 CharIes#13
Useful release :awesome:
12/16/2016 08:28 H34D_B4NG3R#14
Please delete this shit
Where is data @_RefScrapOfPackageItem ? :facepalm: