Cuberite Forum
How to loop all players? - my code is not working - 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: How to loop all players? - my code is not working (/thread-3351.html)



How to loop all players? - my code is not working - _XxFedexX_ - 04-13-2021

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


RE: How to loop all players? - my code is not working - NiLSPACE - 04-13-2021

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)'