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

Feature Anti Anti-Push bot | Works 100%

Xampy

PHP | SQL | LUA | C++
Joined
Jun 22, 2008
Messages
1,109
Reaction score
17
Hello!
I'm making this in a request by kito2. It works with TFS 0.4 | Not tested with TFS 0.3.X neither 0.2.X!

What does it do?
It detects if you're moving an object/item with an ID that is set in config.lua (configurable) then it adds an exhaustion of X ms (configurable). If you try to move an "anti-push item" (dunno how to call it) then it will say an error message if you're exhausted yet. Basically what it does is making non-working Anti-Push bot feature.
It has been added by default these items:
- 2148 (Gold Coin)
- 2152 (Platinum Coin)
- 2160 (Crystal Coin)
- 3976 (Worms)

Surely nobody will throw crystal coins while the anti-push is working, but it has been added by default, you can remove it if you want, or add other items, as you prefer.

Credits goes to:
· Xampy (me) for making the system.
· .3lite for helping me to read arrays from config.lua

Ok, let's start:
Go to line 1440~ of game.cpp and replace this:
PHP:
        ReturnValue ret = internalMoveItem(player, fromCylinder, toCylinder, toIndex, item, count, NULL);
        if(ret == RET_NOERROR)
                return true;

        player->sendCancelMessage(ret);
        return false;
by this:
PHP:
// Anti-Push feature Prevention System by Xampy //
    if(g_config.getBool(ConfigManager::ANTI_PUSH))
    {
        int16_t indexItem = toIndex;
        std::string antiPushItems = g_config.getString(ConfigManager::ANTI_PUSH_ITEMS);
        if(antiPushItems.size())
        {
            IntegerVec tmpVec = vectorAtoi(explodeString(antiPushItems, ","));
            if(tmpVec[0] != 0)
            {                     
                int i;
                int arraySize = tmpVec.size();
                i = 0;
                for(IntegerVec::iterator it = tmpVec.begin(); it != tmpVec.end(); ++it)
                {
                    i++;
                    if(item->getID() == uint32_t(*it) && indexItem < 1 && mapFromPos == mapToPos)
                    {
                        if(player->hasCondition(CONDITION_EXHAUST, EXHAUST_MOVE_ITEMS))
                        {
                            player->sendTextMessage(MSG_INFO_DESCR, "You cannot move this object.\nAnti-Push prevention.");
                            return false;
                        }
                        else
                        {
                            ReturnValue ret = internalMoveItem(player, fromCylinder, toCylinder, toIndex, item, count, NULL);
                            if(ret == RET_NOERROR)
                            {
                                 int32_t ticks = g_config.getNumber(ConfigManager::ANTI_PUSH_DELAY);
                                player->addExhaust(ticks, EXHAUST_MOVE_ITEMS);
                                return true; 
                            }  
                            player->sendCancelMessage(ret);
                            return false;
                        }
                    }
                    else
                    {
                        if(arraySize == i)
                        {
                            ReturnValue ret = internalMoveItem(player, fromCylinder, toCylinder, toIndex, item, count, NULL);
                            if(ret == RET_NOERROR)
                                return true;
                            player->sendCancelMessage(ret);
                            return false;
                        }
                    }
                }
            }
        }
       }
       else
       {
        ReturnValue ret = internalMoveItem(player, fromCylinder, toCylinder, toIndex, item, count, NULL);
        if(ret == RET_NOERROR)
            return true;   
        player->sendCancelMessage(ret);
        return false;
    }
     
    return false;
// Anti-Push feature Prevention System by Xampy //
Then open player.h and replace this:
PHP:
enum Exhaust_t
{
    EXHAUST_COMBAT = 1,
    EXHAUST_HEALING = 2
};
by this:
PHP:
enum Exhaust_t
{
    EXHAUST_COMBAT = 1,
    EXHAUST_HEALING = 2,
    EXHAUST_MOVE_ITEMS = 3
};
Now open configmanager.cpp and after this:
PHP:
m_confBool[ADDONS_PREMIUM] = getGlobalBool("addonsOnlyPremium", true);
paste this:
PHP:
    m_confBool[ANTI_PUSH] = getGlobalBool("useAntiPush", true);
    m_confNumber[ANTI_PUSH_DELAY] = getGlobalNumber("antiPushDelay", 3000);
    m_confString[ANTI_PUSH_ITEMS] = getGlobalString("antiPushItems", "");
