• 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 Help fast! Actionscript

Stormoguden

Professional Mapper~
Joined
Nov 3, 2008
Messages
442
Reaction score
6
Location
Sweden/Stockholm
Code:
  local cfg =
{
    leverPos = {x=1037, y=1148, z=8}, -- Lever Position
    level = 8, -- Required Level
    timeToChange = 5 -- Minutes
}

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

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

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

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if (item.itemid == 1945) and (item.uid == 7001) then
        if getPlayerLevel(cid) >= cfg.level then
            doTeleportThing(getThingfromPos(player1), newPos[1])
            doTeleportThing(getThingfromPos(player2), newPos[2])
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have entered the quest!")
            doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
            event = addEvent(changeLever, timeToChange * 60000)
        else
            doPlayerSendCancel(cid, "All players must be atleast ".. cfg.level .." 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

I get this error;
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/poisonsewers.lua

data/actions/scripts/poisonsewers.lua:20: attemt to index global 'playerpos' <a nil value>
[Warning - Event::loadScript] Cannot load script <data/actions/scripts/poisonsewers.lua>
data/actions/scripts/poisonsewers.lua '<' expected near 'onUse'

Help apprieceted!
 
LUA:
  local cfg =
{
    leverPos = {x=1037, y=1148, z=8}, -- Lever Position
    level = 8, -- Required Level
    timeToChange = 5 -- Minutes
}

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

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.itemid == 1945) and (item.uid == 7001) then
        if getPlayerLevel(cid) >= cfg.level then
            doTeleportThing(getThingfromPos(player1), newPos[1])
            doTeleportThing(getThingfromPos(player2), newPos[2])
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have entered the quest!")
            doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
            event = addEvent(changeLever, timeToChange * 60000)
        else
            doPlayerSendCancel(cid, "All players must be atleast ".. cfg.level .." 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

Cool, now were getting close!

But as always, a lil problem.
When using the lever, the characters don't get teleported and I get one error in the console:
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/poisonsewers.lua:onUse
LuaDoTeleportThing<>. Thing not Found

Lua Script Error: [Action Interface]
data/actions/scripts/poisonsewers.lua:onUse
LuaDoTeleportThing<>. Thing not Found

Lua Script Error: [Action Interface]
data/actions/scripts/poisonsewers.lua:onUse

data/actions/scripts/poisonsewers.lua:31: attemt to perform arithmetic on global 'timeToChange' <a nil value>
stack traceback:
data/actions/scripts/poisonsewers.lua:31: in function <data/actions/scripts/poisonsewers.lua:24>
 
Last edited:
LUA:
  local cfg =
{
    leverPos = {x=1037, y=1148, z=8}, -- Lever Position
    level = 8, -- Required Level
    timeToChange = 5 -- Minutes
}

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

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.itemid == 1945) and (item.uid == 7001) then
        if getPlayerLevel(cid) >= cfg.level then
            doTeleportThing(getThingfromPos(player1).uid, newPos[1])
            doTeleportThing(getThingfromPos(player2).uid, newPos[2])
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have entered the quest!")
            doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
            event = addEvent(changeLever, cfg.timeToChange * 60000)
        else
            doPlayerSendCancel(cid, "All players must be atleast ".. cfg.level .." 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
 
LUA:
  local cfg =
{
    leverPos = {x=1037, y=1148, z=8}, -- Lever Position
    level = 8, -- Required Level
    timeToChange = 5 -- Minutes
}

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

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.itemid == 1945) and (item.uid == 7001) then
        if getPlayerLevel(cid) >= cfg.level then
            doTeleportThing(getThingfromPos(player1).uid, newPos[1])
            doTeleportThing(getThingfromPos(player2).uid, newPos[2])
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have entered the quest!")
            doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
            event = addEvent(changeLever, cfg.timeToChange * 60000)
        else
            doPlayerSendCancel(cid, "All players must be atleast ".. cfg.level .." 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

This makes the server crash when loading script systems. What can be the problem?
 
LUA:
local cfg =
{
    leverPos = {x=1037, y=1148, z=8},
    level = 8, 
    time = 5 * 60000 

}

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

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.itemid == 1945) and (item.uid == 7001) then
        if getPlayerLevel(cid) >= cfg.level then
            doTeleportThing(getThingfromPos(player1).uid, newPos[1])
            doTeleportThing(getThingfromPos(player2).uid, newPos[2])
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have entered the quest!")
            doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
            event = addEvent(changeLever, cfg.time)
        else
            doPlayerSendCancel(cid, "All players must be atleast ".. cfg.level .." 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
 
LUA:
local cfg =
{
    leverPos = {x=1037, y=1148, z=8},
    level = 8, 
    time = 5 * 60000 

}

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

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.itemid == 1945) and (item.uid == 7001) then
        if getPlayerLevel(cid) >= cfg.level then
            doTeleportThing(getThingfromPos(player1).uid, newPos[1])
            doTeleportThing(getThingfromPos(player2).uid, newPos[2])
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have entered the quest!")
            doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
            event = addEvent(changeLever, cfg.time)
        else
            doPlayerSendCancel(cid, "All players must be atleast ".. cfg.level .." 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

This also crashes when loading scripts. :S
 
Back
Top