Page 1 of 1

Spawn delay and timer [Solved]

Posted: Mon Oct 17, 2011 11:19 am
by Noobasaurus
I'm bad at lua stuff, and I want a one and a half minute time to go on right when you start and then when it ends team 3 and team 2 spawn. Does anyone know how to do this?

Re: Spawn delay and timer

Posted: Mon Oct 17, 2011 3:56 pm
by AQT
Yeah. In the stock campaign luas, there is this function that checks if once the player spawns, then the objects will start. You will need that function. For more information, see the following:
And what do you know, that function already has a timer! You may edit that timer to fit your need. For more information, see the following:
Combine the timer with the information here, and you should be good to go. You essentially assign team 2's and 3's command posts to not use spawn paths. Then, when your timer hits zero, you assign the command posts their original spawn paths. Hope this help. I hope you weren't expecting someone to do the entire thing for you, by the way...

Re: Spawn delay and timer

Posted: Mon Oct 17, 2011 6:46 pm
by Noobasaurus
I tried my luck and (of course) it didn't work. Here it is:
Hidden/Spoiler:
[code]
onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
timer = CreateTimer("timer")
SetTimerValue(timer, (90))
StartTimer(timer)
SetProperty("Local_CP", "", "")
SetProperty("cp2", "", "")
OnTimerElapse(
function(timer)
SetProperty("Local_CP", "Local_Spawn", "")
SetProperty("cp2", "cp2_spawn", "")
end,
timer
)
end
end
)
[/code]
Absolutely nothing happened. I assume I put something wrong in the wrong place...

Or maybe I put the whole thing in wrong place! Probably not.

EDIT: I tried my luck again using a stock script and this is what I got and it doesn't work:
Hidden/Spoiler:
[code]
onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
objectives_timer = CreateTimer("objectives_timer")
SetTimerValue(objectives_timer, 2)
StartTimer(objectives_timer)
SetProperty("Local_CP", "", "")
SetProperty("cp2", "", "")
begin_objectives = OnTimerElapse(
function(timer)
StartObjectives ()
SetProperty("Local_CP", "Local_Spawn", "")
SetProperty("cp2", "cp2_spawn", "")

end,
objectives_timer
)
end
end
)[/code]
I also tried putting it after

Code: Select all

function ScriptPostLoad()
All I've seen this do is force you to the team which I want you to do, but no timer and no delayed spawn.

EDIT2: I tried again and got this:
Hidden/Spoiler:
[code]ObjStart_timer = CreateTimer("ObjStart_timer")
SetTimerValue(ObjStart_timer, 90)
StartTimer(ObjStart_timer)
SetProperty("cp2", "team", 0)
SetProperty("Local_Cp", "team", 0)
CountDown = OnTimerElapse(
function()
SetProperty("cp2", "team", 2)
SetProperty("Local_Cp", "team", 3)
ReleaseTimerElapse(CountDown)

end,
ObjStart_timer
)
end

end[/code]
and this was the error:
Hidden/Spoiler:
[code]M:\BF2_Modtools\data_GAA\_BUILD\Common\..\..\..\ToolsFL\Bin\luac.exe: ..\..\common\scripts\GAA\GAAg_con.lua:40: <eof> expected near `end'
ERROR[scriptmunge scripts\GAA\GAAg_con.lua]:Could not read input file.ERROR[scriptmunge scripts\GAA\GAAg_con.lua]:Could not read input file. [continuing]
2 Errors 0 Warnings

[/code]
EDIT: Got it.