• 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.2 Wave event LUA SCRIPT ERROR and other issues

Tbol

Well-Known Member
Joined
Apr 7, 2019
Messages
526
Reaction score
54
Got three issues
1. It doesnt spawn boss once you kill the wave
Lua:
 boss = { -- Boss is spawned after waitTimeBoss seconds after the wave is stated --
            {"Bandit Lvl 10", Position(564, 788, 7)},
        },
2. Doesnt give item rewards once you finish the event
Lua:
 itemRewards = { -- Items rewarded for completing the wave. --
            {2160, 50},
            {14319, 1}
        },
3. Lua script error
1659871150171.png

CODE made by @Itutorial if im not wrong - ---- DONT TOUCH ---MW_STATUS = 0MW_PLAYERS = {}MW_MONSTERS = {}local MW_ - Pastebin.com (https://pastebin.com/Au41NBUB)
 
Maybe try this one instead?
You can just make a reward room through the teleport.

Then change this part (to turn it from a revscript into normal onUse script)
Lua:
local monsterWaveEvent = Action()

function monsterWaveEvent.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == event.leverIds[1] then
        eventManager(toPosition)
    end
    return true
end

monsterWaveEvent:aid(event.leverActionId)
monsterWaveEvent:register()
to this (and register in actions.xml with an ActionId of your choice)
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == event.leverIds[1] then
        eventManager(toPosition)
    end
    return true
end
 
Maybe try this one instead?
You can just make a reward room through the teleport.

Then change this part (to turn it from a revscript into normal onUse script)
Lua:
local monsterWaveEvent = Action()

function monsterWaveEvent.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == event.leverIds[1] then
        eventManager(toPosition)
    end
    return true
end

monsterWaveEvent:aid(event.leverActionId)
monsterWaveEvent:register()
to this (and register in actions.xml with an ActionId of your choice)
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == event.leverIds[1] then
        eventManager(toPosition)
    end
    return true
end
Yea your code looks x10 times better but im not a big fan of levers because than it becomes not event anymore and one player determens when event starts which is kinda gay ngl. Which kills the entire story for me honestly. Reward room too im not a big fan of not automated stuff because it can become a little bit annoying
 
I will work on another version of this. Do you use revscripts? Mainly going to clean up some of the uneeded code/unclean code.
 
I will work on another version of this. Do you use revscripts? Mainly going to clean up some of the uneeded code/unclean code.
Im not using revscript unfortunatly but i should be able to convert it to a regular script
 
Change this function
Lua:
function MW_spawnBosses(waveTable)
 for i = 1, #waveTable.boss do
  local MONS = Game.createMonster(waveTable[i].boss[1], waveTable[i].boss[2])
        MW_MONSTERS[#MW_MONSTERS + 1] = MONS:getId()
   end
end

change to
Lua:
function MW_spawnBosses(waveTable)
 for i = 1, #waveTable.boss do
  local MONS = Game.createMonster(waveTable.boss[i][1], waveTable.boss[i][2])
        MW_MONSTERS[#MW_MONSTERS + 1] = MONS:getId()
   end
end
Post automatically merged:

Also change this part

Lua:
if WAVE.boss then
        addEvent(spawnBosses, WAVE.waitTimeBoss * 1000, WAVE)
        MW_sendMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This waves bosses will spawn in "..WAVE.waitTimeBoss.." seconds.")
    end

to

Lua:
if WAVE.boss then
        addEvent(MW_spawnBosses, WAVE.waitTimeBoss * 1000, WAVE)
        MW_sendMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This waves bosses will spawn in "..WAVE.waitTimeBoss.." seconds.")
    end
 
Change this function
Lua:
function MW_spawnBosses(waveTable)
 for i = 1, #waveTable.boss do
  local MONS = Game.createMonster(waveTable[i].boss[1], waveTable[i].boss[2])
        MW_MONSTERS[#MW_MONSTERS + 1] = MONS:getId()
   end
end

change to
Lua:
function MW_spawnBosses(waveTable)
 for i = 1, #waveTable.boss do
  local MONS = Game.createMonster(waveTable.boss[i][1], waveTable.boss[i][2])
        MW_MONSTERS[#MW_MONSTERS + 1] = MONS:getId()
   end
end
Post automatically merged:

Also change this part

Lua:
if WAVE.boss then
        addEvent(spawnBosses, WAVE.waitTimeBoss * 1000, WAVE)
        MW_sendMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This waves bosses will spawn in "..WAVE.waitTimeBoss.." seconds.")
    end

to

Lua:
if WAVE.boss then
        addEvent(MW_spawnBosses, WAVE.waitTimeBoss * 1000, WAVE)
        MW_sendMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This waves bosses will spawn in "..WAVE.waitTimeBoss.." seconds.")
    end
Yea it spawns the boss now, but its acting not how it suppose, i think because it started the event and it said

16:42 The wave has spawned. Kill all monsters for the next wave to begin.
16:42 This waves bosses will spawn in 60 seconds.

so i decided not to kill the mosnters and wait for that 60 seconds and see if it will spawn the boss or not even tho the first wave is not killed and it said
16:44 There are still monsters left to kill. Kill them to start the next wave.

but it still spawned the boss tho, even i didnt finished killing the first wave.
 
Yea it spawns the boss now, but its acting not how it suppose, i think because it started the event and it said

16:42 The wave has spawned. Kill all monsters for the next wave to begin.
16:42 This waves bosses will spawn in 60 seconds.

so i decided not to kill the mosnters and wait for that 60 seconds and see if it will spawn the boss or not even tho the first wave is not killed and it said
16:44 There are still monsters left to kill. Kill them to start the next wave.

but it still spawned the boss tho, even i didnt finished killing the first wave.
bump
 
Yea it spawns the boss now, but its acting not how it suppose, i think because it started the event and it said

16:42 The wave has spawned. Kill all monsters for the next wave to begin.
16:42 This waves bosses will spawn in 60 seconds.

so i decided not to kill the mosnters and wait for that 60 seconds and see if it will spawn the boss or not even tho the first wave is not killed and it said
16:44 There are still monsters left to kill. Kill them to start the next wave.

but it still spawned the boss tho, even i didnt finished killing the first wave.
Bro its supposed to spawn the boss even if you haven't killed all the monsters. The idea is it is trying to kill the player. You are seeing the message "The next wave won't begin because you haven't killed all monsters + boss"
 
Bro its supposed to spawn the boss even if you haven't killed all the monsters. The idea is it is trying to kill the player. You are seeing the message "The next wave won't begin because you haven't killed all monsters + boss"
Okay lets act like it suppose to be like that w/e. Anyway there is still a lot of flaws like it finishes the event even without killing the boss for example

15:43 The wave has spawned. Kill all monsters for the next wave to begin.
15:43 This waves bosses will spawn in 60 seconds.
15:44 [WAVE REWARD]: 20000 experience.
15:44 Well done. You completed all waves. The event will end in 30 seconds!

i killed first wave and after x time i got a reward and it spawned the boss and got message Well done. You completed all waves and after 30 seconds it tped me out even tho i didnt killed the boss just cleared a wave
 
Act like its supposed to be like that? I made the code, I know how its supposed to work.

Lua:
function MW_startWave()
    local WAVE = MONSTER_WAVES[MW_WAVE]
 
    for i = 1, #WAVE.monsters do
        local MONS = Game.createMonster(WAVE.monsters[i][1], WAVE.monsters[i][2])
        if not MW_MONSTERS[1] then
            MW_MONSTERS[1] = MONS:getId()
        else
            MW_MONSTERS[#MW_MONSTERS + 1] = MONS:getId()
        end
    end
 
    MW_sendMessage(MESSAGE_STATUS_CONSOLE_BLUE, "The wave has spawned. Kill all monsters for the next wave to begin.")
 
    if WAVE.boss then
        addEvent(spawnBosses, WAVE.waitTimeBoss * 1000, WAVE)
        MW_sendMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This waves bosses will spawn in "..WAVE.waitTimeBoss.." seconds.")
        addEvent(MW_proccessWave, 2 * WAVE.waitTimeBoss * 1000)
        return true
    end
 
    addEvent(MW_proccessWave, 60 * 1000)
end

That should fix the problem. Replace that function
 
Act like its supposed to be like that? I made the code, I know how its supposed to work.

Lua:
function MW_startWave()
    local WAVE = MONSTER_WAVES[MW_WAVE]
 
    for i = 1, #WAVE.monsters do
        local MONS = Game.createMonster(WAVE.monsters[i][1], WAVE.monsters[i][2])
        if not MW_MONSTERS[1] then
            MW_MONSTERS[1] = MONS:getId()
        else
            MW_MONSTERS[#MW_MONSTERS + 1] = MONS:getId()
        end
    end
 
    MW_sendMessage(MESSAGE_STATUS_CONSOLE_BLUE, "The wave has spawned. Kill all monsters for the next wave to begin.")
 
    if WAVE.boss then
        addEvent(spawnBosses, WAVE.waitTimeBoss * 1000, WAVE)
        MW_sendMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This waves bosses will spawn in "..WAVE.waitTimeBoss.." seconds.")
        addEvent(MW_proccessWave, 2 * WAVE.waitTimeBoss * 1000)
        return true
    end
 
    addEvent(MW_proccessWave, 60 * 1000)
end

That should fix the problem. Replace that function
Sorry for long delay. Work irl
1663344849834.png
 
addEvent(spawnBosses, WAVE.waitTimeBoss * 1000, WAVE)

addEvent(MW_spawnBosses, WAVE.waitTimeBoss * 1000, WAVE)
 
addEvent(spawnBosses, WAVE.waitTimeBoss * 1000, WAVE)

addEvent(MW_spawnBosses, WAVE.waitTimeBoss * 1000, WAVE)
Yea it seems to work now the only issue i see with this even now its lacking some information messages for example if u kill boss = { it could send a message atleast saying congratulation you killed boss because now when you kill it, you stand like an idiot for 30 seconds and you dont know if even finished the event or not :D
 
Back
Top