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

Fix/Patch Distance Attack/Potion Use - Fix for TFS 1.x

Ascuas Funkeln

Rakkedo Game
Joined
Apr 14, 2013
Messages
549
Solutions
32
Reaction score
305
Location
Poland
GitHub
AscuasFunkeln
Hello, this is my fix of this problem, its not super pro, but should be fine for use.
When i test this problem i noticed that in TFS "ranged weapons" when attack are used like an "action".

Before source edit, check if config.lua edit is enough (by Lessaire)

Change this:
Code:
    integer[ACTIONS_DELAY_INTERVAL] = getGlobalNumber(L, "timeBetweenActions", 200);
    integer[EX_ACTIONS_DELAY_INTERVAL] = getGlobalNumber(L, "timeBetweenExActions", 1000);
To this:
Change this:
Code:
    integer[ACTIONS_DELAY_INTERVAL] = getGlobalNumber(L, "timeBetweenActions", 0);
    integer[EX_ACTIONS_DELAY_INTERVAL] = getGlobalNumber(L, "timeBetweenExActions", 0);
And compile

Then in config.lua set this values
Code:
-- Item Usage
timeBetweenActions = 0
timeBetweenExActions = 0

Then setup potions and all items thats you wanna to have cooldown like this example

In "player:setStorageValue(55555, os.time() + 3)", number "+ 3" define cooldown in seconds.

Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(55555) >= os.time() then
    player:sendTextMessage(MESSAGE_STATUS_SMALL, "You are exhausted")
        return true
    end
local PotionValue = 500
    if target:isPlayer() then
    player:setStorageValue(55555, os.time() + 3)
        item:remove(1)
target:addHealth(PotionValue)
  target:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
            return false
        end
end

Now distance attack and using potions or items should work fine.

OFC, make different storages for each item!
 
Last edited:
🤭

There is probably no reason to make this CPP source change, the parameter provided to function is the defaultor. It's only used if the config.lua entry in question does not exist. So just the config.lua change should do what you want.

C++:
int32_t getGlobalNumber(lua_State* L, const char* identifier, const int32_t defaultValue = 0)
{
    lua_getglobal(L, identifier);
    if (!lua_isnumber(L, -1)) {
        lua_pop(L, 1);
        return defaultValue;
    }

    int32_t val = lua_tonumber(L, -1);
    lua_pop(L, 1);
    return val;
}
 
🤭

There is probably no reason to make this CPP source change, the parameter provided to function is the defaultor. It's only used if the config.lua entry in question does not exist. So just the config.lua change should do what you want.

C++:
int32_t getGlobalNumber(lua_State* L, const char* identifier, const int32_t defaultValue = 0)
{
    lua_getglobal(L, identifier);
    if (!lua_isnumber(L, -1)) {
        lua_pop(L, 1);
        return defaultValue;
    }

    int32_t val = lua_tonumber(L, -1);
    lua_pop(L, 1);
    return val;
}

Maybe i have something messy, but if i dont do that in cpp, then in config.lua "0" will return in game something like "100" o_O
Anyway ofc good point, first check in config.lua edits is enough.
 
Friend, just comment out the line! Or set to nil.

Zero and nil are not equal. And they are not treated the same.

Lua:
-- Item Usage
--timeBetweenActions = 0
--timeBetweenExActions = 0

Lua:
-- Item Usage
timeBetweenActions = nil
timeBetweenExActions = nil
 
Friend, just comment out the line! Or set to nil.

Zero and nil are not equal. And they are not treated the same.

Lua:
-- Item Usage
--timeBetweenActions = 0
--timeBetweenExActions = 0

Lua:
-- Item Usage
timeBetweenActions = nil
timeBetweenExActions = nil
I dont have it like comment xD
Anyway nil work fine, thanks.
 
what about this? This is a fix for the same issue it appears.


 
Last edited:
Sure, I can look into that, but it would be back in your support thread where I can get my virtual clout points. 🥴
 
Back
Top