Skip to content
User Avatar
#259
Auto-translated
The thing is, the GetPlayerHeroes function itself returns an array, so the values of the array fields "heroes" from 2 to 5 are nil, and the first one is a table. The same applies to the "hero" table itself, so in your case, both IsHeroAlive(hero) and IsHeroAlive(hero[k]) will fail – with the error you specified. Therefore, you need to copy the table from the GetPlayerHeroes function into a local array called "heroes," then iterate through the array and perform the specified actions. ```lua function incom() local day = GetDate(3) if day == 2 then local heroes = GetPlayerHeroes(5) for k, hero in heroes do if IsHeroAlive(hero) then local types = {} types[0], types[1], types[2], types[3], types[4], types[5], types[6] = GetHeroCreaturesTypes(hero) for i = 0, 6 do if HasHeroCreature(hero, types[i]) then local stack = GetCreatureById(types[i]) -- If you copied this from RW, I hope you also copied the GetCreatureById function. local amount = GetHeroCreatures(hero, types[i]) AddHeroCreatures(hero, types[i], amount, i) end end end end end end Trigger(NEW_DAY_TRIGGER, "incom")
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________

Statistics

Welcome our newest member: leyu