• 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!

Action Bed Modification Kits

AGS

DeathSouls Owner
Joined
Oct 29, 2007
Messages
400
Reaction score
10
Location
Mexico
As you probably know, one of the new features of Tibia 8.1 is that you can buy kits to transform your beds.

You have to use the kit on a normal bed, it doens't works on cots, straw mats and hammocks.
The bed must be empty
You must be in a house.
modification_kits.lua
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local BEDSINUSE = {1762, 1764, 7480, 7778, 7779, 7787, 7789, 7799, 7801, 7791, 7793, 7803, 7805, 7795, 7797, 7807, 7809}
local horizontalpos = {x = toPosition.x+1, y = toPosition.y, z = toPosition.z, stackpos = 1}
local horizontal = getThingfromPos(horizontalpos)
local verticalpos = {x = toPosition.x, y = toPosition.y+1, z = toPosition.z, stackpos = 1}
local vertical = getThingfromPos(verticalpos)

	if getTileHouseInfo(getPlayerPosition(cid)) ~= 0 then
		if item.itemid == 7904 then --green bed kit
			if itemEx.itemid == 1760 then
				doTransformItem(itemEx.uid, 7813)
				doTransformItem(horizontal.uid, 7814)
				doRemoveItem(item.uid,1)
			elseif itemEx.itemid == 1754 then
				doTransformItem(itemEx.uid, 7811)
				doTransformItem(vertical.uid, 7812)
				doRemoveItem(item.uid,1)
			elseif isInArray(BEDSINUSE,itemEx.itemid) == TRUE then
				doPlayerSendCancel(cid, "Somebody is sleeping there!")
			else
				doPlayerSendCancel(cid, "You can only use modification kits on empty beds.")
			end
		elseif item.itemid == 7905 then --red bed kit
			if itemEx.itemid == 1760 then
				doTransformItem(itemEx.uid, 7817)
				doTransformItem(horizontal.uid, 7818)
				doRemoveItem(item.uid,1)
			elseif itemEx.itemid == 1754 then
				doTransformItem(itemEx.uid, 7815)
				doTransformItem(vertical.uid, 7816)
				doRemoveItem(item.uid,1)
			elseif isInArray(BEDSINUSE,itemEx.itemid) == TRUE then
				doPlayerSendCancel(cid, "Somebody is sleeping there!")
			else
				doPlayerSendCancel(cid, "You can only use modification kits on empty beds.")
			end
		elseif item.itemid == 7906 then --yellow bed kit
			if itemEx.itemid == 1760 then
				doTransformItem(itemEx.uid, 7821)
				doTransformItem(horizontal.uid, 7822)
				doRemoveItem(item.uid,1)
			elseif itemEx.itemid == 1754 then
				doTransformItem(itemEx.uid, 7819)
				doTransformItem(vertical.uid, 7820)
				doRemoveItem(item.uid,1)
			elseif isInArray(BEDSINUSE,itemEx.itemid) == TRUE then
				doPlayerSendCancel(cid, "Somebody is sleeping there!")
			else
				doPlayerSendCancel(cid, "You can only use modification kits on empty beds.")
			end
		elseif item.itemid == 7907 then --remove modification
			if itemEx.itemid == 7813 or itemEx.itemid == 7817 or itemEx.itemid == 7821 then
				doTransformItem(itemEx.uid, 1760)
				doTransformItem(horizontal.uid, 1761)
				doRemoveItem(item.uid,1)
			elseif itemEx.itemid == 7811 or itemEx.itemid == 7815 or itemEx.itemid == 7819 then
				doTransformItem(itemEx.uid, 1754)
				doTransformItem(vertical.uid, 1755)
				doRemoveItem(item.uid,1)
			else
				doPlayerSendCancel(cid, "You can only use this on modified empty beds.")
			end			
		end
	else
		doPlayerSendCancel(cid, "You can only use this inside a house.")
	end
end
actions.xml
Code:
<action fromid="7904" toid="7907" script="modification_kits.lua" />

