• 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 bless book

Lbtg

Intermediate OT User
Joined
Nov 22, 2008
Messages
2,297
Reaction score
127
Well i found on forums much bless boooks but this was most nice and + i lil edited it and i recieve error
What im doing wrong

error.
HTML:
[10:0:46.383] [Error - LuaInterface::loadFile] data/actions/scripts/blessbook1charge.lua:12: 'end' expected (to close 'for' at line 6) near 'else'
[10:0:46.383] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/blessbook1charge.lua)
[10:0:46.383] data/actions/scripts/blessbook1charge.lua:12: 'end' expected (to close 'for' at line 6) near 'else'

was trying to fix it for long but always fail to make fully working ^^


blessbook.lua
PHP:
local cfg = {
    bless = { 1, 2, 3, 4, 5 },
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
     for i = 1, table.maxn(cfg.bless) do
        if(getPlayerBlessing(cid, cfg.bless[i])) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        doPlayerSendCancel(cid, "You have already recieved Blessings!")
        return true
        end
    else
            doCreatureSetDropLoot(cid, false)
            doRemoveItem(cid, item.uid, 1)
            doPlayerAddBlessing(cid, cfg.bless[i])
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYAREA)
            doSendAnimatedText(getCreaturePosition(cid), "BLESSED!", TEXTCOLOR_RED)
            doPlayerSendTextMessage(cid, 21, "You have recieved blessings by Ancient Book!")
   
    end
return true
end
 
now i revieve this
error
PHP:
[10:42:54.810] [Error - Action Interface]
[10:42:54.810] data/actions/scripts/blessbook1charge.lua:onUse
[10:42:54.810] Description:
[10:42:54.810] (luaDoRemoveItem) Item not found


script
Code:
local cfg = {
    bless = { 1, 2, 3, 4, 5 },
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
     for i = 1, table.maxn(cfg.bless) do
        if(getPlayerBlessing(cid, cfg.bless[i])) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        doPlayerSendCancel(cid, "You have already recieved Blessings!")
        return true
    end
            doCreatureSetDropLoot(cid, false)
            doRemoveItem(cid, item.uid, 1)
            doPlayerAddBlessing(cid, cfg.bless[i])
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYAREA)
            doSendAnimatedText(getCreaturePosition(cid), "BLESSED!", TEXTCOLOR_RED)
            doPlayerSendTextMessage(cid, 21, "You have recieved blessings by Ancient Book!")
   
    end
return true
end
 
You can't have an if and an else with an end at the end of the if

This is wrong
Code:
if
end
else
end

This is right
Code:
if
else
end

There are also some other errors..

How to fix?
Learn the language, learn the logic :)
http://www.tutorialspoint.com/lua/if_else_statement_in_lua.htm
i already saved that page to learn something from it, but then someone is teaching its much easier to get things, + my english isint good s i dont get alot of things and translaters SUX
 
can you explain why you posting this and what shall i do ? you gave me blank page basicaly with no info on it ^^
 
can you explain why you posting this and what shall i do ? you gave me blank page basicaly with no info on it ^^
?
I linked you to the function, to show its arguments, the error you are getting, its function is getting the wrong information passed to it
 
error
Code:
[11:1:08.627] [Error - Action Interface]
[11:1:08.627] data/actions/scripts/blessbook1charge.lua:onUse
[11:1:08.627] Description:
[11:1:08.627] (luaDoRemoveItem) Item not found

script
Code:
local cfg = {
    bless = { 1, 2, 3, 4, 5 },
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
     for i = 1, table.maxn(cfg.bless) do
        if(getPlayerBlessing(cid, cfg.bless[i])) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        doPlayerSendCancel(cid, "You have already recieved Blessings!")
        return true
    end
            doCreatureSetDropLoot(cid, false)
            doRemoveItem(uid)
            doPlayerAddBlessing(cid, cfg.bless[i])
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYAREA)
            doSendAnimatedText(getCreaturePosition(cid), "BLESSED!", TEXTCOLOR_RED)
            doPlayerSendTextMessage(cid, 21, "You have recieved blessings by Ancient Book!")
   
end
return true
end
 
error
Code:
[11:1:08.627] [Error - Action Interface]
[11:1:08.627] data/actions/scripts/blessbook1charge.lua:onUse
[11:1:08.627] Description:
[11:1:08.627] (luaDoRemoveItem) Item not found

script
Code:
local cfg = {
    bless = { 1, 2, 3, 4, 5 },
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
     for i = 1, table.maxn(cfg.bless) do
        if(getPlayerBlessing(cid, cfg.bless[i])) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        doPlayerSendCancel(cid, "You have already recieved Blessings!")
        return true
    end
            doCreatureSetDropLoot(cid, false)
            doRemoveItem(uid)
            doPlayerAddBlessing(cid, cfg.bless[i])
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYAREA)
            doSendAnimatedText(getCreaturePosition(cid), "BLESSED!", TEXTCOLOR_RED)
            doPlayerSendTextMessage(cid, 21, "You have recieved blessings by Ancient Book!")
  
end
return true
end
God you are hopeless...
 
Hypothetical item
Code:
item = { -- item is a table
     uid = 12345 -- uid is a property of item, the trailing number is the properties value 
}
doRemoveItem(item.uid)
 
fuk man i cant understand what you mean :( can you explain it morea in easy words ?
so maybe UID is basicaly item putted on xml , i just need do like this doRemoveItem(cid, UID ,1)?
 
Back
Top