• WarSource Races and Powers problem
    4 replies, posted
So I am having a problem with one of my races. It is a health leach and it gives the error: [ERROR] addons/war1source/lua/classes/darkvampire.lua:12: attempt to call method 'GetInfoNum' (a nil value) 1. v - addons/war1source/lua/classes/darkvampire.lua:12 2. unknown - lua/includes/modules/hook.lua:84 [LUA] function healthLeach(victim, attacker) local curHealth = attacker:Health() if (attacker:GetInfoNum("Perk_DarkVampire", 0) == 1) then if (attacker:IsPlayer() && victim:IsPlayer()) then if(math.random(1, 3) == 1) then attacker:SetHealth(curHealth + randomHealth) victim:ChatPrint("[War3Source] You have been leached of health!") attacker:ChatPrint("[War3Source] You have leached health!") end end end end hook.Add("PlayerHurt", "healthLeach", healthLeach) [/LUA] Also with my other race, it is supposed to give health every 2-4 seconds but it only works if I reload that file. There are no errors or anything [lua] function Water() for k, v in pairs( player.GetAll() ) do if (v:GetInfoNum("Perk_Avatar", 0) == 1) then local curHealth = v:Health() v:SetHealth(curHealth + math.random(2, 4)) v:PrintMessage(HUD_PRINTTALK, "[Water] Some soothing water has healed you!") end end end timer.Simple(math.random(2, 4), function() Water() end) [/lua] Note: This is a addon, not a gamemode.
Bump, no help?
[LUA] function healthLeach(victim, attacker) if (attacker:IsPlayer() && victim:IsPlayer()) then if(math.random(1, 3) == 1 and attacker:GetInfoNum("Perk_DarkVampire", 0) == 1) then attacker:SetHealth(attacker:Health() + randomHealth) victim:ChatPrint("[War3Source] You have been leached of health!") attacker:ChatPrint("[War3Source] You have leached health!") end end end hook.Add("PlayerHurt", "healthLeach", healthLeach) [/LUA] [lua] function Water() for k, v in pairs( player.GetAll() ) do if (v:GetInfoNum("Perk_Avatar", 0) == 1) then v:SetHealth(v:Health() + math.random(2, 4)) v:PrintMessage(HUD_PRINTTALK, "[Water] Some soothing water has healed you!") end end timer.Simple(math.random(2, 4), function() Water() end) end [/lua] Btw "randomHealth" does not seem to be a real variable make sure it exist as well.
[QUOTE=Crapy;45285774][LUA] function healthLeach(victim, attacker) if (attacker:IsPlayer() && victim:IsPlayer()) then if(math.random(1, 3) == 1 and attacker:GetInfoNum("Perk_DarkVampire", 0) == 1) then attacker:SetHealth(attacker:Health() + randomHealth) victim:ChatPrint("[War3Source] You have been leached of health!") attacker:ChatPrint("[War3Source] You have leached health!") end end end hook.Add("PlayerHurt", "healthLeach", healthLeach) [/LUA] [lua] function Water() for k, v in pairs( player.GetAll() ) do if (v:GetInfoNum("Perk_Avatar", 0) == 1) then v:SetHealth(v:Health() + math.random(2, 4)) v:PrintMessage(HUD_PRINTTALK, "[Water] Some soothing water has healed you!") end end timer.Simple(math.random(2, 4), function() Water() end) end [/lua] Btw "randomHealth" does not seem to be a real variable make sure it exist as well.[/QUOTE] Thank you. randomHealth does exist I just didn't paste it into my original post.
[QUOTE=Desimay;45285828]Thank you. randomHealth does exist I just didn't paste it into my original post.[/QUOTE] Yes as I thought just wanted to make sure.
Sorry, you need to Log In to post a reply to this thread.