This repository has been archived on 2024-07-18. You can view files and clone it, but cannot push or open issues or pull requests.
lwb5/scripts/game/beta5/rules/library/get.inc

33 lines
681 B
PHP
Raw Normal View History

2016-01-10 11:01:49 +01:00
<?php
class beta5_rules_get {
function beta5_rules_get($lib) {
$this->lib = $lib;
$this->db = $this->lib->game->db;
}
// Loads rules for a player
function run($pid) {
$apid = is_null($pid) ? ' ' : $pid;
if (is_array($this->lib->mainClass->rules[$apid])) {
return $this->lib->mainClass->rules[$apid];
}
$q = $this->db->query("SELECT name,value FROM rule"
. (is_null($pid) ? "_def" : " WHERE player=$pid"));
if (!($q && dbCount($q))) {
return null;
}
$this->lib->mainClass->rules[$apid] = array();
while ($r = dbFetchArray($q)) {
$this->lib->mainClass->rules[$apid][$r[0]] = $r[1];
}
return $this->lib->mainClass->rules[$apid];
}
}
?>