I have this code PHP: <?phpnamespace Core\command;use Core\Main;use pocketmine\Player;use pocketmine\Server;use pocketmine\command\CommandSender;class UNPunishCommand extends BaseCommand implements Listener{ public function __construct(Main $plugin){ $this->plugin = $plugin; parent::__construct($plugin, "unpunish", "Unpunish A Player", "/unpunish [Player]", ["unp"]); } public function execute(CommandSender $sender, $commandLabel, array $args) : bool{ if(!$sender->hasPermission("core.punish") || !$sender->hasPermission("core")){ $sender->sendMessage(Main::PERM_RANK); return true; } if(empty($args[0])){ $sender->sendMessage("§c§l!§r§e Usage: /unpunish <Player>. Pleason enter full name!"); return true; } $target = $this->plugin->getServer()->getPlayer($args[0]); $banInfo = $this->plugin->db->query("SELECT * FROM banPlayers"); if($target === $banInfo){ $banInfo = $this->db->query("SELECT * FROM banPlayers WHERE player = '$target';"); $array = $banInfo->fetchArray(SQLITE3_ASSOC); if(!empty($array)) { $this->db->query("DELETE FROM banPlayers WHERE player = '$target';"); $sender->sendMessage("§aYou unbanned $target"); } } return false; }} WHen i typed the command with a player name (in the .db file), it didnt do anything
It still the same Updated code: PHP: ?phpnamespace Core\command;use Core\Main;use pocketmine\Player;use pocketmine\Server;use pocketmine\command\CommandSender;use muqsit\invmenu\InvMenuHandler;use muqsit\invmenu\InvMenu;use pocketmine\event\Listener;use pocketmine\item\Item;use pocketmine\inventory\transaction\action\SlotChangeAction;use pocketmine\block\Block;class UNPunishCommand extends BaseCommand implements Listener{ public function __construct(Main $plugin){ $this->plugin = $plugin; parent::__construct($plugin, "unpunish", "Unpunish A Player", "/unpunish [Player]", ["unp"]); } public function execute(CommandSender $sender, $commandLabel, array $args) : bool{ if(!$sender->hasPermission("core.punish") || !$sender->hasPermission("core")){ $sender->sendMessage(Main::PERM_RANK); return true; } if(empty($args[0])){ $sender->sendMessage("§c§l!§r§e Usage: /unpunish <Player>. Pleason enter full name!"); return true; } $banInfo = $this->plugin->db->query("SELECT * FROM banPlayers"); $target = $args[0]; if($target === $banInfo){ $banInfo = $this->plugin->db->query("SELECT * FROM banPlayers WHERE player = '$target';"); $array = $banInfo->fetchArray(SQLITE3_ASSOC); if(!empty($array)) { $this->plugin->db->query("DELETE FROM banPlayers WHERE player = '$target';"); $sender->sendMessage("§aYou unbanned $target"); }else{ $sender->sendMessage("§c$target isnt banned from server!"); } } return true; }}
You are comparing an object (player) with a bool (query), it's not gonna do anything because the if won't be executed.
Just delete the if, there's no need to check if the player is in the table if you do this PHP: WHERE player = '$target'