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

Solved Little fix, put interval in a c++ func // Rep +

Rebine

New Member
Joined
Feb 10, 2010
Messages
69
Reaction score
2
Location
Chile
SOLVED: by elime

Hello, i need a little help.-

how it's supposed to be what i can add an interval every 30 seconds for the effect?

This code work but every tick u.u

Code:
if(isSummon() && (getHealth() * 100 / getMaxHealth()) <= 15){
    const Position& tmp = getPosition();
    g_game.addMagicEffect(tmp, 178);
      }

thx
 
Last edited:
My distro is 0.36pl1

Is on monster.cpp
I tried with Scheduler::getInstance().addEvent(createSchedulerTask(500000, boost::bind(&Game::addMagicEffect, &g_game, tmp, 178, false))); but dont work how i need, because sends the effect always.
 
Last edited:
Add a private member in monster.h:
Code:
uint64_t effectTime;

And initialize the variable in monster.cpp in the constructor 'Monster::Monster(MonsterType* _mType)':
Code:
effectTime = 0;

And change your if statement to this:
Code:
if(isSummon() && (getHealth() * 100 / getMaxHealth()) <= 15 && effectTime <= OTSYS_TIME()){
       const Position& tmp = getPosition();
       g_game.addMagicEffect(tmp, 178);
       effectTime = OTSYS_TIME() + 30000;
}
 
Back
Top