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

NO Use item in BP

carlinhous1996

New Member
Joined
Apr 14, 2022
Messages
54
Reaction score
3
How do I make this script unable to use the item from within the bp.
and how do I only be able to use it if it is on top of an item with X action?

THANK YOU ALL FROM NOW!
when I use it inside the bp it does not come out and this error appears
[Error - Action Interface]
data/actions/scripts/npcfer.lua:eek:nUse
Description:
(luaDoCreateNpc) Cannot create npc: Cooking
local id = 11391 -- ItemId da Estatua
local npc = "Cooking" -- Nome do monsto a ser sumonado

function onUse(cid, item, fromPosition, itemEx, toPosition)
doRemoveItem(item.uid, 1)
doCreateNpc(npc, toPosition)

return true
end
 
Last edited:
Cannot create npc: Cooking
Do you have this NPC on your server data?
Post automatically merged:

I don't know if you want to summon an "npc" or a "monster", so I added both options for you.
Lua:
local creatureType = "monster" -- Choose betwen 'monster' or 'npc'
local creatureName = "Cooking" -- This is the name of the creature that will be summoned

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if creatureType == "monster" then
        doCreateMonster(creatureName, toPosition)
    elseif creatureType == "npc" then
        doCreateNpc(creatureName, toPosition)
    else
        print("creatureType: Choose one of the two existing options: 'monster' or 'npc'.")
    end

    doRemoveItem(item.uid, 1)

    return true
end
Post automatically merged:

Added an option if you need the item to be with the player for it to work.
Lua:
local config = {
    removeFromPlayer = true, -- If it is set to 'true' it will remove the item from the player, otherwise it will remove the item from where it is being used
    itemId = 11391,
    creatureType = "monster", -- Choose between 'monster' or 'npc'
    creatureName = "Cooking", -- This is the name of the creature that will be summoned
}

--[[
    If you don't understand programming, please don't change the lines below.
]]
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if config.creatureType == "monster" then
        doCreateMonster(config.creatureName, toPosition)
    elseif config.creatureType == "npc" then
        doCreateNpc(config.creatureName, toPosition)
    else
        print("creatureType: Choose one of the two existing options: 'monster' or 'npc'.")
    end

    if config.removeFromPlayer then
        if getPlayerItemCount(cid, config.itemId) >= 1 then
            doPlayerRemoveItem(cid, config.itemId, 1)
        end
    else
        doRemoveItem(item.uid, 1)
    end

    return true
end
 
Last edited:
Do you have this NPC on your server data?
Post automatically merged:

I don't know if you want to summon an "npc" or a "monster", so I added both options for you.
Lua:
local creatureType = "monster" -- Choose betwen 'monster' or 'npc'
local creatureName = "Cooking" -- This is the name of the creature that will be summoned

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if creatureType == "monster" then
        doCreateMonster(creatureName, toPosition)
    elseif creatureType == "npc" then
        doCreateNpc(creatureName, toPosition)
    else
        print("creatureType: Choose one of the two existing options: 'monster' or 'npc'.")
    end

    doRemoveItem(item.uid, 1)

    return true
end
Post automatically merged:

Added an option if you need the item to be with the player for it to work.
Lua:
local config = {
    removeFromPlayer = true, -- If it is set to 'true' it will remove the item from the player, otherwise it will remove the item from where it is being used
    itemId = 11391,
    creatureType = "monster", -- Choose between 'monster' or 'npc'
    creatureName = "Cooking", -- This is the name of the creature that will be summoned
}

--[[
    If you don't understand programming, please don't change the lines below.
]]
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if config.creatureType == "monster" then
        doCreateMonster(config.creatureName, toPosition)
    elseif config.creatureType == "npc" then
        doCreateNpc(config.creatureName, toPosition)
    else
        print("creatureType: Choose one of the two existing options: 'monster' or 'npc'.")
    end

    if config.removeFromPlayer then
        if getPlayerItemCount(cid, config.itemId) >= 1 then
            doPlayerRemoveItem(cid, config.itemId, 1)
        end
    else
        doRemoveItem(item.uid, 1)
    end

    return true
end
Good morning, thank you for your attention and help.
It's an npc, I already have it on my server.
I will test
Post automatically merged:

I'm using this
local config = {
removeFromPlayer = false, -- If it is set to 'true' it will remove the item from the player, otherwise it will remove the item from where it is being used
itemId = 11391,
creatureType = "npc", -- Choose between 'monster' or 'npc'
creatureName = "Cooking", -- This is the name of the creature that will be summoned
}

--[[
If you don't understand programming, please don't change the lines below.
]]
function onUse(cid, item, fromPosition, itemEx, toPosition)
if config.creatureType == "monster" then
doCreateMonster(config.creatureName, toPosition)
elseif config.creatureType == "npc" then
doCreateNpc(config.creatureName, toPosition)
else
print("creatureType: Choose one of the two existing options: 'monster' or 'npc'.")
end

if config.removeFromPlayer then
if getPlayerItemCount(cid, config.itemId) >= 1 then
doPlayerRemoveItem(cid, config.itemId, 1)
end
else
doRemoveItem(item.uid, 1)
end

return true
end
when I use the item inside the bp this error appears and the item disappears

[Error - Action Interface]
data/actions/scripts/npcfer.lua:eek:nUse
Description:
(luaDoCreateNpc) Cannot create npc: Cooking

and when i use the item on the ground it creates the npc

I wanted it to only be possible to use this item 11391 on top of an item with a 1784 action
equals an altar to summon the npc.
ferumbras.png
 
