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

Lever for monster by money

Yaze

Well-Known Member
Joined
Sep 15, 2014
Messages
382
Reaction score
61
Hello, as the topic says,
i would like to upgrade this script that i got.

I would like it to have that it costs some money (id :2160) , and also it should be able to add few more monsters that should spawn. I am using tfs 0.3.6
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local fromPos = {x = toPosition.x - 10, y = toPosition.y - 10, z = toPosition.z}
local toPos = {x = toPosition.x + 10, y = toPosition.y + 10, z = toPosition.z}

local amount = 0
for x = fromPos.x, toPos.x do
for y = fromPos.y, toPos.y do
for z = fromPos.z, toPos.z do
local monster = getTopCreature({x=x,y=y,z=z}).uid
if(isCreature(monster) == TRUE) then
if getCreatureName(monster) == "Phantom Lord" then
amount = amount+2
end
end
end
end
end

if amount >= 2 then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "You need to kill Phantom Lord first before you can summen one again.")
return true
else
doSummonCreature("Phantom Lord", {x = toPosition.x - 1, y = toPosition.y + 1, z = toPosition.z})
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have summened Phantom Lord.")
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
end
return true
end
 
Code:
local creatures = {
    ["100 100 7"] = {name = 'Phantom Lord', cost = 10},
}

local leverMonster = nil

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tmp = creatures[toPosition.x.." "..toPosition.y.." "..toPosition.z]
    if tmp then
        if isCreature(leverMonster) then
            doPlayerSendCancel(cid, "You need to kill "..getCreatureName(leverMonster).." before you can summon another creature.")
        else
            if getPlayerMoney(cid) >= tmp.cost then
                doPlayerRemoveMoney(cid, tmp.cost)
                leverMonster = doSummonCreature(tmp.name, toPosition)
                doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
            end
        end
    end
    return true
end
this should work
just change "100 100 7" to whatever is the levers xyz position, and you can add more the same way with different positions on levers, should only summon one
 
Code:
local creatures = {
    ["100 100 7"] = {name = 'Phantom Lord', cost = 10},
}

local leverMonster = nil

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tmp = creatures[toPosition.x.." "..toPosition.y.." "..toPosition.z]
    if tmp then
        if isCreature(leverMonster) then
            doPlayerSendCancel(cid, "You need to kill "..getCreatureName(leverMonster).." before you can summon another creature.")
        else
            if getPlayerMoney(cid) >= tmp.cost then
                doPlayerRemoveMoney(cid, tmp.cost)
                leverMonster = doSummonCreature(tmp.name, toPosition)
                doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
            end
        end
    end
    return true
end
this should work
just change "100 100 7" to whatever is the levers xyz position, and you can add more the same way with different positions on levers, should only summon one

Are you saying you want more than 1 monster to spawn, or just different ones?

both, aswell more and different ones too,
and also a cancel message if not enough money please how do i fix it?
 
Last edited:
Code:
local creatures = {
    ["100 100 7"] = {name = 'Phantom Lord', cost = 10},
}

local leverMonster = nil

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tmp = creatures[toPosition.x.." "..toPosition.y.." "..toPosition.z]
    if tmp then
        if isCreature(leverMonster) then
            doPlayerSendCancel(cid, "You need to kill "..getCreatureName(leverMonster).." before you can summon another creature.")
        else
            if getPlayerMoney(cid) >= tmp.cost then
                doPlayerRemoveMoney(cid, tmp.cost)
                leverMonster = doSummonCreature(tmp.name, toPosition)
                doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
            else
                doPlayerSendCancel(cid, 'You need '.. tmp.cost ..' gold coins to use this lever.')
            end
        end
    end
    return true
end
 
Code:
local creatures = {
    ["100 100 7"] = {name = 'Phantom Lord', cost = 10},
}

local leverMonster = nil

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tmp = creatures[toPosition.x.." "..toPosition.y.." "..toPosition.z]
    if tmp then
        if isCreature(leverMonster) then
            doPlayerSendCancel(cid, "You need to kill "..getCreatureName(leverMonster).." before you can summon another creature.")
        else
            if getPlayerMoney(cid) >= tmp.cost then
                doPlayerRemoveMoney(cid, tmp.cost)
                leverMonster = doSummonCreature(tmp.name, toPosition)
                doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
            else
                doPlayerSendCancel(cid, 'You need '.. tmp.cost ..' gold coins to use this lever.')
            end
        end
    end
    return true
end

It dont work to summon more monsters with this, tried out to put one more monster in the list only the last one got summon.
And why does have the monster spawn and lever be the same position? with other position (different sqm then lever) the monster dont summon :eek:
 
It dont work to summon more monsters with this, tried out to put one more monster in the list only the last one got summon.
And why does have the monster spawn and lever be the same position? with other position (different sqm then lever) the monster dont summon :eek:
You don't explain how you want multiple monsters to even spawn, how am I supposed to know exactly what you want?
Do you want other monsters to spawn at specific levels?
Do you want multiple monsters to spawn at once?
????????
 
Code:
local creatures = {
    [9999] = {name = 'Phantom Lord', cost = 10},
}

local lever = {}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tmp = creatures[item:getActionId()]
    if tmp then
        if isCreature(lever[item:getUniqueId()]) then
            doPlayerSendCancel(cid, "You need to kill "..getCreatureName(leverMonster).." before you can summon another creature.")
        else
            if getPlayerMoney(cid) >= tmp.cost then
                doPlayerRemoveMoney(cid, tmp.cost)
                lever[item:getUniqueId()] = doSummonCreature(tmp.name, toPosition)
                doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
            else
                doPlayerSendCancel(cid, 'You need '.. tmp.cost ..' gold coins to use this lever.')
            end
        end
    end
    return true
end
try using this, dont bother with positions, just set AID to lever and it should should
the toPosition at doSummonCreature has to be changed for it to be spawned in another place..
 
You don't explain how you want multiple monsters to even spawn, how am I supposed to know exactly what you want?
Do you want other monsters to spawn at specific levels?
Do you want multiple monsters to spawn at once?
????????

Ok so i explain once again just for you,

The lever should cost xx price
The lever should summon 2 monsters or more,
the lever should be able to use after the monsters got killed
the level doesnt matter.
 
Code:
local creatures = {
    [9999] = {name = 'Phantom Lord', cost = 10},
}

local lever = {}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tmp = creatures[item:getActionId()]
    if tmp then
        if isCreature(lever[item:getUniqueId()]) then
            doPlayerSendCancel(cid, "You need to kill "..getCreatureName(leverMonster).." before you can summon another creature.")
        else
            if getPlayerMoney(cid) >= tmp.cost then
                doPlayerRemoveMoney(cid, tmp.cost)
                lever[item:getUniqueId()] = doSummonCreature(tmp.name, toPosition)
                doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
            else
                doPlayerSendCancel(cid, 'You need '.. tmp.cost ..' gold coins to use this lever.')
            end
        end
    end
    return true
end
try using this, dont bother with positions, just set AID to lever and it should should
the toPosition at doSummonCreature has to be changed for it to be spawned in another place..

[Error - Action Interface]
data/actions/scripts/lever1.lua:eek:nUse
Description:
data/actions/scripts/lever1.lua:8: attempt to call method 'getActionId' (a nil value)
stack traceback:
data/actions/scripts/lever1.lua:8: in function <data/actions/scripts/lever1.lua:7>
 
Back
Top