• 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 Script blessing

darksta

New Member
Joined
Feb 10, 2010
Messages
39
Reaction score
0
hello all!
My problem with the purchase of bless, is that it has limited purchase rather buy them as many times as you want and it is logical that only allowed to purchase only once, till he dies the player to buy another
and the other is that in the command !bless already has bless me also say that I have not
could modify my scripts!
I hope help: c

Script bless
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

  local money = 10000 -- Money Que Quitara
  local bless = 5 --- La Bless Que Dara

if doPlayerRemoveMoney(cid, money) and getPlayerBlessing(cid, bless) then
doPlayerAddBlessing(cid, bless)
  doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_BLUE)
  doPlayerSendTextMessage(cid, 20, ""..getCreatureName(cid).." You buy Bless")
else
  doPlayerSendCancel(cid, "No have money")
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
  end
  return true
  end

The purchase is made by a bless ACTIONID, by a statue

Code:
<action actionid="9696" script="blessing.lua" />

Talksactions command !bless

Code:
function onSay(cid, words, param)

    if getPlayerStorageValue(cid,9999998) == 1 then

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You already possess this blessing.")
    else

            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Sorry, No have Bless! buy it.")

end
    return 1

end
 
Last edited:
If I'm understsanding you correctly, you're wanting to check to see if a player has a blessing before they spend their money, correct? If so, just add an if() that checks whether the player has the blessing BEFORE you call
doPlayerAddBlessing(cid, bless)
 
If I'm understsanding you correctly, you're wanting to check to see if a player has a blessing before they spend their money, correct? If so, just add an if() that checks whether the player has the blessing BEFORE you call
doPlayerAddBlessing(cid, bless)


check using the! bless
if I have bless
and to buy, only to buy once, and let me buy it as often as I want.
 
So you want the player to only pay one time, then after that other blessings are free?
The easiest way to do that is using player storage. I'm currently unable to test this code, so take it as principle only:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

  local money = 10000 -- Money Que Quitara
  local bless = 5 --- La Bless Que Dara
  local blessStorageID = 9999998 --UNIQUE number to represent whether
                  --the player bought bless or not

if(getPlayerStorageValue(cid, blessStorageID) == 1) then
   --Player already paid for bless
   doPlayerAddBlessing(cid, bless)
   doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_BLUE)
   doPlayerSendTextMessage(cid, 20, ""..getCreatureName(cid).." You buy Bless")
   return true
end

if (doPlayerRemoveMoney(cid, money))
   setPlayerStorageValue(blessStorageID,1)
   doPlayerAddBlessing(cid, bless)
   doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_BLUE)
   doPlayerSendTextMessage(cid, 20, ""..getCreatureName(cid).." You buy Bless")
else
   doPlayerSendCancel(cid, "No have money")
   doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end

return true
end

The above code is equivalent to the following pseudo-code:
Code:
If player already bought bless before:
   Give bless for free
   Break out of the function
EndIf

If player has enough money for bless:
   Take player's money and give bless
   Mark that the player bought bless
Else
   Inform player that he doesn't have enough money
EndIf
 
So you want the player to only pay one time, then after that other blessings are free?
The easiest way to do that is using player storage. I'm currently unable to test this code, so take it as principle only:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

  local money = 10000 -- Money Que Quitara
  local bless = 5 --- La Bless Que Dara
  local blessStorageID = 9999998 --UNIQUE number to represent whether
                  --the player bought bless or not

if(getPlayerStorageValue(cid, blessStorageID) == 1) then
   --Player already paid for bless
   doPlayerAddBlessing(cid, bless)
   doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_BLUE)
   doPlayerSendTextMessage(cid, 20, ""..getCreatureName(cid).." You buy Bless")
   return true
end

if (doPlayerRemoveMoney(cid, money))
   setPlayerStorageValue(blessStorageID,1)
   doPlayerAddBlessing(cid, bless)
   doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_BLUE)
   doPlayerSendTextMessage(cid, 20, ""..getCreatureName(cid).." You buy Bless")
else
   doPlayerSendCancel(cid, "No have money")
   doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end

return true
end

The above code is equivalent to the following pseudo-code:
Code:
If player already bought bless before:
   Give bless for free
   Break out of the function
EndIf

If player has enough money for bless:
   Take player's money and give bless
   Mark that the player bought bless
Else
   Inform player that he doesn't have enough money
EndIf

not that, I mean, if the player already bought, not be allowed to buy again until I die,
basically it works the bless

and when using the command !bless
This allows me to know whether I have bless
because in the script "talkactions" that I have so I buy and use the command,
I say they do not and purchased
this is the error..
 
Code:
local bless, money = 5, 10000

function onUse(cid, item, fromPosition, itemEx, toPosition)
   if getPlayerMoney(cid) < money then
     return doPlayerSendCancel(cid, "You don't have enough money."), doSendMagicEffect(getThingPos(cid), CONST_ME_POFF), false
   end

   if getPlayerBlessing(cid, bless) then
     return doPlayerSendCancel(cid, "You already got this blessing."), doSendMagicEffect(getThingPos(cid), CONST_ME_POFF), false
   end

   doPlayerAddBlessing(cid, bless)
   doPlayerRemoveMoney(cid, money)
   doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have purchased the fifth blessing.")
   doSendMagicEffect(getThingPos(cid), CONST_ME_FIREWORK_BLUE)
   return true
end

You should check for player blessing instead of storage key for the talkaction.
 
Last edited:
Code:
local bless, money = 5, 10000

function onUse(cid, item, fromPosition, itemEx, toPosition)
   if not getPlayerMoney(cid, money) then
     return doPlayerSendCancel(cid, "You don't have enough money."), doSendMagicEffect(getThingPos(cid), CONST_ME_POFF), false
   end

   if getPlayerBlessing(cid, bless) then
     return doPlayerSendCancel(cid, "You already got this blessing."), doSendMagicEffect(getThingPos(cid), CONST_ME_POFF), false
   end

   doPlayerAddBlessing(cid, bless)
   doPlayerRemoveMoney(cid, money)
   doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have purchased the fifth blessing.")
   doSendMagicEffect(getThingPos(cid), CONST_ME_FIREWORK_BLUE)
   return true
end

You should check for player blessing instead of storage key for the talkaction.

Error in console

[11/09/2013 10:26:53] [Error - Action Interface]
[11/09/2013 10:26:53] data/actions/scripts/blessing.lua:eek:nUse
[11/09/2013 10:26:53] Description:
[11/09/2013 10:26:53] (luaGetPlayerMoney) Player not found

:/
 
Last edited:
Updated the script, used invalid variable for that function. :p

THANK YOU ALL WORKS OK!

-
Now, when I use the command !bless
to see if I have bless
as you see in the picture, I buy and tells me that I have not bless :/

2z70gi8.jpg
 
It's currently checking if the player got the storage key 9999998
Code:
if getPlayerStorageValue(cid,9999998) == 1 then
change it to
Code:
if getPlayerBlessing(cid, 5) then
 
It's currently checking if the player got the storage key 9999998
Code:
if getPlayerStorageValue(cid,9999998) == 1 then
change it to
Code:
if getPlayerBlessing(cid, 5) then

sorry, a question!
as I do for the lost level when
I have bless it 0
 
It's currently checking if the player got the storage key 9999998
Code:
if getPlayerStorageValue(cid,9999998) == 1 then
change it to
Code:
if getPlayerBlessing(cid, 5) then
the bless man does not work, so what I have low level
as I do to lower level? : s
 
Back
Top