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

Premium account error

nanduzenho

Member
Joined
Mar 21, 2021
Messages
187
Solutions
1
Reaction score
15
GitHub
nanduzenho
Good morning, I'm migrating to TFS 1.5 and with that I'm aware that it changes the way the premium account is done. My database has the premium_ends_at column but when logging into the game all characters have 65000+ days of premium. In data\lib\core\player.lua I changed the script as it was in the original TFS folder:
Lua:
function Player.getPremiumTime(self)
    return math.max(0, self:getPremiumEndsAt() - os.time())
end

function Player.setPremiumTime(self, seconds)
    self:setPremiumEndsAt(os.time() + seconds)
    return true
end

function Player.addPremiumTime(self, seconds)
    self:setPremiumTime(self:getPremiumTime() + seconds)
    return true
end

function Player.removePremiumTime(self, seconds)
    local currentTime = self:getPremiumTime()
    if currentTime < seconds then
        return false
    end

    self:setPremiumTime(currentTime - seconds)
    return true
end

function Player.getPremiumDays(self)
    return math.floor(self:getPremiumTime() / 86400)
end

function Player.addPremiumDays(self, days)
    return self:addPremiumTime(days * 86400)
end

function Player.removePremiumDays(self, days)
    return self:removePremiumTime(days * 86400)
end

function Player.isPremium(self)
    return self:getPremiumTime() > 0 --[[or configManager.getBoolean(configKeys.FREE_PREMIUM)]] or self:hasFlag(PlayerFlag_IsAlwaysPremium)
end


I don't know where else I have to change, could someone help me with this problem?

free false.JPG

premium_ends_at.JPG

daysprem.JPG
 
protocollogin.cpp
C++:
void ProtocolLogin::getCharacterList(const std::string& accountName, const std::string& password)

C++:
//Add premium days
    if (g_config.getBoolean(ConfigManager::FREE_PREMIUM)) {
        output->add<uint16_t>(0xFFFF); //client displays free premium
    } else {
        output->add<uint16_t>(std::max<time_t>(0, account.premiumEndsAt - time(nullptr)) / 86400);
    }

That is how its done in C++. Make sure you are adding time correctly.
 
protocollogin.cpp
C++:
void ProtocolLogin::getCharacterList(const std::string& accountName, const std::string& password)

C++:
//Add premium days
    if (g_config.getBoolean(ConfigManager::FREE_PREMIUM)) {
        output->add<uint16_t>(0xFFFF); //client displays free premium
    } else {
        output->add<uint16_t>(std::max<time_t>(0, account.premiumEndsAt - time(nullptr)) / 86400);
    }

That is how its done in C++. Make sure you are adding time correctly.
I'm just trying to add premiumTime and now it's showing Free Account status
free status.JPG
 
Last edited:
Back
Top