So, whilst working on permissions, I was able to set them when a player joins with the following code: PHP: foreach(RankData::PERMISSIONS[$this->getRank()] as $permissions){ $this->attachment = $this->addAttachment(Loader::getInstance(), $permissions, true); } however, when I update the players rank via mysql, their permissions don't reset and I'm not too sure how to do so. What solutions do y'all recommend?
Instead of adding an attachment, check if the permission is in the array. ¯\_(ツ)_/¯ That's an idea. PHP: // I'm guessing you are doing this in player class. public function hasPermission(string $permission): bool { $permissions = RankData::PERMISSIONS[$this->getRank()]; if(in_array($permission, $permissions)) { return true; } return parent::hasPermission($permission); } And also, kind of off topic, I didn't know you were still in this community, Drew.
How you want the permission to reset? Remove the permissions of previous rank? PHP: //addforeach(RankData::PERMISSIONS[$this->getRank()] as $permissions){ $this->attachments[] = $this->addAttachment(Loader::getInstance(), $permissions, true); }//removeforeach($this->attachments as $a)$this->removeAttachment($a);
I did try that, but the only way it works is if I use a have a delayed task to wait for the mysql task to update, which I'd rather not want to wait for.
I think it should be in reverse PHP: $this->attachments = [];foreach(RankData::PERMISSIONS[$this->getRank()] as $permission){ $this->attachments[] = $this->addAttachment(Loader::getInstance(), $permission, true);}