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

TFS 1.X+ Help convert script, is working but not as it should

johnsamir

Active Member
Joined
Oct 13, 2009
Messages
231
Solutions
1
Reaction score
35
Location
Nowhere
Hello community

I'm trying to convert an script that was made for othire. Must add that im using tfs 1.3/1.4

The script work, the problem is that when i use potion on the ground it doesn't drop the splash, it simply heals the player as if the potion were used on the player when it was not.
this is the original script.

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
and this is was i got, 2025, 7 is the id of the splash, 5604 the empty vial

Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    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 player:addItem(5604, 1) or doCreateItem(5604, 1, fromPosition)
    end
 
   --if getTopCreature(toPosition).uid ~= cid then
      -- return used(true)
    --end
       
  --  doPlayerAddMana(cid, 300)
  player:addMana(math.random(50, 100))
    doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
    --doPlayerSay(cid, "Aaaah...", TALKTYPE_SAY)
    player:say("Aaaah...", TALKTYPE_SAY) --TALKTYPE_MONSTER_SAY) agregado
    return used(false)
end
ideas of what could be wrong? have no error being displayd in console
 
Last edited:
OP
OP
J

johnsamir

Active Member
Joined
Oct 13, 2009
Messages
231
Solutions
1
Reaction score
35
Location
Nowhere
so to make it clear
after using the potion
a splash should appear right?
something else?
yes if the potion is not used on the player it should appear a splash or fluid in the selected spot.
at the moment the script is not working like that. if use the fluid and select the floor it just heal the player.
know that you're here just chilling. Won't ask you anything,you are not obligated to help me,but do not be childist, thank you-
 
Last edited:
OP
OP
J

johnsamir

Active Member
Joined
Oct 13, 2009
Messages
231
Solutions
1
Reaction score
35
Location
Nowhere
yes if the potion is not used on the player it should appear a splash or fluid in the selected spot.
at the moment the script is not working like that. if use the fluid and select the floor it just heal the player.
know that you're here just chilling. Won't ask you anything,you are not obligated to help me,but do not be childist, thank you-
so to make it clear
after using the potion
a splash should appear right?
something else?
everything is good at home? @Levi999x
 
OP
OP
J

johnsamir

Active Member
Joined
Oct 13, 2009
Messages
231
Solutions
1
Reaction score
35
Location
Nowhere
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
 
    Game.createItem(2025, 7, target:getPosition())
    player:addItem(5604, 1)
    player:addMana(math.random(50, 100))
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    player:say("Aaaah...", TALKTYPE_SAY)
    return true
end

up
the script works but it's adding mana to the player if the potion is used in the floor when if only should add the splash and nothing else if the mana has not been used on the player
 
OP
OP
J

johnsamir

Active Member
Joined
Oct 13, 2009
Messages
231
Solutions
1
Reaction score
35
Location
Nowhere
Thanks to @Levi999x
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)

    if not target:isPlayer() then
        Game.createItem(2025, 7, target:getPosition())
        return true
    end
    player:addItem(5604, 1)
    target:addMana(math.random(50, 100))
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    player:say("Aaaah...", TALKTYPE_SAY)
    return true
end
Post automatically merged:

I'm mostly just curious, but what happens if the item is used on a wall?
wow didn't tested. and yes, the item is useable in walls and other places when it should not be possible :(.
also fluid type is not decaying, tried this
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)

    if not target:isPlayer() then
        player:removeItem(5603, 1, -1, false)
        player:addItem(5604, 1)
      local fluid = Game.createItem(2025, 7, target:getPosition())
          doDecayItem(fluid)
    return true
end

    target:addMana(math.random(50, 100))
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    player:say("Aaaah...", TALKTYPE_SAY)
    return true
end

and this, and none decays the fluid type
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)

    if not target:isPlayer() then
        player:removeItem(5603, 1, -1, false)
        player:addItem(5604, 1)
      local fluid = Game.createItem(2025, 7, target:getPosition())
           item:decay()
    item:setAttribute(ITEM_ATTRIBUTE_DURATION, 60000)
    item:setAttribute(ITEM_ATTRIBUTE_DECAYSTATE, true)
    player:addItemEx(fluid)
    return true
end

    target:addMana(math.random(50, 100))
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    player:say("Aaaah...", TALKTYPE_SAY)
    return true
end

could you help me with both issues, please?
 
Last edited:

Levi999x

