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

[7.6] Door System, I made a script I it doesn't work! Please check it!

Erevius

It Was A Good Day
Joined
Feb 12, 2010
Messages
157
Reaction score
7
Location
Poland/Olsztyn
I'm using Avesta 7.6 by Ferrus. The Door System installed with engine didn't work so I made a new one.
This is my MaxLVL, MinLVL, Voc, Premium door script:
Code:
-- by Erevius!!!
-- ActionIDs:
-- 1001~1999: Level doors(level is actionID-1000)
-- 2001~2999: Level doors for low levels(level is actionID-1000)
-- 3001~3008: Vocation doors(voc is ActionID-2000. 1:Sorcerer, 2:Druid, 3:Paladin, 4:Knight, 5:MS, 6:ED, 7:RP, 8:EK)

function onUse(cid, item, frompos, pos, item2, topos)
	local isminLevelDoor = (item.actionid >= 1001 and item.actionid <= 1999)
	local ismaxLevelDoor = (item.actionid >= 2001 and item.actionid <= 2999)
	local isVocationDoor = (item.actionid >= 3001 and item.actionid <= 3008)
	local isPremmyDoor = (item.actionid == 4000)
	-- Positions --
	pos0 = {x=frompos.x, y=frompos.y+1, z=frompos.z, stackpos=253}
	pos1 = {x=frompos.x+1, y=frompos.y, z=frompos.z, stackpos=253}
	pos2 = {x=frompos.x, y=frompos.y-1, z=frompos.z, stackpos=253}
	pos3 = {x=frompos.x-1, y=frompos.y, z=frompos.z, stackpos=253}
	pos4 = {x=frompos.x+1, y=frompos.y-1, z=frompos.z, stackpos=253}
	pos5 = {x=frompos.x-1, y=frompos.y-1, z=frompos.z, stackpos=253}
	pos6 = {x=frompos.x+1, y=frompos.y+1, z=frompos.z, stackpos=253}
	pos7 = {x=frompos.x-1, y=frompos.y+1, z=frompos.z, stackpos=253}

	-- Normal Door --
	
	if not(isminLevelDoor or ismaxLevelDoor or isVocationDoor) then
		doTransformItem(item.uid, item.itemid+1)
	end

	-- Minimum Level Doors --
	minpasslevel = (item.actionid - 1000)

	if (isminLevelDoor) then
		if (getPlayerLevel(cid) >= minpasslevel) then
			if (getPlayerPosition(uid) == pos0) then
				doMoveCreature(cid, 0)
			elseif (getPlayerPosition(uid) == pos1) then
				doMoveCreature(cid, 1)
			elseif (getPlayerPosition(uid) == pos2) then
				doMoveCreature(cid, 2)
			elseif (getPlayerPosition(uid) == pos3) then
				doMoveCreature(cid, 3)
			elseif (getPlayerPosition(uid) == pos4) then
				doMoveCreature(cid, 4)
			elseif (getPlayerPosition(uid) == pos5) then
				doMoveCreature(cid, 5)
			elseif (getPlayerPosition(uid) == pos6) then
				doMoveCreature(cid, 6)
			elseif (getPlayerPosition(uid) == pos7) then
				doMoveCreature(cid, 7)
			end
			doTransformItem(item.uid, item.itemid+1)
		else
			doPlayerSendTextMessage(cid,22,'You need level ' .. minpasslevel .. ' to pass this door.')
		end
	end

	-- Maximum Level Doors --
	maxpasslevel = (item.actionid - 2000)

	if (ismaxLevelDoor) then
		if (getPlayerLevel(cid) <= maxpasslevel) then
			if (getPlayerPosition(uid) == pos0) then
				doMoveCreature(cid, 0)
			elseif (getPlayerPosition(uid) == pos1) then
				doMoveCreature(cid, 1)
			elseif (getPlayerPosition(uid) == pos2) then
				doMoveCreature(cid, 2)
			elseif (getPlayerPosition(uid) == pos3) then
				doMoveCreature(cid, 3)
			elseif (getPlayerPosition(uid) == pos4) then
				doMoveCreature(cid, 4)
			elseif (getPlayerPosition(uid) == pos5) then
				doMoveCreature(cid, 5)
			elseif (getPlayerPosition(uid) == pos6) then
				doMoveCreature(cid, 6)
			elseif (getPlayerPosition(uid) == pos7) then
				doMoveCreature(cid, 7)
			end
			doTransformItem(item.uid, item.itemid+1)
		else
			doPlayerSendTextMessage(cid,22,'You need level ' .. maxpasslevel .. ' and below to pass this door.')
		end
	end

	-- Vocation Doors --
	playervoc = getPlayerVocation(cid)
	allowedvoc = (item.actionid - 3000)

	if (isVocationDoor) then
		if (playervoc(cid) == (allowedvoc or (allowedvoc + 4))) then
			if (getPlayerPosition(uid) == pos0) then
				doMoveCreature(cid, 0)
			elseif (getPlayerPosition(uid) == pos1) then
				doMoveCreature(cid, 1)
			elseif (getPlayerPosition(uid) == pos2) then
				doMoveCreature(cid, 2)
			elseif (getPlayerPosition(uid) == pos3) then
				doMoveCreature(cid, 3)
			elseif (getPlayerPosition(uid) == pos4) then
				doMoveCreature(cid, 4)
			elseif (getPlayerPosition(uid) == pos5) then
				doMoveCreature(cid, 5)
			elseif (getPlayerPosition(uid) == pos6) then
				doMoveCreature(cid, 6)
			elseif (getPlayerPosition(uid) == pos7) then
				doMoveCreature(cid, 7)
			end
			doTransformItem(item.uid, item.itemid+1)
		else
			doPlayerSendTextMessage(cid,22,'You vocation is not allowed to pass this door.')
		end
	end
	
	-- Premium Doors --
	
	if (isPremmyDoor) then
		if (isPremium == true) then
			if (getPlayerPosition(uid) == pos0) then
				doMoveCreature(cid, 0)
			elseif (getPlayerPosition(uid) == pos1) then
				doMoveCreature(cid, 1)
			elseif (getPlayerPosition(uid) == pos2) then
				doMoveCreature(cid, 2)
			elseif (getPlayerPosition(uid) == pos3) then
				doMoveCreature(cid, 3)
			elseif (getPlayerPosition(uid) == pos4) then
				doMoveCreature(cid, 4)
			elseif (getPlayerPosition(uid) == pos5) then
				doMoveCreature(cid, 5)
			elseif (getPlayerPosition(uid) == pos6) then
				doMoveCreature(cid, 6)
			elseif (getPlayerPosition(uid) == pos7) then
				doMoveCreature(cid, 7)
			end
			doTransformItem(item.uid, item.itemid+1)
		else
			doPlayerSendTextMessage(cid,22,'You need a premium account to pass this door.')
		end
	end

	return TRUE
