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

Lua arena bug

Glidarn

Member
Joined
May 9, 2009
Messages
970
Reaction score
16
Location
Åkersberga, Sweden
so basically this is my problem:

I am talking to the Npc (Halvar) and it looks like this... as it should be
Halvar: You test will be greenshore level. If you want enter you must pay 2000 gp and have 30 level. Wanna try?
Zbigniew Biznesmen [201]: yes
Halvar: Now you can go to test.

But when i'm trying to go through the door:
The door seems to be sealed against unwanted intruders.

he takes the cash an everything ^_^

arena.lua
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid)			end
function onCreatureDisappear(cid) 			npcHandler:onCreatureDisappear(cid)			end
function onCreatureSay(cid, type, msg) 		npcHandler:onCreatureSay(cid, type, msg)	end
function onThink() 							npcHandler:onThink()						end

function enterArena(cid, message, keywords, parameters, node)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	local cost = 0
	local levelname = ''
	if getPlayerStorageValue(cid, 45450) < 1 then
		cost = 1000
		levelname = 'greenshore'
		levelneeded = 30
	elseif getPlayerStorageValue(cid, 45450) == 1 then
		cost = 5000
		levelname = 'scrapper'
		levelneeded = 50
	elseif getPlayerStorageValue(cid, 45450) == 2 then
		cost = 10000
		levelname = 'warlord'
		levelneeded = 80
	end
	if string.lower(keywords[1]) == 'yes' and parameters.prepare ~= 1 then
		if(getPlayerLevel(cid) >= levelneeded) then
			if(getPlayerMoney(cid) >= cost) then
				doPlayerRemoveMoney(cid, cost)
				npcHandler:say('Now you can go to test.', cid)
				setPlayerStorageValue(cid, 45451, 1)
			else
				npcHandler:say('You don\'t have ' .. cost .. ' gp! Come back when you will be ready!', cid)
		    end
		else
			npcHandler:say('You don\'t have ' .. levelneeded .. ' level! Come back when you will be ready!', cid)
		end
		npcHandler:resetNpc()
	elseif string.lower(keywords[1]) == 'no' then
		npcHandler:say('Come back later then!', cid)
		npcHandler:resetNpc()
	else
		if getPlayerStorageValue(cid, 45450) < 3 then
			npcHandler:say('You test will be ' .. levelname .. ' level. If you want enter you must pay ' .. cost .. ' gp and have ' .. levelneeded .. ' level. Wanna try?', cid)
		else
			npcHandler:say('You did all arena levels.',cid)
		end
	end
	return true
end

npcHandler:setMessage(MESSAGE_GREET, 'Hello |PLAYERNAME|! Do you want to make arena?')

local yesNode = KeywordNode:new({'yes'}, enterArena, {})
local noNode = KeywordNode:new({'no'}, enterArena, {})

local node1 = keywordHandler:addKeyword({'arena'}, enterArena, {prepare=1})
	node1:addChildKeywordNode(yesNode)
	node1:addChildKeywordNode(noNode)
	
local node1 = keywordHandler:addKeyword({'fight'}, enterArena, {prepare=1})
	node1:addChildKeywordNode(yesNode)
	node1:addChildKeywordNode(noNode)
local node1 = keywordHandler:addKeyword({'yes'}, enterArena, {prepare=1})
	node1:addChildKeywordNode(yesNode)
	node1:addChildKeywordNode(noNode)
npcHandler:addModule(FocusModule:new())

Regards Glidarn
 
If you dont have a script for the door, then it wont work, since its just a random door that does nothing :D
 
kinda explains it i think, but i don't rly know how to make it ... and if i do have it i'm not rly sure where i'll find that script lol ;P

Mostly been working on other quests that were kinda prio~ ... since i'm done with almost all the other scripts this became prio one lol ^_^
 
Put this to door:
data/actions/scripts/svargronddoor.lua
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid,45451) > 0 then
      doTransformItem(item.uid,item.itemid+1)
         doorpos = {x = fromPosition.x, y = fromPosition.y, z = fromPosition.z, stackpos = 253}
	             if playerpos.y == doorpos.y + 1 and playerpos.x == doorpos.x then
		        doMoveCreature(cid, 0)
		elseif playerpos.x == doorpos.x - 1 and playerpos.y == doorpos.y then
			doMoveCreature(cid, 1)
		elseif playerpos.y == doorpos.y - 1 and playerpos.x == doorpos.x then
			doMoveCreature(cid, 2)
		elseif playerpos.y == doorpos.y and playerpos.x == doorpos.x + 1 then
			doMoveCreature(cid, 3)
		elseif playerpos.x == doorpos.x + 1 and playerpos.y == doorpos.y - 1 then
			doMoveCreature(cid, 4)
		elseif playerpos.x == doorpos.x - 1 and playerpos.y == doorpos.y - 1 then
			doMoveCreature(cid, 5)
		elseif playerpos.x == doorpos.x + 1 and playerpos.y == doorpos.y + 1 then
			doMoveCreature(cid, 6)
		elseif playerpos.x == doorpos.x - 1 and playerpos.y == doorpos.y + 1 then
			doMoveCreature(cid, 7)
		end
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"The door seems to be sealed against unwanted intruders.")
        end
return true
end

data/actions/actions.xml
XML:
<action uniqueid="5114" event="script" value="svargronddoor.lua"/>
Put that UID for door, and test ^_^
 
Lol? :l
Then put the AID to 0, and put the UID to whatever u want, and put that line in XML file and the script.
 
