• 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+ tfs 1.5 rook system

bpm91

Intermediate OT User
Joined
May 23, 2019
Messages
931
Solutions
7
Reaction score
127
Location
Brazil
YouTube
caruniawikibr
In player.cpp
I'm trying to remove storage 30018 which is from promotion, in case the player is rooked, then he can ask for promotion again, could anyone tell me how I can remove storage 30018 if the player has it? If you don't have it, then don't remove any storage.

Lua:
if (g_config.getBoolean(ConfigManager::ROOK_SYSTEM)) {
            if (getVocationId() != VOCATION_NONE) {
                if (level <= g_config.getNumber(ConfigManager::ROOK_LEVEL)) {
                    // reset stats
                    level = 1;
                    experience = 0;
                    healthMax = 150;
                    manaMax = 0;
                    capacity = 40000;
                    manaSpent = 0;
                    magLevel = 0;
                    soul = 100;
                    setVocation(0);
                    setTown(g_game.map.towns.getTown(g_config.getNumber(ConfigManager::ROOK_TOWN_ID)));
                    loginPosition = town->getTemplePosition();

                    // reset skills
                    for (uint8_t i = SKILL_FIRST; i <= SKILL_LAST; ++i) { //for each skill
                        skills[i].level = 10;
                        skills[i].percent = 0;
                        skills[i].tries = 0;
                    }

                    // unlearn all spells
                    learnedInstantSpellList.clear();

                    // reset inventory
                    for (int32_t slot = getFirstIndex(); slot < getLastIndex(); slot++) {
                        if (inventory[slot]) {
                            g_game.internalRemoveItem(inventory[slot]);
                        }
                    }
                }
            }
        }
    }
 
Solution
Untested but should work
C++:
uint32_t key = 30018;
int32_t promotedValue;
getStorageValue(key, promotedValue);

if (promotedValue > -1) {
    addStorageValue(key, -1);
}
Untested but should work
C++:
uint32_t key = 30018;
int32_t promotedValue;
getStorageValue(key, promotedValue);

if (promotedValue > -1) {
    addStorageValue(key, -1);
}
 
Solution
Untested but should work
C++:
uint32_t key = 30018;
int32_t promotedValue;
getStorageValue(key, promotedValue);

if (promotedValue > -1) {
    addStorageValue(key, -1);
}
where should i place this?
have a similar code and would like to do the same
Lua:
    }

        //agregado send player to rook /*agregado Enable rookgaard system*/
           // Teleport players from mainland back to rookgaard
        if (g_config.getBoolean(ConfigManager::GLOBAL_ROOKSYSTEM)) {
            if (vocation->getId() != VOCATION_NONE && level <= static_cast<uint32_t>(g_config.getNumber(ConfigManager::ROOKGAARD_LEVEL_THRESHOLD))) {
                Town* rookTown = g_game.map.towns.getTown(g_config.getNumber(ConfigManager::ROOKGAARD_TOWN));
                if (rookTown) {
                    // Restart stats
                    level = 1;
                    experience = 0;
                    levelPercent = 0;
                    capacity = 40000; //400oz
                    health = 150;
                    healthMax = 150;
                    mana = 0;
                    manaMax = 0;
                    magLevel = 0;
                    magLevelPercent = 0;
                    manaSpent = 0;
                    setVocation(0);


                    // Restart skills
                    for (uint8_t i = SKILL_FIRST; i <= SKILL_LAST; ++i) { //for each skill
                        skills[i].level = 10;
                        skills[i].tries = 0;
                        skills[i].percent = 0;
                    }

                    // Restart town
                    setTown(rookTown);
                    loginPosition = getTemplePosition();



                    // unlearn all spells
                    learnedInstantSpellList.clear();
                    

                    // Restart first items
                    addStorageValue(30017, 1);

                    // Restart items
                    for (int32_t slot = CONST_SLOT_FIRST; slot <= CONST_SLOT_LAST; slot++)
                    {
                        Item* item = inventory[slot];
                        if (item) {
                            g_game.internalRemoveItem(item, item->getItemCount());
                        }
                    }
                }
                else {
                    std::cout << "[Warning - Player:death] Rookgaard teletransportation is enabled, rookgaard town does not exist." << std::endl;
                }
            }
        }//agregado send player to sook /*agregado Enable rookgaard system*/

    }
 
Back
Top