• 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 Action script

massuco

Brazilian, sorry for my bad english XD
Joined
Feb 17, 2013
Messages
199
Solutions
8
Reaction score
22
Location
Brasil
Im searching a way to do one script.
I want this:

I will use one rock (id 5000 example) on the map, and this rock will transform on other rock (id 5001), and have a chance of summon one creature or win one item, and after 5minutes, the rock decay to the id 5000 again.

Any ideas on how to start this?
 
Solution
try this. lol
Lua:
local config = {
   create_monster_here = {x = 1000, y = 1000, z = 7}, -- some random place that no players can get to
   teleport_monster_here = {x = 1000, y = 1000, z = 7}, -- location near stone
   stoneResetTimer = 1000
}

local function resetStone(position, current_item, new_item)
   doTransformItem(getTileItemById(position, current_item).uid, new_item)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
   if item.itemid ~= 5194 then
       doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
       doPlayerSendCancel(cid, "Sorry not possible.")
       return true
   end
   doTransformItem(item.uid, 5195)
   addEvent(resetStone, config.stoneResetTimer, toPosition, 5195, 5194)
   
   local summon =...
umm..
a xikini style janky work-around could be to summon the monster somewhere, then teleport the monster into the room. That way the monster is gaurenteed to spawn, and there are less restrictions on teleporting creatures then creating them.
I have no idea on how to do this. You have?
I dont have marked best answer for you because If i mark it the post will be marked with solved, but I will mark later :D

EDIT
I thik that If have one script to check fields arround the rock, it works, for example, a script check if have empty sqms arround the rock, if dont have, the script dont run any function, dont transform the rock, dont summon creature, dont give the item.

I have one way for it works now! :D
But It show me one error on distro.
Look I have changed the system, NOW, every time the player use the rock, the monster will be summoned, and will have a chance of receive the item.
And, If DONT HAVE sqm to place the monster, the monster not appear, but the player also dont receive item.
Now my script are like this:
Lua:
local function resetStone(position, current_item, new_item)
   doTransformItem(getTileItemById(position, current_item).uid, new_item)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid ~= 5194 then
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
        doPlayerSendCancel(cid, "Sorry not possible.")
        return true
    end
    doTransformItem(item.uid, 5195)
    addEvent(resetStone, 1000, toPosition, 5195, 5194)

    local summon = doSummonCreature("frazzlemaw", fromPosition, true, true)
    doSendMagicEffect(getCreaturePosition(summon), CONST_ME_TELEPORT)
   
    local rand = math.random(100)
    if rand <= 50 then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Amidst the pile of various bones you find a large, hollow part, similar to a pipe.")
        doPlayerAddItem(cid, 5196, 1)
        return true
    end
    return true
end

All working good, not perfect, but is good for me, but when dont have sqm to place the monster, I have this error on distro:
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/pile_of_bones.lua:onUse

LuaScriptInterface::luaDoSummonCreature(). Can not summon monster: frazzlemaw

Lua Script Error: [Action Interface]
data/actions/scripts/pile_of_bones.lua:onUse

LuaScriptInterface::luaGetCreaturePosition(). Creature not found

Lua Script Error: [Action Interface]
data/actions/scripts/pile_of_bones.lua:onUse

attempt to index a boolean value
stack traceback:
        [C]: in function 'doSendMagicEffect'
        data/actions/scripts/pile_of_bones.lua:15: in function <data/actions/scripts/pile_of_bones.lua:5>
 
Last edited by a moderator:
try this. lol
Lua:
local config = {
   create_monster_here = {x = 1000, y = 1000, z = 7}, -- some random place that no players can get to
   teleport_monster_here = {x = 1000, y = 1000, z = 7}, -- location near stone
   stoneResetTimer = 1000
}

local function resetStone(position, current_item, new_item)
   doTransformItem(getTileItemById(position, current_item).uid, new_item)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
   if item.itemid ~= 5194 then
       doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
       doPlayerSendCancel(cid, "Sorry not possible.")
       return true
   end
   doTransformItem(item.uid, 5195)
   addEvent(resetStone, config.stoneResetTimer, toPosition, 5195, 5194)
   
   local summon = doSummonCreature("frazzlemaw", config.create_monster_here, true, true)
   doTeleportThing(summon, config.teleport_monster_here)
   doSendMagicEffect(getCreaturePosition(summon), CONST_ME_TELEPORT)
   
   local rand = math.random(100)
   if rand <= 50 then
       doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Amidst the pile of various bones you find a large, hollow part, similar to a pipe.")
       doPlayerAddItem(cid, 5196, 1)
       return true
   end
   return true
