• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

C++ TFS 1.2 I need help in this code

jackl90

Member
Joined
Jul 25, 2017
Messages
249
Reaction score
12
My code of creature death in Player.cpp
C++:
void Player::death(Creature* lastHitCreature)
{
    loginPosition = town->getTemplePosition();

    if (skillLoss) {
        //Magic level loss
        uint64_t sumMana = 0;
        uint64_t lostMana = 0;

        //sum up all the mana
        for (uint32_t i = 1; i <= magLevel; ++i) {
            sumMana += vocation->getReqMana(i);
        }


C++:
loginPosition = town->getTemplePosition();

this code part , how can i modific only for player die in tile hasFlag(TILESTATE_NOPVPZONE)
loginPosition will be x,2002y,1000,z,7 but if not hasFlag(TILESTATE_NOPVPZONE) continue default code
 
Solution
C++:
void Player::death(Creature* lastHitCreature)
{
    const Tile* playerTile = getTile();
    if (playerTile && playerTile->hasFlag(TILESTATE_NOPVPZONE)) {
        loginPosition = Position(2002, 1000, 7);
    } else {
        loginPosition = town->getTemplePosition();
    }
    if (skillLoss) {
        //Magic level loss
        uint64_t sumMana = 0;
        uint64_t lostMana = 0;
        //sum up all the mana
        for (uint32_t i = 1; i <= magLevel; ++i) {
            sumMana += vocation->getReqMana(i);
        }
Excuse me, what are you trying to achieve? That if player dies on nopvpzone it won't lose anything?

Hello Ramirow, no... i just want change the place where the player will go after death, this case a specific position only if player die in TILESTATE_NOPVPZONE.
 
C++:
void Player::death(Creature* lastHitCreature)
{
    const Tile* playerTile = getTile();
    if (playerTile && playerTile->hasFlag(TILESTATE_NOPVPZONE) {
        loginPosition = Position(2002, 1000, 7);
    } else {
        loginPosition = town->getTemplePosition();
    }
    if (skillLoss) {
        //Magic level loss
        uint64_t sumMana = 0;
        uint64_t lostMana = 0;
        //sum up all the mana
        for (uint32_t i = 1; i <= magLevel; ++i) {
            sumMana += vocation->getReqMana(i);
        }
 
I got a error compilling

my current code after modification
C++:
void Player::death(Creature* lastHitCreature)
{
    const Tile* playerTile = getTile();
    if (playerTile && playerTile->hasFlag(TILESTATE_NOPVPZONE) {
        loginPosition = Position(2002, 1000, 7);
    } else {
        loginPosition = town->getTemplePosition();
    }

    if (skillLoss) {
        //Magic level loss
        uint64_t sumMana = 0;
        uint64_t lostMana = 0;

        //sum up all the mana
        for (uint32_t i = 1; i <= magLevel; ++i) {
            sumMana += vocation->getReqMana(i);
        }

Compilling error details
Code:
1>..\src\player.cpp(1670): error C2059: syntax error: ';'
1>..\src\player.cpp(1671): error C2059: syntax error: 'else'
1>..\src\player.cpp(1671): error C2143: syntax error: missing ';' before '{'
1>..\src\player.cpp(1671): error C2447: '{': missing function header (old-style formal list?)
1>..\src\player.cpp(1675): error C2059: syntax error: 'if'
1>..\src\player.cpp(1675): error C2143: syntax error: missing ';' before '{'
1>..\src\player.cpp(1675): error C2447: '{': missing function header (old-style formal list?)
1>..\src\player.cpp(1850): error C2059: syntax error: 'else'
1>..\src\player.cpp(1850): error C2143: syntax error: missing ';' before '{'
1>..\src\player.cpp(1850): error C2447: '{': missing function header (old-style formal list?)
1>..\src\player.cpp(1875): error C2059: syntax error: '}'
1>..\src\player.cpp(1875): error C2143: syntax error: missing ';' before '}'
1>..\src\player.cpp(1878): error C2143: syntax error: missing ';' before '{'
1>..\src\player.cpp(1878): error C2447: '{': missing function header (old-style formal list?)
 
C++:
void Player::death(Creature* lastHitCreature)
{
    const Tile* playerTile = getTile();
    if (playerTile && playerTile->hasFlag(TILESTATE_NOPVPZONE)) {
        loginPosition = Position(2002, 1000, 7);
    } else {
        loginPosition = town->getTemplePosition();
    }
    if (skillLoss) {
        //Magic level loss
        uint64_t sumMana = 0;
        uint64_t lostMana = 0;
        //sum up all the mana
        for (uint32_t i = 1; i <= magLevel; ++i) {
            sumMana += vocation->getReqMana(i);
        }
 
Solution

Similar threads

Back
Top