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

Beds...

brunolopes

New Member
Joined
Nov 8, 2009
Messages
49
Reaction score
1
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local xpos = {x = fromPosition.x+1, y = fromPosition.y, z = fromPosition.z, stackpos = 2}
	local x = getThingFromPos(xpos)
	local ypos = {x = fromPosition.x, y = fromPosition.y+1, z = fromPosition.z, stackpos = 2}
	local y = getThingFromPos(ypos)
	
	if (item.uid == 35000) then
		if (item.itemid == 1754) then
			doTransformItem(item.uid, 1762)
			doTransformItem(y.uid, 1763)
			doSetItemOutfit(cid, 4390, 5*1000)
			doTeleportThing(cid, fromPosition)
		elseif (item.itemid == 1760) then
			doTransformItem(item.uid, 1764)
			doTransformItem(x.uid, 1765)
			doSetItemOutfit(cid, 4390, 5*1000)
			doTeleportThing(cid, fromPosition)
		end
	end
	addEvent(doTeleportThing, 5*1000, cid, {x = 1023, y = 1020, z = 8})
	addEvent(doPlayerSendTextMessage, 5*1000, cid, MESSAGE_EVENT_ADVANCE, 'Your sleeping time has finished!')
	addEvent(doPlayerSetStorageValue, 5*1000, cid, 3501, 0)
	
	if (getPlayerStorageValue(cid, 3501) == 1) then
		addEvent(setGlobalStorageValue, 5*1000, 15001, 0)
	elseif (getPlayerStorageValue(cid, 3501) == 2) then
		addEvent(setGlobalStorageValue, 5*1000, 15002, 0)
	elseif (getPlayerStorageValue(cid, 3501) == 3) then
		addEvent(setGlobalStorageValue, 5*1000, 15003, 0)
	elseif (getPlayerStorageValue(cid, 3501) == 4) then
		addEvent(setGlobalStorageValue, 5*1000, 15004, 0)
	end
end

Hello, I made this script, for when the player uses a bed, this changes to the used bed, and the player sleeps for some time, without logging off.

But, when the player is "kicked off" from the bed, I need to transform it back to the normal bed (IDs: 1754, 1755, 1760, 1761), someone can help me?

This is a Inn System.
 
Global Storage for the rooms in the Inn.
I don't want two players in the same room.

Cykotitan, I only want to transform back the beds when the player is kicked off.
Can you help me?

addEvent with doTransformItem returns a Item Not Found.
 
Code:
local t = {
	time = 5,
	kick = {x=1023, y=1020, z=8}
}
local function reset(cid, newID, pos)
	doTransformItem(getTileItemById(getThingPos(cid), newID).uid, getItemInfo(newID).transformToFree)
	doTransformItem(getTileItemById(pos, newID == 7778 and 1763 or newID+1).uid, getItemInfo(newID == 7778 and 1763 or newID+1).transformToFree)
	doTeleportThing(cid, t.kick)
	doCreatureSetNoMove(cid, false)
	doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'Your sleeping time has finished!')
	setGlobalStorageValue(getPlayerStorageValue(cid, 3501) + 15000, 0)
	setPlayerStorageValue(cid, cid, 3501, 0)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.uid == 35000 then
		local newID = getPlayerSex(cid) == 0 and getItemInfo(item.itemid).transformUseTo.female or getItemInfo(item.itemid).transformUseTo.male
		doTransformItem(item.uid, newID)
		local v = getItemInfo(item.itemid).bedPartnerDirection
		local pos = {x=fromPosition.x + (v==1 and 1 or 0), y=fromPosition.y + (v==2 and 1 or 0), z=fromPosition.z}
		doTransformItem(getTileItemById(pos, item.itemid + 1).uid, getPlayerSex(cid) == 0 and getItemInfo(item.itemid + 1).transformUseTo.female or getItemInfo(item.itemid + 1).transformUseTo.male)
		doSetItemOutfit(cid, 4390, t.time*1000)
		doTeleportThing(cid, fromPosition)
		doCreatureSetNoMove(cid, true)
		addEvent(reset, t.time * 1000, cid, newID, pos)
	end
	return true
end
 
Nothing to do, so i test it and it works just fine!

Edit:just one error in console when the function "reset" and "onUse":

Code:
[31/05/2010 03:49:28] (luaDoTransformItem) Item not found
 
Last edited:
Back
Top