• 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 Need use with Shovel/Pick not only use!

maikons

Member
Joined
Aug 1, 2015
Messages
227
Reaction score
16
I have this scripts working, but i need conditional change to:

OnUse with shovel
Code:
function onUse(cid, item, frompos, item2, topos)
   local storage = 51006
   if item.uid == 7662 then
    queststatus = getPlayerStorageValue(cid,storage)
    if queststatus == -1 then
      doPlayerSendTextMessage(cid,22,"You have found an acient amulet. Strange engravings cover it. Maybe Morris can make them out.")
      setPlayerStorageValue(cid,storage,1)
    else
      doPlayerSendTextMessage(cid,22,"It is empty.")
    end
   end
end

OnUse with pick
Code:
function onUse(cid, item, frompos, item2, topos)
   if item.uid == 7663 then
    local pos = {x= 533, y=746, z=8}
    doTeleportThing(cid, pos)
   end
end
 
I think your function is old :x
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
To use with Shovel and Pick.. You'd have to edit/add to the Shovel and Pick files to accommodate your quest(s).
Code:
if itemEx.uid == 7662 then
    local storage = 51006
    queststatus = getPlayerStorageValue(cid, storage)
    if queststatus == -1 then
        doPlayerSendTextMessage(cid, 22, "You have found an acient amulet. Strange engravings cover it. Maybe Morris can make them out.")
        setPlayerStorageValue(cid, storage, 1)
    else
        doPlayerSendTextMessage(cid,22,"It is empty.")
    end
    return true
end
Code:
if item.uid == 7663 then
    local pos = {x = 533, y =746, z = 8}
    doTeleportThing(cid, pos)
    return true
end
 
Code:
local action = {
    [7662] = 
        function(cid, item)
            local storage = getPlayerStorageValue(cid, 51006)
            if queststatus == -1 then
                doPlayerSendTextMessage(cid, 22, "You have found an acient amulet. Strange engravings cover it. Maybe Morris can make them out.")
                setPlayerStorageValue(cid, storage, 1)
            else
                doPlayerSendTextMessage(cid, 22, "It is empty.")
            end
        end,
    [7663] = 
        function(cid, item)
            if item.uid == 7663 then
                local pos = {x = 533, y = 746, z = 8}
                doTeleportThing(cid, pos)
            end
        end
    
}

function onUse(cid, item, frompos, item2, topos)
    action[item.uid](cid, item)
    return true
end
 
Last edited:
I tried to put in my shovel.lua / pick.lua and try to use and nothing happen...

shovel.lua
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

  local storage
   if item.uid == 7662 then
     storage = 51006
     queststatus = getPlayerStorageValue(cid,storage)
     if queststatus == -1 then
       doPlayerSendTextMessage(cid,22,"You have found an acient amulet. Strange engravings cover it. Maybe Morris can make them out.")
       setPlayerStorageValue(cid,storage,1)
     else
       doPlayerSendTextMessage(cid,22,"It is empty.")
     end
   end

   if(isInArray(HOLES, itemEx.itemid)) then
     if(itemEx.itemid ~= 8579) then
       itemEx.itemid = itemEx.itemid + 1
     else
       itemEx.itemid = 8585
     end

     doTransformItem(itemEx.uid, itemEx.itemid)
     doDecayItem(itemEx.uid)
     return true
   elseif(SAND_HOLES[itemEx.itemid] ~= nil) then
     doSendMagicEffect(toPosition, CONST_ME_POFF)
     doTransformItem(itemEx.uid, SAND_HOLES[itemEx.itemid])

     doDecayItem(itemEx.uid)
     return true
   elseif(itemEx.itemid == SAND and not isRookie(cid)) then
     local rand = math.random(1, 100)
     if(rand >= 1 and rand <= 5) then
       doCreateItem(ITEM_SCARAB_COIN, 1, toPosition)
     elseif(rand > 85) then
       doCreateMonster("Scarab", toPosition, false)
     end

     doSendMagicEffect(toPosition, CONST_ME_POFF)
     return true
   end

   return false
