Cuberite Forum
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)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13


RE: Countdown - daniel0916 - 01-16-2014

(01-16-2014, 02:58 AM)STR_Warrior Wrote: If you want to post it on github privately you have to pay for it.

Yes, i know.

It's now working. Thanks Smile.

How can i make something for all player?
So i can heal all or something else.


RE: Countdown - NiLSPACE - 01-16-2014

(01-16-2014, 03:03 AM)daniel0916 Wrote: How can i make something for all player?
So i can heal all or something else.

cRoot:Get():ForEachPlayer(function(Player)
   Player:Heal(20)
end)
But since you propably know in what world the players are that need to get healed I would use:
local World = Player:GetWorld()
World:ForEachPlayer(function(a_Player)
   a_Player:Heal(20)
end)



RE: Countdown - daniel0916 - 01-16-2014

Is the method with world better? And why?


RE: Countdown - NiLSPACE - 01-16-2014

the cRoot function goes through all the players online and heals them. Since you are creating an SurvivalGames plugin you could heal players who are fighting in another world. You could ofcource check in the callback if the player is in the right world but that would use more CPU power, so you would have less performance.

Also what if you have 100 players online (just an example). If you were to use the cRoot function the server would go through all 100 players and heal them. If you would use the cWorld function you would only heal the players who are in the world you want to heal (like 15 or something)


RE: Countdown - daniel0916 - 01-16-2014

Hmm the method "Player:XpForLevel(60)" don't work for me.

Error:
Code:
[18:51:07] LUA: 2 - Plugins/SurvivalGames/onplayerspawn.lua:54: error in function 'XpForLevel'.
     argument #1 is 'cPlayer'; 'cPlayer' expected.



RE: Countdown - xoft - 01-16-2014

The function is static, meaning that you should call it directly on the class, rather than on the instance:
function OnSomeHook(a_Player)
  a_Player:XpForLevel(60);  -- WRONG
  cPlayer:XpForLevel(60);  -- Correct
It's the same as cPluginManager:AddHook() and all the cFile functions.

I see the documentation doesn't say that, I'll fix it.


RE: Countdown - NiLSPACE - 01-16-2014

I'm afraid I have no idea why it's doing that ;(


RE: Countdown - xoft - 01-16-2014

Yeah, I know, the error message doesn't say that much, but I can't do much about it, really, since it's auto-generated code from a 3rd party tool.


RE: Countdown - NiLSPACE - 01-16-2014

Maybe we can make the APIDump plugin put functions that work that way in a special category?

Propably manualy.


RE: Countdown - xoft - 01-16-2014

APIDump doesn't know whether the function is static or not, otherwise it would already mark them as such. Unfortunately we need to mark them by hand, and sometimes we miss some, such as with this case.