Jump to content
Sign in to follow this  
Sultan

Fast Gem Combiner

Recommended Posts

Special Gem Combiner

 

A lot of friends were asking me to release what I had in my server, which is a normal gem combiner like any other server "but" it takes only level 1. Few servers used to let players keep level 2+ gems in bank before combining. With this Special Gem Combiner, it will only take level 1 and combine it with ease.

 

  • First, add this to any of your NPCscript (Add rest of gems by yourself)
function FastCombinerNpc()
	Talk(1,'Hello! I am the Fast Gem Combiner. How can I help you?')
	Text(1,'Level 4 Gem Combining!', JumpPage, 2)

	Talk(2,'Special Gem Combiner: Here is list of Level 4 Gems!' )
	Text(2,'Refining Gem',FastCombiner,885,4)	-- Gem item id, level to combine
	Text(2,'Gem of Rage',FastCombiner,863,4)		-- Gem item id, level to combine
	Text(2,'Eye of Black Dragon',FastCombiner,864,4)		-- Gem item id, level to combine
end

 

  • Second, add this in your NPCsdk.lua (between lines: 2300~2500?)
elseif item.func == FastCombiner then
	return FastCombiner(character,item.p1,item.p2)

 

  • Finally, add this in your functions.lua
function FastCombiner(cha,itemid,lvl)
	local CombineLvl = {}
	CombineLvl[4] = {pieces=8,fee=100000}
	CombineLvl[5] = {pieces=16,fee=500000}
	CombineLvl[6] = {pieces=32,fee=1000000}
	
	--! Check if Bag is locked
	if(KitbagLock(cha, 0) ~= LUA_TRUE)then 
		HelpInfo(cha,0,'Your bag is locked!') 
		return
	end 
      
	--! Check has money required for gem level
	local m = HasMoney(cha,CombineLvl[lvl].fee)
	if(m == 0)then
		HelpInfo(cha,0,'You must have '..CombineLvl[lvl].fee..'G to combine!')
		return
	end
	
	--! Scan whole inventory and store gem slots location
	local bag,gemSlot,gemLv,array = GetKbCap(cha),0,0,{}
	for i = 0,bag-1 do
		gemSlot = GetChaItem(cha,2,i)
		if(GetItemID(gemSlot) == itemid)then
			gemLv = GetItemAttr(gemSlot,ITEMATTR_VAL_BaoshiLV)
			if(gemLv == 1)then
				table.insert(array,i)
			end
		end
	end
	
	--! Check if player has correct number of gems (Lv1)
	if(table.getn(array) < CombineLvl[lvl].pieces)then
		HelpInfo(cha,0,'You must have x'..CombineLvl[lvl].pieces..' of Lv1 '..GetItemName(itemid)..' to combine!')
		return
	end
	
	--! Remove gems
	local rem = 0
	for k,j in pairs(array) do
		if(rem < CombineLvl[lvl].pieces)then
			RemoveChaItem(cha,0,1,2,j,2,1)
			rem = rem + 1
		else
			break
		end
	end
	
	--! Give a message, take the money & the gem combined
	BickerNotice(cha,GetItemName(itemid)..' was successfully combined to level '..lvl..'!')
	TakeMoney(cha,0,CombineLvl[lvl].fee)
	GiveItem(cha,0,itemid,1,100+lvl)
end

 

Edited by Sultan
Fixed issues with the script
  • Like 5

Share this post


Link to post
Share on other sites

Someone do quick testing for it if you're planning to use, I have lost my original one I used in my server before (currently I'm using another way to combine gems: Vouchers). I'm sure this should work 100%, but someone test to ensure only. ;)

Share this post


Link to post
Share on other sites

Used similar one, It does not remove lv4 gems, but If you have x9 lv1 gems they will be removed and you get x1 lv4
It works with x8 lv1 gems, but if u have x9 it'll take them all.
or for example if you have x16 gems and wanna make x2 lv4 gems, it will take x9 for the 1st lv4 gem, and all you have left is x7 lv1 gems + x1 lv4 gem.
That is the issue I figured out so far.

Share this post


Link to post
Share on other sites
4 hours ago, HILO said:

Used similar one, It does not remove lv4 gems, but If you have x9 lv1 gems they will be removed and you get x1 lv4
It works with x8 lv1 gems, but if u have x9 it'll take them all.
or for example if you have x16 gems and wanna make x2 lv4 gems, it will take x9 for the 1st lv4 gem, and all you have left is x7 lv1 gems + x1 lv4 gem.
That is the issue I figured out so far.

Is this referring to the script provided by Sultan or another one?


logo-big.png   logo.png

                                   Sunny Go! Online                                                                    pko.host                                                 

Share this post


Link to post
Share on other sites

Thanks a lot for pointing it out

 

I think this should be the issue:

	--! Remove gems
	local rem = 0
	for k,j in pairs(array) do
		if(rem < CombineLvl[lvl].pieces)then	-- change "<=" to "<";
			RemoveChaItem(cha,0,1,2,j,2,1)
			rem = rem + 1
		else
			break
		end
	end

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...