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

TFS 1.X+ [TFS 1.4.2] Mana leech, life leech and critital hit simultaneously

Unknown Soldier

Mapping a map
Joined
Oct 30, 2010
Messages
285
Solutions
11
Reaction score
653
Hi,

I was just wondering how could I maintain all 3 conditions at once (as in title: mana leech, life leech and critital hit), using 3 different items to get each one of them. The problem is when I receive first condition and then want to get another one, the first one disappears. Example: I am using item A and receive a life leech. Life leech works. Then I use item B to get mana leech. Mana leech works. BUT life leech disappears.

I would like to maintain each condition, so that player can have either one, two or three at once, depending on how many items were used.

Screenshot as an example, even after using 3 items that apply all 3 conditions, only one condition is active, instead of all 3.

1ITeHJc.png


How can I do that?

Thanks in advance!

Lua:
local config = {
    cdtime = 60, --duration of condition in minutes
    criteffect = 179,
    manaeffect = 176,
    lifeeffect = 178,
}
    
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    
    if target:isPlayer() then   
        if item.itemid == 34398 then
            player:getPosition():sendMagicEffect(config.criteffect)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been imbued with the power of the crystal and received powerful strike (critical hit), that will last for "..config.cdtime.." minutes.")
            item:remove(1)
            local condition1 = Condition(CONDITION_ATTRIBUTES)
            condition1:setParameter(CONDITION_PARAM_SPECIALSKILL_CRITICALHITCHANCE, 20)
            condition1:setParameter(CONDITION_PARAM_SPECIALSKILL_CRITICALHITAMOUNT, 10)
            condition1:setTicks(config.cdtime*60*1000)
            player:addCondition(condition1)

        elseif item.itemid == 34396 then
            player:getPosition():sendMagicEffect(config.manaeffect)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been imbued with the power of the crystal and received powerful void (mana leech), that will last for "..config.cdtime.." minutes.")
            item:remove(1)   
            local condition2 = Condition(CONDITION_ATTRIBUTES)
            condition2:setParameter(CONDITION_PARAM_SPECIALSKILL_MANALEECHCHANCE, 100)
            condition2:setParameter(CONDITION_PARAM_SPECIALSKILL_MANALEECHAMOUNT, 9)
            condition2:setTicks(config.cdtime*60*1000)
            player:addCondition(condition2)

        elseif item.itemid == 34397 then
            player:getPosition():sendMagicEffect(config.lifeeffect)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been imbued with the power of the crystal and received powerful vampirism (life leech), that will last for "..config.cdtime.." minutes.")
            item:remove(1)   
            local condition3 = Condition(CONDITION_ATTRIBUTES)
            condition3:setParameter(CONDITION_PARAM_SPECIALSKILL_LIFELEECHCHANCE, 100)
            condition3:setParameter(CONDITION_PARAM_SPECIALSKILL_LIFELEECHAMOUNT, 9)
            condition3:setTicks(config.cdtime*60*1000)
            player:addCondition(condition3)   
        end
    end
end
 
Last edited:
Solution
You have to use SUBID parameter.

Lua:
local config = {
    cdtime = 60, --duration of condition in minutes
    criteffect = 179,
    manaeffect = 176,
    lifeeffect = 178,
}
    
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    
    if target:isPlayer() then   
        if item.itemid == 34398 then
            player:getPosition():sendMagicEffect(config.criteffect)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been imbued with the power of the crystal and received powerful strike (critical hit), that will last for "..config.cdtime.." minutes.")
            item:remove(1)
            local condition1 = Condition(CONDITION_ATTRIBUTES)...
You have to use SUBID parameter.

Lua:
local config = {
    cdtime = 60, --duration of condition in minutes
    criteffect = 179,
    manaeffect = 176,
    lifeeffect = 178,
}
    
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    
    if target:isPlayer() then   
        if item.itemid == 34398 then
            player:getPosition():sendMagicEffect(config.criteffect)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been imbued with the power of the crystal and received powerful strike (critical hit), that will last for "..config.cdtime.." minutes.")
            item:remove(1)
            local condition1 = Condition(CONDITION_ATTRIBUTES)
            condition1:setParameter(CONDITION_PARAM_SPECIALSKILL_CRITICALHITCHANCE, 20)
            condition1:setParameter(CONDITION_PARAM_SPECIALSKILL_CRITICALHITAMOUNT, 10)
            condition1:setParameter(CONDITION_PARAM_SUBID, 1)
            condition1:setTicks(config.cdtime*60*1000)
            player:addCondition(condition1)

        elseif item.itemid == 34396 then
            player:getPosition():sendMagicEffect(config.manaeffect)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been imbued with the power of the crystal and received powerful void (mana leech), that will last for "..config.cdtime.." minutes.")
            item:remove(1)   
            local condition2 = Condition(CONDITION_ATTRIBUTES)
            condition2:setParameter(CONDITION_PARAM_SPECIALSKILL_MANALEECHCHANCE, 100)
            condition2:setParameter(CONDITION_PARAM_SPECIALSKILL_MANALEECHAMOUNT, 9)
            condition2:setParameter(CONDITION_PARAM_SUBID, 2)
            condition2:setTicks(config.cdtime*60*1000)
            player:addCondition(condition2)

        elseif item.itemid == 34397 then
            player:getPosition():sendMagicEffect(config.lifeeffect)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been imbued with the power of the crystal and received powerful vampirism (life leech), that will last for "..config.cdtime.." minutes.")
            item:remove(1)   
            local condition3 = Condition(CONDITION_ATTRIBUTES)
            condition3:setParameter(CONDITION_PARAM_SPECIALSKILL_LIFELEECHCHANCE, 100)
            condition3:setParameter(CONDITION_PARAM_SPECIALSKILL_LIFELEECHAMOUNT, 9)
            condition1:setParameter(CONDITION_PARAM_SUBID, 3)
            condition3:setTicks(config.cdtime*60*1000)
            player:addCondition(condition3)   
        end
    end
