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

!bless with withdraw money from bank

vexler222

Active Member
Joined
Apr 22, 2012
Messages
714
Solutions
15
Reaction score
46
Hi, why this script not work? I can buy bless unlimited times i don't know why ;/

Code:
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() * 7 * 7) * 10
    local kasa_max = math.floor(totalBlessPrice/10000)
    if player:removeMoney(totalBlessPrice) then
        addAllBlesses(cid)      
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Kupiles wszystkie blessy, kosztowalo cie to: " .. kasa_max .." cc")
    else
        if player:withdrawMoney(totalBlessPrice) then
            if player:removeMoney(totalBlessPrice) then
                addAllBlesses(cid)
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Kupiles wszystkie blessy, kosztowalo cie to: " .. kasa_max .." cc")
            else
                player:sendCancelMessage("Masz za malo pieniedzy! (Potrzebujesz: " .. kasa_max .. " cc)", cid)
            end
        else
            player:sendCancelMessage("Masz za malo pieniedzy! (Potrzebujesz: " .. kasa_max .. " cc)", cid)
        end
    end
end
 
Solution
Because you never check if the player already has blessings.

Added the additional check, and also changed how the pricing works..
Because the player shouldn't pay for all 5 blessings.. only the blessings they are missing.

So make sure to modify the price from 1000, to whatever you want lol

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 blessingsNeeded = 0
    for i = 1, 5 do
        if not player:hasBlessing(i) then
            blessingsNeeded = blessingsNeeded + 1
        end
    end
    if blessingsNeeded == 0 then...
Because you never check if the player already has blessings.

Added the additional check, and also changed how the pricing works..
Because the player shouldn't pay for all 5 blessings.. only the blessings they are missing.

So make sure to modify the price from 1000, to whatever you want lol

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 blessingsNeeded = 0
    for i = 1, 5 do
        if not player:hasBlessing(i) then
            blessingsNeeded = blessingsNeeded + 1
        end
    end
    if blessingsNeeded == 0 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You already have all blessings.")
        return false
    end
  
    local pricePerBlessing = 1000
    local totalBlessPrice = pricePerBlessing * blessingsNeeded
    local kasa_max = math.floor(totalBlessPrice/10000)
  
    --local totalBlessPrice = (player:getLevel() * 7 * 7) * 10
    --local kasa_max = math.floor(totalBlessPrice/10000)
    if player:removeMoney(totalBlessPrice) then
        addAllBlesses(cid)    
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Kupiles wszystkie blessy, kosztowalo cie to: " .. kasa_max .." cc")
    else
        if player:withdrawMoney(totalBlessPrice) then
            if player:removeMoney(totalBlessPrice) then
                addAllBlesses(cid)
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Kupiles wszystkie blessy, kosztowalo cie to: " .. kasa_max .." cc")
            else
                player:sendCancelMessage("Masz za malo pieniedzy! (Potrzebujesz: " .. kasa_max .. " cc)", cid)
            end
        else
            player:sendCancelMessage("Masz za malo pieniedzy! (Potrzebujesz: " .. kasa_max .. " cc)", cid)
        end
    end
end
 
Solution
Back
Top