i have a problem with addSound: when i use the code: PHP: $level->addSound(new $Sound($p->getLocation())); it works! but, when i use the code with variables (on this case, $sound): PHP: $Sound=$cfg->get("Sound"); $level->addSound(new $Sound($p->getLocation())); the code does not work this is the log: i added ALL the sound classes. (((is not problem of my config folder)))
I know you said you imported everything, but are you sure there are use pocketmine\level\sound\PopSound; ? Try $this->plugin->getServer()->getDefaultLevel()->addSound(new PopSound($pos)); To see if it's from popsound not correctly imported or if it's something else Edit : Sound is not a variable :3
What!? You are trying to create a variable instance! PHP: $level->addSound(new $Sound($p->getLocation())); You should create a class instance
You should learn more about OOP in PHP. Sound can't be a varible. "new Sound" creates an instance of the sound class in PocketMine.
If you are using a variable to store the class of the object you are creating you must use the full class path. So using "use" to import and only the base name is not enough.
PHP: $Sound = "pocketmine\\level\\sound\\" . $config->get("things");$level->addSound(new $Sound (position));
In deed, you can use a variable as a class identifier, But you must be sure that the class instance is correctly assigned to the variable, so you will be able to clone it
Of course that won't work! You can't create an instance with just a variable(like the one you did)! Please take a look here: http://php.net/manual/en/language.oop5.php and learn something from it.