• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

watering can

oliverpadron86

New Member
Joined
Mar 1, 2018
Messages
40
Reaction score
0
function onUse(cid, item, fromPosition, itemEx, toPosition)
if (itemEx.itemid == 3984) then
doTransformItem(itemEx.uid, 3985)
doSendMagicEffect(toPosition, 5)
return true

elseif (itemEx.itemid == 2781) then
doTransformItem(itemEx.uid, 2782)
doSendMagicEffect(toPosition, 5)
return true


elseif (itemEx.itemid == 2737) or (itemEx.itemid == 2738) then
doTransformItem(itemEx.uid, 2739)
doSendMagicEffect(toPosition, 5)
return true


elseif (itemEx.itemid == 5463) or (itemEx.itemid == 5464) then
doTransformItem(itemEx.uid, 5466)
doSendMagicEffect(toPosition, 5)
return true

else
doPlayerSendCancel(cid, "You cannot use the watering can with this!")
end
return true
end

How i can make this script grow the grass even if there is a player above the cut grass?
 
Last edited by a moderator:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if (itemEx.itemid == 3984) then
doTransformItem(itemEx.uid, 3985)
doSendMagicEffect(toPosition, 5)
return true

elseif (itemEx.itemid == 2781) then
doTransformItem(itemEx.uid, 2782)
doSendMagicEffect(toPosition, 5)
return true


elseif (itemEx.itemid == 2737) or (itemEx.itemid == 2738) then
doTransformItem(itemEx.uid, 2739)
doSendMagicEffect(toPosition, 5)
return true


elseif (itemEx.itemid == 5463) or (itemEx.itemid == 5464) then
doTransformItem(itemEx.uid, 5466)
doSendMagicEffect(toPosition, 5)
return true

else
doPlayerSendCancel(cid, "You cannot use the watering can with this!")
end
return true
end

How i can make this script grow the grass even if there is a player above the cut grass?
LUA:
local t = {
    [3984] = 3985,
    [2781] = 2782,
    [{2737, 2738}] = 2739,
    [{5463, 5464}] = 5466
}

local regrow = 5

function regrowInMinutes(time, itemid, pos)
    pos.stackpos = 0
    addEvent(doTransformItem, (1000 * 60) * time, getThingFromPos(pos).uid, itemid)
end

function x(itemEx, cid, pos)
    local n = t[itemEx]
    if not n then
        n = {}
        for k, v in pairs(t) do
            if type(k) == "table" then
                for _, e in pairs(k) do
                    n[e] = v
                end
            else
                n[k] = v
            end
        end
        n = n[itemEx]
    end

    if n then
        doTransformItem(itemEx.uid, n)
        doSendMagicEffect(pos, 5)
        regrowInMinutes(regrow, itemEx.itemid, pos)
        return true
    end
    doPlayerSendCancel(cid, "You cannot use the watering can with this!")
    return true
end

function

function onUse(cid, item, fromPosition, itemEx, toPosition)
    return x(itemEx, cid, toPosition)
end

Just noticed I used the same letter for the method as I did the table, corrected.
 
Last edited:
LUA:
local t = {
    [3984] = 3985,
    [2781] = 2782,
    [{2737, 2738}] = 2739,
    [{5463, 5464}] = 5466
}

local regrow = 5

function regrowInMinutes(time, itemid, pos)
    pos.stackpos = 0
    addEvent(doTransformItem, (1000 * 60) * time, getThingFromPos(pos).uid, itemid)
end

function x(itemEx, cid, pos)
    local n = t[itemEx]
    if not n then
        n = {}
        for k, v in pairs(t) do
            if type(k) == "table" then
                for _, e in pairs(k) do
                    n[e] = v
                end
            else
                n[k] = v
            end
        end
        n = n[itemEx]
    end

    if n then
        doTransformItem(itemEx.uid, n)
        doSendMagicEffect(pos, 5)
        regrowInMinutes(regrow, itemEx.itemid, pos)
        return true
    end
    doPlayerSendCancel(cid, "You cannot use the watering can with this!")
    return true
end

function

function onUse(cid, item, fromPosition, itemEx, toPosition)
    return x(itemEx, cid, toPosition)
end

Just noticed I used the same letter for the method as I did the table, corrected.



I GOT THIS ERROR Q.Q
[27/06/2018 17:06:15] [Error - LuaScriptInterface::loadFile] data/actions/scripts/tools/watercan.lua:43: '<name>' expected near 'function'
[27/06/2018 17:06:15] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/tools/watercan.lua)
[27/06/2018 17:06:15] data/actions/scripts/tools/watercan.lua:43: '<name>' expected near 'function'
 
I GOT THIS ERROR Q.Q
[27/06/2018 17:06:15] [Error - LuaScriptInterface::loadFile] data/actions/scripts/tools/watercan.lua:43: '<name>' expected near 'function'
[27/06/2018 17:06:15] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/tools/watercan.lua)
[27/06/2018 17:06:15] data/actions/scripts/tools/watercan.lua:43: '<name>' expected near 'function'
Oh well
 
Back
Top