I'm fairly new to lua and have found myself getting confused quite a bit lately. This is something I'm not quite sure if I did right... Well, I KNOW I didn't do it right, but I'm not sure what's wrong with it. The Timer just never seems to end, therefor it doesn't kill the players in the location.
[php]
function RoundStart()
if timer.IsTimer("roundtimer1") then timer.IsTimer("roundtimer1")
else
for k,v in pairs( player.GetAll() ) do
if ( v:Alive() && v:Team() > 1 ) then
timer.Create("roundtimer1", 30, 1, RoundNotifyStart(v))
if timer.Destroy ("roundtimer1") then RoundNotifyEnd()
end
end
end
end
end
function RoundNotifyStart(ply)
ply:ChatPrint( "Round Started: You have six minutes to locate the cure" )
ZoneSetUp()
end
function ZoneSetUp()
local orgin_ents = ents.FindInSphere( Vector(444.428680, -1874.961670, -79.968750), 224 )
if timer.Destroy("roundtimer1") then ply:Kill() ents.FindInSphere( Vector(444.428680, -1874.961670, -79.968750), 224 )
end
end
function RoundNotifyEnd(ply)
ply:ChatPrint("The Survivors have fallen!")
end
[/php]
You might want to understand what these functions your trying to use actually do.
timer.IsTimer() has 1 argument and only returns a boolean value( true or false ). You cannot set timer.IsTimer().
timer.Create() creates a timer with 1 name to make it unique if you create another timer with the same name all your doing is overwritting the previous timer.
timer.Destroy() does not return a boolean value, it just calls a function that removes the timer.
[lua]
function RoundStart()
if not timer.IsTimer("roundtimer1") then
for k,v in pairs( player.GetAll() ) do
if ( v:Alive() && v:Team() > 1 ) then
RoundNotifyStart(v)
end
end
timer.Create("roundtimer1", 30, 1, RoundEnd)
end
end
function RoundNotifyStart(ply)
ply:ChatPrint( "Round Started: You have six minutes to locate the cure" )
end
function RoundEnd()
for k, v in pairs(ents.FindInSphere( Vector(444.428680, -1874.961670, -79.968750), 224 )) do
if v:IsPlayer() then
v:Kill()
RoundNotifyEnd(v)
end
end
end
function RoundNotifyEnd(ply)
ply:ChatPrint("The Survivors have fallen!")
end
[/lua]
This may be closer to what you're wanting.
Thanks guys, sorry. I should look at the wiki more closely next time, I was in kind of a rush. Also, what does the v: prefix mean exactly? Couldn't find it on a search on the wiki.
v is just a variable name, you can make it anything you want. in the case of those for loops, v is the data item that's in the table. so for player.GetAll() v is each player in that table. k is the index at which that item is stored.
Why do they use V and K. Is it Value and Key?
mhm
Yes I learned something form my book!
[QUOTE=toaster468;27875822]Yes I learned something form my book![/QUOTE]
It certainly wasn't spelling.
Sorry, you need to Log In to post a reply to this thread.