AoT
Joined
Dec 14, 2017
Messages
1,884
Solutions
37
Reaction score
1,099
Location
Germany
Im on pc soon
Post automatically merged:

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  
    local tile = Tile(toPosition)

    if tile:hasFlag(TILESTATE_BLOCKSOLID) then
        player:sendCancelMessage("You cant use it here.")
        return true
    end
  
    if not target:isPlayer() then
        player:removeItem(5603, 1, -1, false)
        local fluid = Game.createItem(2025, 7, toPosition)
        addEvent(function(pos)
            fluid:remove(1)
        end, 60000, toPosition)
        return true
    end
   
    target:addMana(math.random(50, 100))
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    player:say("Aaaah...", TALKTYPE_SAY)
    return true
    player:removeItem(5603, 1, -1, false)
end
 
Last edited:
OP
OP
J

johnsamir

Active Member
Joined
Oct 13, 2009
Messages
231
Solutions
1
Reaction score
35
Location
Nowhere
Im on pc soon
Post automatically merged:

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
 
    local tile = Tile(toPosition)

    if tile:hasFlag(TILESTATE_BLOCKSOLID) then
        player:sendCancelMessage("You cant use it here.")
        return true
    end
 
    if not target:isPlayer() then
        player:removeItem(5603, 1, -1, false)
        local fluid = Game.createItem(2025, 7, toPosition)
        addEvent(function(pos)
            fluid:remove(1)
        end, 60000, toPosition)
        return true
    end
 
    target:addMana(math.random(50, 100))
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    player:say("Aaaah...", TALKTYPE_SAY)
    return true
    player:removeItem(5603, 1, -1, false)
end
Ok, can't use it in TILESTATE_BLOCKSOLID that's good, but now is not adding the empty flask or decaying the fluid state either.
Removed last two lines because it was causing error, it was expecting end at line 24
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
 
    local tile = Tile(toPosition)

    if tile:hasFlag(TILESTATE_BLOCKSOLID) then
        player:sendCancelMessage("You cant use it here.")
        return true
    end
 
    if not target:isPlayer() then
        player:removeItem(5603, 1, -1, false)
        local fluid = Game.createItem(2025, 7, toPosition)
        addEvent(function(pos)
            fluid:remove(1)
        end, 60000, toPosition)
        return true
    end
 
    target:addMana(math.random(50, 100))
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    player:say("Aaaah...", TALKTYPE_SAY)
    player:removeItem(5603, 1, -1, false)
    return true
end
  --  player:removeItem(5603, 1, -1, false)
--end

This is almost working, just need to make decay fluid work in it
Code:
    function onUse(player, item, fromPosition, target, toPosition, isHotkey)

        local tile = Tile(toPosition)

    if tile:hasFlag(TILESTATE_BLOCKSOLID) then
        player:sendCancelMessage("Sorry this is not possible.")
        return true
    end

    if not target:isPlayer() then
        player:removeItem(5603, 1, -1, false)
        player:addItem(5604, 1)
      local fluid = Game.createItem(2025, 7, target:getPosition())
          doDecayItem(fluid)
    return true
end

    target:addMana(math.random(50, 100))
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    player:say("Aaaah...", TALKTYPE_SAY)
    return true
end

maybe something is wrong at items.xml?
XML:
    </item>
    <item id="2025" article="a" name="pool"/>
    <item id="2026" article="a" name="pool"/>
    <item id="2027" article="a" name="pool"/>
    <item id="2028" article="a" name="pool"/>
    <item id="2029" article="a" name="pool"/>
    <item id="2030" article="a" name="pool"/>
    <item id="2031" article="a" name="waterskin">
        <attribute key="weight" value="700"/>
        <attribute key="duration" value="1"/>
    </item>
Post automatically merged:

Ok. Finally figured it out how to make it work like i need
Lua:
    function onUse(player, item, fromPosition, target, toPosition, isHotkey)

        local tile = Tile(toPosition)

    if tile:hasFlag(TILESTATE_BLOCKSOLID) then
        player:sendCancelMessage("Sorry this is not possible.")
        return true
    end

    if not target:isPlayer() then
        player:removeItem(5603, 1, -1, false)
        player:addItem(5604, 1)
       Game.createItem(2016, 7, target:getPosition())
    return true
end
    
    player:removeItem(5603, 1, -1, false)
    player:addItem(5604, 1)
    target:addMana(math.random(50, 100))
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    player:say("Aaaah...", TALKTYPE_SAY)
    return true
end
 
Last edited:
Top