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

Solved Door system

Zolax

New Member
Joined
Feb 16, 2011
Messages
97
Reaction score
1
Hello i'm using door system in avesta but it doesnt work. I got an error 93587065206855194971.jpg and here is my script:
Code:
-- ActionIDs:
-- 1001~1999: Level doors(level is actionID-1000)
-- 2001~2008: 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, item2, topos)
	local isLevelDoor = (item.actionid >= 1001 and item.actionid <= 1999)
	local isVocationDoor = (item.actionid >= 2001 and item.actionid <= 2008)
	local playerPos = getPlayerPosition(cid)


	if not(isLevelDoor or isVocationDoor) then
		-- Make it a normal door
		doTransformItem(item.uid, item.itemid+1)
		return TRUE
	end

	local canEnter = true
	if(isLevelDoor and getPlayerLevel(cid) < (item.actionid-1000)) then
		canEnter = false
	end

	if (isVocationDoor) then
		local doorVoc = item.actionid-2000
		if (doorVoc == 1 and not(isSorcerer(cid))) or
		   (doorVoc == 2 and not(isDruid(cid)))    or
		   (doorVoc == 3 and not(isPaladin(cid)))  or
		   (doorVoc == 4 and not(isKnight(cid)))   or
		   (doorVoc ~= getPlayerVocation(cid))     then
			canEnter = false
		end
	end

	if (not canEnter and getPlayerAccess(cid) == 0) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
		return TRUE
	end

	doTransformItem(item.uid, item.itemid+1)
	local canGo = (queryTileAddThing(cid, frompos, bit.bor(2, 4)) == RETURNVALUE_NOERROR) --Veryfies if the player can go, ignoring blocking things
	if not(canGo) then
		return FALSE
	end

	local dir = getDirectionTo(playerPos, topos)

	doMoveCreature(cid, dir)
	return TRUE
end
Plz help me.
 
You are missing functions. Those are Avesta ones:
Code:
function isSorcerer(cid)
	if (isPlayer(cid)) then
		local voc = getPlayerVocation(cid)
		if (voc == 1 or voc == 5) then
			return true
		end
	end
	
	return false
end

function isDruid(cid)
	if (isPlayer(cid)) then
		local voc = getPlayerVocation(cid)
		if (voc == 2 or voc == 6) then
			return true
		end
	end
	
	return false
end

function isPaladin(cid)
	if (isPlayer(cid)) then
		local voc = getPlayerVocation(cid)
		if (voc == 3 or voc == 7) then
			return true
		end
	end
	
	return false
end

function isKnight(cid)
	if (isPlayer(cid)) then
		local voc = getPlayerVocation(cid)
		if (voc == 4 or voc == 8) then
			return true
		end
	end
	
	return false
end

function isPromoted(cid)
	if (isPlayer(cid)) then
		local voc = getPlayerVocation(cid)
		if (voc >= 5 and voc <= 8) then
			return true
		end
	end
	
	return false
end

Add them to data/functions.lua and make sure functions.lua are included in global.lua
 
This is actually source related. It happens that there is only isCreature(cid) function in Avesta. You would have to add isPlayer to luascript (luascript.cpp/h) yourself.
For now, since creatures does not use doors, remove the isPlayer part from isDruid/Knight/Sorcerer/Paladin.
 
Back
Top