lwb5-in-2025/scripts/game/beta5/player/library/reorderAllies.inc

25 lines
487 B
PHP
Raw Normal View History

2016-01-10 11:01:49 +01:00
<?php
class beta5_player_reorderAllies {
2024-12-31 10:42:58 +01:00
function __construct($lib) {
2016-01-10 11:01:49 +01:00
$this->lib = $lib;
$this->db = $this->lib->game->db;
}
// Reorders the list of allies after it's been modified
function run($pid) {
$q = $this->db->query("SELECT level FROM trusted WHERE player=$pid ORDER BY level ASC");
$i = 0;
while ($r = dbFetchArray($q)) {
if ($r[0] != $i) {
$this->db->query("UPDATE trusted SET level=$i WHERE player=$pid AND level=".$r[0]);
}
$i ++;
}
}
}
?>