end

pick.lua
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   local itemGround = getThingFromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z + 1, stackpos = STACKPOS_GROUND})
   if(isInArray(SPOTS, itemGround.itemid) and isInArray({354, 355}, itemEx.itemid)) then
     doTransformItem(itemEx.uid, 392)
     doDecayItem(itemEx.uid)

     doSendMagicEffect(toPosition, CONST_ME_POFF)
     return true
   end

   if(itemEx.itemid == 7200) then
     doTransformItem(itemEx.uid, 7236)
     doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
     return true
   end

   if item.uid == 7663 then
    local pos = {x= 533, y=746, z=8}
    doTeleportThing(cid, pos)
   end

   return false
end
 
I tried to put in my shovel.lua / pick.lua and try to use and nothing happen...

shovel.lua
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

  local storage
   if item.uid == 7662 then
     storage = 51006
     queststatus = getPlayerStorageValue(cid,storage)
     if queststatus == -1 then
       doPlayerSendTextMessage(cid,22,"You have found an acient amulet. Strange engravings cover it. Maybe Morris can make them out.")
       setPlayerStorageValue(cid,storage,1)
     else
       doPlayerSendTextMessage(cid,22,"It is empty.")
     end
   end

   if(isInArray(HOLES, itemEx.itemid)) then
     if(itemEx.itemid ~= 8579) then
       itemEx.itemid = itemEx.itemid + 1
     else
       itemEx.itemid = 8585
     end

     doTransformItem(itemEx.uid, itemEx.itemid)
     doDecayItem(itemEx.uid)
     return true
   elseif(SAND_HOLES[itemEx.itemid] ~= nil) then
     doSendMagicEffect(toPosition, CONST_ME_POFF)
     doTransformItem(itemEx.uid, SAND_HOLES[itemEx.itemid])

     doDecayItem(itemEx.uid)
     return true
   elseif(itemEx.itemid == SAND and not isRookie(cid)) then
     local rand = math.random(1, 100)
     if(rand >= 1 and rand <= 5) then
       doCreateItem(ITEM_SCARAB_COIN, 1, toPosition)
     elseif(rand > 85) then
       doCreateMonster("Scarab", toPosition, false)
     end

     doSendMagicEffect(toPosition, CONST_ME_POFF)
     return true
   end

   return false
end

I want this shovel script too...
 
Code:
if item.uid == 7662 then
in this snippet, shouldn't item.uid be itemEx.uid? if you're checking unique ID of the item shovel or pick were used ON.
 
dum de dum
-- Set the ActionID on the Map Editor, on the item you want the pick/shovel to be used on.
-- 45001, 45002 respectively.
-- or w/e you change them to.
-- in the event you get an weird error, change "aid" to "actionid"
-- NOTE: This can either be used as an example or as-is. I used @maikons shovel/pick scripts as the base, and modified from there.
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

    if itemEx.aid == 45001 then
        local storage = 51006
        queststatus = getPlayerStorageValue(cid, storage)
        if queststatus == -1 then
            doPlayerSendTextMessage(cid, 22, "You have found an ancient amulet. Strange engravings cover it. Maybe Morris can make them out.")
            -- give item????
            setPlayerStorageValue(cid, storage, 1)
        else
            doPlayerSendTextMessage(cid,22,"It is empty.")
        end
        return true
    end

    if(isInArray(HOLES, itemEx.itemid)) then
        if(itemEx.itemid ~= 8579) then
            itemEx.itemid = itemEx.itemid + 1
        else
            itemEx.itemid = 8585
        end

        doTransformItem(itemEx.uid, itemEx.itemid)
        doDecayItem(itemEx.uid)
        return true
    elseif(SAND_HOLES[itemEx.itemid] ~= nil) then
        doSendMagicEffect(toPosition, CONST_ME_POFF)
        doTransformItem(itemEx.uid, SAND_HOLES[itemEx.itemid])

        doDecayItem(itemEx.uid)
        return true
    elseif(itemEx.itemid == SAND and not isRookie(cid)) then
        local rand = math.random(1, 100)
        if(rand >= 1 and rand <= 5) then
            doCreateItem(ITEM_SCARAB_COIN, 1, toPosition)
        elseif(rand > 85) then
            doCreateMonster("Scarab", toPosition, false)
        end

        doSendMagicEffect(toPosition, CONST_ME_POFF)
        return true
    end

    return false
