• 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.X+ Bless work incorrect TFS 1.2

olekpro

Member
Joined
Nov 1, 2014
Messages
121
Reaction score
6
Hello.
Config.lua
(i added it manualy)
blessings = true
blessingOnlyPremium = true
blessingReductionBase = 99
blessingReductionDecrement = 99
eachBlessReduction = 99
talkactions/scripts/bless.lua
Lua:
function onSay(cid, words, param)
local bless = {1, 2, 3, 4, 5}
local cost = 50000 -- Cost in gp.
local maxlevel = 50000
local lvl = getPlayerLevel(cid)
local new_cost = (lvl * cost) / 500
local target = getPlayerGUID(cid)
if isPremium(cid) == false then
doPlayerSendCancel(cid, "You need to be premium at first")
return true
end
for i = 1, table.maxn(bless) do
                if(getPlayerBlessing(cid, bless[i])) then
                        doPlayerSendCancel(cid, "You have already have been blessed.")
                        return TRUE
                end
        end
if (getPlayerLevel(cid) >= maxlevel) then
if(doPlayerRemoveMoney(cid, new_cost) == TRUE) then
for i = 1, table.maxn(bless) do
doPlayerAddBlessing(cid, bless[i])
doPlayerSendTextMessage(cid,19,"You have successfully all Bless , now do not need aol.")
end
else
doPlayerSendTextMessage(cid,19,"You need to have "..new_cost.."gp to buy Blesss.")
end
elseif(getPlayerLevel(cid) < maxlevel) then
if(doPlayerRemoveMoney(cid, cost) == TRUE) then
for i = 1, table.maxn(bless) do
doPlayerAddBless(cid, bless[i])
end
doPlayerSendTextMessage(cid,19,"You have successfully been blessed.")

If player get level for example 1400, after dead he lose 4-6 levels, how to repair it? Should lose max 1 level in my opinion is it possible?
else
doPlayerSendTextMessage(cid,19,"You need to have "..cost.."gp to buy Blesss.")
end
end
return FALSE
end
 
Of course my friend!

Lua:
function Player:onBrowseField(position)
    return true
end

function Player:onLook(thing, position, distance)
    local description = "You see " .. thing:getDescription(distance)
    if self:getGroup():getAccess() then
        if thing:isItem() then
            description = string.format("%s\nItem ID: %d", description, thing:getId())

            local actionId = thing:getActionId()
            if actionId ~= 0 then
                description = string.format("%s, Action ID: %d", description, actionId)
            end

            local uniqueId = thing:getAttribute(ITEM_ATTRIBUTE_UNIQUEID)
            if uniqueId > 0 and uniqueId < 65536 then
                description = string.format("%s, Unique ID: %d", description, uniqueId)
            end

            local itemType = thing:getType()

            local transformEquipId = itemType:getTransformEquipId()
            local transformDeEquipId = itemType:getTransformDeEquipId()
            if transformEquipId ~= 0 then
                description = string.format("%s\nTransforms to: %d (onEquip)", description, transformEquipId)
            elseif transformDeEquipId ~= 0 then
                description = string.format("%s\nTransforms to: %d (onDeEquip)", description, transformDeEquipId)
            end

            local decayId = itemType:getDecayId()
            if decayId ~= -1 then
                description = string.format("%s\nDecays to: %d", description, decayId)
            end
        elseif thing:isCreature() then
            local str = "%s\nHealth: %d / %d"
            if thing:getMaxMana() > 0 then
                str = string.format("%s, Mana: %d / %d", str, thing:getMana(), thing:getMaxMana())
            end
            description = string.format(str, description, thing:getHealth(), thing:getMaxHealth()) .. "."
        end

        local position = thing:getPosition()
        description = string.format(
            "%s\nPosition: %d, %d, %d",
            description, position.x, position.y, position.z
        )

        if thing:isCreature() then
            if thing:isPlayer() then
                description = string.format("%s\nIP: %s.", description, Game.convertIpToString(thing:getIp()))
            end
        end
    end
    self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

function Player:onLookInBattleList(creature, distance)
    local description = "You see " .. creature:getDescription(distance)
    if self:getGroup():getAccess() then
        local str = "%s\nHealth: %d / %d"
        if creature:getMaxMana() > 0 then
            str = string.format("%s, Mana: %d / %d", str, creature:getMana(), creature:getMaxMana())
        end
        description = string.format(str, description, creature:getHealth(), creature:getMaxHealth()) .. "."

        local position = creature:getPosition()
        description = string.format(
            "%s\nPosition: %d, %d, %d",
            description, position.x, position.y, position.z
        )

        if creature:isPlayer() then
            description = string.format("%s\nIP: %s", description, Game.convertIpToString(creature:getIp()))
        end
    end
    self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

function Player:onLookInTrade(partner, item, distance)
    self:sendTextMessage(MESSAGE_INFO_DESCR, "You see " .. item:getDescription(distance))
end

function Player:onLookInShop(itemType, count)
    return true
end

function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    return true
end

function Player:onMoveCreature(creature, fromPosition, toPosition)
    return true
end

function Player:onTurn(direction)
    return true
end

function Player:onTradeRequest(target, item)
    return true
end

function Player:onTradeAccept(target, item, targetItem)
    return true
end

