• 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 Actionscript - Quest

Stormoguden

Professional Mapper~
Joined
Nov 3, 2008
Messages
441
Reaction score
6
Location
Sweden/Stockholm
Code:
local cfg =
{
	leverPos = {x=1037, y=1148, z=8, stackpos = 1}, -- Lever Position
}

local playerPos =
{
	[1] = {x=1037, y=1147, z=8, stackpos = 253}, -- Player Start Positions
	[2] = {x=1037, y=1149, z=8, stackpos = 253}
}

local newPos =
{
	[1] = {x=1033, y=1146, z=11}, -- New Player Positions
	[2] = {x=1033, y=1148, z=11}
}

local player1 = getThingfromPos(playerPos[1])
local player2 = getThingfromPos(playerPos[2])
local event = 0

function onUse(cid, item, fromPosition, itemEx, toPosition)
   	if item.uid == 7001 and item.itemid == 1945 then
		if player1.itemid > 0 and player2.itemid > 0 then
				doTeleportThing(player1.uid, newPos[1])
				doTeleportThing(player2.uid, newPos[2])
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have entered the quest!")
			doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
         	   event = addEvent(changeLever, 5 * 60000)
		else
			doPlayerSendCancel(cid, "You have to be 2 people to enter this quest.")
		end
	elseif (item.itemid == 1946) then
		doPlayerSendCancel(cid, "The quest is already active, you must wait.")
	end
	return TRUE
end

local function changeLever()
    if getThingfromPos(cid, cfg.leverPos) == 1946 then
        doTransformItem(item.uid, 1945)
        stopEvent(event)
    end
end

Okay, this is how it's supposed to work, 2 people stand on 2 tiles, they pull a lever, get teleported to new positions, lever resets after 5 minutes. If someone is in it says the quest is already active and otherwise it says you need 2 players to enter.

The problem is, it says
Code:
You need 2 players to enter the quest
Even tho there is 2 players, but it works if I reload actions when standing on the 2 tiles and then enters..

Anyone?
 
Code:
}

local playerPos =
{
	[1] = {x=1037, y=1147, z=8, stackpos = 253}, -- Player Start Positions
	[2] = {x=1037, y=1149, z=8, stackpos = 253}
}

local newPos =
{
	[1] = {x=1033, y=1146, z=11}, -- New Player Positions
	[2] = {x=1033, y=1148, z=11}
}

local player1 = getThingfromPos(playerPos[1])
local player2 = getThingfromPos(playerPos[2])

function onUse(cid, item, fromPosition, itemEx, toPosition)
   	if item.uid == 7001 and item.itemid == 1945 then
		if player1.isPlayer(player1) == true and player2.isPlayer(player2) == true then
				doTeleportThing(player1.uid, newPos[1])
				doTeleportThing(player2.uid, newPos[2])
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have entered the quest!")
			doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
			addEvent(changeLever, 5 * 60000)
		else
			doPlayerSendCancel(cid, "You have to be 2 people to enter this quest.")
		end
	elseif (item.itemid == 1946) then
		doPlayerSendCancel(cid, "The quest is already active, you must wait.")
	end
	return TRUE
end

local function changeLever()
    if getThingfromPos(cid, cfg.leverPos) == 1946 then
        doTransformItem(item.uid, 1945)
    end
end

Test it.
 
Code:
}

local playerPos =
{
	[1] = {x=1037, y=1147, z=8, stackpos = 253}, -- Player Start Positions
	[2] = {x=1037, y=1149, z=8, stackpos = 253}
}

local newPos =
{
	[1] = {x=1033, y=1146, z=11}, -- New Player Positions
	[2] = {x=1033, y=1148, z=11}
}

local player1 = getThingfromPos(playerPos[1])
local player2 = getThingfromPos(playerPos[2])