end

For me it's looking fine but:
errorub.png

Can someone repair this script or give me some instructions?
 
Code:
-- by Erevius!!!
-- ActionIDs:
-- 1001~1999: Level doors(level is actionID-1000)
-- 2001~2999: Level doors for low levels(level is actionID-1000)
-- 3001~3008: Vocation doors(voc is ActionID-2000. 1:Sorcerer, 2:Druid, 3:Paladin, 4:Knight, 5:MS, 6:ED, 7:RP, 8:EK)

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.actionid >= 1001 and item.actionid <= 1999 then
		if getPlayerLevel(cid) >= item.actionid - 1000 then
			doRelocate(getCreaturePosition(cid), toPosition)
		else
			doPlayerSendTextMessage(cid,22,'You need level ' .. item.actionid - 1000 .. ' to pass this door.')
		end
	elseif item.actionid >= 2001 and item.actionid <= 2999 then
		if getPlayerLevel(cid) <= item.actionid - 2000 then
			doRelocate(getCreaturePosition(cid), toPosition)
		else
			doPlayerSendTextMessage(cid, 22, 'You need level ' .. item.actionid - 2000 .. ' and below to pass this door.')
		end
	elseif item.actionid >= 3001 and item.actionid <= 3008 then
		if isInArray({item.actionid - 3000, item.actionid - 3000 + 4}, getPlayerVocation(cid)) == TRUE then
			doRelocate(getCreaturePosition(cid), toPosition)
		else
			doPlayerSendTextMessage(cid, 22, 'Your vocation is not allowed to pass this door.')
		end
	elseif item.actionid == 4000 then
		if isPremium == TRUE then
			doRelocate(getCreaturePosition(cid), toPosition)
		else
			doPlayerSendTextMessage(cid, 22, 'You need a premium account to pass this door.')
		end
	end
	doTransformItem(item.uid, item.itemid + 1)
	return TRUE
