Cuberite Forum

Full Version: How to loop all players? - my code is not working
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
function OnTick(TickTime)
    local ForEachPlayerTick = function(Player)
        Player:SendMessage("Player never recieves this message")
    end
end
Of course I have added hook
Code:
cPluginManager:AddHook(cPluginManager.HOOK_TICK, OnTick);
but it is not working.
Console is not giving any error.
Thank you very much! Big Grin
The reason it's not working is because all you're doing is declaring a variable named 'ForEachPlayerTick' and putting a function in it. To execute it you have to call 'cRoot:Get():ForEachPlayer(ForEachPlayerTick)'