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

Solved Summon Monster when use item (quest box)

Exoltes

Novia OTserv Developer
Joined
Jul 2, 2009
Messages
563
Reaction score
47
Location
Belgium
I'm working on a 8.54 Open Tibia Server using The Forgotten Server - Version 0.2.7 (Mystic Spirit).

Code:
      elseif item.uid == 5567 then
        if getPlayerStorageValue(cid, 7007) == -1 then
        local rand = math.random(1, 100)
        if rand < 1 then
            doTargetCombatHealth(0, cid, COMBAT_FIREDAMAGE, -50, -50, CONST_ME_NONE)
              doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"I told you not to touch it.")
                    doSummonCreature("Deadeye Devious", toPosition)
              setPlayerStorageValue(cid,7007,1)
        else
            doTargetCombatHealth(0, cid, COMBAT_FIREDAMAGE, -50, -50, CONST_ME_NONE)
              doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"I told you not to touch it.")
        end
        elseif getPlayerStorageValue(cid, 7007) == 1 and getPlayerStorageValue(cid, 7008) == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You stole XXX his treasure.")
              doPlayerAddItem(cid,8602,1)    -- jagged sword
              setPlayerStorageValue(cid,7000,1)
              setPlayerStorageValue(cid,7008,1)
          end

[08/08/2014 16:00:04] Lua Script Error: [Action Interface]
[08/08/2014 16:00:04] data/actions/scripts/quests/Secret Quests.lua:eek:nUse

[08/08/2014 16:00:04] attempt to index a nil value
[08/08/2014 16:00:04] stack traceback:
[08/08/2014 16:00:04] [C]: in function 'doSummonCreature'
[08/08/2014 16:00:04] data/actions/scripts/quests/Secret Quests.lua:64: in function <data/actions/scripts/quests/Secret Quests.lua:1>

Thanks in advance.
 
Code:
      elseif item.uid == 5567 then
        if getPlayerStorageValue(cid, 7007) == -1 then
        local rand = math.random(1, 100)
        if rand < 1 then
            doSendMagicEffect(topos,CONST_ME_FIREAREA)
            doTargetCombatHealth(0, cid, COMBAT_FIREDAMAGE, -50, -50, CONST_ME_NONE)
              doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"I told you not to touch it.")
                    doSummonCreature("Deadeye Devious", topos.y +1)
              setPlayerStorageValue(cid,7007,1)
        else
            doSendMagicEffect(topos,CONST_ME_FIREAREA)
            doTargetCombatHealth(0, cid, COMBAT_FIREDAMAGE, -50, -50, CONST_ME_NONE)
              doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"I told you not to touch it.")
              setPlayerStorageValue(cid,7007,1)
        end
        elseif getPlayerStorageValue(cid, 7007) == 1 and getPlayerStorageValue(cid, 7008) == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You stole XXX his treasure.")
              doPlayerAddItem(cid,8602,1)    -- jagged sword
              setPlayerStorageValue(cid,7000,1)
              setPlayerStorageValue(cid,7008,1)
          end

[08/08/2014 16:10:23] Lua Script Error: [Action Interface]
[08/08/2014 16:10:23] data/actions/scripts/quests/Secret Quests.lua:eek:nUse

[08/08/2014 16:10:23] attempt to index a number value
[08/08/2014 16:10:23] stack traceback:
[08/08/2014 16:10:23] [C]: in function 'doSummonCreature'
[08/08/2014 16:10:23] data/actions/scripts/quests/Secret Quests.lua:65: in function <data/actions/scripts/quests/Secret Quests.lua:1>
 
topos.y is just 1 part of the position, now it's not in a table and it's still missing x and z.
You can do this.
Code:
{x = topos.x, y = topos.y + 1, z = topos.z}
 
