MyBB Community Forums

Full Version: Servers Board Customization
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi folks


Currently the server board plugin (https://community.mybb.com/mods.php?action=view&pid=117) works listing by registration, the first server that is registered shows at the top and the last registered at the bottom of the list.

I would like to sort by online players, ascending or descending, or both.

Could anyone help?
Try this. Find in /inc/plugins/serverboard/serverboard.php (~1049 line):
$results = $gq->requestData();

And replace:
- Ascending by max pleyers:
$results = $gq->requestData();

usort($results, function($a, $b) {
    return $a['gq_maxplayers'] <=> $b['gq_maxplayers'];
});

- Descending by max players:
$results = $gq->requestData();

usort($results, function($a, $b) {
    return $b['gq_maxplayers'] <=> $a['gq_maxplayers'];
});

And wait (cache time), because in the database you have 'incorrect' data.
(2020-01-06, 10:44 PM)Salvation Wrote: [ -> ]Try this. Find in /inc/plugins/serverboard/serverboard.php (~1049 line):
$results = $gq->requestData();

And replace:
- Ascending by max pleyers:
$results = $gq->requestData();

usort($results, function($a, $b) {
    return $a['gq_maxplayers'] <=> $b['gq_maxplayers'];
});

- Descending by max players:
$results = $gq->requestData();

usort($results, function($a, $b) {
    return $b['gq_maxplayers'] <=> $a['gq_maxplayers'];
});

And wait (cache time), because in the database you have 'incorrect' data.

Thanks for the reply!!

I've made the change as you told but it didn't work.

I already updated the browser cache

[Image: mybb1.png]

[Image: mybb2.png]


Still following the display order
Give the forum URL, please Smile
And try change gq_maxplayers to gq_numplayers
(2020-01-07, 05:55 PM)Salvation Wrote: [ -> ]Give the forum URL, please Smile
And try change gq_maxplayers to gq_numplayers

http://sampforum.ddns.net/serversboard.php

If you need login  

Use demo/password123

I tried change gq_maxplayers to gq_numplayers and nothing change
I do not need credentials.

Strange situation. Last try.
Change:

$results = $gq->requestData();
To:
$results = $gq->requestData();

die(var_dump($results));
Save and wait until you will see a white page with some text. Then copy the text and paste here, and remove the above changes.
(2020-01-07, 07:44 PM)Salvation Wrote: [ -> ]I do not need credentials.

Strange situation. Last try.
Change:

$results = $gq->requestData();
To:
$results = $gq->requestData();

die(var_dump($results));
Save and wait until you will see a white page with some text. Then copy the text and paste here, and remove the above changes.

Thanks for the help!


I got this:

array(1) { [1]=> array(31) { ["dedicated"]=> bool(true) ["gametype"]=> string(31) "FZ:RP v5.00 - Rol em português" ["gq_address"]=> string(19) "br.s1.fenixzone.com" ["gq_dedicated"]=> bool(true) ["gq_gametype"]=> string(31) "FZ:RP v5.00 - Rol em português" ["gq_hostname"]=> string(34) "FZ Roleplay [BR] Rol em português" ["gq_joinlink"]=> string(0) "" ["gq_mapname"]=> string(10) "SA - BR/PT" ["gq_maxplayers"]=> int(600) ["gq_mod"]=> bool(false) ["gq_numplayers"]=> int(434) ["gq_online"]=> bool(true) ["gq_password"]=> bool(false) ["gq_port"]=> string(4) "7777" ["gq_protocol"]=> string(4) "samp" ["gq_transport"]=> string(3) "udp" ["gq_type"]=> string(4) "samp" ["lagcomp"]=> string(3) "Off" ["map"]=> string(22) "Português Brasil - PT" ["mapname"]=> string(10) "SA - BR/PT" ["max_players"]=> int(600) ["num_players"]=> int(434) ["num_rules"]=> int(6) ["password"]=> bool(false) ["players"]=> array(0) { } ["servername"]=> string(34) "FZ Roleplay [BR] Rol em português" ["teams"]=> array(0) { } ["version"]=> string(5) "0.3.7" ["weather"]=> string(2) "10" ["weburl"]=> string(16) "br.fenixzone.com" ["worldtime"]=> string(5) "15:00" } }

By default the listing follows the display order number, right?

Just this modification can change the listing?
Oh. $results contains only one server, but in an extra array... This is the reason why the sort function does not work.

By default order is by disporder field from serversboard entity...

$query = $db->simple_select("serversboard", "*", "visible=1", array('order_by' => 'disporder'));

So, I need to install this plugin on the local to help you, but I do not have data for servers...
(2020-01-07, 10:20 PM)Salvation Wrote: [ -> ]Oh. $results contains only one server, but in an extra array... This is the reason why the sort function does not work.

By default order is by disporder field from serversboard entity...

$query = $db->simple_select("serversboard", "*", "visible=1", array('order_by' => 'disporder'));

So, I need to install this plugin on the local to help you, but I do not have data for servers...

You can find in http://monitor.sacnr.com/


185.240.101.43:7797


198.50.244.204:7777


149.56.106.164:7777

I
 think you only need the ip and port
The code in the plugin is sh** messy Sad
but I've made some changes. Replace the file from an attachment in:
\inc\plugins\

By default, servers are sort ascending by the number of online players. If you want to change sorting, find usort and change the function body.

Cheers Wink
Pages: 1 2