-.- Put UID to 0 ( I dont even get how you test test with 99999 as uid can max be at 65535)
and put actionid to 45451

@santigggg
Why do you want to you another scripts if it is already included in doors.lua?
 
-.- Put UID to 0 ( I dont even get how you test test with 99999 as uid can max be at 65535)
and put actionid to 45451

@santigggg
Why do you want to you another scripts if it is already included in doors.lua?

As i said i'm not that good in lua scripting.


Should i remove svargronddoor.lua ?

i changed the aid to 45451 on the doors and also changed uid to 65535
 
Last edited:
Normally it works if you use a quest door and set the actionid to the storage the player needs to pass.

Post the doors.lua (actions/scripts/other)
 
aight, well heres the doors.lua

LUA:
local function checkStackpos(item, position)
	position.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
	local thing = getThingFromPos(position)

	position.stackpos = STACKPOS_TOP_FIELD
	local field = getThingFromPos(position)

	return (item.uid == thing.uid or thing.itemid < 100 or field.itemid == 0)
end

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

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(fromPosition.x ~= CONTAINER_POSITION and isPlayerPzLocked(cid) and getTileInfo(fromPosition).protection) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
		return true
	end

	if(getItemLevelDoor(item.itemid) > 0) then
		if(item.actionid == 189) then
			if(not isPremium(cid)) then
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
				return true
			end

			doorEnter(cid, item, toPosition)
			return true
		end

		local gender = item.actionid - 186
		if(isInArray({PLAYERSEX_FEMALE,  PLAYERSEX_MALE, PLAYERSEX_GAMEMASTER}, gender)) then
			if(gender ~= getPlayerSex(cid)) then
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
				return true
			end

			doorEnter(cid, item, toPosition)
			return true
		end

		local skull = item.actionid - 180
		if(skull >= SKULL_NONE and skull <= SKULL_BLACK) then
			if(skull ~= getCreatureSkullType(cid)) then
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
				return true
			end

			doorEnter(cid, item, toPosition)
			return true
		end

		local group = item.actionid - 150
		if(group >= 0 and group < 30) then
			if(group > getPlayerGroupId(cid)) then
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
				return true
			end

			doorEnter(cid, item, toPosition)
			return true
		end

		local vocation = item.actionid - 100
		if(vocation >= 0 and vocation < 50) then
			local playerVocationInfo = getVocationInfo(getPlayerVocation(cid))
			if(playerVocationInfo.id ~= vocation and playerVocationInfo.fromVocation ~= vocation) then
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
				return true
			end

			doorEnter(cid, item, toPosition)
			return true
		end

		if(item.actionid == 190 or (item.actionid ~= 0 and getPlayerLevel(cid) >= (item.actionid - getItemLevelDoor(item.itemid)))) then
			doorEnter(cid, item, toPosition)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
		end

		return true
	end

	if(isInArray(specialDoors, item.itemid)) then
		if(item.actionid == 100 or (item.actionid ~= 0 and getPlayerStorageValue(cid, item.actionid) > 0)) then
			doorEnter(cid, item, toPosition)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "The door seems to be sealed against unwanted intruders.")
		end

		return true
	end

	if(isInArray(keys, item.itemid)) then
		if(itemEx.actionid > 0) then
			if(item.actionid == itemEx.actionid and doors[itemEx.itemid] ~= nil) then
				doTransformItem(itemEx.uid, doors[itemEx.itemid])
				return true
			end

			doPlayerSendCancel(cid, "The key does not match.")
			return true
		end

		return false
	end

	if(isInArray(horizontalOpenDoors, item.itemid) and checkStackpos(item, fromPosition)) then
		local newPosition = toPosition
		newPosition.y = newPosition.y + 1
		local doorPosition = fromPosition
		doorPosition.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
		local doorCreature = getThingfromPos(doorPosition)
		if(doorCreature.itemid ~= 0) then
			local pzDoorPosition = getTileInfo(doorPosition).protection
			local pzNewPosition = getTileInfo(newPosition).protection
			if((pzDoorPosition and not pzNewPosition and doorCreature.uid ~= cid) or
				(not pzDoorPosition and pzNewPosition and doorCreature.uid == cid and isPlayerPzLocked(cid))) then
				doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
			else
				doTeleportThing(doorCreature.uid, newPosition)
				if(not isInArray(closingDoors, item.itemid)) then
					doTransformItem(item.uid, item.itemid - 1)
				end
			end

			return true
		end

		doTransformItem(item.uid, item.itemid - 1)
		return true
	end

	if(isInArray(verticalOpenDoors, item.itemid) and checkStackpos(item, fromPosition)) then
		local newPosition = toPosition
		newPosition.x = newPosition.x + 1
		local doorPosition = fromPosition
		doorPosition.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
		local doorCreature = getThingfromPos(doorPosition)
		if(doorCreature.itemid ~= 0) then
			if(getTileInfo(doorPosition).protection and not getTileInfo(newPosition).protection and doorCreature.uid ~= cid) then
				doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
			else
				doTeleportThing(doorCreature.uid, newPosition)
				if(not isInArray(closingDoors, item.itemid)) then
					doTransformItem(item.uid, item.itemid - 1)
				end
			end

			return true
		end

		doTransformItem(item.uid, item.itemid - 1)
		return true
	end

	if(doors[item.itemid] ~= nil and checkStackpos(item, fromPosition)) then
		if(item.actionid == 0) then
			doTransformItem(item.uid, doors[item.itemid])
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is locked.")
		end

		return true
	end

	return false
end

shall i remove he's svargrondoor.lua?
 
Last edited:
Back
Top