Page 1 of 1
"KillObject()" Is not working [Solved! Yay!]
Posted: Tue Sep 29, 2009 4:29 pm
by General_Nate
Hey, I have yet another code problem.
Everything about this code works, save the KillObject function.
Code: Select all
OnObjectKill(
function(object, killer)
local name = GetEntityName(object)
print("OnObjectKill():",name)
if name == "panel" then
ShowMessageText("mods.mymap.arefree")
KillObject("fence1")
KillObject("fence2")
end
end
)
(Ok, I know it's not very efficient, but I'll wait until everything works before I go down that path)
Help is greatly appreciated.
Re: "KillObject()" Is not working
Posted: Fri Oct 02, 2009 12:07 pm
by ForceMaster
Make sure that yours objects "fence1" and "fence2" are in the correct layer on ZE.

Re: "KillObject()" Is not working
Posted: Fri Oct 02, 2009 1:52 pm
by General_Nate
They are in the BASE layer. Is that why it won't work?
Re: "KillObject()" Is not working
Posted: Fri Oct 02, 2009 1:56 pm
by [RDH]Zerted
KillObject works fine on objects. Are the fences ingame objects? mods.mymap.arefree is being displayed right?
Re: "KillObject()" Is not working
Posted: Fri Oct 02, 2009 1:58 pm
by General_Nate
Yes, everything about this code works. Well everything but the KillObject(). And yes, "fence1" and 2 are both objects ingame in the BASE layer.
EDIT: If it helps, I also have this, which does not work, but....
Code: Select all
OnObjectKill(
function(object, killer)
local name = GetEntityName(object)
print("OnObjectKill():",name)
if name == "panel" then
ShowMessageText("mods.mymap.arefree")
local name2 = GetEntityName(object)
if name2 == "fence1" then
KillObject("fence1")
end
local name3 = GetEntityName(object)
if name3 == "fence2" then
KillObject("fence2")
end
end
end
)
Re: "KillObject()" Is not working
Posted: Fri Oct 02, 2009 2:50 pm
by Aman/Pinguin
General_Nate wrote:
EDIT: If it helps, I also have this, which does not work, but....
Code: Select all
OnObjectKill(
function(object, killer)
local name = GetEntityName(object)
print("OnObjectKill():",name)
if name == "panel" then
ShowMessageText("mods.mymap.arefree")
local name2 = GetEntityName(object)
if name2 == "fence1" then
KillObject("fence1")
end
local name3 = GetEntityName(object)
if name3 == "fence2" then
KillObject("fence2")
end
end
end
)
That makes no sense. You're trying to kill something that got killed. Also you're creating 3 variables (name, name2, name3) for the same thing (the killed object).
Not sure why the code in your first post doesn't work though. Post your Errorlog.
Re: "KillObject()" Is not working
Posted: Wed Oct 07, 2009 9:51 am
by General_Nate
Woops, sorry for the late reply. Any ways, here is the log:
Re: "KillObject()" Is not working
Posted: Wed Oct 07, 2009 12:21 pm
by Aman/Pinguin
Not sure if that's the problem, but did you setup any health for your fences? I think they have to have health to be killable.
Re: "KillObject()" Is not working
Posted: Wed Oct 07, 2009 1:42 pm
by [RDH]Zerted
Entity "Fence1" is EntityProp, but need GameObject
Like I mentioned, it would only work on objects. You have your fences as props. Use objects instead and it will work.
Re: "KillObject()" Is not working
Posted: Wed Oct 07, 2009 1:58 pm
by General_Nate
Ok, here is my odf:
What do I need to change?
Re: "KillObject()" Is not working
Posted: Wed Oct 07, 2009 2:00 pm
by Aman/Pinguin
Re: "KillObject()" Is not working
Posted: Wed Oct 07, 2009 2:39 pm
by General_Nate

Yes! I finally works!! Have a cookie, all of you! (::)
Thanks guys.