• 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 Another blessing system

Way20

Well-Known Member
Joined
Sep 29, 2014
Messages
227
Solutions
3
Reaction score
91
Hi to everyone, well, I was having problems with my blessing system then I decided to modificate the system to set a less loss EXP, I did it, but now I found one problem when players logout the "bless" disappear. I'm thinking if is possible to set an storage with the "bless" and put in login.lua a way to check it, if player has the storage will set the "bless" again, then make a script with OnDeath function to remove the storage. I don't know if I explain it right, if not, tell me and I'll try explain a bit more.

My blessing NPC (BEFORE)

Code:
local focuses = {}
local function isFocused(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            return true
        end
    end
    return false
end

local function addFocus(cid)
    if(not isFocused(cid)) then
        table.insert(focuses, cid)
    end
end
local function removeFocus(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            table.remove(focuses, i)
            break
        end
    end
end
local function lookAtFocus()
    for i, v in pairs(focuses) do
        if(isPlayer(v)) then
            doNpcSetCreatureFocus(v)
            return
        end
    end
    doNpcSetCreatureFocus(0)
end

local price = 10000 -- Valor da bless

function onCreatureSay(cid, type, msg)
    if(not (isFocused(cid)) and (msg == "hi" or msg == "hello")) then
    if not isPremium(cid) then
        selfSay("You are not VIP, I only sell to VIP players.", cid)
    else
        selfSay("Welcome, ".. getCreatureName(cid) ..". I sell {blessing}.", cid)
        addFocus(cid)
    end
    elseif((isFocused(cid)) and (msg == "bless" or msg == "blessing")) then
        selfSay("Would you like buying blessing per "..price.." gold coins?", cid)
    elseif((isFocused(cid)) and (msg == "yes")) then
        if getPlayerMoney(cid) >= price then
            selfSay("Alright.", cid)
            doPlayerRemoveMoney(cid, price)
            doPlayerAddBlessing(cid, 1)
            doPlayerAddBlessing(cid, 2)
            doPlayerAddBlessing(cid, 3)
            doPlayerAddBlessing(cid, 4)
            doPlayerAddBlessing(cid, 5)
            doPlayerAddBlessing(cid, 6)
        else
            selfSay("You don't have enough money.", cid)
        end
    elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
        selfSay("Goodbye!", cid)
        closeShopWindow(cid)
        removeFocus(cid)
    end
end


function onThink()
    for i, focus in pairs(focuses) do
        if(not isCreature(focus)) then
            removeFocus(focus)
        else
            local distance = getDistanceTo(focus) or -1
            if((distance > 4) or (distance == -1)) then
                selfSay("Hey, where you going?")
                removeFocus(focus)
            end
        end
    end
    lookAtFocus()
end

My blessing NPC (NOW)

Code:
local focuses = {}
local function isFocused(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            return true
        end
    end
    return false
end

local function addFocus(cid)
    if(not isFocused(cid)) then
        table.insert(focuses, cid)
    end
end
local function removeFocus(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            table.remove(focuses, i)
            break
        end
    end
end
local function lookAtFocus()
    for i, v in pairs(focuses) do
        if(isPlayer(v)) then
            doNpcSetCreatureFocus(v)
            return
        end
    end
    doNpcSetCreatureFocus(0)
end

local price = 4000 -- Valor da bless

function onCreatureSay(cid, type, msg)
    if(not (isFocused(cid)) and (msg == "hi" or msg == "hello")) then
    if not isPremium(cid) then
        selfSay("You are not VIP, I only sell blessings to VIP players.", cid)
    else
        selfSay("Welcome, ".. getCreatureName(cid) ..". I sell {blessing}.", cid)
        addFocus(cid)
    end
    elseif((isFocused(cid)) and (msg == "bless" or msg == "blessing")) then
        selfSay("Would you like buying blessing per "..price.." gold coins?", cid)
    elseif((isFocused(cid)) and (msg == "yes")) then
        if getPlayerMoney(cid) >= price then
            selfSay("Alright.", cid)
            doPlayerRemoveMoney(cid, price)
            doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, 10)
        else
            selfSay("You don't have enough money.", cid)
        end
    elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
        selfSay("Goodbye!", cid)
        closeShopWindow(cid)
        removeFocus(cid)
    end
end


function onThink()
    for i, focus in pairs(focuses) do
        if(not isCreature(focus)) then
            removeFocus(focus)
        else
            local distance = getDistanceTo(focus) or -1
            if((distance > 4) or (distance == -1)) then
                selfSay("Hey, where you going?")
                removeFocus(focus)
            end
        end
    end
    lookAtFocus()
end

Someone can help me with this?
 
Check out your creaturescripts and find Login script. That's where it checks if the player has the blessings or not, when logging in.

I only have this part in my login.lua man.

Code:
function onLogin(cid)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 7)
    end
 
blessings should be level based
Code:
 if getPlayerMoney(cid) >= (getPlayerLevel(cid) * price) then

Code:
doPlayerRemoveMoney(cid, (getPlayerLevel(cid) * price))
 
blessings should be level based
Code:
 if getPlayerMoney(cid) >= (getPlayerLevel(cid) * price) then

Code:
doPlayerRemoveMoney(cid, (getPlayerLevel(cid) * price))

I know, thanks for it but I don't care so much about prices, I need a creaturescript with function OnDeath that set a storage value +1, can you help me with this?
 
Back
Top