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

C++ Help ! How remove option to wear addons free account TFS 1.2

gubbo123

New Member
Joined
Aug 15, 2017
Messages
151
Solutions
1
Reaction score
3
How can i remove all (addons) from players free account?

i saw something related to addons in ProtocolGame.cpp
C++:
void ProtocolGame::AddOutfit(NetworkMessage& msg, const Outfit_t& outfit)
{
    msg.add<uint16_t>(outfit.lookType);

    if (outfit.lookType != 0) {
        msg.addByte(outfit.lookHead);
        msg.addByte(outfit.lookBody);
        msg.addByte(outfit.lookLegs);
        msg.addByte(outfit.lookFeet);
        msg.addByte(outfit.lookAddons);
    } else {
        msg.addItemId(outfit.lookTypeEx);
    }

    msg.add<uint16_t>(outfit.lookMount);
}
 
Solution
Code:
function onLogin(player)
    local outfit = player:getOutfit()
    if not player:isPremium() and outfit.addons ~= 0 then
        outfit.addons = 0
        player:setOutfit(outfit)
    end
return true
end

player.cpp

find

Code:
bool Player::getOutfitAddons(const Outfit& outfit, uint8_t& addons) const

replace whole code with this

Code:
bool Player::getOutfitAddons(const Outfit& outfit, uint8_t& addons) const
{
    if (group->access) {
        addons = 3;
        return true;
    }

    if (outfit.premium && !isPremium()) {
        return false;
    }
  
  

    for (const OutfitEntry& outfitEntry : outfits) {
        if (outfitEntry.lookType != outfit.lookType) {
            continue;
        }
      
        if (!isPremium())...
You mean only premium players can get first and second addon? If yes then you can just do it through data\XML\outfits.xml and add to all addons premium="yes"
 
but, if the outfit is free account?, but the outfit have addons, how can i remove only addons of outfit? because if i set premium="yes" the outfit will be removed too.
 
How do players get addons? through NPC? you can just edit the NPC to sell for premium players only instead of source edits and removing it at all.
 
through npc, the npc only sell addons for premium players... but the problem is when the premium player lose premium account, i just want remove the addons of outfit.
 
You can just add onlogin script like this

Lua:
function onLogin(player)
    local outfitsToUpgrade = {
        136, 137, 138, 139, 140, 141, 142, 147, 148, 149, 150, 155, 156, 157, 158, 252, 269, 270, 279, 288, 324, 329,
        336, 366, 431, 433, 464, 466, 471, 513, 514, 542, 575, 578, 618, 620, 632, 635, 636, 664, 666, 683, 694, 696,
        698, 724, 732, 745, 749, 759, 845, 852, 874, 885, 900, 909, 929, 956, 958, 963, 965, 967, 969, 971, 973, 975,
        128, 129, 130, 131, 132, 133, 134, 143, 144, 145, 146, 151, 152, 153, 154, 251, 268, 273, 278, 289, 325, 328,
        335, 367, 430, 432, 463, 465, 472, 512, 516, 541, 574, 577, 610, 619, 633, 634, 637, 665, 667, 684, 695, 699,
        725, 733, 746, 750, 760, 846, 853, 873, 884, 899, 908, 931, 955, 957, 962, 964, 966, 968, 970, 972, 974
    }


    if not player:isPremium() then
        for i = 1, #outfitsToUpgrade do
            player:removeOutfitAddon(outfitsToUpgrade[i], 2)
            player:removeOutfitAddon(outfitsToUpgrade[i], 1)
        end
    end

    return true
end
it will remove outfit addons if a player isn't premium.
 
When players are premium do they get all addons by default? Or they have to buy 1 by 1 and collect items etc..?
 
Same thing happened with Lua will happen if you edited source unless you added custom lines.
I only have 1 thing to help if you think it isn't the solution you are looking for then wait for someone else to try helping you.
Make the addons NPC seller adds a storage to players on first addon/second addon then when the premium time is ended set onlogin script to remove this storage and when it is bought again set a onlogin script to re-add the storage. (Exactly like quest addons) Wayfarer/Yalahar.
if you want me to try doing it post your NPC script.
 
well, to solve my problem now, i just need a script onLogin to check

if the player have this storages separated, and not is premium remove this storages...
and if the player back to be premium, storages removed will back.

If the player have just addon 1
Addon 1 storage = 10001001 value = 8585217

If the player have just addon 2
Addon 2 storage = 10001001 value = 8585218

and both addons added, storage = 10001001 value = 8585219
 
Just use a storage seed.

Find a range of available storage values, etc 40000 - 41000 is available

Then store a copy of your outfit states as a storage value.

Lua:
function onLogin(player)
    local outfitList = {
        136, 137, 138, 139, 140, 141, 142, 147, 148, 149, 150, 155, 156, 157, 158, 252, 269, 270, 279, 288, 324, 329,
        336, 366, 431, 433, 464, 466, 471, 513, 514, 542, 575, 578, 618, 620, 632, 635, 636, 664, 666, 683, 694, 696,
        698, 724, 732, 745, 749, 759, 845, 852, 874, 885, 900, 909, 929, 956, 958, 963, 965, 967, 969, 971, 973, 975,
        128, 129, 130, 131, 132, 133, 134, 143, 144, 145, 146, 151, 152, 153, 154, 251, 268, 273, 278, 289, 325, 328,
        335, 367, 430, 432, 463, 465, 472, 512, 516, 541, 574, 577, 610, 619, 633, 634, 637, 665, 667, 684, 695, 699,
        725, 733, 746, 750, 760, 846, 853, 873, 884, 899, 908, 931, 955, 957, 962, 964, 966, 968, 970, 972, 974
    }
    local storageSeed = 40000

    local is_premium = player:isPremium()

    for i = 1, #outfitList do
        -- We don't have a -1 -> 3 getOutFit function?
        local has_outfit = player:hasOutfit(outfitList[i], 0)
        local has_addon1 = nil
        local has_addon2 = nil
       
        -- -1 = no outfit, 0 = has outfit, 1 = outfit with first addon, 2 = outfit with 2nd addon, 3 = outfit with both addons
        local outfit_value = -1

        -- Calculate user addons (without checking storage copy)
        if has_outfit then
            outfit_value = 0
            has_addon1 = player:hasOutfit(outfitList[i], 1)
            has_addon2 = player:hasOutfit(outfitList[i], 2)

            if has_addon1 then
                outfit_value = outfit_value + 1
            end
            if has_addon2 then
                outfit_value = outfit_value + 2
            end
        end

        -- If you are free account
        if not is_premium then
            -- If you have an addon
            if outfit_value > 0 then
                -- Store it before you remove it
                player:setStorageValue(storageSeed + outfitList[i],outfit_value)

                -- Remove it
                if has_addon1 then player:removeOutfitAddon(outfitList[i], 1) end
                if has_addon2 then player:removeOutfitAddon(outfitList[i], 2) end
            end
       
        else -- You are premium account

            -- Get stored outfit addons
            local storage_outfit_value = player:getStorageValue(storageSeed + outfitList[i])

            -- Perhaps you have an addon from storage that we need to add?
            if outfit_value ~= storage_outfit_value then
                if storage_outfit_value > 0 then
                    -- If you have 2nd addon, add it
                    if storage_outfit_value > 1 then
                        player:addOutfitAddon(outfitList[i], 2)
                        -- If you also have 1st addon, add it
                        if storage_outfit_value > 2 then
                            player:addOutfitAddon(outfitList[i], 1)
                        end

                    else -- You just have first addon
                        player:addOutfitAddon(outfitList[i], 1)
                    end
                end
            end
        end
    end
    return true
end
 
Last edited:
Code:
function onLogin(player)
    local outfit = player:getOutfit()
    if not player:isPremium() and outfit.addons ~= 0 then
        outfit.addons = 0
        player:setOutfit(outfit)
    end
return true
end

player.cpp

find

Code:
bool Player::getOutfitAddons(const Outfit& outfit, uint8_t& addons) const

replace whole code with this

Code:
bool Player::getOutfitAddons(const Outfit& outfit, uint8_t& addons) const
{
    if (group->access) {
        addons = 3;
        return true;
    }

    if (outfit.premium && !isPremium()) {
        return false;
    }
  
  

    for (const OutfitEntry& outfitEntry : outfits) {
        if (outfitEntry.lookType != outfit.lookType) {
            continue;
        }
      
        if (!isPremium()) {
            addons = 0;
            return true;
        } else {
            addons = outfitEntry.addons;
            return true;
        }
    }

    if (!outfit.unlocked) {
        return false;
    }

    addons = 0;
    return true;
}
 
Last edited:
Solution
Thanks so much guys, solved my problem, i market the best aswer :))


@Itutorial i solved a compilation error
here
if (!isPremium) i changed to if (!isPremium())

if u can, edit ur post with the replace, for others guys that want this solution too
 
Back
Top