01-16-2014, 02:01 AM
01-16-2014, 02:06 AM
Not sure if this is the best method (or if it works) but:
function CountDown(Param) cRoot:Get():BroadcastChat(Param[1]) end) for I=1, 10 do -- Countdown. AddSchedule(CountDown, {I}, I * 20)) -- 20 ticks is one second right? then 1 * 20 is 20 ticks is one second etc. end
01-16-2014, 02:26 AM
it works but it is not
9 8 7
it is:
1 2 3
And it comes this error:
The line is:
9 8 7
it is:
1 2 3
And it comes this error:
Code:
[17:25:11] Stack trace:
[17:25:11] [C](-1): (no name)
[17:25:11] Plugins/SurvivalGames/main.lua(75): (no name)
[17:25:11] Stack trace end
[17:25:11] Error in plugin SurvivalGames calling function <callback>()
[17:25:12] LUA: Plugins/SurvivalGames/main.lua:75: attempt to index field '?' (a nil value)
The line is:
if ScheduleTable[I][3] < 0 then
01-16-2014, 02:30 AM
(01-16-2014, 02:26 AM)daniel0916 Wrote: [ -> ]it works but it is notThen change
9 8 7
it is:
1 2 3
for I=1, 10 do -- Countdown. AddSchedule(CountDown, {I}, I * 20)) -- 20 ticks is one second right? then 1 * 20 is 20 ticks is one second etc. endto
local COUNT_TO = 10 for I=COUNT_TO, 1, -1 do -- Countdown AddSchedule(CountDown, {I}, (COUNT_TO - I) * 20)) end
Quote:And it comes this error:
Code:[17:25:11] Stack trace:
[17:25:11] [C](-1): (no name)
[17:25:11] Plugins/SurvivalGames/main.lua(75): (no name)
[17:25:11] Stack trace end
[17:25:11] Error in plugin SurvivalGames calling function <callback>()
[17:25:12] LUA: Plugins/SurvivalGames/main.lua:75: attempt to index field '?' (a nil value)
The line is:
if ScheduleTable[I][3] < 0 then
When do you get the error? When it has finished counting down?
01-16-2014, 02:35 AM
(01-16-2014, 02:30 AM)STR_Warrior Wrote: [ -> ]When do you get the error? When it has finished counting down?
Every second and after 10 seconds the error stops.
01-16-2014, 02:38 AM
And you do still get the countdown message(9, 8, 7 etc)? Do you have anything else in the function that gets called?
01-16-2014, 02:43 AM
(01-16-2014, 02:38 AM)STR_Warrior Wrote: [ -> ]And you do still get the countdown message(9, 8, 7 etc)? Do you have anything else in the function that gets called?
Yes, the message come. No, i haven't anything else in this function.
01-16-2014, 02:45 AM
Could you post all your code somewhere? or send it to me using an PM. Ofcourse if you don't want to just don't do it, but I don't think I can see what's going on without seeing the code around everything.
EDIT:
Wait!! I've might found the problem. I'll have to rewrite the ScheduleTicking though. Just a sec.
EDIT:
Wait!! I've might found the problem. I'll have to rewrite the ScheduleTicking though. Just a sec.
01-16-2014, 02:51 AM
(01-16-2014, 02:45 AM)STR_Warrior Wrote: [ -> ]Could you post all your code somewhere? or send it to me using an PM. Ofcourse if you don't want to just don't do it, but I don't think I can see what's going on without seeing the code around everything.
EDIT:
Wait!! I've might found the problem. I'll have to rewrite the ScheduleTicking though. Just a sec.
(Do you know a git page where i can upload my code private? It should be safe.)
Okey, thanks.
01-16-2014, 02:58 AM
Use this code for the OnScheduleTick function:
If you want to post it on github privately you have to pay for it.
function OnScheduleTick(Time) for Idx, ScheduleTask in pairs(ScheduleTable) do ScheduleTable[Idx][3] = ScheduleTable[Idx][3] - 1 -- Countdown if ScheduleTask[3] < 1 then ScheduleTask[1](ScheduleTask[2]) ScheduleTable[Idx] = nil end end end
If you want to post it on github privately you have to pay for it.