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

[Warning - Actions::registerEvent] Duplicate registered item

Luiz Oliveira

New Member
Joined
May 15, 2014
Messages
8
Reaction score
0
Hello everybody! I'm pretty new with scripts and how they work... Everytime I run my server I get this message:
"[Warning - Actions::registerEvent] Duplicate registered item with id: 5710
[Warning - Actions::registerEvent] Duplicate registered item with id: 2554
"

I do understand what it means, and I got 2 .lua files using the IDs above: shovel.lua and leech.lua.
I don't know how to merge both scripts into one simple .lua file, and that's why I'm here looking for some help.
ID: 5710 (Shovel)
ID: 2554 (Light Shovel)

Here's my leech.lua script:

local config = {
waters = {18580, 18581, 18582, 18583, 18584, 18585, 18586, 18587, 18588, 18589, 18590, 20230 , 18593 , 18594 , 18595 , 18596 , 18597 , 18598 , 18599 , 18600 , 18601 , 18602 , 18603 , 18604}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
if(isInArray(config.waters, itemEx.itemid)) and (math.random(1,40) <= 1) then
doPlayerAddItem(cid, 20138)
doCreatureSay(cid, "You Found a Leech!", TALKTYPE_ORANGE_1)
return true
elseif(isInArray(config.waters, itemEx.itemid)) and (math.random(7,10) <= 7) then
doPlayerAddItem(cid, 2817)
doCreatureSay(cid, "Again dead snake?! Again? I guess I'll have to dig more!", TALKTYPE_ORANGE_1)
return true
elseif(isInArray(config.waters, itemEx.itemid)) and (math.random(2,10) <= 2) then
doPlayerAddItem(cid, 2817)
doCreatureSay(cid, "You Found a Small Diamond!", TALKTYPE_ORANGE_1)
return true
end

return true
end

And here's my shovel.lua script:

local holes = {468, 481, 483}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if isInArray(holes, itemEx.itemid) then
local iEx = Item(itemEx.uid)
iEx:transform(itemEx.itemid + 1)
iEx:decay()
elseif itemEx.itemid == 231 then
local rand = math.random(1, 100)
if rand == 1 then
Game.createItem(2159, 1, toPosition)
elseif rand > 95 then
Game.createMonster("Scarab", toPosition)
end
toPosition:sendMagicEffect(CONST_ME_POFF)
else
return false
end

return true
end


The leech.lua file is being used to get the mount item (water buffalo). I already tried to merge both scripts into one .lua file, but it doesn't work.
Can you guys help me out? Best regards,
Luiz Oliveira
 
You can have as many items as you want merged into 1 action script.
You can check which item is being used with item.id.
Since 'item' (ID of item that's been used) is a parameter of the onUse function, you just need to do the check like this:

function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.id == 2554
--- something that happens when you use a shovel (ID 2554)
elseif item.id == 2120
--- something that happens when you use a rope (ID 2120)
end
return true
end


Based on 0.3.6
 
Dude, I mean it when I say I don't understand these languages, lol. However, after a great time working on it, I finally got it working pretty fine.
Here's my shovel.lua file (working with holes, swamp and sand for scarab coins):
PS.: Is there any error? I mean, it's working for me, but I don't know if it's gonna work for everyone.

Code:
local holes = {468, 481, 483}
local config = {
    waters = {18580, 18581, 18582, 18583, 18584, 18585, 18586, 18587, 18588, 18589, 18590, 20230 , 18593 , 18594 , 18595 , 18596 , 18597 , 18598 , 18599 , 18600 , 18601 , 18602 , 18603 , 18604}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
   if isInArray(holes, itemEx.itemid) then
       local iEx = Item(itemEx.uid)
        iEx:transform(itemEx.itemid + 1)
        iEx:decay()
    elseif(isInArray(config.waters, itemEx.itemid)) and (math.random(1,40) <= 1) then
    doPlayerAddItem(cid, 20138)
    doCreatureSay(cid, "You Found a Leech!", TALKTYPE_ORANGE_1)
    return true
    elseif(isInArray(config.waters, itemEx.itemid)) and (math.random(7,10) <= 7) then
    doPlayerAddItem(cid, 2817)
    doCreatureSay(cid, "Again dead snake?! Again? I guess I'll have to dig more!", TALKTYPE_ORANGE_1)
    return true
   elseif(isInArray(config.waters, itemEx.itemid)) and (math.random(2,10) <= 2) then
    doPlayerAddItem(cid, 2817)
    doCreatureSay(cid, "You Found a Small Diamond!", TALKTYPE_ORANGE_1)
    return true
   elseif itemEx.itemid == 231 then
        local rand = math.random(1, 100)
        if rand == 1 then
            Game.createItem(2159, 1, toPosition)
       elseif rand > 95 then
            Game.createMonster("Scarab", toPosition)
       end
        toPosition:sendMagicEffect(CONST_ME_POFF)
   else
        return false
    end

    return true
end
 
Last edited:
Code:
local config = {
    holes = {468, 481, 483},
    waters = {18580, 18581, 18582, 18583, 18584, 18585, 18586, 18587, 18588, 18589, 18590, 20230 , 18593 , 18594 , 18595 , 18596 , 18597 , 18598 , 18599 , 18600 , 18601 , 18602 , 18603 , 18604}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local p = Player(cid)
    if(isInArray(config.holes, itemEx.itemid)) then
        local iEx = Item(itemEx.uid)
        iEx:transform(itemEx.itemid + 1)
        iEx:decay()
    elseif(isInArray(config.waters, itemEx.itemid) and math.random(1,40) <= 1) then
        p:addItem(20138)
        p:say("You Found a Leech!", TALKTYPE_ORANGE_1)
        return true
    elseif(isInArray(config.waters, itemEx.itemid) and math.random(7,10) <= 7) then
        p:addItem(2817)
        p:say("Again dead snake?! Again? I guess I'll have to dig more!", TALKTYPE_ORANGE_1)
        return true
    elseif(isInArray(config.waters, itemEx.itemid) and math.random(2,10) <= 2) then
        p:addItem(2817)
        p:say("You Found a Small Diamond!", TALKTYPE_ORANGE_1)
        return true
    elseif(itemEx.itemid == 231) then
        local rand = math.random(1, 100)
        if(rand == 1) then
            Game.createItem(2159, 1, toPosition)
        elseif rand > 95 then
            Game.createMonster("Scarab", toPosition)
        end
        toPosition:sendMagicEffect(CONST_ME_POFF)
    else
        return false
    end
return true
end

Use [.code] [/.code] without the dots.
 
Back
Top