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

npc spawn with chance at hour

Rashha

Member
Joined
Aug 5, 2019
Messages
26
Reaction score
9
Hello, someone have script to spawn NPC on x pos with 10% chance at 22:00?

Please help me :)
 
put this on your data/scripts folder:

Lua:
local globalevent = GlobalEvent("npc")

function globalevent.onTime(interval)
    if math.random(10) == 1 then
        Game.createNpc("NPC Name", Position(150, 150, 7), false, true)
    end
    return true
end

globalevent:time("22:00")
globalevent:register()
 
Try this, written from memory
Lua:
function onThink(interval)
    if math.random(10) == 1 then
        Game.createNpc("NPC Name", Position(150, 150, 7), false, true)
    end
    return true
end

Not onThink, should be onTime if its on specific time such as 22:00 in this case
 
its work now

thanks all for help

Code:
local pos = {x = 1774, y = 968, z = 7}
local npc = {"npc"}

function onTimer(interval)
     local npc = npc[math.random(#bosses)]
     doCreateNpc(npc, pos)
     doBroadcastMessage(npc.." has spawned.", MESSAGE_STATUS_WARNING)
     return true
end
 
Back
Top