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

[Help] Postman Quest (Door)

Xexza

New Member
Joined
Sep 3, 2007
Messages
1,053
Reaction score
3
Hello, I was trying to make a door where only people who made a quest could enter.
Doesnt work, when I click at the door nothing happens, also no error msg in console.
Using TFS 0.2.6

Code:
function onUse(cid, item, frompos, item2, topos)

queststatus = getPlayerStorageValue(cid,1385)

if item.uid == 1385 and item2.itemid == 1221 and queststatus == -1 or queststatus == 0 then

doPlayerSendTextMessage(cid,22,"You do not have access to open this door.")

   else

doTransformItem(item2.uid,item2.itemid+1)

if item2.itemid == 1222 then

doTransformItem(item2.uid,item2.itemid-1)


end
end
 
hmm try this

Code:
function onUse(cid, item, frompos, item2, topos)
queststatus = getPlayerStorageValue(cid,1385)
if item.uid == 1385 and item2.itemid == 1221 and queststatus == -1 then
doPlayerSendCancel(cid, "You do not have access to open this door.")
else
doTransformItem(item2.uid,item2.itemid+1)
elseif item2.itemid == 1222 then
doTransformItem(item2.uid,item2.itemid-1)

end
return TRUE
end
 
hmm try this

Code:
function onUse(cid, item, frompos, item2, topos)
queststatus = getPlayerStorageValue(cid,1385)
if item.uid == 1385 and item2.itemid == 1221 and queststatus == -1 then
doPlayerSendCancel(cid, "You do not have access to open this door.")
else
doTransformItem(item2.uid,item2.itemid+1)
elseif item2.itemid == 1222 then
doTransformItem(item2.uid,item2.itemid-1)

end
return TRUE
end

It didn't work (error: 'end' expected <to close 'if' at line 3>
Thanks for help.
 
This should work:
Code:
function onUse(cid, item, frompos, item2, topos)
	local queststatus = getPlayerStorageValue(cid,1385)
	if item.uid == 1385 and item2.itemid == 1221 and queststatus == -1 then
		doPlayerSendCancel(cid, "You do not have access to open this door.")
	elseif item2.itemid == 1222 then
		doTransformItem(item2.uid,item2.itemid-1)	
	else
		doTransformItem(item2.uid,item2.itemid+1)
	end
	return TRUE
end
 
This should work:
Code:
function onUse(cid, item, frompos, item2, topos)
	local queststatus = getPlayerStorageValue(cid,1385)
	if item.uid == 1385 and item2.itemid == 1221 and queststatus == -1 then
		doPlayerSendCancel(cid, "You do not have access to open this door.")
	elseif item2.itemid == 1222 then
		doTransformItem(item2.uid,item2.itemid-1)	
	else
		doTransformItem(item2.uid,item2.itemid+1)
	end
	return TRUE
end
I love you Ispiro. Also Thanks mokerhamer ^,^
 
I love you Ispiro. Also Thanks mokerhamer ^,^

No problem, but I just took a look at the script and realized it's a bit messy.
This code: will only let people that did the quest to be able to close and open the door. (without keys, and door UID must be 1385)

Code:
function onUse(cid, item, frompos, item2, topos)

	local queststatus = getPlayerStorageValue(cid, 1385)
	local questDoorUID = 1385
	if(item.uid == questDoorUID and queststatus > 0) then
		if(item.itemid == 1222) then
			doTransformItem(item2.uid,item2.itemid-1)
		else
			doTransformItem(item2.uid,item2.itemid+1)
		end
	else
		doPlayerSendTextMessage(cid, 22, "You do not have access to open this door.")
	end	
end

Not sure how the quest works really, you didn't mention any keys but the script shows otherwise.
 
No problem, but I just took a look at the script and realized it's a bit messy.
This code: will only let people that did the quest to be able to close and open the door. (without keys, and door UID must be 1385)

Code:
function onUse(cid, item, frompos, item2, topos)

	local queststatus = getPlayerStorageValue(cid, 1385)
	local questDoorUID = 1385
	if(item.uid == questDoorUID and queststatus > 0) then
		if(item.itemid == 1222) then
			doTransformItem(item2.uid,item2.itemid-1)
		else
			doTransformItem(item2.uid,item2.itemid+1)
		end
	else
		doPlayerSendTextMessage(cid, 22, "You do not have access to open this door.")
	end	
end

Not sure how the quest works really, you didn't mention any keys but the script shows otherwise.
The script works perfectly fine for mine (the one you gave above) so I think I will use it.
I don't really care if your new one have more optis or so thx anyway
 
I use this script on my server, and it works perfectly, experiment it, I think u'll like too, its like global tibia ;)

All that u need to make is set the UniqueID on ur door, and edit your actions.xml making the pointer of the UniqueID that u set in your map to these script.

postman_door.lua:
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local doorPosition = {x = toPosition.x, y = toPosition.y, z = toPosition.z, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE}
	local doorCreature = getThingfromPos(doorPosition)
	if isInArray(questDoors, item.itemid) == TRUE then
		if getPlayerStorageValue(cid, 1385) ~= -1 then
			doTransformItem(item.uid, item.itemid + 1)
			doTeleportThing(cid, toPosition, TRUE)
		else
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "The door seems to be sealed against unwanted intruders.")
	end
return TRUE
end
return FALSE
end
 
Back
Top