• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Tibia crafting table with points cost

Cornex

Web Developer
Staff member
Global Moderator
Joined
Jun 15, 2008
Messages
3,444
Solutions
6
Reaction score
1,169
Location
Sweden
Hello there.

I want to release my crafting table script.
Tested in 0.4

Do not post your own version of this script here. (Respect)

Well, with this table you put 2 right items to craft another one. When you craft an item it will cost you an amount of premium points! You can add how many more ingredients you want..

I will give you guys 100% noob friendly tutorial.

First of all,

Go to your ot folder and open data/actions/scripts and create new file called crafting.lua and paste this inside :

LUA:
local items = {
	{ingredient1 = 2466, ingredient2 = 2470, itemreward = 2471 , name = "Golden Helmet" , points = 50}, 
	{ingredient1 = 2453, ingredient2 = 2472, itemreward = 2646 , name = "Golden Boots" , points = 25}, 
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
        local pos = {x = 979, y = 1461, z = 4}	
 
    	for i = 1, #items do
		local items = items[i]
		      if getTileItemById(pos, items.ingredient1).uid > 0 and getTileItemById(pos, items.ingredient2).uid > 0 and getPremiumPoints(cid,items.points) > items.points then
			  if doRemoveItem(getTileItemById(pos, items.ingredient1).uid,1) and doRemoveItem(getTileItemById(pos, items.ingredient2).uid,1) and getPremiumPoints(cid,items.points) > items.points  then
			  if item.itemid == 1945 then
				doTransformItem(item.uid, 1946)
				elseif item.itemid == 1946 then
				doTransformItem(item.uid, 1945)
			end
		local first, second, third = getItemInfo(items.ingredient1), getItemInfo(items.ingredient2)
				doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You have successfully crafted "..first.article.." "..first.name.." and"..second.article.." "..second.name.." for a "..items.name..", the work cost you "..items.points.." points. ")
	            db.executeQuery('UPDATE accounts SET premium_points=premium_points-'..items.points..' WHERE id=' .. getPlayerAccountId(cid))
				doPlayerAddItem(cid, items.itemreward)
				return true
			end
		    end
	        end  
           	    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You dont have the right items or enought of points to craft! ")
   	           return true
end
 
function getPremiumPoints(cid)
local res = db.getResult('select `premium_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
if(res:getID() == -1) then
return 0
end
local ret = res:getDataInt("premium_points")
res:free()
return tonumber(ret)
end


After that go to data/actions/actions.xml and paste this row :

LUA:
<action uniqueid="65416" event="script" value="crafttable.lua"/>

Configuration is simple:

ingredient1 = The Id of item you need
ingredient2 = The id of second item you need
itemreward = The id of item you will get
name = "Golden Helmet" -- the name of "Itemreward"
points = 50 the amount of points it will cost to craft


Go to RME and make like

E-irNf.png


And put the unique id in lever like this :

in7Q8P.png


And the local pos in first script :

LUA:
local pos = {x = 979, y = 1461, z = 4}

Put your destination of the right bench, there you will put the items.

Any buggs / feedback just comment. Also feel free to repp =)

E-ALBS.png

c7ULkQ.png

8EWKP.png
 
Last edited:
It's interesing o.0
But could be more funny if it worked as in Minecraft - 9 fields and need to put items in right place.
 
Thanks for taking time writing the noob guide! :) And also as always thx for sharing godiskungen <3
 
better way, u can put more ingrendiens

LUA:
local items = {
	{ingredients = {2466, 2470}, itemreward = 2471, points = 50},
	
}
function getPremiumPoints(cid)
local res = db.getResult('select `premium_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
if(res:getID() == -1) then
return 0
end
local ret = res:getDataInt("premium_points")
res:free()
return tonumber(ret)
end


function onUse(cid, item, fromPosition, itemEx, toPosition)
 
local pos = {x = 979, y = 1461, z = 4}	
local status = 0
    	for i = 1, #items do
		local items = items[i]
			for g = 1, #items.ingredients do
				if getTileItemById(pos, items.ingredients[g]).uid > 0 then 
					status = status + 1
				else
					return doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You dont have the right items.")
				end
			end
			if status >= #items.ingredients then
				for j = 1, #items.ingredients do
					doRemoveItem(getTileItemById(pos, items.ingredients[j]).uid,1)
				end
				if getPremiumPoints(cid,items.points) > items.points then
					if item.itemid == 1945 then
						doTransformItem(item.uid, 1946)
					elseif item.itemid == 1946 then
						doTransformItem(item.uid, 1945)
					end
					doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You have successfully crafted items for a ".. getItemNameById(items.itemreward) ..", the work cost you "..items.points.." points. ")
					db.executeQuery('UPDATE accounts SET premium_points=premium_points-'..items.points..' WHERE id=' .. getPlayerAccountId(cid))
					doPlayerAddItem(cid, items.itemreward)
					return true
				end
			end
		end  
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You dont have the right items or enought of points to craft! ")
		return true
		end
 
better way, u can put more ingrendiens

how to make count support to store items like this: "ingredients = {{xxxx, 5}, {xxxx, 3}}" ?
what should insert instead of 0 here?:
LUA:
			for g = 1, #items.ingredients do
				if getTileItemById(pos, items.ingredients[g]).uid > 0 then
 
Back
Top