Page 1 of 1

Prevent class from spawning at CP

Posted: Thu Dec 05, 2013 7:59 pm
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.

Re: fixing a simple mistake

Posted: Thu Dec 05, 2013 8:59 pm
by Marth8880
Hmm. Try putting the entire checkJediRegion() function before OnCharacterSpawn().

Re: fixing a simple mistake

Posted: Thu Dec 05, 2013 10:33 pm
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.

Re: Prevent class from spawning at CP

Posted: Tue Dec 10, 2013 4:09 pm
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]