• 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 Problem with item.uid and lua tables

Joined
Jul 18, 2014
Messages
193
Solutions
2
Reaction score
15
Hi, i'm trying to create a script for my quest. This script consist in: you have to get on a throne to get a storage and with that can pass through an invisible portal.
In console doesnt appear any mistake or something and in game it doesnt work.

This is my script:
Code:
function onStepIn (cid, item, position, lastPosition)

local thrones = {

[9632] = {storage = 96320},
[9633] = {storage = 96321},
[9634] = {storage = 96322},
[9635] = {storage = 96323}

}

local teleports = {
[9732] = {newPos = {x = 32425, y = 32312, z = 15}, storage = 96320},
[9733] = {newPos = {x = 32457, y = 32316, z = 15}, storage = 96321},
[9734] = {newPos = {x = 32476, y = 32310, z = 15}, storage = 96322},
[9735] = {newPos = {x = 32497, y = 32309, z = 15}, storage = 96323}
}
local v = thrones[item.uid]
local vv = teleports[item.uid]
if (v) then
    if getPlayerStorageValue(cid, thrones[item.uid].storage) == -1 then
        setPlayerStorageValue(cid, thrones[item.uid].storage, 1)
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
        doCreatureSay(cid, "Muahaha...", TALKTYPE_ORANGE_1)
    end
end

if (vv) then
    if getPlayerStorageValue(cid, teleports[item.uid].storage) == 1 then
        doTeleportThing(cid, teleports[item.uid].newPos)
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
    else
        doTeleportThing(cid, lastPosition)
        doCreatureSay(cid, "You don't have the throne bless.", TALKTYPE_ORANGE_1)
    end
end
return true
end

And i put this on movements.xml

Code:
    <movement event="StepIn" fromuid="9632" touid="9635" script="exceed quest/exceedsteps.lua"/>
    <movement event="StepIn" fromuid="9732" touid="9735" script="exceed quest/exceedsteps.lua"/>

Please help. Thanks!.
 
Code:
    local thrones = {9632, 9633, 9634, 9635}
    local teleporters = {
        [9732] = { {x = 32425, y = 32312, z = 15}, thrones[1] * 10 },
        [9733] = { {x = 32457, y = 32316, z = 15}, thrones[2] * 10 },
        [9734] = { {x = 32476, y = 32310, z = 15}, thrones[3] * 10 },
        [9735] = { {x = 32497, y = 32309, z = 15}, thrones[4] * 10 }
    }
 
    function isInTable(array, search)
        if type(array) == 'table' then
            for i, value in pairs(array) do
                if i == search then
                    return true, value[1], value[2]
                end
            end
        end
        return false
    end

    function onStepIn (cid, item, position, lastPosition)
        if isInArray(thrones, item.uid) then
            if getPlayerStorageValue(cid, item.uid * 10) < 1 then
                setPlayerStorageValue(cid, item.uid * 10, 1)
                doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
                doCreatureSay(cid, "Muahaha...", TALKTYPE_ORANGE_1)
                return true
            end
        end
        local condition, pos, storage = isInTable(teleporters, item.uid)
        if condition then
            if getPlayerStorageValue(cid, storage) == 1 then
                doTeleportThing(cid, pos)
                doSendMagicEffect(position, CONST_ME_TELEPORT)
            else
                doTeleportThing(cid, lastPosition)
                doCreatureSay(cid, "You don't have the throne bless.", TALKTYPE_ORANGE_1)
            end
        end
        return true
    end
 
Last edited:
Code:
    local thrones = {9632, 9633, 9634, 9635}
    local teleporters = {
        [9732] = { {x = 32425, y = 32312, z = 15}, thrones[1] * 10 },
        [9733] = { {x = 32457, y = 32316, z = 15}, thrones[2] * 10 },
        [9734] = { {x = 32476, y = 32310, z = 15}, thrones[3] * 10 },
        [9735] = { {x = 32497, y = 32309, z = 15}, thrones[4] * 10 }
    }

    function isInTable(array, search)
        if type(array) == 'table' then
            for i, value in pairs(array) do
                if i == search then
                    return true, value[1], value[2]
                end
            end
        end
        return false
    end

    function onStepIn (cid, item, position, lastPosition)
        if isInArray(thrones, item.uid) then
            if getPlayerStorageValue(cid, item.uid * 10) < 1 then
                setPlayerStorageValue(cid, item.uid * 10, 1)
                doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
                doCreatureSay(cid, "Muahaha...", TALKTYPE_ORANGE_1)
                return true
            end
        end
        local condition, pos, storage = isInTable(teleporters, item.uid)
        if condition then
            if getPlayerStorageValue(cid, storage) == 1 then
                doTeleportThing(cid, pos)
                doSendMagicEffect(position, CONST_ME_TELEPORT)
            else
                doTeleportThing(cid, lastPosition)
                doCreatureSay(cid, "You don't have the throne bless.", TALKTYPE_ORANGE_1)
            end
        end
        return true
    end

Thanks for take the time to make this :D
 
Back
Top