• 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,315
Reaction score
136
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
 
like this

PHP:
local cfg = {
    bless = { 1, 2, 3, 4, 5 },
    uid = 9004
}
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(cfg.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

?
 
tryed alot different ways with this line doRemoveItem(cfg.uid ,1) always same error
[11:20:59.524] [Error - Action Interface]
[11:20:59.524] data/actions/scripts/blessbook1charge.lua:eek:nUse
[11:20:59.524] Description:
[11:20:59.524] (luaDoRemoveItem) Item not found
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

onUse is what is known as an interface, the parameters cid, item, fromPosition, itemEx, toPosition are values which are sent from the server.

cid is a number of the player, its player id,
item is a table, the item associated with the script.
fromPosition is also a table, it contains the x,y,z and stackpos of the item of where it is used from, e.g. the ground, your backpack etc.
itemEx is also a table, it is the item if any you used the item on
toPosition is the position of itemEx

Since your script does not use these parameters fromPosition, itemEx, toPosition they can be omitted.

Since you are click on an item associated with the script, you want to remove that item, so you would pass item.uid to doRemoveItem
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

onUse is what is known as an interface, the parameters cid, item, fromPosition, itemEx, toPosition are values which are sent from the server.

cid is a number of the player, its player id,
item is a table, the item associated with the script.
fromPosition is also a table, it contains the x,y,z and stackpos of the item of where it is used from, e.g. the ground, your backpack etc.
itemEx is also a table, it is the item if any you used the item on
toPosition is the position of itemEx

Since your script does not use these parameters fromPosition, itemEx, toPosition they can be omitted.

Since you are click on an item associated with the script, you want to remove that item, so you would pass item.uid to doRemoveItem
onUse(cid, uid, fromPosition, itemEx, toPosition) tryed this same error.
im realy trying to figure out what you wrote here but its dificult for me
trying figure out , can you gimme more hints ?
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

onUse is what is known as an interface, the parameters cid, item, fromPosition, itemEx, toPosition are values which are sent from the server.

cid is a number of the player, its player id,
item is a table, the item associated with the script.
fromPosition is also a table, it contains the x,y,z and stackpos of the item of where it is used from, e.g. the ground, your backpack etc.
itemEx is also a table, it is the item if any you used the item on
toPosition is the position of itemEx

Since your script does not use these parameters fromPosition, itemEx, toPosition they can be omitted.

Since you are click on an item associated with the script, you want to remove that item, so you would pass item.uid to doRemoveItem
can't make it work always same error,
can you explain what you mean here
Since your script does not use these parameters fromPosition, itemEx, toPosition they can be omitted.
since i dont understand much
 
no offense, but imho it just looks like you've opened an already existing script in your datapack and you have added functions that you have no clue about. cfg.uid doesn't make any sense. You use doRemoveItem like this usually:
Code:
 doRemoveItem(item.uid, 1)
 
can't make it work always same error,
can you explain what you mean here
Since your script does not use these parameters fromPosition, itemEx, toPosition they can be omitted.
since i dont understand much
I thought I just did.
 
no offense, but imho it just looks like you've opened an already existing script in your datapack and you have added functions that you have no clue about. cfg.uid doesn't make any sense. You use doRemoveItem like this usually:
Code:
 doRemoveItem(item.uid, 1)
Of course s/he did, this is not the point of my posting... my point is s/he should learn the language, but that is just me being asshole right?
 
no offense, but imho it just looks like you've opened an already existing script in your datapack and you have added functions that you have no clue about. cfg.uid doesn't make any sense. You use doRemoveItem like this usually:
Code:
 doRemoveItem(item.uid, 1)
if cfg means nothing why i recieve bless ? and i made this script working but anyway error was.
and changing to doRemoveItem(item.uid, 1) gives error anyway

[12:3:31.102] [Error - Action Interface]
[12:3:31.102] data/actions/scripts/blessbook1charge.lua:eek:nUse
[12:3:31.102] Description:
[12:3:31.102] (luaDoRemoveItem) Item not found
 
I thought I just did.
thats the thing that you thought but you are wrong , but information you gave for ME doesnt light me enought readed alot times translated all things i didint understandand anyway i didint come on point what you mean(translater works as kebab). and yes im asshole and you arent one ? :O
 
In actions.xml, you usually declare your item like this in tfs 0.4: <action itemid="xxxx" event="script" value="script.lua"/> Have you already done that? The error is quite obvious
Code:
 [12:3:31.102] (luaDoRemoveItem) Item not found <----------------
 
@Lbtg

And actually your script looks so bad!
I am not so familiar with tfs 0.3.6 but script should look like this!
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local blessAdded = 0
    for i = 0, 5 do -- not need at all to a table!
        if not getPlayerBlessing(cid, i) then -- we just add blessing if not!
            doPlayerAddBlessing(cid, i)
            blessAdded = blessAdded + 1
        end
    end
   
    -- Here we know if we sent him any blessing!
    if blessAdded > 0 then
        -- I am not so familiar with 0.4 or 0.3.6, but shouldn't blessing has itself setDropFale?
        doCreatureSetDropLoot(cid, false)
        doRemoveItem(item.uid ,1)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYAREA)
        doSendAnimatedText(getCreaturePosition(cid), "BLESSED!", TEXTCOLOR_RED)
        doPlayerSendTextMessage(cid, 21, "You have recieved blessings by Ancient Book!")
    else
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        doPlayerSendCancel(cid, "You have already recieved Blessings!")
    end
   
    -- There is not point returning false/true
    return true
end
 
yes
i can remove the remove item and item id and the script will work anyway i have added from beggining :)
<action itemid="9004" event="script" value="blessbook1charge.lua"/>
 
@Lbtg

And actually your script looks so bad!
I am not so familiar with tfs 0.3.6 but script should look like this!
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local blessAdded = 0
    for i = 0, 5 do -- not need at all to a table!
        if not getPlayerBlessing(cid, i) then -- we just add blessing if not!
            doPlayerAddBlessing(cid, i)
            blessAdded = blessAdded + 1
        end
    end
  
    -- Here we know if we sent him any blessing!
    if blessAdded > 0 then
        -- I am not so familiar with 0.4 or 0.3.6, but shouldn't blessing has itself setDropFale?
        doCreatureSetDropLoot(cid, false)
        doRemoveItem(item.uid ,1)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYAREA)
        doSendAnimatedText(getCreaturePosition(cid), "BLESSED!", TEXTCOLOR_RED)
        doPlayerSendTextMessage(cid, 21, "You have recieved blessings by Ancient Book!")
    else
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        doPlayerSendCancel(cid, "You have already recieved Blessings!")
    end
  
    -- There is not point returning false/true
    return true
end
My brother i use 0.4 will test it fast running out of time on pc
 
My brother i use 0.4 will test it fast running out of time on pc
Its working as my script before forum , no erros all good but if player has full blessings he can anyway eat book same issue as in beggining lol
 
like this

PHP:
local cfg = {
    bless = { 1, 2, 3, 4, 5 },
    uid = 9004
}
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(cfg.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

?
Good luck in your endeavors.
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
     end
     
     doCreatureSetDropLoot(cid, false)
     doRemoveItem(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!")
     
     return true
end
 
Good luck in your endeavors.
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
     end
    
     doCreatureSetDropLoot(cid, false)
     doRemoveItem(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!")
    
     return true
end
aint working aswell :( it doesnt give bless on use

No, my script doesn't eat book if he has blessing!
nop i tested with different chars/god/normal and sso i can eat xxx of it.. :) why would i lie ?
 
aint working aswell :( it doesnt give bless on use


nop i tested with different chars/god/normal and sso i can eat xxx of it.. :) why would i lie ?
Of course not. Look where it's..
uff.. you know what? do this

I left it there so you'd see the error in console and try to fix it yourself.

replace this line
Code:
doPlayerAddBlessing(cid, cfg.bless[i])
with this
Code:
doPlayerAddBlessing(cid, cfg.bless[1])
doPlayerAddBlessing(cid, cfg.bless[2])
doPlayerAddBlessing(cid, cfg.bless[3])
doPlayerAddBlessing(cid, cfg.bless[4])
doPlayerAddBlessing(cid, cfg.bless[5])
Code:
for i = 1, 5 do
    doPlayerAddBlessing(cid, cfg.bless[i])
end
 
Back
Top