function onUse(cid, item, fromPosition, itemEx, toPosition)
   	if item.uid == 7001 and item.itemid == 1945 then
		if player1.isPlayer(player1) == true and player2.isPlayer(player2) == true then
				doTeleportThing(player1.uid, newPos[1])
				doTeleportThing(player2.uid, newPos[2])
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have entered the quest!")
			doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
			addEvent(changeLever, 5 * 60000)
		else
			doPlayerSendCancel(cid, "You have to be 2 people to enter this quest.")
		end
	elseif (item.itemid == 1946) then
		doPlayerSendCancel(cid, "The quest is already active, you must wait.")
	end
	return TRUE
end

local function changeLever()
    if getThingfromPos(cid, cfg.leverPos) == 1946 then
        doTransformItem(item.uid, 1945)
    end
end

Test it.

gives me this;
Code:
[Warning - Event::loadScript] Cannot load script <data/actions/scripts/poisonsewers.lua>
data/actions/scripts/poisonsewers.lua:1: unexpected symbol near '<'
:s
 
Code:
local playerPos =
{
	[1] = {x=1037, y=1147, z=8, stackpos = 253}, -- Player Start Positions
	[2] = {x=1037, y=1149, z=8, stackpos = 253}
}

local newPos =
{
	[1] = {x=1033, y=1146, z=11}, -- New Player Positions
	[2] = {x=1033, y=1148, z=11}
}

local player1 = getThingfromPos(playerPos[1])
local player2 = getThingfromPos(playerPos[2])

function onUse(cid, item, fromPosition, itemEx, toPosition)
   	if item.uid == 7001 and item.itemid == 1945 then
		if player1.isPlayer(player1) == true and player2.isPlayer(player2) == true then
				doTeleportThing(player1.uid, newPos[1])
				doTeleportThing(player2.uid, newPos[2])
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have entered the quest!")
			doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
			addEvent(changeLever, 5 * 60000)
		else
			doPlayerSendCancel(cid, "You have to be 2 people to enter this quest.")
		end
	elseif (item.itemid == 1946) then
		doPlayerSendCancel(cid, "The quest is already active, you must wait.")
	end
	return TRUE
end

local function changeLever()
    if getThingfromPos(cid, cfg.leverPos) == 1946 then
        doTransformItem(item.uid, 1945)
    end
end
 
Code:
local playerPos =
{
	[1] = {x=1037, y=1147, z=8, stackpos = 253}, -- Player Start Positions
	[2] = {x=1037, y=1149, z=8, stackpos = 253}
}

local newPos =
{
	[1] = {x=1033, y=1146, z=11}, -- New Player Positions
	[2] = {x=1033, y=1148, z=11}
}

local player1 = getThingfromPos(playerPos[1])
local player2 = getThingfromPos(playerPos[2])

function onUse(cid, item, fromPosition, itemEx, toPosition)
   	if item.uid == 7001 and item.itemid == 1945 then
		if player1.isPlayer(player1) == true and player2.isPlayer(player2) == true then
				doTeleportThing(player1.uid, newPos[1])
				doTeleportThing(player2.uid, newPos[2])
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have entered the quest!")
			doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
			addEvent(changeLever, 5 * 60000)
		else
			doPlayerSendCancel(cid, "You have to be 2 people to enter this quest.")
		end
	elseif (item.itemid == 1946) then
		doPlayerSendCancel(cid, "The quest is already active, you must wait.")
	end
	return TRUE
end

local function changeLever()
    if getThingfromPos(cid, cfg.leverPos) == 1946 then
        doTransformItem(item.uid, 1945)
    end
end

Now theres no errors until using the lever, when using it, it just gets to id 1946 and then it says, The quest is already active, you must wait. And no one gets tped or anything, and when pulling the lever, I get this:
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/poisonsewers.lua:onUse

data/actions/scripts/poisonsewers.lua:18: attempt to call field 'isPlayer' <a nil value>
stack traceback:
data/actions/scripts/poisonsewers.lua:18: in function <data/actions/scripts/poisonsewers.lua:16>
;S
 
