Countdown
#71
(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.
Reply
Thanks given by:
#72
(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)
Reply
Thanks given by:
#73
Is the method with world better? And why?
Reply
Thanks given by:
#74
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)
Reply
Thanks given by:
#75
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.
Reply
Thanks given by:
#76
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.
Reply
Thanks given by:
#77
I'm afraid I have no idea why it's doing that ;(
Reply
Thanks given by:
#78
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.
Reply
Thanks given by:
#79
Maybe we can make the APIDump plugin put functions that work that way in a special category?

Propably manualy.
Reply
Thanks given by:
#80
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.
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)