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

[Actions] Switch and items on correct places (like desert q).

DVEagle

New Member
Joined
Aug 29, 2009
Messages
95
Reaction score
3
Location
PoLand
Edited 2 simple ver.:

I need to put da 4 items on 4 xyz places and if i use the lever then some floor appears in specifed place ... uhhuh uhhuh

If anyone could write this script,please rep waiting :) ++...
 
Last edited:
Code:
local config = { 
    -- level needed to make the quest
    level = 20, 
 
    -- if players should be able to do the quest unlimited amount of times (not conflicting quest rewards)
    redo = {
        status = true, -- true = unlimited, false = once
        storageValue = 4535 -- only if status is false this will be used
    },
 
    -- vocation requirement, positions and item configuration
    { 
        vocations = {1, 5}, 
        itemId = 2175, 
        playerPos = {x=32677, y=32089, z=8},
        newPos = {x=32671, y=32069, z=8},
        itemPos = {x=32679, y=32089, z=8} 
    }, 
 
    { 
        vocations = {2, 6}, 
        itemId = 2674, 
        playerPos = {x=32669, y=32089, z=8},
        newPos = {x=32672, y=32069, z=8}, 
        itemPos = {x=32667, y=32089, z=8} 
    }, 
 
    { 
        vocations = {3, 7}, 
        itemId = 2455, 
        playerPos = {x=32673, y=32085, z=8},
        newPos = {x=32671, y=32070, z=8}, 
        itemPos = {x=32673, y=32083, z=8} 
    }, 
 
    { 
        vocations = {4, 8}, 
        itemId = 2376, 
        playerPos = {x=32673, y=32093, z=8},
        newPos = {x=32672, y=32070, z=8}, 
        itemPos = {x=32673, y=32094, z=8} 
    } 
} 
 
function onUse(cid)
    local players = {}
    for _, v in ipairs(config) do
 
        v.playerPos.stackpos = 253
        local player = getThingfromPos(v.playerPos).uid
 
        if isPlayer(player) == FALSE then
            return doPlayerSendCancel(cid, "There are not enough players.")
        elseif getPlayerLevel(player) < config.level then
            players.level = true
        elseif isInArray(v.vocations, getPlayerVocation(player)) == FALSE then
            players.vocation = true
        elseif config.redo.status and getPlayerStorageValue(cid, config.redo.storageValue) ~= TRUE then
            players.done = true
        else
            v.itemPos.stackpos = 1
            local item = getThingfromPos(v.itemPos)
 
            if item.itemid ~= v.itemId then
                players.item = true
            else
                table.insert(players, player)
            end
        end
    end
 
    if players.level then
        doPlayerSendCancel(cid, "All players need to be level " .. config.level .. " or above.")
    elseif players.vocation then
        doPlayerSendCancel(cid, "All players must stand on the correct tiles.")
    elseif players.done then
        doPlayerSendCancel(cid, "A player in your team has already done this quest.")
    elseif players.item then
        doPlayerSendCancel(cid, "All items must be on the correct positions.")
    else
        for k, player in ipairs(players) do
            doSendMagicEffect(getCreaturePosition(player), CONST_ME_POFF)
            doTeleportThing(player, config[k].newPos)
            doSendMagicEffect(getCreaturePosition(player), CONST_ME_TELEPORT)
        end
    end
 
    return TRUE
end
 
Writting in quick reply window. don't mind tabbing

Lua:
local Items = {
{pos = {x=1,y=1,z=1}, id = 1234},
{pos = {x=1,y=1,z=1}, id = 1234},
{pos = {x=1,y=1,z=1}, id = 1234},
{pos = {x=1,y=1,z=1}, id = 1234}
}

function onUse(cid)
local items, item = {};
for _,itemData in pairs(Items) do
item = getTileItemById(itemData.pos, itemData.id);
if(item.uid>0)then
table.insert(items, item);
end
item = NULL; -- not sure;
end

if #items == #Items then
--here action when all items are placed
else
--here action that there's no items;
end

return true;
end;
 
I tested it and i've got error (btw. i can't write scripts or even edit it correctly ;/)...

Code:
[Error - LuaScriptInterface::loadFile] data/actions/scripts/gqbridge.lua:11: '}' expected (to close '{' at line 7) near 'function'
[08/01/2011 01:23:30] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/gqbridge.lua)
[08/01/2011 01:23:30] data/actions/scripts/gqbridge.lua:11: '}' expected (to close '{' at line 7) near 'function'

SCRIPT :

Lua:
local Items = {
{pos = {x=1030,y=1325,z=13}, id = 9447},
{pos = {x=1033,y=1323,z=13}, id = 2557},
{pos = {x=1036,y=1325,z=13}, id = 6531},
{pos = {x=1033,y=1329,z=13}, id = 5797}
}
local bridge = {
{pos = {x=1034,y=1263,z=11}
}
 
function onUse(cid)
local items, item = {};
for _,itemData in pairs(Items) do
item = getTileItemById(itemData.pos, itemData.id);
if(item.uid == 2001)then
table.insert(items, item);
end
item = NULL; -- not sure;
end
 
if #items == #Items then
doCreateItem(1284,bridge)  -- i like to write here because i can't fuck up the script :);
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need to put item's on correct positions!") -- gay;
end
 
return true;
end;
 
Now i don't have any errors but when i put the lever and items are on correct positions i have message
"You need to put item's on correct positions!" ;/ ...
 
Lua:
local Items = {
{pos = {x=1030,y=1325,z=13}, id = 9447},
{pos = {x=1033,y=1323,z=13}, id = 2557},
{pos = {x=1036,y=1325,z=13}, id = 6531},
{pos = {x=1033,y=1329,z=13}, id = 5797}
}
local bridge = {
{pos = {x=1034,y=1263,z=11}}
}
 
function onUse(cid)
local items, item = {};
for _,itemData in pairs(Items) do
item = getTileItemById(itemData.pos, itemData.id);
if(item.uid == 2001)then
table.insert(items, item);
end
item = NULL; -- not sure;
end
 
if #items == #Items then
doCreateItem(1284,bridge)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need to put item's on correct positions!")
end
 
return true
end
 
Oh My Satan, something's is still wrong, for prove i've taken a screenshot that show's this action ingame..
saxg.png

Position's are in simple cross, so they are correct and i still recieve error about it..
 
Back
Top