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

Lua bless talkactions help please

darknelson

Member
Joined
Jun 19, 2011
Messages
193
Solutions
1
Reaction score
13
im trying to make a bless talkaction, but when u say !bless it works, but when u relog, and say bless again, it take your money again, like is not adding a blessing. or something, please help me

i use nostalrius tfs 1,2 7.7

Lua:
function onSay(cid, words, param)
    local p = Player(cid)
    local cost = 30000
    if(not(isPlayerPzLocked(cid))) then
        if(p:hasBlessing(1) and p:hasBlessing(2) and p:hasBlessing(3) and p:hasBlessing(4) and p:hasBlessing(5) and p:hasBlessing(6) and p:hasBlessing(7) and p:hasBlessing(8)) then
            p:sendCancelMessage("You have already been blessed by the gods.")
            return false
        end
        if(Player(cid):removeMoney(cost)) then
                  for i = 1, 8 do
            if not p:hasBlessing(i) then
                p:addBlessing(i, 1)
            end
        end
            p:getPosition():sendMagicEffect(50)
            p:sendTextMessage(19, "You have been blessed by the gods!")
        else
            p:sendCancelMessage("You need "..cost.." gold coins to buy all blessings.")
        end
    else
        p:sendCancelMessage("You can't buy bless, when you are in a battle.")
    end
return false
end
 

Terotrificy

Active Member
Joined
Oct 18, 2020
Messages
149
Solutions
5
Reaction score
44
Location
Santiago, Chile.
I don't use your distro but you might try this one:


Lua:
function onSay(cid, words, param)
    local p = Player(cid)
    local cost = 30000
    local blessings = false
    if(not(isPlayerPzLocked(cid))) then
        if(p:hasBlessing(1) and p:hasBlessing(2) and p:hasBlessing(3) and p:hasBlessing(4) and p:hasBlessing(5) and p:hasBlessing(6) and p:hasBlessing(7) and p:hasBlessing(8)) then
        blessings = true
        end
        if(Player(cid):removeMoney(cost)) then
            if blessings == false then
                for i = 1, 8 do
                    p:addBlessing(i, 1)
                end
            p:getPosition():sendMagicEffect(50)
            p:sendTextMessage(19, "You have been blessed by the gods!")  
            else p:sendCancelMessage("You have already been blessed by the gods.")
            end
        else p:sendCancelMessage("You need "..cost.." gold coins to buy all blessings.")
        end
    else p:sendCancelMessage("You can't buy bless, when you are in a battle.")
    end
return false
end

I recommend you to check the for iteration too, i'm not sure if it starts in 0 to 7, or 1 to 8.
 
Top