• 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 create monster

mmheo

New Member
Joined
Sep 14, 2017
Messages
157
Reaction score
1
hello guys
i use 0.4 and need help in when player use lever create 20 monster in area in random place
local fromPosition = {x = xxxx, y = xxxx, z = x}
local toPosition = {x = xxxxx, y = xxxx, z = x}
pos = {x = math.random(fromPosition.x, toPosition.x), y = math.random(fromPosition.y, toPosition.y), z = math.random(fromPosition.z, toPosition.z)}

but area have water ground don't make monster spawn on it just create monster in normal ground
 
Solution
[4:40:24.270] [Error - Action Interface]
[4:40:24.270] data/actions/scripts/creatmonster.lua:eek:nUse
[4:40:24.270] Description:
[4:40:24.270] (luaDoCreateMonster) Cannot create monster: dragon

and about room i can't its big room not small
Give me any screenshot of the room, cuz without it, I don't know what the issue is.
Post automatically merged:

[4:40:24.270] [Error - Action Interface]
[4:40:24.270] data/actions/scripts/creatmonster.lua:eek:nUse
[4:40:24.270] Description:
[4:40:24.270] (luaDoCreateMonster) Cannot create monster: dragon

and about room i can't its big room not small
omg dude.. how long does it take to give me a screenshot?

whatever I'll just guess at the issue.

untested.
Lua:
local function isPathable(pos)...
Untested.

Lua:
local water_tiles = {4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4665, 4666, 4820, 4821, 4822, 4823, 4824, 4825}

local top_left_corner = {x = 990, y = 990, z = 7}
local bottom_right_corner = {x = 1010, y = 1010, z = 7}

