Lua Great mana potion

Discussion in 'Support' started by zcorpy, Nov 10, 2017.

  1. zcorpy

    zcorpy New Member

    Joined:
    Sep 12, 2017
    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    Hi, what I need is the lua script of great mana potion similar to collapser for example regenerate mana depending on the level and magic level please!!!
     
    Last edited: Nov 10, 2017
  2. Okke

    Okke whatever

    Joined:
    Jul 19, 2015
    Messages:
    587
    Likes Received:
    282
    Best Answers:
    6
    What did I just read?

    We will need detailed info about your distro and what you exactly want to do, what‘s even single to collapser zulu?
     
  3. zcorpy

    zcorpy New Member

    Joined:
    Sep 12, 2017
    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    oh sorry, what I need is the lua script of great mana potion similar to collapser for example regenerate mana depending on the level and magic level
     
  4. WibbenZ

    WibbenZ Support Team Support Team

    Joined:
    Oct 16, 2008
    Messages:
    5,912
    Likes Received:
    1,021
    Best Answers:
    199
    Post the script so we can modify it.

    To my understanding he wants to change mana potions to give a certain amount depending on mlvl and lvl.
     
    zcorpy likes this.
  5. zcorpy

    zcorpy New Member

    Joined:
    Sep 12, 2017
    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    local MIN = 2.0
    local MAX = 2.01


    local exhaust = createConditionObject(CONDITION_EXHAUST)
    setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

    function onUse(cid, item, fromPosition, itemEx, toPosition)
    if isPlayer(itemEx.uid) == FALSE then
    return FALSE
    end

    if hasCondition(cid, CONDITION_EXHAUST_HEAL) == TRUE then
    doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
    return TRUE
    end

    if doPlayerAddMana(itemEx.uid, math.random((getPlayerLevel(cid) * MIN), (getPlayerLevel(cid) * MAX))) == LUA_ERROR then
    return FALSE
    end

    doAddCondition(cid, exhaust)
    doSendMagicEffect(getThingPos(itemEx.uid), 13)
    doCreatureSay(itemEx.uid, "", TALKTYPE_ORANGE_1)
    return TRUE
    end
     
  6. WibbenZ

    WibbenZ Support Team Support Team

    Joined:
    Oct 16, 2008
    Messages:
    5,912
    Likes Received:
    1,021
    Best Answers:
    199
    Changed so it checks both lvl and mlvl, you just have to change the formula to w/e you want.
    Code (Lua):
    1. local min = 2.0
    2. local max = 2.01
    3.  
    4. local exhaust = createConditionObject(CONDITION_EXHAUST)
    5. setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
    6.  
    7. function onUse(cid, item, fromPosition, itemEx, toPosition)
    8.     if not isPlayer(itemEx.uid) then
    9.         return false
    10.     end
    11.  
    12.     if hasCondition(cid, CONDITION_EXHAUST_HEAL) then
    13.         doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
    14.         return true
    15.     end
    16.  
    17.     if doPlayerAddMana(itemEx.uid, math.random((getPlayerLevel(cid) * min), (getPlayerMagLevel(cid) * max))) == LUA_ERROR then
    18.         return false
    19.     end
    20.  
    21.     doAddCondition(cid, exhaust)
    22.     doSendMagicEffect(getThingPos(itemEx.uid), 13)
    23.     doCreatureSay(itemEx.uid, "", TALKTYPE_ORANGE_1)
    24.     return true
    25. end
    Can you see the min / max by doing this;
    level * min and magic lvl * max.

    So ex min = 2.0 and max = 3.0
    Magic lvl 70 and level 100 would be min 200 and max 210
     
    zcorpy likes this.
  7. zcorpy

    zcorpy New Member

    Joined:
    Sep 12, 2017
    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    Msg error you cant not use this object
     
  8. WibbenZ

    WibbenZ Support Team Support Team

    Joined:
    Oct 16, 2008
    Messages:
    5,912
    Likes Received:
    1,021
    Best Answers:
    199
    Code (Lua):
    1. local min = 2.0
    2. local max = 2.01
    3.  
    4. local exhaust = createConditionObject(CONDITION_EXHAUST)
    5. setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
    6.  
    7. function onUse(cid, item, fromPosition, itemEx, toPosition)
    8.     print("test script")
    9.     if not isPlayer(itemEx.uid) then
    10.         print("1")
    11.         return false
    12.     end
    13.  
    14.     if hasCondition(cid, CONDITION_EXHAUST_HEAL) then
    15.         doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
    16.         print("3")
    17.         return true
    18.     end
    19.  
    20.     if doPlayerAddMana(itemEx.uid, math.random((getPlayerLevel(cid) * min), (getPlayerMagLevel(cid) * max))) == LUA_ERROR then
    21.         print("4")
    22.         return false
    23.     end
    24.  
    25.     doAddCondition(cid, exhaust)
    26.     doSendMagicEffect(getThingPos(itemEx.uid), 13)
    27.     doCreatureSay(itemEx.uid, "", TALKTYPE_ORANGE_1)
    28.  
    29.     print("5")
    30.  
    31.     return true
    32. end
    Test it and take an SS of your console.
     
    zcorpy likes this.
  9. zcorpy

    zcorpy New Member

    Joined:
    Sep 12, 2017
    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    The Forgotten Server, version 0.3.1 (Crying Damson)
    its console and no have fail in console only in tibia error you cant not use this object
    look friend I have a good option since it is by mlvl, lvl, and mana-life maximum but now the problem is that the lua is potions.lua and I have no idea what kind of xml put in actions example
    <action itemid="????" script="liquids/potions.lua"/>
    I do not want it to be through great mana.lua now I want all potions to reference potions.lua
    or if the option with which you are helping me is better and easier, tell me what I need to show you
     
    Last edited: Nov 13, 2017
  10. WibbenZ

    WibbenZ Support Team Support Team

    Joined:
    Oct 16, 2008
    Messages:
    5,912
    Likes Received:
    1,021
    Best Answers:
    199
    Then it's either not registerd in actions.xml (could also be ex wrong itemid) or you are editing the wrong file.
    That code should always print out 1 if it's started / loaded.
     
  11. zcorpy

    zcorpy New Member

    Joined:
    Sep 12, 2017
    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    the great potion if it has its xml in fact I return it to normal and if it works but when I change to that script that you send me it stops working
     
  12. WibbenZ

    WibbenZ Support Team Support Team

    Joined:
    Oct 16, 2008
    Messages:
    5,912
    Likes Received:
    1,021
    Best Answers:
    199
    Dafuq the only thing I changed was == FALSE to not and removed the == TRUE since they are not needed.
    Can you check your source code if you have this function aswell; getPlayerMagLevel
     
  13. zcorpy

    zcorpy New Member

    Joined:
    Sep 12, 2017
    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    no man I do not have it lol!
     
  14. WibbenZ

    WibbenZ Support Team Support Team

    Joined:
    Oct 16, 2008
    Messages:
    5,912
    Likes Received:
    1,021
    Best Answers:
    199
    Upload your luascript.cpp
     
  15. zcorpy

    zcorpy New Member

    Joined:
    Sep 12, 2017
    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    No have man! :/
     
  16. Okke

    Okke whatever

    Joined:
    Jul 19, 2015
    Messages:
    587
    Likes Received:
    282
    Best Answers:
    6
    Without the sources to your distribution we can't do a thing, sorry!
     
  17. zcorpy

    zcorpy New Member

    Joined:
    Sep 12, 2017
    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    Is there any way that this manarune script can be done as in great mana potion?
    here script mr
    --Created to make the script easy to manipulate
    --If used without using server potion exhaust (EX: potExhaust = false), it will work regardless of server
    --Remember, true = yes, false = no, in the config

    function onUse(cid, item, frompos, item2, topos)
    --Config
    local reqml = 8 --Magic Level required to use it
    local reqlvl = 250 --Character Level required to use it
    local potExhaust = false -- causes exhaust like potions (false creates seperate exhaust for mana rune)
    --Maximum amount of mana to be added
    local minMana = ((getPlayerLevel(cid) * 1.5 + getPlayerMagLevel(cid) * 1.6) * 1.25) + 20
    local maxMana = ((getPlayerLevel(cid) * 1.5 + getPlayerMagLevel(cid) * 1.6) * 1.25) + 20

    local ani = 1 --Animation to be sent to player when used (these can be found in your global.lua; search for CONST_ME_)
    --If you don't want it to give health, set both to 0
    local minHealth = ((getPlayerLevel(cid) * 0 + getPlayerMagLevel(cid) * 0) * 0.0) + 0 --Minimum amount of health to be added
    local maxHealth = ((getPlayerLevel(cid) * 0 + getPlayerMagLevel(cid) * 0) * 0.0) + 0 --Maximum amount of health to be added

    if getPlayerSlotItem(cid, CONST_SLOT_RING).itemid == 6536 and getPlayerStorageValue(cid, 50781) == 1 then
    minHealth = minHealth * 0.0 --Minimum amount of health to be added
    maxHealth = maxHealth * 0.0 --Maximum amount of health to be added
    end



    --If you're not using potion exhaust (potExhaust = false) edit the following the way you'd like
    local storeValue = 50995 --The storage value that will be used for exhaust if you have potexhaust to false
    local exhaustTime = 1 --Exhaust in seconds
    local infinite = true --Will it cause rune to lose charges
    local canUseInPz = true --If true, mana rune may be used in PZ, otherwise, it will not work.

    local player_say = "Ahhh..." --What player says after successfully using the mana rune
    local error_ml = "You don't have the required magic level to use that rune." --What the cancel says when ml is too low
    local error_lvl = "You don't have the required magic level to use that rune." --What the cancel says when level is too low
    local error_notPlayer = "You can only use this rune on players." --What the cancel says when you try to use it on something not a player
    local error_exhaust = "You are exhausted." --What the cancel says when you are exhausted
    local error_pz = "You may not use this in Protected Zones." --What the cancel says when you are in PZ and canUseInPz is false
    ------------------------------------------- DO NOT EDIT BELOW THIS LINE!! -------------------------------------------

    ---------------------------START Check for Errors--------------------------------
    --If doesn't allow use in PZ, send poof and cancel message
    if canUseInPz == false and getTilePzInfo(getPlayerPosition(cid)) == 1 then
    doSendMagicEffect(frompos, CONST_ME_POFF)
    doPlayerSendCancel(cid, error_pz)
    return 0
    end
    --If not high enough level, send poof and cancel message
    if getPlayerLevel(cid) < reqlvl then
    doSendMagicEffect(frompos, CONST_ME_POFF)
    doPlayerSendCancel(cid, error_lvl)
    return 0
    end
    --if character is not knight, sejnd poof and cancel message
    if((not(isKnight(cid)) or getPlayerLevel(cid) < 250) and getPlayerCustomFlagValue(cid, PlayerCustomFlag_GamemasterPrivileges) == FALSE) then
    doSendMagicEffect(frompos, CONST_ME_POFF)
    doPlayerSendCancel(cid, error_lvl)
    return 0
    end

    --If ml is too low, send poof and cancel message
    if getPlayerMagLevel(cid) < reqml then
    doSendMagicEffect(frompos, CONST_ME_POFF)
    doPlayerSendCancel(cid, error_ml)
    return 0
    end

    --If it's not a player, send poof and cancel message
    if isPlayer(item2.uid) == FALSE then
    doSendMagicEffect(frompos, CONST_ME_POFF)
    doPlayerSendCancel(cid, error_notPlayer)
    return 0
    end

    --Check if exhausted
    if potExhaust == false then --If not using Potion Exhaust
    if exhaust(cid, storeValue, exhaustTime) == 0 then
    doSendMagicEffect(frompos, CONST_ME_POFF)
    doPlayerSendCancel(cid, error_exhaust)
    return 0
    end
    else --If you are using potion exhaust
    if hasCondition(cid, CONDITION_EXHAUSTED) == 1 then
    doPlayerSendCancel(cid, error_exhaust)
    return 0
    end
    end

    ---------------------------END Check for Errors--------------------------------

    doSendMagicEffect(topos, ani)
    doCreatureAddHealth(item2.uid, math.random(minHealth, maxHealth))
    doPlayerAddMana(item2.uid, math.random(minMana, maxMana))
    if infinite == false then
    if item.type > 1 then
    doChangeTypeItem(item.uid,item.type-1)
    else
    doRemoveItem(item.uid,1)
    end
    end
    end

    --Exhaust System created by Alreth
    --Edited by OsoSangre
    function exhaust(cid, storeValue, exhaustTime)
    local newExhaust = os.time()
    local oldExhaust = getPlayerStorageValue(cid, storeValue)
    if (oldExhaust == nil or oldExhaust < 0) then
    oldExhaust = 0
    end
    if (exhaustTime == nil or exhaustTime < 0) then
    exhaustTime = 1
    end
    diffTime = os.difftime(newExhaust, oldExhaust)
    if (diffTime >= exhaustTime) then
    setPlayerStorageValue(cid, storeValue, newExhaust)
    return 1
    else
    return 0
    end
    end
     
  18. 2Rec

    2Rec Well-Known Member

    Joined:
    Jul 31, 2013
    Messages:
    259
    Likes Received:
    261
    Best Answers:
    29
  19. Xikini

    Xikini Titan Kingdoms

    Joined:
    Nov 17, 2010
    Messages:
    3,085
    Likes Received:
    1,567
    Best Answers:
    36
    As far as I can tell from a quick glance, you just need to assign the great mana potions item id in actions.xml to this script, and it'll work the exact same as the rune did.
     

Share This Page

Loading...