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

Lua doPlayerSendCancel does not work as it should be

whiteblXK

Active Member
Joined
Apr 20, 2011
Messages
315
Solutions
9
Reaction score
32
Location
Poland
Hi, I have problem with my script. When a player meets the requirements of the script it still shows up else, this:
Code:
            else
                doPlayerSendCancel(cid,"You must complete the appropriate quest to receive Buff.")
                doSendMagicEffect(frompos, CONST_ME_POFF)
            end
I use Devland 0.97B, this is tibia 8.0
This is my script:
Code:
local itemTables = {
    [7559] = {buff = 'Test', szukanyZamienicNaId = 7560, storage = 15423, ile = 1}
    }
              
              
function onUse(cid, item, frompos, item2, topos)
local skillBag = isPlayer(cid) and getPlayerSlotItem(cid,CONST_SLOT_NECKLACE).uid or 0
if skillBag == 0 or not isPlayer(cid) then
    return false
end
for itemId, itemTable in pairs(itemTables) do
        for i = 0, getContainerSize(skillBag) - 1 do
            local skillItem = getContainerItem(skillBag, i)
                if skillItem.itemid == itemId and getPlayerStorageValue(cid, itemTable.storage) == itemTable.ile then
                    doRemoveItem(item.uid, 1)  
                    doTransformItem(skillItem.uid, itemTable.szukanyZamienicNaId)
                    doPlayerSay(cid, "Congratulations! You received a new Buff[" ..itemTable.buff.. "]", TALKTYPE_ORANGE_1)
            else
                doPlayerSendCancel(cid,"You must complete the appropriate quest to receive Buff.")
                doSendMagicEffect(frompos, CONST_ME_POFF)
            end  
        end  
end  
return 1
end
 
I'm not sure what the exact purpose of the script is but judging from the fact that some of the variables use bag in there name that your script is checking the wrong slot, it should be CONST_SLOT_BACKPACK
 
Have no ide what "Devland 0.97B" is, But check the source code for the function, if it exists, then check how to use it. Would be alot faster to do, then wait x amount of hours for an awnser.
WibbenZ
 
I don't have source for this engine :/ In code i have use CONST_SLOT_NECKLACE because i don't use this slot, I give new bag(Skill Bag) at this slot.

Edit.
I found source for this engine.
I also found this function but do not know what it's about, I do not know c++
Code:
    //getContainerItem(uid, slot)
    lua_register(m_luaState, "getContainerItem", LuaScriptInterface::luaGetContainerItem);



int LuaScriptInterface::luaGetContainerItem(lua_State *L)
{
    //getContainerItem(uid, slot)
    uint32_t slot = popNumber(L);
    uint32_t uid = popNumber(L);
   
    ScriptEnviroment* env = getScriptEnv();
   
    if(Container* container = env->getContainerByUID(uid)){
        Item* item = container->getItem(slot);
        if(item){
            uint32_t uid = env->addThing(item);
            pushThing(L, item, uid);
        }
        else{
            pushThing(L, NULL, 0);
        }
    }
    else{
        reportErrorFunc(getErrorDesc(LUA_ERROR_CONTAINER_NOT_FOUND));
        pushThing(L, NULL, 0);
    }
    return 1;
   
}
 
Last edited:
Which map?
Never heard that starter for a 8.00 server.
There's only 0.7.8 Evolutions-XML & Arbee's.
And thoose scripts for a 8.00 is hard.
I hope you can make this script would be awesome!
 
try this

Code:
local itemTables = {
   [7559] = {buff = 'Test', szukanyZamienicNaId = 7560, storage = 15423, ile = 1}
}
   
   
function onUse(cid, item, frompos, item2, topos)
   local skillBag = isPlayer(cid) and getPlayerSlotItem(cid,CONST_SLOT_NECKLACE).uid or 0
   if skillBag == 0 or not isPlayer(cid) then
     return false
   end
   for itemId, itemTable in pairs(itemTables) do
     for i = 0, getContainerSize(skillBag) - 1 do
       local skillItem = getContainerItem(skillBag, i)
       if skillItem.itemid == itemId and getPlayerStorageValue(cid, itemTable.storage) == itemTable.ile then
           doRemoveItem(item.uid, 1)  
           doTransformItem(skillItem.uid, itemTable.szukanyZamienicNaId)
           doPlayerSay(cid, "Congratulations! You received a new Buff[" ..itemTable.buff.. "]", TALKTYPE_ORANGE_1)
           break
       end
       if i == (getContainerSize(skillBag) - 1) then
         doPlayerSendCancel(cid,"You must complete the appropriate quest to receive Buff.")
         doSendMagicEffect(frompos, CONST_ME_POFF)
       end  
     end
   end
   return 1
end
 
Back
Top