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

Solved item on bag

Aeronx

Intermediate OT User
Joined
Dec 17, 2015
Messages
735
Solutions
9
Reaction score
119
Hello everybody,

I've been trying to add a condition by having and item on your inventori

This is the code at /events/players.lua

Code:
local mlvl = Condition(CONDITION_ATTRIBUTES)
mlvl:setParameter(CONDITION_PARAM_TICKS, -1)
mlvl:setParameter(CONDITION_PARAM_SUBID, 390)
mlvl:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 15)
function Player:onMoveItem1(item, count, fromPosition, toPosition)
if item:getId() == 2349 and toPosition.x == CONTAINER_POSITION then
self:sendTextMessage(MESSAGE_INFO_DESCR, "You moved item to inside a container.")
self:addCondition(mlvl)
end
return true
end
function Player:onMoveItem2(item, count, fromPosition, toPosition)
if item:getId() == 2349 and toPosition.x ~= CONTAINER_POSITION then
self:sendTextMessage(MESSAGE_INFO_DESCR, "You moved item to outside a container.")
self:removeCondition(mlvl)
end
return true
end
function Player:onMoveItem(item, count, fromPosition, toPosition)
local ret1 = self:onMoveItem1(item, count, fromPosition, toPosition)
local ret2 = self:onMoveItem2(item, count, fromPosition, toPosition)
    return ret1 and ret2
end

Everything works fine, all msg show up, i get the condition.. but when i put the item back on the floor, my condition is still there :S I dont know why my condition wont get removed.

Also, i've been trying to add a magic effect happening every X seconds. But addEvent didnt seem to work here.

Any help would be really appreciated.

Thanks
 
Solution
Lua:
creature:removeCondition(conditionType[, conditionId = CONDITIONID_COMBAT[, subId = 0[, force = false]]])

You don't pass a condition userdata to this function.
Lua:
creature:removeCondition(conditionType[, conditionId = CONDITIONID_COMBAT[, subId = 0[, force = false]]])

You don't pass a condition userdata to this function.
 
Solution
thanks for help mkalo. Was as easy as this:
Code:
self:removeCondition(mlvl:getType(), mlvl:getId(), mlvl:getSubId())
 
Back
Top