Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ($args[0] == "warp"){
- if ($args[1] == "list") {
- // define the sqlite path and the database object
- define("pdoline", "sqlite:/path/to/minecraft/plugins/xWarp/warps.db");
- $dbpdo = new PDO(pdoline);
- //
- $CountQuery = "SELECT COUNT(*) FROM warpTable WHERE owner LIKE '$player'";
- $CountStatement = $dbpdo->query($CountQuery);
- $Count = $CountStatement->fetchColumn();
- $pages = ceil($Count / '10');
- if (!isset($args[2])) {
- $page = '1';
- print("/Chatcolor-white:------------------- /Chatcolor-green: Page $page/$pages /Chatcolor-white:-----------------;");
- $offset = ($page - 1) * '10';
- }
- else {
- if (!is_numeric($args[2]) || $args[2] > $pages || $args[2] <= 0) {
- $page = '1';
- }
- else {
- $page = $args[2];
- }
- print("/Chatcolor-white:------------------- /Chatcolor-green: Page $page/$pages /Chatcolor-white:-----------------;");
- $offset = ($page - 1) * '10';
- }
- // Create the query and perform it.
- $WarpQuery = "SELECT name, x, y, z, world FROM warpTable WHERE owner LIKE '$player' LIMIT '$offset', '10'";
- $WarpStatement = $dbpdo->query($WarpQuery);
- // Fetch an array of all the results
- $WarpArray = $WarpStatement->fetchAll(PDO::FETCH_ASSOC);
- foreach($WarpArray as $warp) {
- $x = substr($warp['x'], 0, strpos($warp['x'], "."));
- $y = substr($warp['y'], 0, strpos($warp['y'], "."));
- $z = substr($warp['z'], 0, strpos($warp['z'], "."));
- print("/Chatcolor-yellow:'’".$warp['name']."'’ /Chatcolor-white: by $player @(".$warp['world'].", ".$x.", ".$y.", ".$z.");");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement