• 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,312
Reaction score
134
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
 
This is the last time I'm editing this damn script.
if you get error's change all
Code:
item.aid
item.uid
to
Code:
item.actionid
item.uniqueid
Code:
local cfg = {
    bless = { 1, 2, 3, 4, 5 }
}
function onUse(cid, item, fromPosition, itemEx, toPosition)

    if item.aid > 0 then
        if item.aid ~= getPlayerGUID(cid) then
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
            doPlayerSendCancel(cid, "Get your filthy hands off Master " .. getPlayerNameByGUID(item.aid) .. "'s Book you thief!")
            return true
        end
    end

    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

    local exstorage = 45001
    if exhaustion.check(cid, exstorage) then
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
        doPlayerSendCancel(cid, "You are exhausted. Please wait awhile.")
        return true
    end
    exhaustion.set(cid, exstorage, 120)

    for i = 1,5 do
        doPlayerAddBlessing(cid, cfg.bless[i])
    end
    doCreatureSetDropLoot(cid, false)
    doSetItemActionId(item.uid, getPlayerGUID(cid))
    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

got some error
PHP:
[8:0:44.989] [Error - Action Interface]
[8:0:44.989] data/actions/scripts/blessbook.lua:onUse
[8:0:44.989] Description:
[8:0:44.989] (luaDoItemSetAttribute) Item not found

script
PHP:
local cfg = {
    bless = { 1, 2, 3, 4, 5 }
}
function onUse(cid, item, fromPosition, itemEx, toPosition)

    if item.actionid > 24354 then
        if item.actionid ~= getPlayerGUID(cid) then
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
            doPlayerSendCancel(cid, "Get your filthy hands off Master " .. getPlayerNameByGUID(item.actionid) .. "'s Book you thief!")
            return true
        end
    end

    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

    local exstorage = 45001
    if exhaustion.check(cid, exstorage) then
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
        doPlayerSendCancel(cid, "You are exhausted. Please wait awhile.")
        return true
    end
    exhaustion.set(cid, exstorage, 120)

    for i = 1,5 do
        doPlayerAddBlessing(cid, cfg.bless[i])
    end
    doCreatureSetDropLoot(cid, false)
    doSetItemActionId(item.uniqueid, getPlayerGUID(cid))
    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

xml part
Code:
<action itemid="11128" event="script" value="blessbook.lua"/>

is it all good ?
 
I changed this a couple minutes ago. I copy pasted tokens edit, assuming it was the same script I posted earlier. >.>
also you can do something like
Code:
x = 0
for i = 1, #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
        x = i
    end

    (...)

    doPlayerAddBlessing(cid, x)
 
got some error
PHP:
[8:0:44.989] [Error - Action Interface]
[8:0:44.989] data/actions/scripts/blessbook.lua:onUse
[8:0:44.989] Description:
[8:0:44.989] (luaDoItemSetAttribute) Item not found

script
PHP:
local cfg = {
    bless = { 1, 2, 3, 4, 5 }
}
function onUse(cid, item, fromPosition, itemEx, toPosition)

    if item.actionid > 24354 then
        if item.actionid ~= getPlayerGUID(cid) then
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
            doPlayerSendCancel(cid, "Get your filthy hands off Master " .. getPlayerNameByGUID(item.actionid) .. "'s Book you thief!")
            return true
        end
    end

    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

    local exstorage = 45001
    if exhaustion.check(cid, exstorage) then
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
        doPlayerSendCancel(cid, "You are exhausted. Please wait awhile.")
        return true
    end
    exhaustion.set(cid, exstorage, 120)

    for i = 1,5 do
        doPlayerAddBlessing(cid, cfg.bless[i])
    end
    doCreatureSetDropLoot(cid, false)
    doSetItemActionId(item.uniqueid, getPlayerGUID(cid))
    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

xml part
Code:
<action itemid="11128" event="script" value="blessbook.lua"/>

is it all good ?
if item.actionid > 24354 then
keep this as
if item.actionid > 0 then

Did you get the same error with..
item.aid
and
item.uid
?

Try this?

Code:
item = item.uid
doSetItemActionId(item, getPlayerGUID(cid))
 
pls codex no h8 :'(


Try this perhaps?
Code:
 local cfg = {
  bless = { 1, 2, 3, 4, 5 }
}
function onUse(cid, item, fromPosition, itemEx, toPosition)

  if item.actionid > 24354 then
  if item.actionid ~= getPlayerGUID(cid) then
  doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  doPlayerSendCancel(cid, "Get your filthy hands off Master " .. getPlayerNameByGUID(item.actionid) .. "'s Book you thief!")
  return true
  end
  end

  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

  local exstorage = 45001
  if exhaustion.check(cid, exstorage) then
  doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
  doPlayerSendCancel(cid, "You are exhausted. Please wait awhile.")
  return true
  end
  exhaustion.set(cid, exstorage, 120)

  for i = 1,5 do
  doPlayerAddBlessing(cid, cfg.bless[i])
  end
  doCreatureSetDropLoot(cid, false)
  doSetItemActionId(item.uid, getPlayerGUID(cid))
  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
 
if item.actionid > 24354 then
keep this as
if item.actionid > 0 then

Did you get the same error with..
item.aid
and
item.uid
?
So i keep actionid 0 ?

item.aid
item.uid
nothing happend then used this , but after i changed to action.aid and so it worked but thats the error and it didint came with name on book and no cooldown worked like regular bless book with error
 
pls codex no h8 :'(


Try this perhaps?
Code:
local cfg = {
  bless = { 1, 2, 3, 4, 5 }
}
function onUse(cid, item, fromPosition, itemEx, toPosition)

  if item.actionid > 24354 then
  if item.actionid ~= getPlayerGUID(cid) then
  doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  doPlayerSendCancel(cid, "Get your filthy hands off Master " .. getPlayerNameByGUID(item.actionid) .. "'s Book you thief!")
  return true
  end
  end

  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

  local exstorage = 45001
  if exhaustion.check(cid, exstorage) then
  doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
  doPlayerSendCancel(cid, "You are exhausted. Please wait awhile.")
  return true
  end
  exhaustion.set(cid, exstorage, 120)

  for i = 1,5 do
  doPlayerAddBlessing(cid, cfg.bless[i])
  end
  doCreatureSetDropLoot(cid, false)
  doSetItemActionId(item.uid, getPlayerGUID(cid))
  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
it gives actionid ActionID: [1008]. after otheer player used same book actionid changed to ActionID: [1110]. to item, but no name of first player who used it (first who used the book becomes book owner and hes the only one who can use book and recieve blessings)
 
it gives actionid ActionID: [1008]. after otheer player used same book actionid changed to ActionID: [1110]. to item, but no name of first player who used it (first who used the book becomes book owner and hes the only one who can use book and recieve blessings)
So you want it so when a player uses a book, nobody else can use that book except the player who used it first?
 
@Codex NG
Why do I even bother?
Edit the script in regular notepad on my phone at work, people complain I'm not scripting it properly.
I only added the functionality asked.

DestinationSer changes nothing regarding the line that set's the actionid and now actionID magically appears on the book.
https://www.diffchecker.com/9m7ch2jq

everytime I send a script they modify it, before testing, and give it back asking why it doesn't work.

not even going to post anymore.
 
Last edited:
@Codex NG
Why do I even bother?
Edit the script in regular notepad on my phone at work, people complain I'm not scripting it properly.
I only added the functionality asked.

DestinationSer changes nothing regarding the line that set's the actionid and now actionID magically appears on the book.
https://www.diffchecker.com/9m7ch2jq

everytime I send a script they modify it, before testing, and give it back asking why it doesn't work.

not even going to post anymore.
These people don't make an attempt to learn.. you can see it in the 4 pages of 1 script... "it doesn't work.. it doesn't work..", help requires that you the original poster make an effort too.
 
@Xikini and everyone else who is making an attempt to help these knuckle heads with their servers... don't go overboard and stress yourself out for these fools.. it isn't worth it, just provide your solution and move on, people need to realize they need to develop these skillsets as well or appreciate the help they receive while at the same time making some effort on their part.

You know why people don't like me now?
Its not because I am argumentative with just about everyone (sorry i like to form my own opinion), its because I won't be your slave, you all want me and people like myself to just shut up and keep providing content or done to death concepts for your "unique" projects..

Sorry I didn't grow up in a fascists country or nanny state, a lot of you like to argue how america is a country of dumb down idiots... where the education system sucks.. while that might be true, it wasn't always that way...

Or maybe you are just jealous because now you have competition.
 
@Xikini and everyone else who is making an attempt to help these knuckle heads with their servers... don't go overboard and stress yourself out for these fools.. it isn't worth it, just provide your solution and move on, people need to realize they need to develop these skillsets as well or appreciate the help they receive while at the same time making some effort on their part.

You know why people don't like me now?
Its not because I am argumentative with just about everyone (sorry i like to form my own opinion), its because I won't be your slave, you all want me and people like myself to just shut up and keep providing content or done to death concepts for your "unique" projects..

Sorry I didn't grow up in a fascists country or nanny state, a lot of you like to argue how america is a country of dumb down idiots... where the education system sucks.. while that might be true, it wasn't always that way...

Or maybe you are just jealous because now you have competition.
kk money lover , no more to say. Xikini got good words on hes signature you shoud read it sometimes :)
 
How is the script rigth now? Ill fix it from cellphone gosh 4 pages already.
The script is easy.
Every time we finished the script, he'd want something else added and then modify it before testing, and say it was broken.

Good luck.
 
The script is easy.
Every time we finished the script, he'd want something else added and then modify it before testing, and say it was broken.

Good luck.
Oh rip, I didn't even bother to read the 4 pages cause lol...
 
@Codex NG
Why do I even bother?
Edit the script in regular notepad on my phone at work, people complain I'm not scripting it properly.
I only added the functionality asked.

DestinationSer changes nothing regarding the line that set's the actionid and now actionID magically appears on the book.
https://www.diffchecker.com/9m7ch2jq

everytime I send a script they modify it, before testing, and give it back asking why it doesn't work.

not even going to post anymore.
if i edited the script it means i trying to do soome modifacation or learn something... i learning like this.
 
unrelated from it actually working, this is kinda unnecessary to have..
Code:
local cfg = {bless = { 1, 2, 3, 4, 5 }
}

together with

for i = 1,5 do
doPlayerAddBlessing(cid, cfg.bless[i])
end
either use
Code:
for i=1,#cfg.bless,1 do
or remove local cfg entirely and use
[code]doPlayerAddBlessing(cid, i)
 
unrelated from it actually working, this is kinda unnecessary to have..
Code:
local cfg = {bless = { 1, 2, 3, 4, 5 }
}

together with

for i = 1,5 do
doPlayerAddBlessing(cid, cfg.bless[i])
end
either use
Code:
for i=1,#cfg.bless,1 do
or remove local cfg entirely and use
[code]doPlayerAddBlessing(cid, i)
the thing about adding bless or so is all good , what need i asking that the first player who uses the book becomes book owner and the owner even can have 5 minutes cooldown to use spellbook even if he die/relog
 
Not testing it.
Any bugs, someone else can help.
Scripted it from scratch the way I'd create such a book.
And yes, I always green-text my own code. :rolleyes:

Code:
local exstorage = 45001 -- any free storage
local exhaust_time = 5 -- in minutes
local dmg_if_not_master = 1 -- 1 = true | 0 = false

function onUse(cid, item, fromPosition, itemEx, toPosition)

     -- Check for Exhaustion
     if exhaustion.check(cid, exstorage) then
         doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
         doPlayerSendCancel(cid, "You are exhausted. You can use this item again in ".. os.date("!%Hh %Mm %Ss", getPlayerStorageValue(cid, exstorage) - os.time()) ..".")
         return true
     end
    
     -- check ownership of book
     if item.aid > 0 then
         if item.aid ~= getPlayerGUID(cid) then
             if dmg_if_not_master == 1 then
                 health = math.random(getCreatureMaxHealth(cid)/10*2, getCreatureMaxHealth(cid)/10*4)
                 if getCreatureHealth(cid) > health then
                     doCreatureAddHealth(cid, -(health))
                 else
                     doCreatureAddHealth(cid, -(getCreatureHealth(cid) - math.random(10)))
                 end
                 doSendMagicEffect(getThingPos(cid), CONST_ME_DRAWBLOOD)
             else
                 doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
             end
             exhaustion.set(cid, exstorage, 10)
             doCreatureSay(cid, "Get your filthy hands off Master " .. getPlayerNameByGUID(item.aid) .. "'s Book you thief!", TALKTYPE_ORANGE_1, cid)
             return true
         end
     end
    
     -- check for blessings
     for i = 1, 5 do
         if getPlayerBlessing(cid, cfg.bless[i]) then
             doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
             doPlayerSendCancel(cid, "You currently have all available blessings.")
             return true
         end
     end
    
     -- Give Blessing, ownership, description, exhaust
     for i = 1, 5 do
         doPlayerAddBlessing(cid, cfg.bless[i])
     end
     if item.aid < 1 then
         doSetItemActionId(item.uid, getPlayerGUID(cid))
         doItemSetAttribute(item.uid, "description", "This item belongs to " .. getCreatureName(cid) .. ".")
     end
     doCreatureSetDropLoot(cid, false)
     exhaustion.set(cid, exstorage, exhaust_time * 60)
    
     -- send effect/text/anim.text
     doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYAREA)
     doSendAnimatedText(getCreaturePosition(cid), "BLESSED!", TEXTCOLOR_RED)
     doPlayerSendTextMessage(cid, 21, "You have been granted all available blessings!")
    
     return true
end
 
Last edited:
Not testing it.
Any bugs, someone else can help.
Scripted it from scratch the way I'd create such a book.
And yes, I always green-text my own code. :rolleyes:

Code:
local exstorage = 45001 -- any free storage
local exhaust_time = 5 -- in minutes
local dmg_if_not_master = 1 -- 1 = true | 0 = false

function onUse(cid, item, fromPosition, itemEx, toPosition)

     -- Check for Exhaustion
     if exhaustion.check(cid, exstorage) then
         doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
         doPlayerSendCancel(cid, "You are exhausted. You can use this item again in ".. os.date("!%Hh %Mm %Ss", getPlayerStorageValue(cid, exstorage) - os.time()) ..".")
         return true
     end
  
     -- check ownership of book
     if item.aid > 0 then
         if item.aid ~= getPlayerGUID(cid) then
             if dmg_if_not_master == 1 then
                 health = math.random(getCreatureMaxHealth(cid)/10*2, getCreatureMaxHealth(cid)/10*4)
                 if getCreatureHealth(cid) > health then
                     doCreatureAddHealth(cid, -(health))
                 else
                     doCreatureAddHealth(cid, -(getCreatureHealth(cid) - math.random(10)))
                 end
                 doSendMagicEffect(getThingPos(cid), CONST_ME_DRAWBLOOD)
             else
                 doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
             end
             exhaustion.set(cid, exstorage, 10)
             doCreatureSay(cid, "Get your filthy hands off Master " .. getPlayerNameByGUID(item.aid) .. "'s Book you thief!", TALKTYPE_ORANGE_1, cid)
             return true
         end
     end
  
     -- check for blessings
     for i = 1, 5 do
         if getPlayerBlessing(cid, cfg.bless[i]) then
             doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
             doPlayerSendCancel(cid, "You currently have all available blessings.")
             return true
         end
     end
  
     -- Give Blessing, ownership, description, exhaust
     for i = 1, 5 do
         doPlayerAddBlessing(cid, cfg.bless[i])
     end
     if item.aid < 1 then
         doSetItemActionId(item.uid, getPlayerGUID(cid))
         doItemSetAttribute(item.uid, "description", "This item belongs to " .. getCreatureName(cid) .. ".")
     end
     doCreatureSetDropLoot(cid, false)
     exhaustion.set(cid, exstorage, exhaust_time * 60)
  
     -- send effect/text/anim.text
     doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYAREA)
     doSendAnimatedText(getCreaturePosition(cid), "BLESSED!", TEXTCOLOR_RED)
     doPlayerSendTextMessage(cid, 21, "You have been granted all available blessings!")
  
     return true
end
He didn't even say thank you, no like no nothing :(
 
Back
Top