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/alliance/library/acceptRequest.inc

51 lines
1 KiB
PHP

<?php
class beta5_alliance_acceptRequest {
function beta5_alliance_acceptRequest($lib) {
$this->lib = $lib;
$this->db = $this->lib->game->db;
$this->msgs = $this->lib->game->getLib('beta5/msg');
}
// Accepts a request to join an alliance
function run($aid, $pid, $kid) {
$q = $this->db->query("SELECT id FROM player WHERE alliance=$aid AND a_status='REQ' AND id=$pid");
if (!($q && dbCount($q) == 1)) {
return;
}
$a = $this->lib->call('get', $aid);
if (is_null($a)) {
return;
}
$tag = addslashes($a['tag']);
$tm = time();
$this->msgs->call('send', $pid, 'alint', array(
"msg_type" => 10,
"alliance" => $aid,
"tag" => $a['tag'],
"player" => $pid,
));
$l = $this->lib->call('getKeepers', $aid);
foreach ($l as $id) {
if ($id == $kid) {
continue;
}
$this->msgs->call('send', $id, 'alint', array(
"msg_type" => 11,
"alliance" => $aid,
"tag" => $a['tag'],
"player" => $pid,
));
}
$this->db->query("UPDATE player SET a_status='IN',a_vote=NULL,a_grade=NULL WHERE id=$pid");
}
}
?>