01-16-2014, 03:03 AM
Countdown
|
01-16-2014, 03:06 AM
(01-16-2014, 03:03 AM)daniel0916 Wrote: How can i make something for all player? 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)
01-16-2014, 03:13 AM
Is the method with world better? And why?
01-16-2014, 03:19 AM
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) Thanks given by: daniel0916
01-16-2014, 03:53 AM
(This post was last modified: 01-16-2014, 04:53 AM by daniel0916.)
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'.
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); -- CorrectIt's the same as cPluginManager:AddHook() and all the cFile functions. I see the documentation doesn't say that, I'll fix it. Thanks given by: daniel0916 , NiLSPACE
01-16-2014, 04:19 AM
I'm afraid I have no idea why it's doing that ;(
01-16-2014, 04:27 AM
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.
Maybe we can make the APIDump plugin put functions that work that way in a special category?
Propably manualy.
01-16-2014, 04:32 AM
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.
|
« Next Oldest | Next Newest »
|
Users browsing this thread: 53 Guest(s)