Finally, open configmanager.h and after this:
PHP:
ADDONS_PREMIUM,
paste this:
PHP:
ANTI_PUSH,
2)after this:
PHP:
STAMINA_DESTROY_LOOT,
paste this:
PHP:
ANTI_PUSH_DELAY,
3)after this:
PHP:
ADMIN_ENCRYPTION_DATA,
paste this:
PHP:
ANTI_PUSH_ITEMS,
Now compile the server and paste this in the config.lua file:

PHP:
-- Anti-Push Prevention System by Xampy
useAntiPush = true --// enabled = true or disabled = false
antiPushDelay = 3000 --// default is 3000 (3 seconds)
antiPushItems = "2148,2152,2160,3976" --// add as much items as you want separated by comma
Now you can run the server and you're done.
This system is enabled by default with 3000ms of exhaustion.

It has been fully tested, and no errors have been found. If you think something is not working properly, ask for help in this thread.

Enjoy!
 
Last edited:
Xampy, would you believe me that my solution of transforming gps was sufficient? xD

Now people just use anti-push some times, and just go with 200-300 gps to wars, and now it is 100% breakable xD

This will help on ots where wars are 10 vs 10 or less...

Anyway thanks, it rox!
 
Last edited:
configmanager.h add:
PHP:
ANTI_PUSH_ITEMS
configmanager.cpp add:
PHP:
m_confString[ANTI_PUSH_ITEMS] = getGlobalString("antiPushItems", "");


game.cpp change previous code with this:
PHP:
char buffer[90];
if(g_config.getBool(ConfigManager::ANTI_PUSH) && player->hasCondition(CONDITION_EXHAUST, EXHAUST_MOVE_ITEMS) && g_config.getString(ConfigManager::ANTI_PUSH_ITEMS).pos(itoa(item->getID(),buffer,10)) != std::string::npos)
    {
        player->sendTextMessage(MSG_INFO_DESCR, "You cannot move this object.\nAnti-Push prevention.");
        return false;
    }
    if(internalMoveItem(player, fromCylinder, toCylinder, toIndex, item, count, NULL) == RET_NOERROR)
    {
     if(g_config.getBool(ConfigManager::ANTI_PUSH) && g_config.getString(ConfigManager::ANTI_PUSH_ITEMS).pos(itoa(item->getID(),buffer,10)) != std::string::npos)
       player->addExhaust(ticks, g_config.getNumber(ConfigManager::ANTI_PUSH_DELAY));
     return true;
    }

Should work, no tested, in that case you shall have in config.lua :

Code:
antiPushItems = "" -- ids in there

Like:

Code:
antiPushItems = "1234,2345,6567,9786"

You can separate them using anything, thats the beauty using simply string search function if item is in "array"
 
Xampy, would you believe me that my solution of transforming gps was sufficient? xD

Now people just use anti-push some times, and just go with 200-300 gps to wars, and now it is 100% breakable xD

This will help on ots where wars are 10 vs 10 or less...

Anyway thanks, it rox!
Yea, it's a tiny solution, but I prefer to people can change platinum coins by crystal coins and viceversa. Thanks :)!
configmanager.h add:
PHP:
ANTI_PUSH_ITEMS
configmanager.cpp add:
PHP:
m_confString[ANTI_PUSH_ITEMS] = getGlobalString("antiPushItems", "");


game.cpp change previous code with this:
PHP:
char buffer[90];
if(g_config.getBool(ConfigManager::ANTI_PUSH) && player->hasCondition(CONDITION_EXHAUST, EXHAUST_MOVE_ITEMS) && g_config.getString(ConfigManager::ANTI_PUSH_ITEMS).pos(itoa(item->getID(),buffer,10)) != std::string::npos)
    {
        player->sendTextMessage(MSG_INFO_DESCR, "You cannot move this object.\nAnti-Push prevention.");
        return false;
    }
    if(internalMoveItem(player, fromCylinder, toCylinder, toIndex, item, count, NULL) == RET_NOERROR)
    {
     if(g_config.getBool(ConfigManager::ANTI_PUSH) && g_config.getString(ConfigManager::ANTI_PUSH_ITEMS).pos(itoa(item->getID(),buffer,10)) != std::string::npos)
       player->addExhaust(ticks, g_config.getNumber(ConfigManager::ANTI_PUSH_DELAY));
     return true;
    }

Should work, no tested, in that case you shall have in config.lua :

Code:
antiPushItems = "" -- ids in there

Like:

Code:
antiPushItems = "1234,2345,6567,9786"