local soulCondition = Condition(CONDITION_SOUL, CONDITIONID_DEFAULT)
soulCondition:setTicks(4 * 60 * 1000)
soulCondition:setParameter(CONDITION_PARAM_SOULGAIN, 1)

local function useStamina(player)
    local staminaMinutes = player:getStamina()
    if staminaMinutes == 0 then
        return
    end

    local playerId = player:getId()
    local currentTime = os.time()
    local timePassed = currentTime - nextUseStaminaTime[playerId]
    if timePassed <= 0 then
        return
    end

    if timePassed > 60 then
        if staminaMinutes > 2 then
            staminaMinutes = staminaMinutes - 2
        else
            staminaMinutes = 0
        end
        nextUseStaminaTime[playerId] = currentTime + 120
    else
        staminaMinutes = staminaMinutes - 1
        nextUseStaminaTime[playerId] = currentTime + 60
    end
    player:setStamina(staminaMinutes)
end

function Player:onGainExperience(source, exp, rawExp)
    local ring = self:getSlotItem(CONST_SLOT_RING)
    if ring and ring.itemid == 22516 or ring and ring.itemid == 26188 or ring and ring.itemid == 13826 then
        exp = exp * 2
    end
    if not source or source:isPlayer() then
        return exp
    end

    -- Soul regeneration
    local vocation = self:getVocation()
    if self:getSoul() < vocation:getMaxSoul() and exp >= self:getLevel() then
        soulCondition:setParameter(CONDITION_PARAM_SOULTICKS, vocation:getSoulGainTicks() * 1000)
        self:addCondition(soulCondition)
    end

    -- Apply experience stage multiplier
    exp = exp * Game.getExperienceStage(self:getLevel())

    -- Stamina modifier
    if configManager.getBoolean(configKeys.STAMINA_SYSTEM) then
        useStamina(self)

        local staminaMinutes = self:getStamina()
        if staminaMinutes > 2400 and self:isPremium() then
            exp = exp * 1.5
        elseif staminaMinutes <= 840 then
            exp = exp * 0.5
        end
    end

    return exp
end

function Player:onLoseExperience(exp)
    return exp
end

function Player:onGainSkillTries(skill, tries)
    if APPLY_SKILL_MULTIPLIER == false then
        return tries
    end

    if skill == SKILL_MAGLEVEL then
        return tries * configManager.getNumber(configKeys.RATE_MAGIC)
    end
    return tries * configManager.getNumber(configKeys.RATE_SKILL)
end
 
still lose 5 levels. Should i compile tfs after config.lua changes?
Post automatically merged:

i compiled, it doesn't change anything. On level 1470 i lose 15 levels. (without bless i lose 20)
Post automatically merged:

is it possible if player dead he will lose always 2 levels?
 
Last edited:
Czy ktoś znajdzie rozwiązanie?
Mam ten sam problem w tfs 1.3


EDIT:
I found a working script for tfs 1.3

Lua:
function onSay(cid)

    local player = Player(cid)
    local totalBlessPrice = getBlessingsCost(player:getLevel()) * 5 * 0.7
    if(not(isPlayerPzLocked(cid))) then
    if player:getBlessings() == 5 then
                player:sendCancelMessage("You already have been blessed!", cid)
            elseif player:removeMoney(totalBlessPrice) then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been blessed by all of eight gods!")
                for b = 1, 5 do
                    player:addBlessing(b, 1)
                end
                player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
              
            else
                player:sendCancelMessage("You don't have enough money. You need " .. totalBlessPrice .. " to buy bless.", cid)
            end
    else
        player:sendCancelMessage("You can't buy bless while you are in a battle.")
    end
end
 
Last edited:
Sorry but would it be difficult to adapt an action? I tried and I was not successful with

Lua:
local bless = {1, 2, 3, 4, 5}
local cost = 1 -- Cost in gp.

function onUse(player, words, param)
    if player:getPremiumDays() <= 0 then
        player:sendCancelMessage("You need a premium account to use house scroll.")
        return true
    end

    for i = 1, table.maxn(bless) do
        if player:hasBlessing(bless[i]) then
            return player:sendTextMessage(MESSAGE_INFO_DESCR, "You already have all blessings.")
        end
    end

    if player:removeMoney(cost) then
        for i = 1, table.maxn(bless) do
            player:addBlessing(bless[i])
        end
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have bought all blessings.")
        player:say("You have bought all blessings.",  TALKTYPE_MONSTER_SAY)
        player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You don't have enough money.")
    end
    return true
end
 
Sorry but would it be difficult to adapt an action? I tried and I was not successful with

Lua:
local bless = {1, 2, 3, 4, 5}
local cost = 1 -- Cost in gp.

function onUse(player, words, param)
    if player:getPremiumDays() <= 0 then
        player:sendCancelMessage("You need a premium account to use house scroll.")
        return true
    end

    for i = 1, table.maxn(bless) do
        if player:hasBlessing(bless[i]) then
            return player:sendTextMessage(MESSAGE_INFO_DESCR, "You already have all blessings.")
        end
    end

    if player:removeMoney(cost) then
        for i = 1, table.maxn(bless) do
            player:addBlessing(bless[i])
        end
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have bought all blessings.")
        player:say("You have bought all blessings.",  TALKTYPE_MONSTER_SAY)
        player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You don't have enough money.")
    end
    return true
end
You changed the function but not the arguments (player, words, param)
 
Back
Top