• 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 Simple anti-push system

Fire Element

Member
Joined
Sep 10, 2010
Messages
193
Reaction score
22
Location
Brazil
Tested on TFS 0.4

game.cpp

after
Code:
    if(!canThrowObjectTo(mapFromPos, mapToPos) && !player->hasCustomFlag(PlayerCustomFlag_CanThrowAnywhere))
    {
        player->sendCancelMessage(RET_CANNOTTHROW);
        return false;
    }

add
Code:
    uint8_t items[] = {2148, 2152, 2160, 3976, 2599, 7636, 7635, 7634};
    uint8_t n = 0;
    for (n; n < sizeof(items) / sizeof(uint8_t); n++) {
        if(item->getID() == items[n] && player->hasCondition(CONDITION_EXHAUST, 3)) {
            player->sendTextMessage(MSG_STATUS_SMALL, "Please wait a few seconds to move this item.");
            return false;
        }
    }

    if(Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_EXHAUST, 500, 0, false, 3))
        player->addCondition(condition);

if you need to add new items:

int items[] = {2148, 2152, 2160, 3976, 2599, 6000};
 
Last edited:
Mine is smaller than xampy system and does the same thing, only it's not easy to configure for beginners.

Can't be
Code:
for (n = 0; n < items.Length(); n++)

does not work, I think it work:
Lua:
for (n = 0; n < sizeof(items); n++){
 
Last edited:
Is possible add in config.lua for example
int items[] = {(g_config.getString(ConfigManager::ANTIPUSHITEMSIDS), ",")};
antiPushItems = "2148, 2152, 2160, 3976, 2599"

or more simple: all items
antiPushItems = false
antiPushItems = true
 
Last edited:
You created a bug that may crash the server (processing of invalid memory and buffer overflow). Pleasae change the code to

PHP:
int items[] = {2148, 2152, 2160, 3976, 2599};
int n = 0;
for (n = 0; n < sizeof(items) / sizeof(int); n++)

In C and C++, the sizeof operator is the size in bytes of an object. Since an int is 4 bytes, sizeof(items) would be 20. The correct way is to divide by the sizeof(int) to get the number of items in the array.
 
Back
Top