Separate names with a comma.
Comments in 'Plugin Development' started by iiDeathStrokeii, Jun 4, 2015.
$stats is a local variable.
$this->stats is a class property.
This is PHP, not Java.
I dont understand.
Does that mean I should use $stats->get?
Because I need to use $this or else they will get the same one?
I am confusing myself now...
Well thanks for the help.
Ok it still says its undefined...
I even tried getting the config with $this->stats->get and it still says undefined.
No. To make it save over functions, use $this->stats.
And it would be a good practice to define `private $stats;` at the beginning of your class too, although it is not needed.
Oh! So got get something I just have to to $this->stats("deaths"); ? But how do it set or save it then?
I can't define it, stats is defined in on enable, I just need to be able to get, set, and save to it.
No. Just simply use $this->stats instead of $stats.
When defining or using it?
I'd you define it as $stats, use it as $stats.
If you define it as $this->stats, use it as $this->stats.
But $stats is a function-local variable. It won't save over functions. So use $this->stats instead.
Alright thank you for a clean and easy to understand reply.
It no longer crashes, but it does not work which is worse than crashing because now I don't know the problem.