My server is Otx 2 - 0.7 - Version 7.72.
I have a problem with my potions.lua script.
When I use any fluid inside a backpack it gives an error. I wanted to block it so as not to use it inside the backpack.
Can you help me?
If possible, I also need to adjust it only when players are in Stack, only those on top can use mana fluid. If another player at the bottom of the stack tries to use mana fluid, the fluid has to fall to the ground. If you can help me with that too.
I have a problem with my potions.lua script.
When I use any fluid inside a backpack it gives an error. I wanted to block it so as not to use it inside the backpack.
Can you help me?
If possible, I also need to adjust it only when players are in Stack, only those on top can use mana fluid. If another player at the bottom of the stack tries to use mana fluid, the fluid has to fall to the ground. If you can help me with that too.
Lua:-- Config -- local ITEM_RUM_FLASK = 2006 local SPLASH_CONTAINER = 2016 local POOLS = {2016, 2017, 2018, 2019, 2020, 2019, 2020, 2021, 2025, 2026, 2027} local WATERS = {494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587 , 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 630, 631, 632, 633, 634, 635, 636, 637, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 3246, 3247, 3248, 3249, 3250, 3251, 3252, 3253, 3254, 3255, 3256, 3257, 3553, 3554, 3555, 3556, 3557, 3558, 3559, 3560, 3561, 3562, 3563, 3564, 3565, 3566, 3567, 3568, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4626} local TYPE_EMPTY = 0 local TYPE_WATER = 1 local TYPE_BLOOD = 2 local TYPE_BEER = 3 local TYPE_SLIME = 4 local TYPE_LEMONADE = 5 local TYPE_MILK = 6 local TYPE_MANA_FLUID = 7 local TYPE_LIFE_FLUID = 10 local TYPE_OIL = 11 local TYPE_URINE = 13 local TYPE_COCONUT_MILK = 14 local TYPE_WINE = 15 local TYPE_MUD = 19 local TYPE_FRUIT_JUICE = 21 local TYPE_LAVA = 26 local TYPE_RUM = 27 local TYPE_SWAMP = 28 local TYPE_TEA = 35 local oilLamps = {[2046] = 2044} local casks = {[1771] = TYPE_BEER, [1772] = TYPE_WATER, [1773] = TYPE_WINE} local alcoholDrinks = {TYPE_BEER, TYPE_WINE, TYPE_RUM} local poisonDrinks = {TYPE_SLIME, TYPE_SWAMP} local exhaust = createConditionObject(CONDITION_EXHAUST) setConditionParam(exhaust, CONDITION_PARAM_TICKS, 4) local drunk = createConditionObject(CONDITION_DRUNK) setConditionParam(drunk, CONDITION_PARAM_TICKS, 60000) local poison = createConditionObject(CONDITION_POISON) setConditionParam(poison, CONDITION_PARAM_DELAYED, true) -- Condition will delay the first damage from when it's added setConditionParam(poison, CONDITION_PARAM_MINVALUE, -50) -- Minimum damage the condition can do at total setConditionParam(poison, CONDITION_PARAM_MAXVALUE, -120) -- Maximum damage setConditionParam(poison, CONDITION_PARAM_STARTVALUE, -5) -- The damage the condition will do on the first hit setConditionParam(poison, CONDITION_PARAM_TICKINTERVAL, 4000) -- Delay between damages setConditionParam(poison, CONDITION_PARAM_FORCEUPDATE, true) -- Re-update condition when adding it(ie. min/max value) local burn = createConditionObject(CONDITION_FIRE) setConditionParam(burn, CONDITION_PARAM_DELAYED, true) -- Condition will delay the first damage from when it's added setConditionParam(burn, CONDITION_PARAM_MINVALUE, -70) -- Minimum damage the condition can do at total setConditionParam(burn, CONDITION_PARAM_MAXVALUE, -150) -- Maximum damage setConditionParam(burn, CONDITION_PARAM_STARTVALUE, -10) -- The damage the condition will do on the first hit setConditionParam(burn, CONDITION_PARAM_TICKINTERVAL, 10000) -- Delay between damages setConditionParam(burn, CONDITION_PARAM_FORCEUPDATE, true) -- Re-update condition when adding it(ie. min/max value) -- FIM DA CONFIG -- function onUse(cid, item, fromPosition, itemEx, toPosition) local getAgua = getThingfromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z, stackpos = 0}) -- usado para verificar se é um local que contem agua, para enxer os potions de agua local blockingItem = getThingfromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z, stackpos = 1}) -- Verifica primeiro player da stack local blockingItem2 = getThingfromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z, stackpos = 2}) -- Verifica o Segundo Player da Stack local blockingItem3 = getThingfromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z, stackpos = 3}) -- Verifica o Terceiro Player da Stack local topCreature = getTopCreature(isPlayer(cid)) -- Verifica se está Exausted e retorna a mensagem if(hasCondition(cid, CONDITION_EXHAUST) == TRUE) then doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED) return true end if(doComparePositions(getCreaturePosition(cid), toPosition))then itemEx.uid = cid end if(itemEx.uid == cid) then if(item.type == TYPE_EMPTY) then doPlayerSendCancel(cid, "It is empty.") return true end if(item.type == TYPE_MANA_FLUID) then if isPlayer(blockingItem.uid) and isPlayer(blockingItem2.uid) then local ret = RETURNVALUE_NOERROR local fluid_pool = doCreateItemEx(2025, item.type) ret = doTileAddItemEx(toPosition, fluid_pool) if ret == RETURNVALUE_NOERROR then doDecayItem(fluid_pool) end doRemoveItem(item.uid, 1) elseif isInArray(POOLS, blockingItem.itemid) and isPlayer(blockingItem2.uid) and isPlayer(blockingItem3.uid) then local ret = RETURNVALUE_NOERROR local fluid_pool = doCreateItemEx(2025, item.type) ret = doTileAddItemEx(toPosition, fluid_pool) if ret == RETURNVALUE_NOERROR then doDecayItem(fluid_pool) end doRemoveItem(item.uid, 1) else if(not doPlayerAddMana(itemEx.uid, math.random(40, 80))) then return false end doAddCondition(cid, exhaust) doCreatureSay(itemEx.uid, "Aaaah...") doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE) doRemoveItem(item.uid, 1) end elseif(item.type == TYPE_LIFE_FLUID) then if isPlayer(blockingItem.uid) and isPlayer(blockingItem2.uid) then local ret = RETURNVALUE_NOERROR local fluid_pool = doCreateItemEx(2025, item.type) ret = doTileAddItemEx(toPosition, fluid_pool) if ret == RETURNVALUE_NOERROR then doDecayItem(fluid_pool) end doRemoveItem(item.uid, 1) elseif isInArray(POOLS, blockingItem.itemid) and isPlayer(blockingItem2.uid) and isPlayer(blockingItem3.uid) then local ret = RETURNVALUE_NOERROR local fluid_pool = doCreateItemEx(2025, item.type) ret = doTileAddItemEx(toPosition, fluid_pool) if ret == RETURNVALUE_NOERROR then doDecayItem(fluid_pool) end doRemoveItem(item.uid, 1) else if(not doCreatureAddHealth(itemEx.uid, math.random(55, 105))) then return false end doAddCondition(cid, exhaust) doCreatureSay(itemEx.uid, "Aaaah...") doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE) doRemoveItem(item.uid, 1) end elseif(isInArray(alcoholDrinks, item.type)) then if(not doTargetCombatCondition(0, cid, drunk, CONST_ME_NONE)) then return false end doCreatureSay(cid, "Aaah...") elseif(isInArray(poisonDrinks, item.type)) then if(not doTargetCombatCondition(0, cid, poison, CONST_ME_NONE)) then return false end doCreatureSay(cid, "Urgh!") elseif(item.type == TYPE_LAVA) then if(not doTargetCombatCondition(0, cid, burn, CONST_ME_NONE)) then return false end doCreatureSay(cid, "Urgh!") else doCreatureSay(cid, "Gulp.") end doChangeTypeItem(item.uid, TYPE_EMPTY) return true end if(not isCreature(itemEx.uid)) then if(item.type == TYPE_EMPTY) then if isInArray(WATERS, getAgua.itemid) then -- agua = getFluidSourceType(itemEx.itemid) doChangeTypeItem(item.uid, TYPE_WATER) return true end if(isItemFluidContainer(itemEx.itemid) and itemEx.type ~= TYPE_EMPTY) then doChangeTypeItem(item.uid, itemEx.type) doChangeTypeItem(itemEx.uid, TYPE_EMPTY) return true end local tmp = casks[itemEx.itemid] if tmp then tmp = getFluidSourceType(itemEx.itemid) doChangeTypeItem(item.uid, tmp) return true end if (itemEx.itemid == SPLASH_CONTAINER or itemEx.itemid == 2025) then if (itemEx.type == TYPE_MANA_FLUID or itemEx.type == TYPE_LIFE_FLUID) then doPlayerSendCancel(cid, "It is empty.") else doChangeTypeItem(item.uid, itemEx.type) doSendMagicEffect(fromPosition, CONST_ME_MAGIC_BLUE) doRemoveItem(itemEx.uid, 1) end return true end doPlayerSendCancel(cid, "It is empty.") return true end local tmp = oilLamps[itemEx.itemid] if(item.type == TYPE_OIL and tmp ~= nil) then doTransformItem(itemEx.uid, tmp) doChangeTypeItem(item.uid, TYPE_NONE) return true end if (item.type == TYPE_MANA_FLUID or item.type == TYPE_LIFE_FLUID) then doPlayerSendCancel(cid, "It is empty.") else if(isItemFluidContainer(itemEx.itemid) and itemEx.type == TYPE_EMPTY) then -- Verifica se o pote q vou usar está cheio doChangeTypeItem(itemEx.uid, item.type) -- Transforma o pote vazio em pote com o liquido do outro doChangeTypeItem(item.uid, TYPE_EMPTY) -- Transforma o pote que usei em pote vazio return true end end if(hasProperty(itemEx.uid, CONST_PROP_BLOCKSOLID)) then return false end end if(item.type == TYPE_EMPTY) then doPlayerSendCancel(cid, "It is empty.") return true end local ret = RETURNVALUE_NOERROR local fluid_pool = doCreateItemEx(2025, item.type) ret = doTileAddItemEx(toPosition, fluid_pool) if ret == RETURNVALUE_NOERROR then doDecayItem(fluid_pool) end doChangeTypeItem(item.uid, TYPE_EMPTY) return true end