• 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+ combat:execute with targets from getSpectators

Paulix

Active Member
Joined
Sep 13, 2012
Messages
129
Solutions
7
Reaction score
26
I was playing around with some spells, trying to do some combat on multi creatures...

Lua:
function onCastSpell(cid, var)
  alt_targets = Game.getSpectators(Creature(var.number):getPosition(), false, false, 1, 2, 1, 2) --minRangeX, maxRangeX, minRangeY, maxRangeY

  for i=1,#alt_targets do
    combat:execute(cid, alt_targets[i])
  end

    return combat:execute(cid, var)
end

I'm getting the following error...
1648583560164.png

The question is, how could combat:execute work when using var, and not work when using creatures from getSpectators, what am I missing?
 
I manage to make it work using this

Lua:
combat:execute(cid, {["type"] = 1, ["number"] = alt_targets[i].uid})

But this probably isn't the best way to make this, does anyone know how to get this kind of information from "Creature" userdata?
 
Solved, here is the solution
Lua:
combat:execute(cid, Variant(alt_targets[i].uid))
 
Solution
Back
Top