Code:
function onUse(cid, item, frompos, item2, topos)

      if item.uid == 5551 then
          queststatus = getPlayerStorageValue(cid,7001)
          if queststatus == -1 then
              doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found the hidden dragon treasure.")
              doPlayerAddItem(cid,8602,1)    -- jagged sword
              setPlayerStorageValue(cid,7000,1)
              setPlayerStorageValue(cid,7001,1)
          end

      elseif item.uid == 5552 then
          queststatus = getPlayerStorageValue(cid,7002)
          if queststatus == -1 then
              doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found the hidden minotaur treasure.")
              doPlayerAddItem(cid,8602,1)    -- jagged sword
              setPlayerStorageValue(cid,7000,1)
              setPlayerStorageValue(cid,7002,1)
          end

      elseif item.uid == 5553 then
          queststatus = getPlayerStorageValue(cid,7003)
          if queststatus == -1 then
              doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found the ice serpent treasure.")
              doPlayerAddItem(cid,8602,1)    -- jagged sword
              setPlayerStorageValue(cid,7000,1)
              setPlayerStorageValue(cid,7003,1)
          end

      elseif item.uid == 5554 then
          queststatus = getPlayerStorageValue(cid,7004)
          if queststatus == -1 then
              doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found the ice witch treasure.")
              doPlayerAddItem(cid,8602,1)    -- jagged sword
              setPlayerStorageValue(cid,7000,1)
              setPlayerStorageValue(cid,7004,1)
          end

      elseif item.uid == 5555 then
          queststatus = getPlayerStorageValue(cid,7005)
          if queststatus == -1 then
              doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found the grim reaper treasure.")
              doPlayerAddItem(cid,8602,1)    -- jagged sword
              setPlayerStorageValue(cid,7000,1)
              setPlayerStorageValue(cid,7005,1)
          end


      elseif item.uid == 5565 then
          queststatus = getPlayerStorageValue(cid,7006)
          if queststatus == -1 then
              doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found the behemoth treasure.")
              doPlayerAddItem(cid,8602,1)    -- jagged sword
              setPlayerStorageValue(cid,7000,1)
              setPlayerStorageValue(cid,7006,1)
          end

      elseif item.uid == 5567 then
        if getPlayerStorageValue(cid, 7007) == -1 then
        local rand = math.random(1, 100)
        if rand < 1 then
            doSendMagicEffect(topos,CONST_ME_FIREAREA)
            doTargetCombatHealth(0, cid, COMBAT_FIREDAMAGE, -50, -50, CONST_ME_NONE)
              doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Aarrrg! I told you not to touch it!")
                    doSummonCreature("Deadeye Devious", {x = topos.x, y = topos.y + 2, z = topos.z})
              setPlayerStorageValue(cid,7007,1)
        else
            doSendMagicEffect(topos,CONST_ME_FIREAREA)
            doTargetCombatHealth(0, cid, COMBAT_FIREDAMAGE, -50, -50, CONST_ME_NONE)
              doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"I told you not to touch it!")
              setPlayerStorageValue(cid,7007,1)
        end
        elseif getPlayerStorageValue(cid, 7007) == 1 and getPlayerStorageValue(cid, 7008) == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You stole XXX his treasure.")
              doPlayerAddItem(cid,8602,1)    -- jagged sword
              setPlayerStorageValue(cid,7000,1)
              setPlayerStorageValue(cid,7008,1)
          end


        return 1
    else
        return 0
    end
end
 
Yea, my bad but that doesn't really mather since I test the script like this:
Code:
elseif item.uid == 5567 then
if getPlayerStorageValue(cid, 7007) == -1 then
local rand = math.random(1, 100)
if rand < 99 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Aarrrg! I told you not to touch it!")
doSummonCreature("Deadeye Devious", {x = topos.x, y = topos.y + 2, z = topos.z})
setPlayerStorageValue(cid,7007,1)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"I told you not to touch it!")
end
elseif getPlayerStorageValue(cid, 7007) == 1 and getPlayerStorageValue(cid, 7008) == -1 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You stole XXX his treasure.")
end
 
Do you get the textmessage: "Aarrrg! I told you not to touch it!"? or do you get an error in your console about the summon creature?
 
17:25 You lose 50 hitpoints.
17:25 Aarrrg! I told you not to touch it!

[08/08/2014 17:25:28] Lua Script Error: [Action Interface]
[08/08/2014 17:25:28] data/actions/scripts/quests/Secret Quests.lua:eek:nUse

[08/08/2014 17:25:28] luaDoSummonCreature(). Can not summon monster: Deadeye Devious

Also tried to change the monster to a Demon but that made no difference.

I'll be rechecking my script soon because I think I found a way to make it work since my shovel script does summon monsters when used on desert floor.
 
Last edited by a moderator:
Yup, fixed it :)

Code:
      elseif item.uid == 5567 then
        if getPlayerStorageValue(cid, 7007) == -1 then
        local rand = math.random(1, 100)
        if rand == 1 then
            doSendMagicEffect(topos,CONST_ME_FIREAREA)
            doTargetCombatHealth(0, cid, COMBAT_FIREDAMAGE, -50, -50, CONST_ME_NONE)
              doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Aarrrg! I told you not to touch it!")
                    doSummonCreature("Deadeye Devious", {x = 823, y = 1153, z = 5})
              setPlayerStorageValue(cid,7007,1)
        else
            doSendMagicEffect(topos,CONST_ME_FIREAREA)
            doTargetCombatHealth(0, cid, COMBAT_FIREDAMAGE, -50, -50, CONST_ME_NONE)
              doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"I told you not to touch it!")
              setPlayerStorageValue(cid,7007,1)
        end
        elseif getPlayerStorageValue(cid, 7007) == 1 and getPlayerStorageValue(cid, 7008) == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You stole XXX his treasure.")
              doPlayerAddItem(cid,8602,1)    -- jagged sword
              setPlayerStorageValue(cid,7000,1)
              setPlayerStorageValue(cid,7008,1)
          end
 
Back
Top