Hi, I'm trying to make CombatLog for MCServer and I have a problem.
I need to increase player combat time. The code should do it, but I get this error every second:
[20:28:04] LUA: 2 - Plugins/CombatLog/main.lua:46: attempt to perform arithmetic
on field '?' (a nil value)
Any idea why? How to fix it?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | CombatTime = 5 Time = 0 local seconds = {} local IsOnCombat = {} function OnTakeDamage(Receiver, TDI) if Receiver:IsPlayer() then Player = tolua.cast(Receiver, "cPlayer" ) IsOnCombat[Player:GetName()] = true seconds[Player:GetName()] = 0 Player:SendMessage( "You're on a combat, don't disconnect" ) end end function OnPlayerDestroyed(Player) if IsOnCombat[Player:GetName()] == true then Player:TakeDamage(dtPlugin, nil , 1000, 1000, 0) cRoot:Get():BroadcastChat(Player:GetName().. " disconnected while being on a combat, buuuhhh, you suck" ) end end function OnTick(TimeDelta) if Time == 20 then local EachPlayer = function (Player) if seconds[Player:GetName()] == CombatTime then Player:SendMessage( "You are no longer in combat" ) else seconds[Player:GetName()] = seconds[Player:GetName()] + 1 print (seconds[Player:GetName()]) end end local EachWorld = function (World) World:ForEachPlayer(EachPlayer) end cRoot:Get():ForEachWorld(EachWorld) Time = 0 else Time = Time + 1 end end |
[20:28:04] LUA: 2 - Plugins/CombatLog/main.lua:46: attempt to perform arithmetic
on field '?' (a nil value)
Any idea why? How to fix it?