You can separate them using anything, thats the beauty using simply string search function if item is in "array"
I'll test it, if it works I'll put it in the first thread. Thanks.^_^
@edit:
Your code doesn't work for me, I get this error while compiling (dunno how to repair it):
PHP:
1441 game.cpp 'const struct std::basic_string<char, std::char_traits<char>, std::allocator<char> >' has no member named 'pos' 
1449 game.cpp 'const struct std::basic_string<char, std::char_traits<char>, std::allocator<char> >' has no member named 'pos'
Problem is in this:
Code:
g_config.getString(ConfigManager::ANTI_PUSH_ITEMS).pos(itoa(item->getID(),buffer,10)) != std::string::npos
 
Last edited:
I'll test it, if it works I'll put it in the first thread. Thanks.^_^

I hope it works, I never tested it, just came to my mind and wrote it here.

but I'm pretty sure it won't work in Linux, since itoa isn't std standard I believe, so we need to declare it somewhere:
PHP:
#ifndef WIN32
char* itoa(int val, char *buffer /* spaceholder */, int base){
	
	static char buf[32] = {0};
	
	int i = 30;
	
	for(; val && i ; --i, val /= base)
	
		buf[i] = "0123456789abcdef"[val % base];
	
	return &buf[i+1];
	
}
#endif
 
I hope it works, I never tested it, just came to my mind and wrote it here.

but I'm pretty sure it won't work in Linux, since itoa isn't std standard I believe, so we need to declare it somewhere:
PHP:
#ifndef WIN32
char* itoa(int val, char *buffer /* spaceholder */, int base){
	
	static char buf[32] = {0};
	
	int i = 30;
	
	for(; val && i ; --i, val /= base)
	
		buf[i] = "0123456789abcdef"[val % base];
	
	return &buf[i+1];
	
}
#endif
I keep getting the same error. Btw, I'm compiling on Windows, not Linux... xD The error is in 'pos', idk.
 
Sorry, I was working on several Strings class and I've missed function, here it is:
PHP:
char buffer[90];
if(g_config.getBool(ConfigManager::ANTI_PUSH) && player->hasCondition(CONDITION_EXHAUST, EXHAUST_MOVE_ITEMS) && g_config.getString(ConfigManager::ANTI_PUSH_ITEMS).find(itoa(item->getID(),buffer,10)) != std::string::npos)
    {
        player->sendTextMessage(MSG_INFO_DESCR, "You cannot move this object.\nAnti-Push prevention.");
        return false;
    }
    if(internalMoveItem(player, fromCylinder, toCylinder, toIndex, item, count, NULL) == RET_NOERROR)
    {
     if(g_config.getBool(ConfigManager::ANTI_PUSH) && g_config.getString(ConfigManager::ANTI_PUSH_ITEMS).find(itoa(item->getID(),buffer,10)) != std::string::npos)
       player->addExhaust(ticks, g_config.getNumber(ConfigManager::ANTI_PUSH_DELAY));
     return true;
    }
 
Sorry, I was working on several Strings class and I've missed function, here it is:
PHP:
char buffer[90];
if(g_config.getBool(ConfigManager::ANTI_PUSH) && player->hasCondition(CONDITION_EXHAUST, EXHAUST_MOVE_ITEMS) && g_config.getString(ConfigManager::ANTI_PUSH_ITEMS).find(itoa(item->getID(),buffer,10)) != std::string::npos)
    {
        player->sendTextMessage(MSG_INFO_DESCR, "You cannot move this object.\nAnti-Push prevention.");
        return false;
    }
    if(internalMoveItem(player, fromCylinder, toCylinder, toIndex, item, count, NULL) == RET_NOERROR)
    {
     if(g_config.getBool(ConfigManager::ANTI_PUSH) && g_config.getString(ConfigManager::ANTI_PUSH_ITEMS).find(itoa(item->getID(),buffer,10)) != std::string::npos)
       player->addExhaust(ticks, g_config.getNumber(ConfigManager::ANTI_PUSH_DELAY));
     return true;
    }
It's working fine, I'll put it in first post with your credits and fixed code. Thanks :)!

UPDATED MAIN POST
 
Last edited:
Hey, nice.

;]
Thanks to both of you :p

yes, is annyoning... make one more configurable "anti-pushTry = 5" for make a try times for pick up items
It was the first attempt. Ant not 3 seconds, you can configure for 1 second, or 1.5 seconds, like you want...
I'll try to do it for tomorrow, but I don't think I can, so for Sunday.

Regards.

@edit:
Done!
Now it will only detect as Anti-Push if you throw an item from your inventory to the tile you're standing.
 
Last edited:
Back
Top