• 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+ [LUA] - On spawn - spawn random monster

lexus21

Active Member
Joined
Dec 14, 2022
Messages
88
Reaction score
25
I have a bit of a strange question. I would like to spawn snake, but i want to get random snake, for example cobra, grass snake or viper

Lua:
function Monster:onSpawn(position, startup, artificial)

    if (artificial or startup == true or false) and (self:getName() == "Snake") then
        local monstersName = {"Cobra", "Rat", "Viper"}     
        local spawnMonster = Game.createMonster(math.random(#monstersName), position, true, true)
            if spawnMonster then
                spawnMonster:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            end
    end
    return true

end
but when i spawn snake it's spawn also cobra or rat. But i just want spawn Cobra or Rat
im looking something like "self:setMonster"

how to "on spawn" spawn Cobra" or "Rat" or "Viper" instead snake from local?
 
It will never work properly because even if you remove the snake after the onSpawn event is completed, you will overspawn the snake over and over, it must be strictly done in sources
 
Back
Top