1. Hi

    I have couple questions for Plugins devlopper / lua pro!

    1:
    What is the difference between
    Code:
    function PLUGIN:myfunc()
            something
    end
    and

    Code:
    function myfunc()
            something
    end
    My understanding is, with "PLUGIN:" make the function "public" and w/o "PLUGIN:" make it "private" to my plugin. And I know the call won't be the same (self:myfunc() vs myfunc())
    What are the pros/cons of each method?

    2:
    For this question I'll use BasePlayer as exemple

    Is it better to store a BasePlayer in a var or store a userID, then search activePlayerList every time I need to use a BasePlayer?

    3:
    This one isn't really a question

    Am I right when I say

    use something:somefunc() when the function use "this."
    and use something.somefunc() when the function don't use "this."
    and as @Reneb already told me, use methodarray when multiple func has the same name

    Thank you!
     
  2. Wulf

    Wulf Community Admin

    Not using the PLUGIN scope would cause possible conflicts if another plugin uses the same function name. It's better to use PLUGIN, as it isolates it to your function which you'd then call with self.
     
  3. using
    location function blabla()
    is good also, i like doing that :)
     
  4. And what about my question #2??
     
  5. I have no idea, i would say store BasePlayer in the var, it's faster and you dont have to loop all the players to get the userid