• 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 add storage this script?

God tiburons

New Member
Joined
Dec 18, 2010
Messages
25
Reaction score
0
how can add storage to exaust* Example:
when using a person the lever alos 5 them d the sotrage of exaust 1 day

function onUse(cid, item, fromPosition, itemEx)
local player = Player(cid)
if not player then
return true
end
pos1 = {x = 33201, y = 31475, z = getCreaturePosition(cid).z}
pos2 = {x = 33200, y = 31475, z = getCreaturePosition(cid).z}
pos3 = {x = 33199, y = 31475, z = getCreaturePosition(cid).z}
pos4 = {x = 33198, y = 31475, z = getCreaturePosition(cid).z}
pos5 = {x = 33197, y = 31475, z = getCreaturePosition(cid).z}
if(isPlayer(getTopCreature(pos1).uid)) then
if(isPlayer(getTopCreature(pos2).uid)) then
if(isPlayer(getTopCreature(pos3).uid)) then
if(isPlayer(getTopCreature(pos4).uid)) then
if(isPlayer(getTopCreature(pos5).uid)) then
doSummonCreature("the lord of the lice", {x=33217, y=31454, z=12})
item:transform(item.itemid == 9825 and 9826 or 9825)
doTeleportThing(getTopCreature(pos1).uid, {x = 33208, y = 31434, z = 12})

else
doPlayerSendTextMessage(cid,21,"You need 5 players in certain floors to proceed.")
end
else
doPlayerSendTextMessage(cid,21,"You need 5 players in certain floors to proceed.")
end
else
doPlayerSendTextMessage(cid,21,"You need 5 players in certain floors to proceed.")
end
else
doPlayerSendTextMessage(cid,21,"You need 5 players in certain floors to proceed.")
end
else
doPlayerSendTextMessage(cid,21,"You need 5 players in certain floors to proceed.")
end
return true
end
 
Last edited:
Instead of this..
Lua:
function onUse(cid, item, fromPosition, itemEx)
    local player = Player(cid)
    if not player then
        return true
    end
    pos1 = {x = 33201, y = 31475, z = getCreaturePosition(cid).z} 
    pos2 = {x = 33200, y = 31475, z = getCreaturePosition(cid).z}
    pos3 = {x = 33199, y = 31475, z = getCreaturePosition(cid).z}
    pos4 = {x = 33198, y = 31475, z = getCreaturePosition(cid).z}
    pos5 = {x = 33197, y = 31475, z = getCreaturePosition(cid).z}
    if(isPlayer(getTopCreature(pos1).uid)) then
        if(isPlayer(getTopCreature(pos2).uid)) then
            if(isPlayer(getTopCreature(pos3).uid)) then
                if(isPlayer(getTopCreature(pos4).uid)) then
                    if(isPlayer(getTopCreature(pos5).uid)) then
                        doSummonCreature("the lord of the lice", {x=33217, y=31454, z=12})
                        item:transform(item.itemid == 9825 and 9826 or 9825) 
                        doTeleportThing(getTopCreature(pos1).uid, {x = 33208, y = 31434, z = 12})
                    else
                        doPlayerSendTextMessage(cid,21,"You need 5 players in certain floors to proceed.")
                    end
                else
                    doPlayerSendTextMessage(cid,21,"You need 5 players in certain floors to proceed.")
                end
            else
                doPlayerSendTextMessage(cid,21,"You need 5 players in certain floors to proceed.")
            end
        else
            doPlayerSendTextMessage(cid,21,"You need 5 players in certain floors to proceed.")
        end
    else
        doPlayerSendTextMessage(cid,21,"You need 5 players in certain floors to proceed.")
    end
    return true
end

use a table and loops. like this.
Lua:
local positions = {
    {33201, 31475} 
    {33200, 31475}
    {33199, 31475}
    {33198, 31475}
    {33197, 31475}
}

function onUse(cid, item, fromPosition, itemEx)
    local player = Player(cid)
    if not player then
        return true
    end
    local pos_z = getCreaturePosition(cid).z
    for i = 1, #positions do
        if not isPlayer(getTopCreature({x = positions[i][1], y = positions[i][2], z = pos_z}).uid) then
            doPlayerSendTextMessage(cid, 21, "You need 5 players in certain floors to proceed.")
            return true
        end
    end
    doSummonCreature("the lord of the lice", {x = 33217, y = 31454, z = 12})
    item:transform(item.itemid == 9825 and 9826 or 9825) 
    doTeleportThing(getTopCreature({x = positions[1][1], y = positions[1][2], z = pos_z}).uid, {x = 33208, y = 31434, z = 12})
    return true
end

It should work just like your above code, but it looks a fair bit cleaner then the multiple nested if statements.

I didn't add anything to the script, so your original post still needs to be answered.
Just figured I'd show you how to make these kinds of scripts shorter and cleaner looking.

Cheers.
 
Back
Top