01-13-2014, 12:34 AM
How can i make a countdown or something else like Bukkit Scheduler?
Give it a method for that? I need it for a minigame.
Give it a method for that? I need it for a minigame.
Countdown
|
01-13-2014, 12:34 AM
How can i make a countdown or something else like Bukkit Scheduler?
Give it a method for that? I need it for a minigame.
What do you want to schedule? If you want to set a block after some ticks you can use QueueSetBlock. If you want to schedule a function... You can't sorry. We do have an issue on github for it: https://github.com/mc-server/MCServer/issues/150
I did once create a plugin that counted down using OnTick and then execute it. You could maybe use the code from that: Table = {} function Initialize(Plugin) PLUGIN = Plugin Plugin:SetName("Scheduler") Plugin:SetVersion(1) cPluginManager.AddHook(cPluginManager.HOOK_TICK, OnTick) return true end function Add(Function, Parameters, Ticks) table.insert(Table, {Function, Parameters, Ticks}) end function OnTick(Time) for I=1, #Table do if Table[I][4] < 0 then Table[I][2](Table[I][3]) table.remove(Table, I) else Table[I][4] = Table[I][4] - 1 end end end
01-13-2014, 01:00 AM
(01-13-2014, 12:37 AM)STR_Warrior Wrote: What do you want to schedule? If you want to set a block after some ticks you can use QueueSetBlock. If you want to schedule a function... You can't sorry. We do have an issue on github for it: https://github.com/mc-server/MCServer/issues/150 Thanks. What do you mean with Parameters? Ticks is 20 * seconds as always?
Parameters is a table with all you parameters. For example I want to queue an function that needs block coordinates:
-- The function that you want to queue. -- It simple prints all coordinates. function MyFunction(Params) -- Do something awesome with the coordinates. end -- Add the function in the queue BlockX = -50 BlockY = 128 BlockZ = 324 Add(MyFunction, {BlockX, BlockY, BlockZ}, 500) -- The function now gets called in 500 ticks. BUT Because it uses tables to store all the parameters you have to put this code directly in your plugin. You can't use Inter-plugin communication to make the scheduler an 2th plugin. Yes I think 20 * ticks is seconds. Thanks given by: daniel0916
01-13-2014, 02:12 AM
Actually you should schedule tasks for a specific world, and use the OnWorldTick() function to tick only those scheduled tasks that match the currently ticked world.
Thanks given by: daniel0916
01-13-2014, 02:18 AM
I created that plugin before the OnWorldTick hook existed
01-13-2014, 02:18 AM
Thanks currently i'm working on the hooks..
But i think MCServer hasn't an id for fire or cake. Is this right? How can i block placing of fire or cakes? And how can i block smelting from ice blocks? (01-13-2014, 02:18 AM)daniel0916 Wrote: But i think MCServer hasn't an id for fire or cake. Is this right? How can i block placing of fire or cakes?Use the OnRightClick hook. You can use E_BLOCK_FIRE for fire and E_BLOCK_CAKE for cake. daniel0916 Wrote:And how can i block smelting from ice blocks?You can't but don't worry ice and snow smelting isn't implemented yet. Thanks given by: daniel0916
01-13-2014, 02:35 AM
(This post was last modified: 01-13-2014, 02:41 AM by daniel0916.)
Give it more blocks who haven't a id? I need to block all blocks from griefing..
And give it a hook who will be called when a player lose food? And how can i block that a block will be broken when it burns and fire spreading? Sorry for the many questions but now i'm working for a minigame on MCServer.
You know, you don't need to quote everything when it's right above your post, the forum then becomes a chaos of quotes inside quotes inside quotes. Consider this a conversation, and only quote if you want to react to something very specific and older in the conversation.
|
« Next Oldest | Next Newest »
|