Action Bed Modification Kits

AGS

DeathSouls Owner
Joined
Oct 29, 2007
Messages
400
Best answers
0
Reaction score
8
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:

manerinhu

I'm very very MaNeRiNhU
Joined
Jan 14, 2008
Messages
79
Best answers
0
Reaction score
1
Location
Behind you!
my server dont have the function:
getThingFromPos
do u know what server have ?
 

JayBeee

Retired Global Mod
Joined
Jun 2, 2007
Messages
5,225
Best answers
0
Reaction score
13
Location
Sweden
The Forgotten Server has getThingFromPos... I thought every server had that function... o_O
 

manerinhu

I'm very very MaNeRiNhU
Joined
Jan 14, 2008
Messages
79
Best answers
0
Reaction score
1
Location
Behind you!
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:
OP
AGS

AGS

DeathSouls Owner
Joined
Oct 29, 2007
Messages
400
Best answers
0
Reaction score
8
Location
Mexico
I though that all servers had that function too....

YurOts, Evolutions, all the distros I've used have it...
 

JayBeee

Retired Global Mod
Joined
Jun 2, 2007
Messages
5,225
Best answers
0
Reaction score
13
Location
Sweden
Download and use TFS instead, Manerinhu.
 

slawkens

Developer
Premium User
Joined
Aug 27, 2007
Messages
2,880
Best answers
61
Reaction score
391
Location
Germany
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
 

manerinhu

I'm very very MaNeRiNhU
Joined
Jan 14, 2008
Messages
79
Best answers
0
Reaction score
1
Location
Behind you!
TYYYY
it's functionally!!!
ty a lot
but i cant sleep
can u make a sleep script ?
bye and thx a lot
 
OP
AGS

AGS

DeathSouls Owner
Joined
Oct 29, 2007
Messages
400
Best answers
0
Reaction score
8
Location
Mexico
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
 

Ronaldino

Esso Eh
Joined
Dec 25, 2007
Messages
745
Best answers
0
Reaction score
0
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.
 
OP
AGS

AGS

DeathSouls Owner
Joined
Oct 29, 2007
Messages
400
Best answers
0
Reaction score
8
Location
Mexico
Use the furniture package with id 7907 on the header of the bed.
 

Atlas

GM Atlas
Joined
Jun 7, 2007
Messages
79
Best answers
0
Reaction score
0
Location
Wroclaw
is there any posibility to make this bed save to map? Because when server restarts bed is going to its normal id :(
 

Evil Hero

Legacy Member
TFS Developer
Joined
Dec 12, 2007
Messages
1,179
Best answers
15
Reaction score
553
Location
Germany
Nice like always m8 :D! keep the good work going ;)

yours Evil Hero,
 

Colandus

Advanced OT User
Joined
Jun 6, 2007
Messages
2,424
Best answers
18
Reaction score
165
Location
Sweden
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 ^^
 
Top