Advertisement
Guest User

Untitled

a guest
Aug 26th, 2011
123
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if ($args[0] == "warp"){
  2. if ($args[1] == "list") {
  3.  
  4. // define the sqlite path and the database object
  5. define("pdoline", "sqlite:/path/to/minecraft/plugins/xWarp/warps.db");
  6. $dbpdo = new PDO(pdoline);
  7.  
  8. //
  9. $CountQuery = "SELECT COUNT(*) FROM warpTable WHERE owner LIKE '$player'";
  10. $CountStatement = $dbpdo->query($CountQuery);
  11. $Count = $CountStatement->fetchColumn();
  12. $pages = ceil($Count / '10');
  13. if (!isset($args[2])) {
  14. $page = '1';
  15. print("/Chatcolor-white:------------------- /Chatcolor-green: Page $page/$pages /Chatcolor-white:-----------------;");
  16. $offset = ($page - 1) * '10';
  17. }
  18. else {
  19. if (!is_numeric($args[2]) || $args[2] > $pages || $args[2] <= 0) {
  20. $page = '1';
  21. }
  22. else {
  23. $page = $args[2];
  24. }
  25. print("/Chatcolor-white:------------------- /Chatcolor-green: Page $page/$pages /Chatcolor-white:-----------------;");
  26. $offset = ($page - 1) * '10';
  27. }
  28.  
  29. // Create the query and perform it.
  30. $WarpQuery = "SELECT name, x, y, z, world FROM warpTable WHERE owner LIKE '$player' LIMIT '$offset', '10'";
  31. $WarpStatement = $dbpdo->query($WarpQuery);
  32.  
  33. // Fetch an array of all the results
  34. $WarpArray = $WarpStatement->fetchAll(PDO::FETCH_ASSOC);
  35.  
  36. foreach($WarpArray as $warp) {
  37. $x = substr($warp['x'], 0, strpos($warp['x'], "."));
  38. $y = substr($warp['y'], 0, strpos($warp['y'], "."));
  39. $z = substr($warp['z'], 0, strpos($warp['z'], "."));
  40. print("/Chatcolor-yellow:'’".$warp['name']."'’ /Chatcolor-white: by $player @(".$warp['world'].", ".$x.", ".$y.", ".$z.");");
  41.  
  42. }
  43. }
  44. }
Advertisement
RAW Paste Data Copied
Advertisement