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

[TFS 1.3] !bless and !aol withdrawing money from your bank account if needed.

Joined
Dec 7, 2016
Messages
22
Reaction score
6
Hey guys, I'd like to share something I created. I learned from all the scripts that you guys shared in here. If you have any suggestions for improvements, they'll be most welcome.
Lets get to it, both !aol and !bless are pretty simple but they try to withdraw money from the player's bank account if the player doesn't have money available.

!aol command

Add this to /data/talkactions/talkactions.xml:
XML:
<talkaction words="!aol" script="aol.lua"/>

Create a new file called aol.lua in /data/talkactions/scripts and paste this in its content:
Lua:
local price_aol = 10000

function onSay(player, words, param)
    if player:removeMoney(price_aol) then
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
        player:addItem(2173, 1)
    else
        if player:withdrawMoney(price_aol) then
            if player:removeMoney(price_aol) then
                player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
                player:addItem(2173, 1)
            end
        else
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
            player:sendCancelMessage("You don't have enought money. Not even in your bank!")
        end
    end

    return true
end

!bless command

Add this to /data/talkactions/talkactions.xml:
XML:
<talkaction words="!bless" script="bless.lua"/>

Create a new file called bless.lua in /data/talkactions/scripts and paste this in its content:
Lua:
function addAllBlesses(cid)
    local player = Player(cid)
    for i = 1, 5 do
        if not player:hasBlessing(i) then
            player:addBlessing(i, 1)
        end
    end
end

function onSay(cid)
    local player = Player(cid)
   
    local totalBlessPrice = (player:getLevel() * 5 * 5) * 10

    if player:removeMoney(totalBlessPrice) then
        addAllBlesses(cid)      
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been blessed by all of five gods!")
    else
        if player:withdrawMoney(totalBlessPrice) then
            if player:removeMoney(totalBlessPrice) then
                addAllBlesses(cid)
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been blessed by all of five gods!")
            else
                player:sendCancelMessage("You don't have enough money. You need " .. totalBlessPrice .. " to buy bless.", cid)
            end
        else
            player:sendCancelMessage("You don't have enough money. Not even in your bank account! You need " .. totalBlessPrice .. " to buy bless.", cid)
        end
    end
end

And thats it I guess. Thank you all for being a great community. I'll share our implementation of an account manager on TFS 1.3 once it is somewhat presentable. lmao.

By the way, I have not tested this in prior versions nor will I try to make them work on your version because I don't have time to do it. Sorry.

Credits to: @roriscave.
 
Last edited:
is better, change it:

Lua:
function addAllBlesses(cid)
    local player = Player(cid)

    if not player:hasBlessing(1) then
        player:addBlessing(1,1)
    end
    if not player:hasBlessing(2) then
        player:addBlessing(2,1)
    end
    if not player:hasBlessing(3) then
        player:addBlessing(3,1)
    end
    if not player:hasBlessing(4) then
        player:addBlessing(4,1)
    end
    if not player:hasBlessing(5) then
        player:addBlessing(5,1)
    end
end
to it:

Lua:
function addAllBlesses(cid)
    local player = Player(cid)
    for i = 1, 5 do
        if not player:hasBlessing(i) then
            player:addBlessing(i, 1)
        end
    end
end
 
is better, change it:

Lua:
function addAllBlesses(cid)
    local player = Player(cid)

    if not player:hasBlessing(1) then
        player:addBlessing(1,1)
    end
    if not player:hasBlessing(2) then
        player:addBlessing(2,1)
    end
    if not player:hasBlessing(3) then
        player:addBlessing(3,1)
    end
    if not player:hasBlessing(4) then
        player:addBlessing(4,1)
    end
    if not player:hasBlessing(5) then
        player:addBlessing(5,1)
    end
end
to it:

Lua:
function addAllBlesses(cid)
    local player = Player(cid)
    for i = 1, 5 do
        if not player:hasBlessing(i) then
            player:addBlessing(i, 1)
        end
    end
end
Nice, already edited into the post and added to my own function, thanks!
 
Hey, i am using this script.
One bug.

Example:

You bless cost: 40k
If you have 20k on bp and 20k on bank, he dont buy bless. You need 40k+ on bp or bank.
 
Hey, i am using this script.
One bug.

Example:

You bless cost: 40k
If you have 20k on bp and 20k on bank, he dont buy bless. You need 40k+ on bp or bank.
tfs 1.3 already has a function to remove money from inventory and bank (here), just change all :removeMoney to :removeTotalMoney, and :getMoney with :getTotalMoney
 
Hi!
Would this work then?
Lua:
function addAllBlesses(cid)
    local player = Player(cid)
    for i = 1, 5 do
        if not player:hasBlessing(i) then
            player:addBlessing(i, 1)
        end
    end
end

function onSay(cid)
    local player = Player(cid)
    local totalBlessPrice = (player:getLevel() * 5 * 5) * 10

    if player:removeTotalMoney(totalBlessPrice) then
        addAllBlesses(cid)     
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been blessed by all of five gods!")
    else
        player:sendCancelMessage("You don't have enough money. Not even in your bank account! You need " .. totalBlessPrice .. " to buy bless.", cid)
    end
end
 
working blessing script tfs1.3


Lua:
function onSay(cid)
    local player = Player(cid)
    local totalBlessPrice = getBlessingsCost(player:getLevel()) * 10 * 0.5   
    if player:getBlessings() == 5 then
        player:sendCancelMessage("You already have been blessed!", cid)
    elseif player:removeMoneyNpc(totalBlessPrice) then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been blessed by all of eight gods!")
        for b = 1, 8 do
            if not player:hasBlessing(b) then
                player:addBlessing(b, 1)
            end
        end
        player:setStorageValue(999563, 1)
        player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
    else
        player:sendCancelMessage("You don't have enough money. You need " .. totalBlessPrice .. " to buy bless.", cid)
    end
    
    return false
end
 
working good.

i use it for !backpack
Lua:
local price_backpack = 1000

function onSay(player, words, param)
    if player:removeMoney(price_backpack) then
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
        player:addItem(2004, 1)
    else
        if player:withdrawMoney(price_backpack) then
            if player:removeMoney(price_backpack) then
                player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
                player:addItem(2004, 1)
            end
        else
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
            player:sendCancelMessage("You don't have enought money. Not even in your bank!")
        end
    end

    return true
end
 
Back
Top