end
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

    if itemEx.aid == 45002 then
        local pos = {x = 533, y = 746, z = 8}
        doTeleportThing(cid, pos)
        -- tell player something????
    end

    local itemGround = getThingFromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z + 1, stackpos = STACKPOS_GROUND})
    if(isInArray(SPOTS, itemGround.itemid) and isInArray({354, 355}, itemEx.itemid)) then
        doTransformItem(itemEx.uid, 392)
        doDecayItem(itemEx.uid)

        doSendMagicEffect(toPosition, CONST_ME_POFF)
        return true
    end

    if(itemEx.itemid == 7200) then
        doTransformItem(itemEx.uid, 7236)
        doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
        return true
    end

    return false
end
 
dum de dum
-- Set the ActionID on the Map Editor, on the item you want the pick/shovel to be used on.
-- 45001, 45002 respectively.
-- or w/e you change them to.
-- in the event you get an weird error, change "aid" to "actionid"
-- NOTE: This can either be used as an example or as-is. I used @maikons shovel/pick scripts as the base, and modified from there.
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

    if itemEx.aid == 45001 then
        local storage = 51006
        queststatus = getPlayerStorageValue(cid, storage)
        if queststatus == -1 then
            doPlayerSendTextMessage(cid, 22, "You have found an ancient amulet. Strange engravings cover it. Maybe Morris can make them out.")
            -- give item????
            setPlayerStorageValue(cid, storage, 1)
        else
            doPlayerSendTextMessage(cid,22,"It is empty.")
        end
        return true
    end

    if(isInArray(HOLES, itemEx.itemid)) then
        if(itemEx.itemid ~= 8579) then
            itemEx.itemid = itemEx.itemid + 1
        else
            itemEx.itemid = 8585
        end

        doTransformItem(itemEx.uid, itemEx.itemid)
        doDecayItem(itemEx.uid)
        return true
    elseif(SAND_HOLES[itemEx.itemid] ~= nil) then
        doSendMagicEffect(toPosition, CONST_ME_POFF)
        doTransformItem(itemEx.uid, SAND_HOLES[itemEx.itemid])

        doDecayItem(itemEx.uid)
        return true
    elseif(itemEx.itemid == SAND and not isRookie(cid)) then
        local rand = math.random(1, 100)
        if(rand >= 1 and rand <= 5) then
            doCreateItem(ITEM_SCARAB_COIN, 1, toPosition)
        elseif(rand > 85) then
            doCreateMonster("Scarab", toPosition, false)
        end

        doSendMagicEffect(toPosition, CONST_ME_POFF)
        return true
    end

    return false
end
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

    if itemEx.aid == 45002 then
        local pos = {x = 533, y = 746, z = 8}
        doTeleportThing(cid, pos)
        -- tell player something????
    end

    local itemGround = getThingFromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z + 1, stackpos = STACKPOS_GROUND})
    if(isInArray(SPOTS, itemGround.itemid) and isInArray({354, 355}, itemEx.itemid)) then
        doTransformItem(itemEx.uid, 392)
        doDecayItem(itemEx.uid)

        doSendMagicEffect(toPosition, CONST_ME_POFF)
        return true
    end

    if(itemEx.itemid == 7200) then
        doTransformItem(itemEx.uid, 7236)
        doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
        return true
    end

    return false
end


Ty so much! It's solved!
 
Back
Top