end
 
Solution
You have to use SUBID parameter.

Lua:
local config = {
    cdtime = 60, --duration of condition in minutes
    criteffect = 179,
    manaeffect = 176,
    lifeeffect = 178,
}
   
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
   
    if target:isPlayer() then  
        if item.itemid == 34398 then
            player:getPosition():sendMagicEffect(config.criteffect)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been imbued with the power of the crystal and received powerful strike (critical hit), that will last for "..config.cdtime.." minutes.")
            item:remove(1)
            local condition1 = Condition(CONDITION_ATTRIBUTES)
            condition1:setParameter(CONDITION_PARAM_SPECIALSKILL_CRITICALHITCHANCE, 20)
            condition1:setParameter(CONDITION_PARAM_SPECIALSKILL_CRITICALHITAMOUNT, 10)
            condition1:setParameter(CONDITION_PARAM_SUBID, 1)
            condition1:setTicks(config.cdtime*60*1000)
            player:addCondition(condition1)

        elseif item.itemid == 34396 then
            player:getPosition():sendMagicEffect(config.manaeffect)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been imbued with the power of the crystal and received powerful void (mana leech), that will last for "..config.cdtime.." minutes.")
            item:remove(1)  
            local condition2 = Condition(CONDITION_ATTRIBUTES)
            condition2:setParameter(CONDITION_PARAM_SPECIALSKILL_MANALEECHCHANCE, 100)
            condition2:setParameter(CONDITION_PARAM_SPECIALSKILL_MANALEECHAMOUNT, 9)
            condition2:setParameter(CONDITION_PARAM_SUBID, 2)
            condition2:setTicks(config.cdtime*60*1000)
            player:addCondition(condition2)

        elseif item.itemid == 34397 then
            player:getPosition():sendMagicEffect(config.lifeeffect)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been imbued with the power of the crystal and received powerful vampirism (life leech), that will last for "..config.cdtime.." minutes.")
            item:remove(1)  
            local condition3 = Condition(CONDITION_ATTRIBUTES)
            condition3:setParameter(CONDITION_PARAM_SPECIALSKILL_LIFELEECHCHANCE, 100)
            condition3:setParameter(CONDITION_PARAM_SPECIALSKILL_LIFELEECHAMOUNT, 9)
            condition1:setParameter(CONDITION_PARAM_SUBID, 3)
            condition3:setTicks(config.cdtime*60*1000)
            player:addCondition(condition3)  
        end
    end
end
Thanks bro, works perfectly
 
You have to use SUBID parameter.

Lua:
local config = {
    cdtime = 60, --duration of condition in minutes
    criteffect = 179,
    manaeffect = 176,
    lifeeffect = 178,
}
   
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
   
    if target:isPlayer() then  
        if item.itemid == 34398 then
            player:getPosition():sendMagicEffect(config.criteffect)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been imbued with the power of the crystal and received powerful strike (critical hit), that will last for "..config.cdtime.." minutes.")
            item:remove(1)
            local condition1 = Condition(CONDITION_ATTRIBUTES)
            condition1:setParameter(CONDITION_PARAM_SPECIALSKILL_CRITICALHITCHANCE, 20)
            condition1:setParameter(CONDITION_PARAM_SPECIALSKILL_CRITICALHITAMOUNT, 10)
            condition1:setParameter(CONDITION_PARAM_SUBID, 1)
            condition1:setTicks(config.cdtime*60*1000)
            player:addCondition(condition1)

        elseif item.itemid == 34396 then
            player:getPosition():sendMagicEffect(config.manaeffect)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been imbued with the power of the crystal and received powerful void (mana leech), that will last for "..config.cdtime.." minutes.")
            item:remove(1)  
            local condition2 = Condition(CONDITION_ATTRIBUTES)
            condition2:setParameter(CONDITION_PARAM_SPECIALSKILL_MANALEECHCHANCE, 100)
            condition2:setParameter(CONDITION_PARAM_SPECIALSKILL_MANALEECHAMOUNT, 9)
            condition2:setParameter(CONDITION_PARAM_SUBID, 2)
            condition2:setTicks(config.cdtime*60*1000)
            player:addCondition(condition2)

        elseif item.itemid == 34397 then
            player:getPosition():sendMagicEffect(config.lifeeffect)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been imbued with the power of the crystal and received powerful vampirism (life leech), that will last for "..config.cdtime.." minutes.")
            item:remove(1)  
            local condition3 = Condition(CONDITION_ATTRIBUTES)
            condition3:setParameter(CONDITION_PARAM_SPECIALSKILL_LIFELEECHCHANCE, 100)
            condition3:setParameter(CONDITION_PARAM_SPECIALSKILL_LIFELEECHAMOUNT, 9)
            condition1:setParameter(CONDITION_PARAM_SUBID, 3)
            condition3:setTicks(config.cdtime*60*1000)
            player:addCondition(condition3)  
        end
    end