Last edited:
Try this:
Lua:
local config = {
    removeFromPlayer = false, -- If it is set to 'true' it will remove the item from the player, otherwise it will remove the item from where it is being used
    itemPosition = { x = 123, y = 456, z = 7, stackpos = 255 },
    itemId = 11391,
    creatureType = "npc", -- Choose between 'monster' or 'npc'
    creatureName = "Cooking", -- This is the name of the creature that will be summoned
}

--[[
    If you don't understand programming, please don't change the lines below.
]]
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local position = getPlayerPosition(cid)
    if config.creatureType == "monster" then
        doCreateMonster(config.creatureName, position)
    elseif config.creatureType == "npc" then
        doCreateNpc(config.creatureName, position)
    else
        print("creatureType: Choose one of the two existing options: 'monster' or 'npc'.")
    end
    if config.removeFromPlayer then
        if getPlayerItemCount(cid, config.itemId) >= 1 then
            doPlayerRemoveItem(cid, config.itemId, 1)
        end
    else
        if getThingFromPos(config.itemPosition).itemid == config.itemId then
            doRemoveItem(item.uid, 1)
        else
            doCreatureSay(cid, "<Thought> I'm not sure, but maybe the statue is not in the right place.", TALKTYPE_MONSTER_SAY)
        end
    end

    return true
end
Post automatically merged:

A small correction:
Lua:
local config = {
    removeFromPlayer = false, -- If it is set to 'true' it will remove the item from the player, otherwise it will remove the item from where it is being used
    itemPosition = { x = 123, y = 456, z = 7, stackpos = 255 },
    itemId = 11391,
    creatureType = "npc", -- Choose between 'monster' or 'npc'
    creatureName = "Cooking", -- This is the name of the creature that will be summoned
}

--[[
    If you don't understand programming, please don't change the lines below.
]]
function doSpawnCreature(cid)
    local position = getPlayerPosition(cid)
    if config.creatureType == "monster" then
        doCreateMonster(config.creatureName, position)
    elseif config.creatureType == "npc" then
        doCreateNpc(config.creatureName, position)
    else
        print("creatureType: Choose one of the two existing options: 'monster' or 'npc'.")
    end

    return true
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if config.removeFromPlayer then
        if getPlayerItemCount(cid, config.itemId) >= 1 then
            doPlayerRemoveItem(cid, config.itemId, 1)
            doSpawnCreature(cid)
        end
    else
        if getThingFromPos(config.itemPosition).itemid == config.itemId then
            doRemoveItem(item.uid, 1)
            doSpawnCreature(cid)
        else
            doCreatureSay(cid, "<Thought> I'm not sure, but maybe the statue is not in the right place.", TALKTYPE_MONSTER_SAY)
        end
    end

    return true
end

@EDIT: fromPosition and toPosition returns CONTAINER_POSITION if target item is not on the floor.
 
Last edited:
Try this:
Lua:
local config = {
    removeFromPlayer = false, -- If it is set to 'true' it will remove the item from the player, otherwise it will remove the item from where it is being used
    itemPosition = { x = 123, y = 456, z = 7, stackpos = 255 },
    itemId = 11391,
    creatureType = "npc", -- Choose between 'monster' or 'npc'
    creatureName = "Cooking", -- This is the name of the creature that will be summoned
}

--[[
    If you don't understand programming, please don't change the lines below.
]]
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local position = getPlayerPosition(cid)
    if config.creatureType == "monster" then
        doCreateMonster(config.creatureName, position)
    elseif config.creatureType == "npc" then
        doCreateNpc(config.creatureName, position)
    else
        print("creatureType: Choose one of the two existing options: 'monster' or 'npc'.")
    end
    if config.removeFromPlayer then
        if getPlayerItemCount(cid, config.itemId) >= 1 then
            doPlayerRemoveItem(cid, config.itemId, 1)
        end
    else
        if getThingFromPos(config.itemPosition).itemid == config.itemId then
            doRemoveItem(item.uid, 1)
        else
            doCreatureSay(cid, "<Thought> I'm not sure, but maybe the statue is not in the right place.", TALKTYPE_MONSTER_SAY)
        end
    end

    return true
end
Post automatically merged:

A small correction:
Lua:
local config = {
    removeFromPlayer = false, -- If it is set to 'true' it will remove the item from the player, otherwise it will remove the item from where it is being used
    itemPosition = { x = 123, y = 456, z = 7, stackpos = 255 },
    itemId = 11391,
    creatureType = "npc", -- Choose between 'monster' or 'npc'
    creatureName = "Cooking", -- This is the name of the creature that will be summoned
}

--[[
    If you don't understand programming, please don't change the lines below.
]]
function doSpawnCreature(cid)
    local position = getPlayerPosition(cid)
    if config.creatureType == "monster" then
        doCreateMonster(config.creatureName, position)
    elseif config.creatureType == "npc" then
        doCreateNpc(config.creatureName, position)
    else
        print("creatureType: Choose one of the two existing options: 'monster' or 'npc'.")
    end

    return true
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if config.removeFromPlayer then
        if getPlayerItemCount(cid, config.itemId) >= 1 then
            doPlayerRemoveItem(cid, config.itemId, 1)
            doSpawnCreature(cid)
        end
    else
        if getThingFromPos(config.itemPosition).itemid == config.itemId then
            doRemoveItem(item.uid, 1)
            doSpawnCreature(cid)
        else
            doCreatureSay(cid, "<Thought> I'm not sure, but maybe the statue is not in the right place.", TALKTYPE_MONSTER_SAY)
        end
    end

    return true
end

@EDIT: fromPosition and toPosition returns CONTAINER_POSITION if target item is not on the floor.
a part is ready it is being summoned on top of the altar, but when I use the item anywhere else it gives a debug other than the coordinate
I changed that part and it worked 100%
thank you very much for your time and your help
doPlayerSendTextMessage(cid,22,"I'm not sure, but maybe the statue is not in the right place.")
 
Back
Top