• 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 Stackable Manafluids on 7.72 OTHire

massuco

Brazilian, sorry for my bad english XD
Joined
Feb 17, 2013
Messages
199
Solutions
8
Reaction score
22
Location
Brasil
I was trying to make vials stackable on 7.72 and I preferred to add 2 new items, one manafluid and one empty vial and I got this action script that works like a manafluid, all is working good. but...

The problem is that player can use mana fluid on each other, how i can make it no usable on other player? to check if is not a player, make splash on the ground, and I need to add the empty vial to the player also. when he use the manafluid, the manafluid (id 5998) transform in a empty vial (id 6000)

Lua:
function onUse(cid, item, frompos, item2, topos)
addmanapos = topos
addmanapos.stackpos = 253
playeraddmana = getThingfromPos(addmanapos)

if getPlayerMagLevel(cid) >= 0 then
    if playeraddmana.itemid > 0 then
        random_number = math.random(300,300)
        doSendMagicEffect(topos,12)
        doPlayerAddMana(playeraddmana.uid,random_number)
            doPlayerSay(cid,"Aaaah...",1)
    if item.type > 1 then
        doChangeTypeItem(item.uid,item.type-1)
    else
        doRemoveItem(item.uid,1)
    end
    else
        doSendMagicEffect(frompos,2)
    return false
    end
else
    doSendMagicEffect(frompos,2)
    doPlayerSendCancel(cid,"You don't have the required magic level to use that rune.")
end
return true
end
 
Last edited:
Try this
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)   
    if toPosition.x == 65535 or toPosition.x == 0 then
        return true
    end

    if itemEx.uid ~= cid then
        doDecayItem(doCreateItem(2025, item.type, toPosition))
        doTransformItem(item.uid, 6000, 1)
        return true
    end

    if getPlayerMagLevel(cid) == 0 then -- unsigned values cannot go below 0
        doPlayerSendCancel(cid,"You don't have the required magic level to use that rune.")
        doSendMagicEffect(toPosition, CONST_ME_POFF)
        return true
    end
    
    doPlayerAddMana(cid, math.random(300, 300)) -- 300, 300? Why not just doPlayerAddMana(cid, 300)
    doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
    doPlayerSay(cid,"Aaaah...",1)
    doTransformItem(item.uid, 6000, 1)
    return true
end
 
Ive just changed the lines:
doTransformItem(item.uid, 6000, 1)

for:
doPlayerRemoveItem(cid, 5998,1)
doPlayerAddItem(item.uid, 6000, 1)

because the script was transforming the stack of potions into one vial, and one removing one manafluid and adding one vial empty.
and change the item.type for my mana fluid splash id
Thank you

-- EDIT
I have simplified the script, remove this check magic level and its ok, the problem is that when you have one stack of 100 manafluids on the ground, and you use it, its infinite, dont remove count of the stack on the ground
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)   
    if toPosition.x == 65535 or toPosition.x == 0 then
        return true
    end

    if itemEx.uid ~= cid then
        doDecayItem(doCreateItem(2025, 7, toPosition))
        doPlayerRemoveItem(cid, MANAFLUID, 1)
        doPlayerAddItem(cid, EMPTY_VIAL, 1)
        return true
    end    
        doPlayerAddMana(cid, 300) -- math.random(100, 300)
        doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
        doPlayerSay(cid,"Aaaah...",1)
        doPlayerRemoveItem(cid, MANAFLUID, 1)
        doPlayerAddItem(cid, EMPTY_VIAL, 1)
    return true
end
 
Last edited:
What do you mean, doesn't doTransformItem(item.uid, 6000, 1) transform one vial at the time?

Edit:
Try this instead then:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)  
    if toPosition.x == 65535 or toPosition.x == 0 then
        return true
    end

    local pos = getThingPos(cid)
    if pos.x ~= toPosition.x and pos.y ~= toPosition.y and pos.z ~= toPosition.z then
        doDecayItem(doCreateItem(2025, 7, toPosition))
        doChangeTypeItem(item.uid, item.type - 1)
        return true
    end

    doPlayerAddMana(cid, 300)
    doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
    doPlayerSay(cid, "Aaaah...", TALKTYPE_SAY)
    doChangeTypeItem(item.uid, item.type - 1)
    return true
end

