"KillObject()" Is not working [Solved! Yay!]

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
General_Nate
Lieutenant General
Lieutenant General
Posts: 689
Joined: Sun Jun 28, 2009 4:01 pm
Projects :: None because BFII is not working
Games I'm Playing :: Minecraft
xbox live or psn: No gamertag set
Location: 127.0.0.1

"KillObject()" Is not working [Solved! Yay!]

Post 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.
Last edited by General_Nate on Wed Oct 07, 2009 2:40 pm, edited 1 time in total.
ForceMaster
Lieutenant General
Lieutenant General
Posts: 737
Joined: Fri Aug 08, 2008 11:27 pm
Projects :: Tron The Grid
Games I'm Playing :: The best..SWBFII
xbox live or psn: No gamertag set
Location: C:\Program Files\ForceMaster\Bin\ForceMaster.exe

Re: "KillObject()" Is not working

Post by ForceMaster »

Make sure that yours objects "fence1" and "fence2" are in the correct layer on ZE. :wink:
User avatar
General_Nate
Lieutenant General
Lieutenant General
Posts: 689
Joined: Sun Jun 28, 2009 4:01 pm
Projects :: None because BFII is not working
Games I'm Playing :: Minecraft
xbox live or psn: No gamertag set
Location: 127.0.0.1

Re: "KillObject()" Is not working

Post by General_Nate »

They are in the BASE layer. Is that why it won't work?
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: "KillObject()" Is not working

Post by [RDH]Zerted »

KillObject works fine on objects. Are the fences ingame objects? mods.mymap.arefree is being displayed right?
User avatar
General_Nate
Lieutenant General
Lieutenant General
Posts: 689
Joined: Sun Jun 28, 2009 4:01 pm
Projects :: None because BFII is not working
Games I'm Playing :: Minecraft
xbox live or psn: No gamertag set
Location: 127.0.0.1

Re: "KillObject()" Is not working

Post 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
)
Aman/Pinguin
Jedi
Jedi
Posts: 1104
Joined: Tue Jan 30, 2007 6:04 am
Projects :: Inactive
Location: Germany

Re: "KillObject()" Is not working

Post 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.
User avatar
General_Nate
Lieutenant General
Lieutenant General
Posts: 689
Joined: Sun Jun 28, 2009 4:01 pm
Projects :: None because BFII is not working
Games I'm Playing :: Minecraft
xbox live or psn: No gamertag set
Location: 127.0.0.1

Re: "KillObject()" Is not working

Post by General_Nate »

Woops, sorry for the late reply. Any ways, here is the log:
Hidden/Spoiler:
OnObjectKill(): panel

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(642)
Entity "Fence1" is EntityProp, but need GameObject

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(642)
Entity "Fence2" is EntityProp, but need GameObject
Aman/Pinguin
Jedi
Jedi
Posts: 1104
Joined: Tue Jan 30, 2007 6:04 am
Projects :: Inactive
Location: Germany

Re: "KillObject()" Is not working

Post 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.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: "KillObject()" Is not working

Post 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.
User avatar
General_Nate
Lieutenant General
Lieutenant General
Posts: 689
Joined: Sun Jun 28, 2009 4:01 pm
Projects :: None because BFII is not working
Games I'm Playing :: Minecraft
xbox live or psn: No gamertag set
Location: 127.0.0.1

Re: "KillObject()" Is not working

Post by General_Nate »

Ok, here is my odf:
Hidden/Spoiler:
[GameObjectClass]
ClassLabel = "prop"
GeometryName = "gt1_build_fencebig_01.msh"

[Properties]
GeometryName = "gt1_build_fencebig_01"
FoleyFXGroup = "metal_foley"
What do I need to change?
Aman/Pinguin
Jedi
Jedi
Posts: 1104
Joined: Tue Jan 30, 2007 6:04 am
Projects :: Inactive
Location: Germany

Re: "KillObject()" Is not working

Post by Aman/Pinguin »

Hidden/Spoiler:
[GameObjectClass]
ClassLabel = "destructablebuilding"
GeometryName = "gt1_build_fencebig_01.msh"

[Properties]
GeometryName = "gt1_build_fencebig_01"
FoleyFXGroup = "metal_foley"
IsNotTargetableByPlayer = "1"
MaxHealth = "99999999999"
AddHealth = "99999999999"
User avatar
General_Nate
Lieutenant General
Lieutenant General
Posts: 689
Joined: Sun Jun 28, 2009 4:01 pm
Projects :: None because BFII is not working
Games I'm Playing :: Minecraft
xbox live or psn: No gamertag set
Location: 127.0.0.1

Re: "KillObject()" Is not working

Post by General_Nate »

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