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

Bug in my tfs 1.2 freepremium = false

dervin13

Active Member
Joined
Apr 26, 2008
Messages
458
Solutions
1
Reaction score
28
Hello, i got a problem that i put freePremium = false in config.lua, and if player get any premium day he will get automaticaly free premium when log in to account... where i can change it?

** The problem is probably in protocollogin.cpp but i cant fix it in tfs 1.2

**Solved

in protocollogin.cpp was
Code:
    //Add premium days
    if (version >= 1080) {
        if (version >= 1082)
            output->addByte(0);
        output->addByte(0x01);
        output->add<uint32_t>(0);
    }
    else {
        output->add<uint16_t>(g_config.getBoolean(ConfigManager::FREE_PREMIUM) ? 0xFFFF : account.premiumDays);
    }

    send(output);

    disconnect();
}

and i chance to
Code:
    // Add premium days
    if (version >= 1080) {
        if (version >= 1082)
            output->addByte(0);
        output->addByte(g_config.getBoolean(ConfigManager::FREE_PREMIUM) || account.premiumDays > 0);
        output->add<uint32_t>(g_config.getBoolean(ConfigManager::FREE_PREMIUM) ? 0 : (time(nullptr) + (account.premiumDays * 86400)));
    }
    else {
        output->add<uint16_t>(g_config.getBoolean(ConfigManager::FREE_PREMIUM) ? 0xFFFF : account.premiumDays);
    }

    send(output);

    disconnect();
}
 
Last edited:
Code:
-- ordered as in creaturescripts.xml
local events = {
    'TutorialCockroach',
    'ElementalSpheresOverlords',
    'BigfootBurdenVersperoth',
    'BigfootBurdenWarzone',
    'BigfootBurdenWeeper',
    'BigfootBurdenWiggler',
    'SvargrondArenaKill',
    'NewFrontierShardOfCorruption',
    'NewFrontierTirecz',
    'ServiceOfYalaharDiseasedTrio',
    'ServiceOfYalaharAzerus',
    'ServiceOfYalaharQuaraLeaders',
    'InquisitionBosses',
    'InquisitionUngreez',
    'KillingInTheNameOfKills',
    'MastersVoiceServants',
    'SecretServiceBlackKnight',
    'ThievesGuildNomad',
    'WotELizardMagistratus',
    'WotELizardNoble',
    'WotEKeeper',
    'WotEBosses',
    'WotEZalamon',
    'PlayerDeath',
    'AdvanceSave',
    'AdvanceRookgaard',
    'PythiusTheRotten',
    'AncedentTarbaz',
    'AncedentShulgrax',
    'AncedentPlagirath',
    'AncedentZamulosh',
    'AncedentMazoran',
    'AncedentRazzagorn',
    'AncedentRagiaz',
    'AncedentFerumbras',
    'Gloombringer',
    'AscedentFerumbrasQuest',
    'DropLoot'
}

local function onMovementRemoveProtection(cid, oldPosition, time)
    local player = Player(cid)
    if not player then
        return true
    end

    local playerPosition = player:getPosition()
    if (playerPosition.x ~= oldPosition.x or playerPosition.y ~= oldPosition.y or playerPosition.z ~= oldPosition.z) or player:getTarget() then
        player:setStorageValue(Storage.combatProtectionStorage, 0)
        return true
    end

    addEvent(onMovementRemoveProtection, 1000, cid, oldPosition, time - 1)
end

function onLogin(player)
    local loginStr = 'Welcome to ' .. configManager.getString(configKeys.SERVER_NAME) .. '!'
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. ' Please choose your outfit.'
        player:sendTutorial(1)
    else
        if loginStr ~= '' then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format('Your last visit was on %s.', os.date('%a %b %d %X %Y', player:getLastLoginSaved()))
    end
    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    local playerId = player:getId()

    -- Stamina
    nextUseStaminaTime[playerId] = 0

    -- Promotion
    local vocation = player:getVocation()
    local promotion = vocation:getPromotion()
    if player:isPremium() then
        local value = player:getStorageValue(Storage.Promotion)
        if not promotion and value ~= 1 then
            player:setStorageValue(Storage.Promotion, 1)
        elseif value == 1 then
            player:setVocation(promotion)
        end
    elseif not promotion then
        player:setVocation(vocation:getDemotion())
    end

    -- Events
    for i = 1, #events do
        player:registerEvent(events[i])
        player:registerEvent("RewardLoot")
    end

    if player:getStorageValue(Storage.combatProtectionStorage) <= os.time() then
        player:setStorageValue(Storage.combatProtectionStorage, os.time() + 10)
        onMovementRemoveProtection(playerId, player:getPosition(), 10)
    end
    return true
end
 
Back
Top