Lua help fix potions bugs otx2 772 based on tfs 0.3.7

Discussion in 'Support' started by Falacchi, Mar 13, 2018.

  1. Falacchi

    Falacchi Member

    Joined:
    May 3, 2011
    Messages:
    71
    Likes Received:
    2
    Best Answers:
    3
    Hello otlanders

    Well, i have this bug and consists in that if a player uses a manafluid/lifefluid or other potions fluids and uses the fluid to drop it on the backpack, the fluid doesn't fall to the floor and i get this exe console error

    Code (Text):
    1. [Error - Action Interface]
    2. data/actions/scripts/liquids/potions.lua:onUse
    3. Description:
    4. (luaHasItemProperty) Item not found
    5.  
    6. [Error - Action Interface]
    7. data/actions/scripts/liquids/potions.lua:onUse
    8. Description:
    9. (luaDoCreateItem) Tile not found
    this is my potions.lua

    Code (Lua):
    1. local ITEM_RUM_FLASK = 2006
    2.  
    3. local TYPE_EMPTY = 0
    4. local TYPE_WATER = 1
    5. local TYPE_BLOOD = 2
    6. local TYPE_BEER = 3
    7. local TYPE_SLIME = 4
    8. local TYPE_LEMONADE = 5
    9. local TYPE_MILK = 6
    10. local TYPE_MANA_FLUID = 7
    11. local TYPE_LIFE_FLUID = 10
    12. local TYPE_OIL = 11
    13. local TYPE_URINE = 13
    14. local TYPE_COCONUT_MILK = 14
    15. local TYPE_WINE = 15
    16. local TYPE_MUD = 19
    17. local TYPE_FRUIT_JUICE = 21
    18. local TYPE_LAVA = 26
    19. local TYPE_RUM = 27
    20. local TYPE_SWAMP = 28
    21. local TYPE_TEA = 35
    22.  
    23. local oilLamps = {[2046] = 2044}
    24. local casks = {[1771] = TYPE_WATER, [1772] = TYPE_BEER, [1773] = TYPE_WINE}
    25. local alcoholDrinks = {TYPE_BEER, TYPE_WINE, TYPE_RUM}
    26. local poisonDrinks = {TYPE_SLIME, TYPE_SWAMP}
    27.  
    28. local exhaust = createConditionObject(CONDITION_EXHAUST)
    29. setConditionParam(exhaust, CONDITION_PARAM_TICKS, 4)
    30.  
    31. local drunk = createConditionObject(CONDITION_DRUNK)
    32. setConditionParam(drunk, CONDITION_PARAM_TICKS, 60000)
    33.  
    34. local poison = createConditionObject(CONDITION_POISON)
    35. setConditionParam(poison, CONDITION_PARAM_DELAYED, true) -- Condition will delay the first damage from when it's added
    36. setConditionParam(poison, CONDITION_PARAM_MINVALUE, -50) -- Minimum damage the condition can do at total
    37. setConditionParam(poison, CONDITION_PARAM_MAXVALUE, -120) -- Maximum damage
    38. setConditionParam(poison, CONDITION_PARAM_STARTVALUE, -5) -- The damage the condition will do on the first hit
    39. setConditionParam(poison, CONDITION_PARAM_TICKINTERVAL, 4000) -- Delay between damages
    40. setConditionParam(poison, CONDITION_PARAM_FORCEUPDATE, true) -- Re-update condition when adding it(ie. min/max value)
    41.  
    42. local burn = createConditionObject(CONDITION_FIRE)
    43. setConditionParam(burn, CONDITION_PARAM_DELAYED, true) -- Condition will delay the first damage from when it's added
    44. setConditionParam(burn, CONDITION_PARAM_MINVALUE, -70) -- Minimum damage the condition can do at total
    45. setConditionParam(burn, CONDITION_PARAM_MAXVALUE, -150) -- Maximum damage
    46. setConditionParam(burn, CONDITION_PARAM_STARTVALUE, -10) -- The damage the condition will do on the first hit
    47. setConditionParam(burn, CONDITION_PARAM_TICKINTERVAL, 10000) -- Delay between damages
    48. setConditionParam(burn, CONDITION_PARAM_FORCEUPDATE, true) -- Re-update condition when adding it(ie. min/max value)
    49.  
    50. function onUse(cid, item, fromPosition, itemEx, toPosition)
    51. if(hasCondition(cid, CONDITION_EXHAUST) == TRUE) then
    52. doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
    53. return TRUE
    54. end
    55.  
    56.     if(doComparePositions(getCreaturePosition(cid), toPosition))then
    57.         itemEx.uid = cid
    58.     end
    59.  
    60.     if(itemEx.uid == cid) then
    61.         if(item.type == TYPE_EMPTY) then
    62.             doPlayerSendCancel(cid, "It is empty.")
    63.             return true
    64.         end
    65.  
    66.         if(item.type == TYPE_MANA_FLUID) then
    67.             if(not doPlayerAddMana(itemEx.uid, math.random(80, 150))) then
    68.                 return false
    69.             end
    70.             doAddCondition(cid, exhaust)
    71.             doCreatureSay(itemEx.uid, "Aaaah...")
    72.             doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
    73.         elseif(item.type == TYPE_LIFE_FLUID) then
    74.             if(not doCreatureAddHealth(itemEx.uid, math.random(55, 105))) then
    75.                 return false
    76.             end
    77.             doAddCondition(cid, exhaust)
    78.             doCreatureSay(itemEx.uid, "Aaaah...")
    79.             doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
    80.         elseif(isInArray(alcoholDrinks, item.type)) then
    81.             if(not doTargetCombatCondition(0, cid, drunk, CONST_ME_NONE)) then
    82.                 return false
    83.             end
    84.  
    85.             doCreatureSay(cid, "Aaah...")
    86.         elseif(isInArray(poisonDrinks, item.type)) then
    87.             if(not doTargetCombatCondition(0, cid, poison, CONST_ME_NONE)) then
    88.                 return false
    89.             end
    90.  
    91.             doCreatureSay(cid, "Urgh!")
    92.         elseif(item.type == TYPE_LAVA) then
    93.             if(not doTargetCombatCondition(0, cid, burn, CONST_ME_NONE)) then
    94.                 return false
    95.             end
    96.  
    97.             doCreatureSay(cid, "Urgh!")
    98.         else
    99.             doCreatureSay(cid, "Gulp.")
    100.         end
    101.  
    102.         doRemoveItem(item.uid, 1)
    103.         return true
    104.     end
    105.  
    106.     if(not isCreature(itemEx.uid)) then
    107.         if(item.type == TYPE_EMPTY) then
    108.             if(isItemFluidContainer(itemEx.itemid) and itemEx.type ~= TYPE_EMPTY) then
    109.                 doChangeTypeItem(item.uid, itemEx.type)
    110.                 doChangeTypeItem(itemEx.uid, TYPE_EMPTY)
    111.                 return true
    112.             end
    113.  
    114.             local tmp = casks[itemEx.itemid]
    115.             if(tmp == nil) then
    116.                 tmp = getFluidSourceType(itemEx.itemid)
    117.             end
    118.  
    119.             if(tmp) then
    120.                 doChangeTypeItem(item.uid, tmp)
    121.                 return true
    122.             end
    123.  
    124.             doPlayerSendCancel(cid, "It is empty.")
    125.             return true
    126.         end
    127.  
    128.         local tmp = oilLamps[itemEx.itemid]
    129.         if(item.type == TYPE_OIL and tmp ~= nil) then
    130.             doTransformItem(itemEx.uid, tmp)
    131.             doChangeTypeItem(item.uid, TYPE_NONE)
    132.             return true
    133.         end
    134.  
    135.         if(isItemFluidContainer(itemEx.itemid) and itemEx.type == TYPE_EMPTY) then
    136.             doChangeTypeItem(itemEx.uid, itemEx.type)
    137.             doChangeTypeItem(item.uid, TYPE_EMPTY)
    138.             return true
    139.         end
    140.  
    141.         if(hasProperty(itemEx.uid, CONST_PROP_BLOCKSOLID)) then
    142.             return false
    143.         end
    144.     end
    145.  
    146.     if(item.type == TYPE_EMPTY) then
    147.         doPlayerSendCancel(cid, "It is empty.")
    148.         return true
    149.     end
    150.  
    151.     doCreateItem(2025, item.type, toPosition)
    152.     doChangeTypeItem(item.uid, TYPE_EMPTY)
    153.     return true
    154. end
    155.  
    please help me i'll be very grateful

    regards
     
  2. Falacchi

    Falacchi Member

    Joined:
    May 3, 2011
    Messages:
    71
    Likes Received:
    2
    Best Answers:
    3

Share This Page

Loading...