Prevent class from spawning at CP

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
Lorul1
Rebel Colonel
Rebel Colonel
Posts: 562
Joined: Wed Apr 24, 2013 10:34 pm
Projects :: Assault on Theed
Games I'm Playing :: Battlegrounds
xbox live or psn: No gamertag set
Location: Your House

Prevent class from spawning at CP

Post by Lorul1 »

i didn't want to double post and get in trouble to bring back up my last post so i made this one
(I NEVER asked this question on my old post this is a NEW question concerning something posted on my old post)

someone named Locutus gave me a script so when my jedi class spawned at a certain command post they would get killed BUT only if they were AI (not players)
it doesn't work though so can anyone figure out why (It shouldn't be hard to do)
I think you can do it via Lua, too.

Place a region around your spawn path at the CP and add sth. like this:

OnCharacterSpawn(
function(character)
if GetCharacterClass(character) == "YOURJEDICLASS" then
checkJediRegion()
end
end
end
)

checkJediRegion()
OnEnterRegion(
function(region, player)
if IsCharacterHuman(player) then
print("Do nothing because jedi is human")
elseif GetCharacterClass(player) == "YOURJEDICLASS" then
KillObject (player)
end
end,
"YOURREGIONNAME"
)
end


This code kills a Jedi as soon as it's spawned and not controlled by a player.
Everything untested.
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: fixing a simple mistake

Post by Marth8880 »

Hmm. Try putting the entire checkJediRegion() function before OnCharacterSpawn().
User avatar
Lorul1
Rebel Colonel
Rebel Colonel
Posts: 562
Joined: Wed Apr 24, 2013 10:34 pm
Projects :: Assault on Theed
Games I'm Playing :: Battlegrounds
xbox live or psn: No gamertag set
Location: Your House

Re: fixing a simple mistake

Post by Lorul1 »

tried it, still doesn't work
this is a cut out from my lua
Hidden/Spoiler:
conquest:Start()


timeoutTimer = CreateTimer("timeout")
SetTimerValue(timeoutTimer, 10)

OnTimerElapse(
function(timer)
MissionVictory(REP)
ShowTimer(nil)
DestroyTimer(timer)
end,
timeoutTimer
)

Mom = OnObjectKill(
function(object, killer)
if GetEntityName(object) == "myg1_bldg_energy_collector_core" then
PlayAnimation("final")
end
end
)

checkJediRegion()
OnEnterRegion(
function(region, player)
if IsCharacterHuman(player) then
print("Do nothing because jedi is human")
elseif GetCharacterClass(player) == "jed_knight_03" then
KillObject(player)
end
end,
"Kill01"
)

OnCharacterSpawn(
function(character)
if GetCharacterClass(character) == "jed_knight_03" then
checkJediRegion()
end
end
end
)

Dtime = OnObjectKill(
function(object, killer)
if GetEntityName(object) == "myg1_bldg_energy_collector_core" then
StartTimer(timeoutTimer)
ShowTimer(timeoutTimer)
end
end
)

Time = OnObjectKill(
function(object, killer)
if GetEntityName(object) == "myg1_bldg_energy_collector_core" then
PlayAnimation("fallfire")
end
end
)
and I get this message from my munge log
Hidden/Spoiler:
C:\*****\******\*****\BF2_ModTools\data_GZB\_BUILD\Common\..\..\..\ToolsFL\Bin\luac.exe: ..\..\common\scripts\GZB\GZBc_con.lua:93: `)' expected (to close `(' at line 87) near `end'
ERROR[scriptmunge scripts\GZB\GZBc_con.lua]:Could not read input file.ERROR[scriptmunge scripts\GZB\GZBc_con.lua]:Could not read input file. [continuing]
2 Errors 0 Warnings
something is missing or misspelled.
how should this scrip be properly done.
User avatar
Locutus
1st Lieutenant
1st Lieutenant
Posts: 420
Joined: Fri Jun 04, 2010 10:08 am
Projects :: Stargate Battlefront Pegasus
Location: Germany
Contact:

Re: Prevent class from spawning at CP

Post by Locutus »

It would be easier to find if you had used code-tags...
Make sure to use tabs to format your code so you can always see which end tag ends which function.

In your script you're using this three times in a row:

Code: Select all

OnObjectKill(
 function(object, killer)
 if GetEntityName(object) == "myg1_bldg_energy_collector_core" then
Is there a reason for that?
If you're not calling the functions somewhere you can write all commands in a single OnObjectKill function.
Hidden/Spoiler:
[code]conquest:Start()

timeoutTimer = CreateTimer("timeout")
SetTimerValue(timeoutTimer, 10)

OnTimerElapse(
function(timer)
MissionVictory(REP)
ShowTimer(nil)
DestroyTimer(timer)
end,
timeoutTimer
)

OnObjectKill(
function(object, killer)
if GetEntityName(object) == "myg1_bldg_energy_collector_core" then
PlayAnimation("final")
PlayAnimation("fallfire")
StartTimer(timeoutTimer)
ShowTimer(timeoutTimer)
end
end
)

OnCharacterSpawn(
function(character)
if GetCharacterClass(character) == "jed_knight_03" then
checkJediRegion()
end
end
)


--put this after ScriptPostLoad() but before ScriptInit()
checkJediRegion()
OnEnterRegion(
function(region, player)
if IsCharacterHuman(player) then
print("Do nothing because jedi is human")
elseif GetCharacterClass(player) == "jed_knight_03" then
KillObject(player)
end
end,
"Kill01"
)
end
[/code]
Post Reply