• 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++ Fast attack, very fast.

Pifafa

Well-Known Member
Joined
Nov 9, 2010
Messages
108
Reaction score
51
Good morning dear friends, how can I prohibit the use of fast attack scripts on my server? Players who use them attack slightly faster than normal, which is detrimental to the game.
I tried a few improvements but nothing has worked yet.


C++:
    // 3. PROTEÇÃO ANTI-FAST ATTACK (Aqui está a mudança)
    if (creature) {
        g_dispatcher.addTask(createTask(std::bind(&Game::checkCreatureAttack, &g_game, getID())));
        // Calcula quanto tempo passou desde o último ataque
        int64_t diff = OTSYS_TIME() - lastAttack;

        // Se o tempo que passou for MAIOR que a velocidade, pode atacar agora.
        if (diff >= getAttackSpeed()) {
            g_dispatcher.addTask(createTask(std::bind(&Game::checkCreatureAttack, &g_game, getID())));
        }
        // Se for MENOR (está no cooldown), nós AGENDAMOS o ataque para o futuro.
        // Isso impede o exploit, mas garante que o ataque saia na hora certa sem travar o char.
        else {
            g_scheduler.addEvent(createSchedulerTask(getAttackSpeed() - diff, std::bind(&Game::checkCreatureAttack, &g_game, getID())));
        }
    }
    return true;
}
 
Back
Top