Code:
local playerPos =
{
	[1] = {x=1037, y=1147, z=8, stackpos = 253}, -- Player Start Positions
	[2] = {x=1037, y=1149, z=8, stackpos = 253}
}

local newPos =
{
	[1] = {x=1033, y=1146, z=11}, -- New Player Positions
	[2] = {x=1033, y=1148, z=11}
}

local player1 = getThingfromPos(playerPos[1])
local player2 = getThingfromPos(playerPos[2])

function onUse(cid, item, fromPosition, itemEx, toPosition)
   	if item.uid == 7001 and item.itemid == 1945 then
		if isPlayer(player1) == true and isPlayer(player2) == true then
				doTeleportThing(player1.uid, newPos[1])
				doTeleportThing(player2.uid, newPos[2])
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have entered the quest!")
			doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
			addEvent(changeLever, 5 * 60000)
		else
			doPlayerSendCancel(cid, "You have to be 2 people to enter this quest.")
		end
	elseif (item.itemid == 1946) then
		doPlayerSendCancel(cid, "The quest is already active, you must wait.")
	end
	return TRUE
end

local function changeLever()
    if getThingfromPos(cid, cfg.leverPos) == 1946 then
        doTransformItem(item.uid, 1945)
    end
end
 
Code:
local playerPos =
{
	[1] = {x=1037, y=1147, z=8, stackpos = 253}, -- Player Start Positions
	[2] = {x=1037, y=1149, z=8, stackpos = 253}
}

local newPos =
{
	[1] = {x=1033, y=1146, z=11}, -- New Player Positions
	[2] = {x=1033, y=1148, z=11}
}

local player1 = getThingfromPos(playerPos[1])
local player2 = getThingfromPos(playerPos[2])

function onUse(cid, item, fromPosition, itemEx, toPosition)
   	if item.uid == 7001 and item.itemid == 1945 then
		if isPlayer(player1) == true and isPlayer(player2) == true then
				doTeleportThing(player1.uid, newPos[1])
				doTeleportThing(player2.uid, newPos[2])
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have entered the quest!")
			doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
			addEvent(changeLever, 5 * 60000)
		else
			doPlayerSendCancel(cid, "You have to be 2 people to enter this quest.")
		end
	elseif (item.itemid == 1946) then
		doPlayerSendCancel(cid, "The quest is already active, you must wait.")
	end
	return TRUE
end

local function changeLever()
    if getThingfromPos(cid, cfg.leverPos) == 1946 then
        doTransformItem(item.uid, 1945)
    end
end

No errors but like before, if 2 players tries to enter it says "You need 2 players" even if it is 2 players.
 
Lua:
if isPlayer(player1) == true and isPlayer(player2) == true then
not true but TRUE! and it is not nessesary...

Lua:
local playerPos =
{
	[1] = {x=1037, y=1147, z=8, stackpos = 253}, -- Player Start Positions
	[2] = {x=1037, y=1149, z=8, stackpos = 253}
}

local newPos =
{
	[1] = {x=1033, y=1146, z=11}, -- New Player Positions
	[2] = {x=1033, y=1148, z=11}
}

local player1 = getThingfromPos(playerPos[1])
local player2 = getThingfromPos(playerPos[2])

function onUse(cid, item, fromPosition, itemEx, toPosition)
   	if item.uid == 7001 and item.itemid == 1945 then
		if isPlayer(player1) and isPlayer(player2) then
				doTeleportThing(player1.uid, newPos[1])
				doTeleportThing(player2.uid, newPos[2])
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have entered the quest!")
			doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
			addEvent(changeLever, 5 * 60000)
		else
			doPlayerSendCancel(cid, "You have to be 2 people to enter this quest.")
		end
	elseif (item.itemid == 1946) then
		doPlayerSendCancel(cid, "The quest is already active, you must wait.")
	end
	return TRUE
end

local function changeLever()
    if getThingfromPos(cid, cfg.leverPos) == 1946 then
        doTransformItem(item.uid, 1945)
    end
end
 
Back
Top