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

Lua Translate to 1.x please

Athenuz

Owlz!
Joined
Oct 1, 2015
Messages
234
Reaction score
27
Location
México
Hello,

I've found this script but doesn't works for TFS 1.x

Can please someone translate? :(

Code:
local config = {
summonName = "Orc",
cost = 10000 -- in gp, put 0 to disable
remove = "yes" -- should egg by removed after use?
}

config.remove = getBooleanFromString(config.remove)
function onUse(cid, item, fromPosition, itemEx, toPosition)
local pos = getCreaturePosition(cid)
if(pos.x == CONTAINER_POSITION) then
doPlayerSendCancel(cid, "Put item on the floor first.")
return TRUE
end

if(config.cost > 0 and getPlayerMoney(cid) < config.cost) then
doPlayerSendCancel(cid, "Not enought money, trainer cost " .. config.cost .. " gp's.")
return TRUE
end

local ret, effect = doSummonMonster(cid, config.summonName), CONST_ME_MAGIC_RED
if(ret ~= RETURNVALUE_NOERROR) then
effect = CONST_ME_POFF
doPlayerSendDefaultCancel(cid, ret)
else
if(config.cost > 0) then
doPlayerRemoveMoney(cid, config.cost)
end
if(config.remove == TRUE) then
doRemoveItem(item.uid)
end
end

doSendMagicEffect(pos, effect)
return TRUE
end
 
Not tested
Code:
local config = {
summonName = "Orc",
cost = 10000, -- in gp, put 0 to disable
remove1 = "yes" -- should egg by removed after use?
}

function onUse(player, item, fromPosition, itemEx, toPosition)
local pos = player:getPosition()
if pos.x == CONTAINER_POSITION then
player:sendCancelMessage("Put item on the floor first.")
return false
end

if config.cost > 0 and player:getMoney() < config.cost  then
player:sendCancelMessage("Not enought money, trainer cost " ..config.cost.. " gp's.")
return false
end
local ret, effect = Game.createMonster(config.summonName, toPosition), CONST_ME_POFF
if ret then
effect = CONST_ME_MAGIC_RED
if config.cost > 0 then
print("aqui listo")
player:removeMoney(config.cost)
item:remove(1)
    end
else
effect = CONST_ME_POFF
doSendMagicEffect(pos, effect)
end
return true
end
 
Not tested
Code:
local config = {
summonName = "Orc",
cost = 10000, -- in gp, put 0 to disable
remove1 = "yes" -- should egg by removed after use?
}

function onUse(player, item, fromPosition, itemEx, toPosition)
local pos = player:getPosition()
if pos.x == CONTAINER_POSITION then
player:sendCancelMessage("Put item on the floor first.")
return false
end

if config.cost > 0 and player:getMoney() < config.cost  then
player:sendCancelMessage("Not enought money, trainer cost " ..config.cost.. " gp's.")
return false
end
local ret, effect = Game.createMonster(config.summonName, toPosition), CONST_ME_POFF
if ret then
effect = CONST_ME_MAGIC_RED
if config.cost > 0 then
print("aqui listo")
player:removeMoney(config.cost)
item:remove(1)
    end
else
effect = CONST_ME_POFF
doSendMagicEffect(pos, effect)
end
return true
end

Thanks for your reply.

Sadly doesn't woks u.u
 
Code:
local config = {
    summonName = "Orc",
    cost = 10000 -- in gp, put 0 to disable
    remove = "yes" -- should egg by removed after use?
}

config.remove = (config.remove == "yes" and true or false)
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local pos = player:getPosition()
    if(pos.x == CONTAINER_POSITION) then
        player:sendCancelMessage("Put item on the floor first.")
        return true
    end

    if(config.cost > 0 and getPlayerMoney(cid) < config.cost) then
        player:sendCancelMessage("Not enought money, trainer cost " .. config.cost .. " gp's.")
        return true
    end

    local ret, effect = Game.createMonster(config.summonName, pos), CONST_ME_MAGIC_RED
    if(ret ~= RETURNVALUE_NOERROR) then
        effect = CONST_ME_POFF
        player:sendCancelMessage(cid, ret)
    else
        ret:setMaster(player)
        if(config.cost > 0) then
            player:removeMoney(config.cost)
        end
        if(config.remove == true) then
            item:remove(1)
        end
    end

    pos:sendMagicEffect(effect)
    return true
end

Summoning monsters in lua is... iffy.
 
in config, after
cost = 10000
jsut add a comma
cost = 10000,

:32: 'end' expected <to close 'function' at line 8> near '<eof>'

._. i guess it's because this part:

Code:
local ret, effect = Game.createMonster(config.summonName, pos), CONST_ME_MAGIC_RED
    if(ret ~= RETURNVALUE_NOERROR) then
        effect = CONST_ME_POFF
        player:sendCancelMessage(cid, ret)
    else
        ret:setMaster(player)
        if(config.cost > 0) then
            player:removeMoney(config.cost)
        end
        if(config.remove1 == true) then
            item:remove1(1)
        end

There's much "if" :p but not sure, tried to fix but got nothing
 
I thought I'd try too :)
Code:
    local c = {
        name = "Orc",
        cost = 10000, -- in gp, put 0 to disable
        egg = true -- should egg by removed after use?
    }


    function onUse(player, item, fromPosition, target, toPosition, isHotkey)
        if(player:getPosition().x == CONTAINER_POSITION) then
            player:sendCancelMessage("Put item on the floor first.")
            return false
        end
      
        local itemPos = getThingfromPos(item)
      
        if(player:getMoney() < c.cost) then
            player:sendCancelMessage("Not enought money, trainer cost " .. c.cost .. " gp's.")
            itemPos:sendMagicEffect(CONST_ME_POFF)
            return false
        else
            player:removeMoney(c.cost)
            doSummonCreature(c.name, itemPos)
            itemPos:sendMagicEffect(CONST_ME_MAGIC_RED)
            if(c.egg) then
                item:remove()
            end
        end
        return true
    end
 
Last edited:
I thought I'd try too :)
Code:
    local c = {
        name = "Orc",
        cost = 10000 -- in gp, put 0 to disable
        egg = true -- should egg by removed after use?
    }


    function onUse(player, item, fromPosition, target, toPosition, isHotkey)
        if(player:getPosition().x == CONTAINER_POSITION) then
            player:sendCancelMessage("Put item on the floor first.")
            return false
        end
      
        local itemPos = getThingfromPos(item)
      
        if(player:getMoney() < c.cost) then
            player:sendCancelMessage("Not enought money, trainer cost " .. c.cost .. " gp's.")
            itemPos:sendMagicEffect(CONST_ME_POFF)
            return false
        else
            player:removeMoney(c.cost)
            doSummonCreature(c.name, itemPos)
            itemPos:sendMagicEffect(CONST_ME_MAGIC_RED)
            if(c.egg) then
                item:remove()
            end
        end
        return true
    end
don't forget the comma after the cost ;)
 
I see a few little errors there, might be related to copying from your browser.
http://pastebin.com/CR3NDVTX
take it from there using the download button

Copied from pastebin and the error stills:

HnkFOri.png


Also:

I thought I'd try too :)
Code:
    local c = {
        name = "Orc",
        cost = 10000, -- in gp, put 0 to disable
        egg = true -- should egg by removed after use?
    }


    function onUse(player, item, fromPosition, target, toPosition, isHotkey)
        if(player:getPosition().x == CONTAINER_POSITION) then
            player:sendCancelMessage("Put item on the floor first.")
            return false
        end
    
        local itemPos = getThingfromPos(item)
    
        if(player:getMoney() < c.cost) then
            player:sendCancelMessage("Not enought money, trainer cost " .. c.cost .. " gp's.")
            itemPos:sendMagicEffect(CONST_ME_POFF)
            return false
        else
            player:removeMoney(c.cost)
            doSummonCreature(c.name, itemPos)
            itemPos:sendMagicEffect(CONST_ME_MAGIC_RED)
            if(c.egg) then
                item:remove()
            end
        end
        return true
    end

Got this error:

6p0nXCH.png


so changed this:
doSendMagicEffect(toPosition, CONST_ME_POFF)

and this:

doSendMagicEffect(toPosition, CONST_ME_MAGIC_RED)

Working fine, but the egg dissapear and the summon doesn't appear, now trying to fix that xD

Edit:

Also the egg dissapears on equipment/backpack slot, the item is doesn't ask for be used at floor

Sorry guys :c
 
Why are you posting on pastebin?
Code:
local config = {
    summonName = "Orc",
    cost = 10000, -- in gp, put 0 to disable
    remove = "yes" -- should egg by removed after use?
}

config.remove = (config.remove == "yes" and true or false)
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local pos = player:getPosition()
    if(pos.x == CONTAINER_POSITION) then
        player:sendCancelMessage("Put item on the floor first.")
        return true
    end

    if(config.cost > 0 and player:getMoney() < config.cost) then
        player:sendCancelMessage("Not enought money, trainer cost " .. config.cost .. " gp's.")
        return true
    end

    effect = CONST_ME_MAGIC_RED
   
    Game.createMonster(config.summonName, pos)
    ret:setMaster(player)
    if(config.cost > 0) then
            player:removeMoney(config.cost)
    end
    if(config.remove == true) then
        item:remove(1)
    end
   
    Position(pos):sendMagicEffect(effect)
    return true
end
 
Why are you posting on pastebin?
Code:
local config = {
    summonName = "Orc",
    cost = 10000, -- in gp, put 0 to disable
    remove = "yes" -- should egg by removed after use?
}

config.remove = (config.remove == "yes" and true or false)
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local pos = player:getPosition()
    if(pos.x == CONTAINER_POSITION) then
        player:sendCancelMessage("Put item on the floor first.")
        return true
    end

    if(config.cost > 0 and player:getMoney() < config.cost) then
        player:sendCancelMessage("Not enought money, trainer cost " .. config.cost .. " gp's.")
        return true
    end

    effect = CONST_ME_MAGIC_RED
  
    Game.createMonster(config.summonName, pos)
    ret:setMaster(player)
    if(config.cost > 0) then
            player:removeMoney(config.cost)
    end
    if(config.remove == true) then
        item:remove(1)
    end
  
    Position(pos):sendMagicEffect(effect)
    return true
end
because last time he copied it a bunch of random 1s got stuck into the script due to browser error, so as I said above, I wanted him to use the pastebin link and use the download button.
 

This one works but there's this error:

LLt3EIa.png


1.- Checks for money but if i have the money, it doesn't remove
2.- Summons as monster, not as own summon "ret:setMaster(player)"
3.- Still can use the egg on equipment slot or backpack (and floor as it is right)


Why are you posting on pastebin?
Code:
local config = {
    summonName = "Orc",
    cost = 10000, -- in gp, put 0 to disable
    remove = "yes" -- should egg by removed after use?
}

config.remove = (config.remove == "yes" and true or false)
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local pos = player:getPosition()
    if(pos.x == CONTAINER_POSITION) then
        player:sendCancelMessage("Put item on the floor first.")
        return true
    end

    if(config.cost > 0 and player:getMoney() < config.cost) then
        player:sendCancelMessage("Not enought money, trainer cost " .. config.cost .. " gp's.")
        return true
    end

    effect = CONST_ME_MAGIC_RED
  
    Game.createMonster(config.summonName, pos)
    ret:setMaster(player)
    if(config.cost > 0) then
            player:removeMoney(config.cost)
    end
    if(config.remove == true) then
        item:remove(1)
    end
  
    Position(pos):sendMagicEffect(effect)
    return true
end

Same errors :c
 
Back
Top