end
 
Solution
try this. lol
Lua:
local config = {
   create_monster_here = {x = 1000, y = 1000, z = 7}, -- some random place that no players can get to
   teleport_monster_here = {x = 1000, y = 1000, z = 7}, -- location near stone
   stoneResetTimer = 1000
}

local function resetStone(position, current_item, new_item)
   doTransformItem(getTileItemById(position, current_item).uid, new_item)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
   if item.itemid ~= 5194 then
       doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
       doPlayerSendCancel(cid, "Sorry not possible.")
       return true
   end
   doTransformItem(item.uid, 5195)
   addEvent(resetStone, config.stoneResetTimer, toPosition, 5195, 5194)
 
   local summon = doSummonCreature("frazzlemaw", config.create_monster_here, true, true)
   doTeleportThing(summon, config.teleport_monster_here)
   doSendMagicEffect(getCreaturePosition(summon), CONST_ME_TELEPORT)
 
   local rand = math.random(100)
   if rand <= 50 then
       doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Amidst the pile of various bones you find a large, hollow part, similar to a pipe.")
       doPlayerAddItem(cid, 5196, 1)
       return true
   end
   return true
end
LOL you are a god....

Only other problem more.. haha
I dont have only 1 rock on the map, i have 10 rocks,
can I make the monster to be summoned on one place and teleported to the rock position?

-- EDIT
done! doTeleportThing(summon, toPosition)
 
LOL you are a god....

Only other problem more.. haha
I dont have only 1 rock on the map, i have 10 rocks,
can I make the monster to be summoned on one place and teleported to the rock position?
like this?
It'll teleport on top of the rock, I think
Lua:
local config = {
   create_monster_here = {x = 1000, y = 1000, z = 7}, -- some random place that no players can get to
   stoneResetTimer = 1000
}

local function resetStone(position, current_item, new_item)
   doTransformItem(getTileItemById(position, current_item).uid, new_item)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
   if item.itemid ~= 5194 then
       doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
       doPlayerSendCancel(cid, "Sorry not possible.")
       return true
   end
   doTransformItem(item.uid, 5195)
   addEvent(resetStone, config.stoneResetTimer, toPosition, 5195, 5194)
   
   local summon = doSummonCreature("frazzlemaw", config.create_monster_here, true, true)
   doTeleportThing(summon, toPosition)
   doSendMagicEffect(getCreaturePosition(summon), CONST_ME_TELEPORT)
   
   local rand = math.random(100)
   if rand <= 50 then
       doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Amidst the pile of various bones you find a large, hollow part, similar to a pipe.")
       doPlayerAddItem(cid, 5196, 1)
       return true
   end
   return true
end
 
like this?
It'll teleport on top of the rock, I think
Lua:
local config = {
   create_monster_here = {x = 1000, y = 1000, z = 7}, -- some random place that no players can get to
   stoneResetTimer = 1000
}

local function resetStone(position, current_item, new_item)
   doTransformItem(getTileItemById(position, current_item).uid, new_item)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
   if item.itemid ~= 5194 then
       doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
       doPlayerSendCancel(cid, "Sorry not possible.")
       return true
   end
   doTransformItem(item.uid, 5195)
   addEvent(resetStone, config.stoneResetTimer, toPosition, 5195, 5194)
  
   local summon = doSummonCreature("frazzlemaw", config.create_monster_here, true, true)
   doTeleportThing(summon, toPosition)
   doSendMagicEffect(getCreaturePosition(summon), CONST_ME_TELEPORT)
  
   local rand = math.random(100)
   if rand <= 50 then
       doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Amidst the pile of various bones you find a large, hollow part, similar to a pipe.")
       doPlayerAddItem(cid, 5196, 1)
       return true
   end
   return true
end
I have used doTeleportThing(summon, getThingPos(cid))
And it teleport above the player, for me its fine. if dont have other way to teleport next the player
 
Back
Top Bottom