That's it, it's a simple script.

If you like it, you can thank me giving me rep:thumbup:.
 
Last edited:
The Forgotten Server has getThingFromPos... I thought every server had that function... o_O
 
i implant this script in my server and make this error:
modifications_kit:4 attempt to call global 'getThingFromPos' (a nil value)
can u pass to me the function ? :)

i downlaod the new TFS and dont have :O
 
Last edited:
I though that all servers had that function too....

YurOts, Evolutions, all the distros I've used have it...
 
All server have this function.

But not: getThingFromPos but getThingfromPos.

Also, i made there another fix.
So, try this:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local BEDSINUSE = {1762, 1764, 7480, 7778, 7779, 7787, 7789, 7799, 7801, 7791, 7793, 7803, 7805, 7795, 7797, 7807, 7809}
local horizontalpos = {x = toPosition.x+1, y = toPosition.y, z = toPosition.z}
local horizontal = getThingfromPos(horizontalpos)
local verticalpos = {x = toPosition.x, y = toPosition.y+1, z = toPosition.z}
local vertical = getThingfromPos(verticalpos)

	if getTileHouseInfo(getPlayerPosition(cid)) ~= 0 then
		if item.itemid == 7904 then --green bed kit
			if itemEx.itemid == 1760 then
				doTransformItem(itemEx.uid, 7813)
				doTransformItem(horizontal.uid, 7814)
			elseif itemEx.itemid == 1754 then
				doTransformItem(itemEx.uid, 7811)
				doTransformItem(vertical.uid, 7812)
			elseif isInArray(BEDSINUSE,itemEx.itemid) == TRUE then
				doPlayerSendCancel(cid, "Somebody is sleeping there!")
			else
				doPlayerSendCancel(cid, "You can only use modification kits on empty beds.")
			end
		elseif item.itemid == 7905 then --red bed kit
			if itemEx.itemid == 1760 then
				doTransformItem(itemEx.uid, 7817)
				doTransformItem(horizontal.uid, 7818)
			elseif itemEx.itemid == 1754 then
				doTransformItem(itemEx.uid, 7815)
				doTransformItem(vertical.uid, 7816)
			elseif isInArray(BEDSINUSE,itemEx.itemid) == TRUE then
				doPlayerSendCancel(cid, "Somebody is sleeping there!")
			else
				doPlayerSendCancel(cid, "You can only use modification kits on empty beds.")
			end
		elseif item.itemid == 7906 then --yellow bed kit
			if itemEx.itemid == 1760 then
				doTransformItem(itemEx.uid, 7821)
				doTransformItem(horizontal.uid, 7822)
			elseif itemEx.itemid == 1754 then
				doTransformItem(itemEx.uid, 7819)
				doTransformItem(vertical.uid, 7820)
			elseif isInArray(BEDSINUSE,itemEx.itemid) == TRUE then
				doPlayerSendCancel(cid, "Somebody is sleeping there!")
			else
				doPlayerSendCancel(cid, "You can only use modification kits on empty beds.")
			end
		end
	else
		doPlayerSendCancel(cid, "You can only use this inside a house.")
	end
end
 
Thanks Slawkens, I was about to post the fixed script =O!

I updated the script on first post:
-Now it works
-Added the furniture package that removes the modification
-Now the kit is removed after you use it
 
Thanks Slawkens, I was about to post the fixed script =O!

I updated the script on first post:
-Now it works
-Added the furniture package that removes the modification
-Now the kit is removed after you use it

How can I delete bed modification because slawkens script bug my beds, but your upadte scripy work fine.
 
Use the furniture package with id 7907 on the header of the bed.
 
is there any posibility to make this bed save to map? Because when server restarts bed is going to its normal id :(
 
Nice like always m8 :D! keep the good work going ;)

yours Evil Hero,
 
Nice, indeed. I was actually thinking about doing all new Tibia scripts first, but well... I'm retierd and don't know very much about the update :p

Great script, hope you come with more ^^
 
Back
Top