Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- __PocketMine Plugin__
- name=ListLoader
- description=Allows use of an external whitelist
- version=0.1
- author=Falkirks
- class=ListLoader
- apiversion=10
- */
- $domain = "SQL Domain";
- $conuser = "Username to connect as";
- $password = "Password to connect with";
- $db = "Database to connect to";
- $tablename = "Table to load (eg: mybb_user)";
- $usercol = "The colum with usernames probably is username";
- class ListLoader implements Plugin{
- public function __construct(ServerAPI $api, $server = false){
- $this->api = $api;
- }
- public function init(){
- $this->api->schedule(10*1200, array($this, "purgePlayers()"), array(), true);
- console("[INFO] ListLoader Enabled!");
- }
- public function purgePlayers() {
- console("[ListLoader] Purging Data...");
- $con=mysqli_connect($domain,$conuser",$password,$db);
- if (mysqli_connect_errno()){
- console("[ListLoader] Failed to connect to database, make sure you have defined variables in the plugin.");
- console("[ListLoader] Make sure you have defined all variables in the plugin.");
- }
- $result = mysqli_query($con,"SELECT" . $usercol . "FROM" . $tablename);
- foreach ($result as $user) {
- foreach ($user as $username) {
- $save .= $username;
- $save .= "\r\n";
- }
- }
- file_put_contents('white-list.txt',$save);
- mysqli_close($con);
- $this->api->console->run(whitelist reload);
- console("[ListLoader] Whitelist purged");
- $this->api->chat->broadcast("[ListLoader] White-list purged! ");
- }
- public function __destruct(){
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement