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

darcioantonio

www.adventurerpg.com.br
Joined
Jul 30, 2013
Messages
165
Solutions
1
Reaction score
4
Location
Brasil
Twitch
darcio_
YouTube
UCEXCOEw_dYchojHNz
I Need check more itens.


I did this script but it only checks if it is 1 item just wanted to check + 1 an example of item 2152 wanted it 22 items

Lua:
function onUse(cid)

local sqm = {x = 975, y = 844, z = 6}
local Bancada = 1642
local Item1 = 2152

if getTileItemById(sqm, Bancada).uid >= 1 and getTileItemById(sqm, Item1).uid >= 2  then
doSendMagicEffect(sqm, 30)
end
end
 
You still didn't say your version so this may not work for you. But it's something along the lines of this.

Lua:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local pos = {x = 975, y = 844, z = 6}
    local banana = INSERT BANANA ID
    local milk = INSERT MILK ID
    local mace = INSERT MACE ID
   
    local tile = Tile(pos)
    if tile then
        if tile:getItemCountById(banana) == 2 and tile:getItemCountById(milk) == 2 and tile:getItemCountById(mace) == 2 then
            pos:doSendMagicEffect(30)
            return true
        end
    end
    return true
end
 
You still didn't say your version so this may not work for you. But it's something along the lines of this.

Lua:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local pos = {x = 975, y = 844, z = 6}
    local banana = INSERT BANANA ID
    local milk = INSERT MILK ID
    local mace = INSERT MACE ID
 
    local tile = Tile(pos)
    if tile then
        if tile:getItemCountById(banana) == 2 and tile:getItemCountById(milk) == 2 and tile:getItemCountById(mace) == 2 then
            pos:doSendMagicEffect(30)
            return true
        end
    end
    return true
end
Milk isn't the best example.. as liquids use the itemID + subID.
I Need check more itens.


I did this script but it only checks if it is 1 item just wanted to check + 1 an example of item 2152 wanted it 22 items

Lua:
function onUse(cid)

local sqm = {x = 975, y = 844, z = 6}
local Bancada = 1642
local Item1 = 2152

if getTileItemById(sqm, Bancada).uid >= 1 and getTileItemById(sqm, Item1).uid >= 2  then
doSendMagicEffect(sqm, 30)
end
end
Honestly, this should work as-is.
Your just missing a return true.. I guess?
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)

    local sqm = {x = 975, y = 844, z = 6}
    local Bancada = 1642
    local Item1 = 2152

    if getTileItemById(sqm, Bancada).uid >= 1 and getTileItemById(sqm, Item1).uid >= 2  then
        doSendMagicEffect(sqm, 30)
    end
    return true
end
 
The problem that the script so does not identify the values if it is 3 items or 2 or 1 it will do the effect is to do in the script with 2 or more items and not with 1.

Lua:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local pos = {x = 975, y = 844, z = 6}
    local banana = 7732
    local tile = Tile(pos)
    if tile then
        if tile:getItemCountById(banana) == 2 then
            pos:doSendMagicEffect(30)
            return true
        end
    end
    return true
end


[17:15:12.018] [Error - Action Interface]
[17:15:12.019] data/actions/scripts/Forja/forja.lua:eek:nUse
[17:15:12.019] Description:
[17:15:12.020] data/actions/scripts/Forja/forja.lua:41: attempt to call global 'Tile' (a nil value)
[17:15:12.021] stack traceback:
[17:15:12.022] data/actions/scripts/Forja/forja.lua:41: in function <data/actions/scripts/Forja/forja.lua:37>

UP
 
Last edited by a moderator:
THEX @Xikini
Lua:
local xyz = {x = 975, y = 844, z = 6} -- [ Cordenada ]
local Bancada = 1642 -- [ Bancada ]
local Item1 = 2152

function onUse(cid)

if getItemCountFromPosition(Bancada, xyz) == 1 and
   getItemCountFromPosition(Item1, xyz) == 3 then
   doSendMagicEffect(xyz, 30)   
end
end


function getItemCountFromPosition(item, pos)
    local item_pos = {x = pos.x, y = pos.y, z = pos.z}
    local item_count = 0
    for i = 1, 255 do
        local check_pos = {x = item_pos.x, y = item_pos.y, z = item_pos.z, stackpos = i}
        if getThingFromPos(check_pos).itemid <= 0 then
            break
        elseif getThingFromPos(check_pos).itemid == item then
            if isItemStackable(getThingFromPos(check_pos).itemid) == true then
                item_count = item_count + getThingFromPos(check_pos).type
            else
                item_count = item_count + 1
            end
        end
    end
    return item_count
end

Nice Script THX :D
 
Back
Top