end
data/actions/scripts/tools/critleechboost.lua:eek:nUse
data/actions/scripts/tools/critleechboost.lua:10: attempt to call method 'isPlayer' (a nil value)
stack traceback:
[C]: in function 'isPlayer'
data/actions/scripts/tools/critleechboost.lua:10: in function <data/actions/scripts/tools/critleechboost.lua:8>

on 1.4.2, somehow
 
data/actions/scripts/tools/critleechboost.lua:eek:nUse
data/actions/scripts/tools/critleechboost.lua:10: attempt to call method 'isPlayer' (a nil value)
stack traceback:
[C]: in function 'isPlayer'
data/actions/scripts/tools/critleechboost.lua:10: in function <data/actions/scripts/tools/critleechboost.lua:8>

on 1.4.2, somehow
bump
 
data/actions/scripts/tools/critleechboost.lua:eek:nUse
data/actions/scripts/tools/critleechboost.lua:10: attempt to call method 'isPlayer' (a nil value)
stack traceback:
[C]: in function 'isPlayer'
data/actions/scripts/tools/critleechboost.lua:10: in function <data/actions/scripts/tools/critleechboost.lua:8>

on 1.4.2, somehow
anyone?
 
luascript.h
Bellow:
C++:
static int luaPlayerCreate(lua_State* L);
Add:
C++:
static int luaPlayerIsPlayer(lua_State* L);

luascript.cpp
Bellow:
C++:
registerMethod("Player", "getGuid", LuaScriptInterface::luaPlayerGetGuid);
Add:
C++:
registerMethod("Player", "isPlayer", LuaScriptInterface::luaPlayerIsPlayer);

at the end of file add:
C++:
int LuaScriptInterface::luaPlayerIsPlayer(lua_State* L)
{
    // player:isPlayer()
    pushBoolean(L, getUserdata<const Player>(L, 1) != nullptr);
    return 1;
}
 
Nice one!
You have to use SUBID parameter.

Lua:
local config = {
    cdtime = 60, --duration of condition in minutes
    criteffect = 179,
    manaeffect = 176,
    lifeeffect = 178,
}
   
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
   
    if target:isPlayer() then  
        if item.itemid == 34398 then
            player:getPosition():sendMagicEffect(config.criteffect)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been imbued with the power of the crystal and received powerful strike (critical hit), that will last for "..config.cdtime.." minutes.")
            item:remove(1)
            local condition1 = Condition(CONDITION_ATTRIBUTES)
            condition1:setParameter(CONDITION_PARAM_SPECIALSKILL_CRITICALHITCHANCE, 20)
            condition1:setParameter(CONDITION_PARAM_SPECIALSKILL_CRITICALHITAMOUNT, 10)
            condition1:setParameter(CONDITION_PARAM_SUBID, 1)
            condition1:setTicks(config.cdtime*60*1000)
            player:addCondition(condition1)

        elseif item.itemid == 34396 then
            player:getPosition():sendMagicEffect(config.manaeffect)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been imbued with the power of the crystal and received powerful void (mana leech), that will last for "..config.cdtime.." minutes.")
            item:remove(1)  
            local condition2 = Condition(CONDITION_ATTRIBUTES)
            condition2:setParameter(CONDITION_PARAM_SPECIALSKILL_MANALEECHCHANCE, 100)
            condition2:setParameter(CONDITION_PARAM_SPECIALSKILL_MANALEECHAMOUNT, 9)
            condition2:setParameter(CONDITION_PARAM_SUBID, 2)
            condition2:setTicks(config.cdtime*60*1000)
            player:addCondition(condition2)

        elseif item.itemid == 34397 then
            player:getPosition():sendMagicEffect(config.lifeeffect)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been imbued with the power of the crystal and received powerful vampirism (life leech), that will last for "..config.cdtime.." minutes.")
            item:remove(1)  
            local condition3 = Condition(CONDITION_ATTRIBUTES)
            condition3:setParameter(CONDITION_PARAM_SPECIALSKILL_LIFELEECHCHANCE, 100)
            condition3:setParameter(CONDITION_PARAM_SPECIALSKILL_LIFELEECHAMOUNT, 9)
            condition1:setParameter(CONDITION_PARAM_SUBID, 3)
            condition3:setTicks(config.cdtime*60*1000)
            player:addCondition(condition3)  
        end
    end
end
 
Back
Top