local monsters = {"rat", "cave rat"}
local monster_amount = 20

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local pos = {x = 0, y = 0, z = 0, stackpos = 0}
    local continue = false
    for i = 1, monster_amount do
        while continue == false do
            pos.x = math.random(top_left_corner.x, bottom_right_corner.x)
            pos.y = math.random(top_left_corner.y, bottom_right_corner.y)
            pos.z = math.random(top_left_corner.z, bottom_right_corner.z)
            if not isInArray(water_tiles, getTileThingByPos(pos).itemid) then
                continue = true
            end
        end
        continue = false
        doCreateMonster(monsters[math.random(#monsters)], pos)
    end
    return true
end
 
Last edited:
Untested.

Lua:
local water_tiles = {4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4665, 4666, 4820, 4821, 4822, 4823, 4824, 4825}

local top_left_corner = {x = 990, y = 990, z = 7}
local bottom_right_corner = {x = 1010, y = 1010, z = 7}

local monsters = {"rat", "cave rat"}
local monster_amount = 20

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local pos = {x = 0, y = 0, z = 0, stackpos = 0}
    local continue = false
    for i = 1, monster_amount do
        while continue == false do
            pos.x = math.random(top_left_corner.x, bottom_right_corner.x)
            pos.y = math.random(top_left_corner.y, bottom_right_corner.y)
            pos.z = math.random(top_left_corner.z, bottom_right_corner.z)
            if not isInArray(water_tiles, getTileThingByPos(pos).itemid) then
                continue = true
            end
        end
        continue = false
        doCreateMonster(monsters[math.random(#monsters)], pos)
    end
    return true
end
its create monster but not all give me error in console cannot create monster: dragon
how i can check how many monster in room
 
its create monster but not all give me error in console cannot create monster: dragon
how i can check how many monster in room
Give me a screenshot of the room?
Give me a screenshot of the console?
 
Give me a screenshot of the room?
Give me a screenshot of the console?

[4:40:24.270] [Error - Action Interface]
[4:40:24.270] data/actions/scripts/creatmonster.lua:eek:nUse
[4:40:24.270] Description:
[4:40:24.270] (luaDoCreateMonster) Cannot create monster: dragon

and about room i can't its big room not small
 
[4:40:24.270] [Error - Action Interface]
[4:40:24.270] data/actions/scripts/creatmonster.lua:eek:nUse
[4:40:24.270] Description:
[4:40:24.270] (luaDoCreateMonster) Cannot create monster: dragon

and about room i can't its big room not small
Give me any screenshot of the room, cuz without it, I don't know what the issue is.
Post automatically merged:

[4:40:24.270] [Error - Action Interface]
[4:40:24.270] data/actions/scripts/creatmonster.lua:eek:nUse
[4:40:24.270] Description:
[4:40:24.270] (luaDoCreateMonster) Cannot create monster: dragon

and about room i can't its big room not small
omg dude.. how long does it take to give me a screenshot?

whatever I'll just guess at the issue.

untested.
Lua:
local function isPathable(pos)
    if getTileThingByPos(pos).itemid ~= 0 then
        local tile = getThingfromPos(pos).uid    
        if hasProperty(tile, CONST_PROP_BLOCKSOLID) then
            return false
        end
        return true
    end
    return false
end

local water_tiles = {4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4665, 4666, 4820, 4821, 4822, 4823, 4824, 4825}

local top_left_corner = {x = 990, y = 990, z = 7}
local bottom_right_corner = {x = 1010, y = 1010, z = 7}

local monsters = {"rat", "cave rat"}
local monster_amount = 20

local monsters_summoned = {}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if monsters_summoned[1] then
        local monster_count = 0
        for i = 1, #monsters_summoned do
            if isCreature(monsters_summoned[i]) then
                monster_count = monster_count + 1
            end
        end
        if monster_count > 0 then
            doCreatureSay(cid, monster_count .. " creatures from previous lever activation are still alive.", TALKTYPE_MONSTER)
            return true
        end
    end
    monsters_summoned = {}
    local pos = {x = 0, y = 0, z = 0, stackpos = 0}
    local continue = false
    for i = 1, monster_amount do
        while continue == false do
            pos.x = math.random(top_left_corner.x, bottom_right_corner.x)
            pos.y = math.random(top_left_corner.y, bottom_right_corner.y)
            pos.z = math.random(top_left_corner.z, bottom_right_corner.z)
            if not isInArray(water_tiles, getTileThingByPos(pos).itemid) then
                if isPathable(pos) then
                    continue = true
                end
            end
        end
        continue = false
        local thing = doCreateMonster(monsters[math.random(#monsters)], pos)
        table.insert(monsters_summoned, thing)
    end
    doCreatureSay(cid, monster_amount .. " creatures have been created.", TALKTYPE_MONSTER)
    return true
end
 
Last edited:
Solution
Give me any screenshot of the room, cuz without it, I don't know what the issue is.
Post automatically merged:


omg dude.. how long does it take to give me a screenshot?

whatever I'll just guess at the issue.

untested.
Lua:
local function isPathable(pos)
    if getTileThingByPos(pos).itemid ~= 0 then
        local tile = getThingfromPos(pos).uid  
        if hasProperty(tile, CONST_PROP_BLOCKSOLID) then
            return false
        end
        return true
    end
    return false
end

local water_tiles = {4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4665, 4666, 4820, 4821, 4822, 4823, 4824, 4825}

local top_left_corner = {x = 990, y = 990, z = 7}
local bottom_right_corner = {x = 1010, y = 1010, z = 7}

local monsters = {"rat", "cave rat"}
local monster_amount = 20

local monsters_summoned = {}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if monsters_summoned[1] then
        local monster_count = 0
        for i = 1, #monsters_summoned do
            if isCreature(monsters_summoned[i]) then
                monster_count = monster_count + 1
            end
        end
        if monster_count > 0 then
            doCreatureSay(cid, monster_count .. " creatures from previous lever activation are still alive.", TALKTYPE_MONSTER)
            return true
        end
    end
    monsters_summoned = {}
    local pos = {x = 0, y = 0, z = 0, stackpos = 0}
    local continue = false
    for i = 1, monster_amount do
        while continue == false do
            pos.x = math.random(top_left_corner.x, bottom_right_corner.x)
            pos.y = math.random(top_left_corner.y, bottom_right_corner.y)
            pos.z = math.random(top_left_corner.z, bottom_right_corner.z)
            if not isInArray(water_tiles, getTileThingByPos(pos).itemid) then
                if isPathable(pos) then
                    continue = true
                end
            end
        end
        continue = false
        local thing = doCreateMonster(monsters[math.random(#monsters)], pos)
        table.insert(monsters_summoned, thing)
    end
    doCreatureSay(cid, monster_amount .. " creatures have been created.", TALKTYPE_MONSTER)
    return true
end
thx work fine always your work is 100% good
 
Last edited:
Back
Top