Countdown - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Plugins (https://forum.cuberite.org/forum-1.html) +--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html) +--- Thread: Countdown (/thread-1314.html) |
RE: Countdown - daniel0916 - 01-15-2014 RE: Countdown - NiLSPACE - 01-15-2014 When you use table.insert you basicly create an array. local Table = {} Table.insert(Table, "Test") print(Table[1]) -- Result is "Test" Table.insert(Table, "Test2") print(Table[2]) -- Result is "Test2"When you use your way: local Table = {} Table["Test"] = "Test" print(Table["Test"]) -- Result is "Test"You add a key. This is propably better then using table.insert because you already know the name of the key. If you want to check if he's in the table you can use: if (rank[Player:GetName()] == nil) then -- He's not in the table end RE: Countdown - daniel0916 - 01-16-2014 Some new questions: 1. How can i get the number of online players? So i can check if 5 players are online. 2. How can i copy a folder with lua? 3. How can i delete a folder with lua? RE: Countdown - NiLSPACE - 01-16-2014 1: local Amount = cRoot:Get():GetServer():GetNumPlayers() 2 and 3: the cFile class might be able to do something. RE: Countdown - daniel0916 - 01-16-2014 (01-16-2014, 12:11 AM)STR_Warrior Wrote: 2 and 3: the cFile class might be able to do something. Thanks, but cFile can only copy files or not? Quote: Copies a single file to a new destination I will copy on startup from the server the backup from the minigame map to the mcserver folder. And on server stop i will delete the world folder. RE: Countdown - xoft - 01-16-2014 (01-16-2014, 12:22 AM)daniel0916 Wrote: I will copy on startup from the server the backup from the minigame map to the mcserver folder. You might want to consider the Forgetful storage schema, settable in world.ini. It will cause the server to load chunks from the MCA files, but not save them anywhere, so as soon as the chunks are unloaded (all players log out or move too far away) the chunks seemingly regenerate back to their previous state. http://wiki.mc-server.org/doku.php?id=configure:world.ini#storage_section RE: Countdown - daniel0916 - 01-16-2014 (01-16-2014, 12:49 AM)xoft Wrote: You might want to consider the Forgetful storage schema, settable in world.ini. It will cause the server to load chunks from the MCA files, but not save them anywhere, so as soon as the chunks are unloaded (all players log out or move too far away) the chunks seemingly regenerate back to their previous state. Thanks i will try it . The Schedule with onTick or onWorldTick don't work. function AddSchedule(Function, Parameters, Ticks) table.insert(ScheduleTable, {Function, Parameters, Ticks}) end function OnScheduleTick(Time) for I=1, #ScheduleTable do if ScheduleTable[I][4] < 0 then ScheduleTable[I][2](ScheduleTable[I][3]) table.remove(ScheduleTable, I) else ScheduleTable[I][4] = ScheduleTable[I][4] - 1 end end end cPluginManager.AddHook(cPluginManager.HOOK_TICK, OnScheduleTick); AddSchedule(MyFunction, {}, 200); function MyFunction(Params) cRoot:Get():BroadcastChat("Schedule!"); end Code: [16:12:40] Stack trace: In the line is: if ScheduleTable[I][4] < 0 then RE: Countdown - NiLSPACE - 01-16-2014 Without the error you get I can't do allot Assuming you didn't forget to put it in the post: did you create the ScheduleTable table? worktycho implented a cWorld:ScheduleTask function. You could try to use that instead. I have no idea how to use it yet though ;( EDIT: Ah you now posted the error now I think you should change if ScheduleTable[I][4] to ScheduleTable[I][3]. Because when you create a table using braces well.. Let me try to show it: local Table = {12, 43, 13} Index: 1 2 3 RE: Countdown - daniel0916 - 01-16-2014 RE: Countdown - NiLSPACE - 01-16-2014 No I think this should work: function OnScheduleTick(Time) for I=1, #ScheduleTable do if ScheduleTable[I][3] < 0 then ScheduleTable[I][1](ScheduleTable[I][2]) table.remove(ScheduleTable, I) else ScheduleTable[I][3] = ScheduleTable[I][3] - 1 end end end |