Added a position check instead of checking cid. Else you won't be able to use it on stacks or even on ladders and rope holes
 
Last edited:
No, like this didnt worked properly on stack, but ive changed only put the lines doChangeTypeItem
and now its ok, when u use it from ground its ok, it disapear 1 vial, but the only problem now it that, when u use it from ground, the empty vial appears on your backpack, and if you dont have cap, below you, i want that empty vial appears above the stack of manafluids you used on the ground
if u use it from your backpack, its ok, it add to you one empty vial.

code right now
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)   
    if toPosition.x == 65535 or toPosition.x == 0 then
        return true
    end

    if itemEx.uid ~= cid then
        doDecayItem(doCreateItem(2025, 7, toPosition))
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, 6000,1)
        return true
    end   
        doPlayerAddMana(cid, 300) -- math.random(100, 300)
        doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
        doPlayerSay(cid,"Aaaah...",1)
        doChangeTypeItem(item.uid, item.type - 1)
        doPlayerAddItem(cid, 6000,1)
    return true
end
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition) 
    if toPosition.x == 65535 or toPosition.x == 0 then
        return true
    end
    
    local empty = fromPosition.x == 65535 and doPlayerAddItem(cid, 6000, 1) or doCreateItem(6000, 1, fromPosition)
        
    local pos = getThingPos(cid)
    if not (toPosition.x == pos.x and toPosition.y == pos.y and toPosition.z == pos.z) then
        doDecayItem(doCreateItem(2025, 7, toPosition))
        doChangeTypeItem(item.uid, item.type - 1)
        return true, empty
    end
    
    doPlayerAddMana(cid, 300)
    doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
    doPlayerSay(cid, "Aaaah...", TALKTYPE_SAY)
    doChangeTypeItem(item.uid, item.type - 1)
    return true, empty
end
 
Thank you. Ive just changed the
Lua:
  local pos = getThingPos(cid)
    if not (toPosition.x == pos.x and toPosition.y == pos.y and toPosition.z == pos.z) then

for
Lua:
 if itemEx.uid ~= cid then

because was not working on stack properly, but now its ok! all ok

If someone needs the script final:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if toPosition.x == 65535 or toPosition.x == 0 then
        return true
    end
    
    local empty = fromPosition.x == 65535 and doPlayerAddItem(cid, 6000, 1) or doCreateItem(6000, 1, fromPosition)
        
     if itemEx.uid ~= cid then
        doDecayItem(doCreateItem(2025, 7, toPosition))
        doChangeTypeItem(item.uid, item.type - 1)
        return true, empty
    end
    
    doPlayerAddMana(cid, 300)
    doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
    doPlayerSay(cid, "Aaaah...", TALKTYPE_SAY)
    doChangeTypeItem(item.uid, item.type - 1)
    return true, empty
end

credits for @ond
 
the latest u sent me i tested on stack, and if I use one manafluid and Im not first of stack, i can heal, with my change, you can heal yourself only if you are first of stack, if not, the mana go on ground

the latest i posted is working properly on stacks, on the ground, on the inventory. 100%
 
Depends on how you want it to work, if you want to mimic 7.4, then use itemEx.uid ~= cid to check target. On 7.72 you should use the position check. Also, with the itemEx.uid you cannot stand on ladders/rope holes to use it.
 
aah now i understand, i didnt tested it on ladder/rope hole, i tested on in stack, by your way it works properly on ladders and rope holes, but if Im stacked, i can heal myself if im not the first of stack, is there a way to fix it? to not heal if im not the first of stack (it works on itemEx.uid, but with itemEx.uid like u said, the ladder and rope holes dont work as spot for heal)
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if toPosition.x == 65535 or toPosition.x == 0 then
        return true
    end
  
    local used = function(splash)
        doChangeTypeItem(item.uid, item.type - 1)
        if splash then
            doDecayItem(doCreateItem(2025, 7, toPosition))
        end
        return true, fromPosition.x == 65535 and doPlayerAddItem(cid, 6000, 1) or doCreateItem(6000, 1, fromPosition)
    end
  
    if getTopCreature(toPosition).uid ~= cid then
        return used(true)
    end
         
    doPlayerAddMana(cid, 300)
    doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
    doPlayerSay(cid, "Aaaah...", TALKTYPE_SAY)
    return used(false)
end
 
Last edited:
Back
Top