end
 
Last edited:
Noooo!.... ;(

Code:
-- by Erevius!!!
-- ActionIDs:
-- 1001~1999: Level doors(level is actionID-1000)
-- 2001~2999: Level doors for low levels(level is actionID-1000)
-- 3001~3008: Vocation doors(voc is ActionID-2000. 1:Sorcerer, 2:Druid, 3:Paladin, 4:Knight, 5:MS, 6:ED, 7:RP, 8:EK)

local function doorEnter(cid, item, toPosition)
	doTransformItem(item.uid, item.itemid + 1)
	doTeleportThing(cid, toPosition)
end

function onUse(cid, item, frompos, pos, item2, topos)
	if item.actionid >= 1001 and item.actionid <= 1999 then
		if (getPlayerLevel(cid) >= item.actionid - 1000) then
			doorEnter(cid, item, topos)
		else
			doPlayerSendTextMessage(cid,22,'You need level ' .. item.actionid - 1000 .. ' to pass this door.')
		end
	elseif item.actionid >= 2001 and item.actionid <= 2999 then
		if getPlayerLevel(cid) <= item.actionid - 2000 then
			doorEnter(cid, item, topos)
		else
			doPlayerSendTextMessage(cid, 22, 'You need level ' .. item.actionid - 2000 .. ' and below to pass this door.')
		end
	elseif item.actionid >= 3001 and item.actionid <= 3008 then
		if isInArray({item.actionid - 3000, item.actionid - 3000 + 4}, getPlayerVocation(cid)) == TRUE then
			doorEnter(cid, item, topos)
		else
			doPlayerSendTextMessage(cid, 22, 'Your vocation is not allowed to pass this door.')
		end
	elseif item.actionid == 4000 then
		if isPremium == TRUE then
			doorEnter(cid, item, topos)
		else
			doPlayerSendTextMessage(cid, 22, 'You need a premium account to pass this door.')
		end
	else
		doTransformItem(item.uid, item.itemid + 1)
	end
	return TRUE
end

Thanks for help. But your script don't works on Avesta 7.6:
errorcc.png


#1 - However, the "doTeleportThing" will not the player walk but just teleport. I want to make character walking and there is not other way than mine script. I have no idea why didn't my script work...
#2 - The second way is to find me a "getDirectionTo(getPlayerPosition(cid), frompos)" function.
 
Last edited:
ow it was fault with your initial script :p edited my post now
Code:
function onUse(cid, item, frompos, [B][COLOR="Red"]pos[/COLOR][/B], item2, topos)
#1 - However, the "doTeleportThing" will not the player walk but just teleport. I want to make character walking and there is not other way than mine script. I have no idea why didn't my script work...
edited again, now using doRelocate(getCreaturePosition(cid), toPosition)
 
Back
Top