/** * Utfør kriminalitet */ public function utfor($id) { $this->options_load(); if (!isset($this->options[$id])) { throw new HSException("Fant ikke ønsket alternativ."); } $krim = $this->options[$id]; $ret = array("success" => false); // treffer vi med sannsynligheten? if (rand(0, 100) <= $krim['prob'] * 100) { // vellykket $ret['success'] = true; // gi penger til spilleren $cash = rand($krim['cash_min'], $krim['cash_max']); \Kofradia\DB::get()->exec("UPDATE users_players SET up_cash = up_cash + {$cash} WHERE up_id = {$this->up->id}"); $ret['cash'] = $cash; // trigger $this->up->update_money($cash, true, false); // gi rank til spilleren $ret['rank_change'] = $this->up->increase_rank($krim['points']); $ret['rank'] = $krim['points']; } // wanted nivå $ret['wanted_change'] = $this->up->fengsel_rank($krim['points'], $ret['success']); // oppdater kriminalitet-status $s = $ret['success'] ? 2 : 1; \Kofradia\DB::get()->exec("\n\t\t\tINSERT INTO kriminalitet_status\n\t\t\tSET krimid = {$id}, ks_up_id = {$this->up->id}, count = 1, success = " . ($ret['success'] ? 1 : 0) . ", last = " . time() . ", ks_strength = ks_strength + {$s}\n\t\t\tON DUPLICATE KEY\n\t\t\tUPDATE count = count + 1, success = success + VALUES(success), last = VALUES(last), ks_strength = VALUES(ks_strength)"); // oppdater kriminalitet \Kofradia\DB::get()->exec("\n\t\t\tUPDATE kriminalitet\n\t\t\tSET k_strength = k_strength + {$s}\n\t\t\tWHERE id = {$id}"); // trigger $this->up->trigger("kriminalitet", array("option" => $krim, "success" => $ret['success'])); // sett ned energien til spilleren $this->up->energy_use(self::ENERGY_KRIM); return $ret; }
/** * Bryte ut fra fengsel */ protected function bryt_ut() { // allerede i fengsel? if ($this->up->fengsel_check()) { ess::$b->page->add_message("Du er allerede i fengsel.", "error"); redirect::handle(); } // har vi ikke nok energi? if (!$this->up->energy_check(self::ENERGY)) { ess::$b->page->add_message("Du har ikke nok energi for å bryte ut andre spillere nå."); redirect::handle(); } $time = intval(postval('time')); // hent informasjon @(list($up_id, $expire, $dusor) = explode("_", $_POST['up_id'] . "_", 3)); $up_id = intval($up_id); $expire = intval($expire); $dusor = game::intval($dusor); $up = player::get($up_id); if (!$up) { ess::$b->page->add_message("Fant ikke brukeren.", "error"); redirect::handle(); } // ikke i fengsel lengre? $wait = $up->fengsel_wait(); if ($wait == 0) { ess::$b->page->add_message('<user id="' . $up->id . '" /> er nok allerede brutt ut!', "error"); redirect::handle(); } // ikke riktig tid? if ($up->data['up_fengsel_time'] != $expire) { ess::$b->page->add_message('<user id="' . $up->id . '" /> har kommet i fengsel på nytt. Prøv igjen.', "error"); redirect::handle(); } // feil dusør? if ($up->data['up_fengsel_dusor'] != $dusor) { ess::$b->page->add_message('Dusøren til <user id="' . $up->id . '" /> har endret seg. Prøv på nytt.', "error"); redirect::handle(); } // sett opp sannsynlighet $prob = self::calc_prob($wait, $up->data['up_wanted_level'] / 10); $points = self::calc_points($prob); // sett opp dusør $dusor_org = $up->data['up_fengsel_dusor']; $dusor = bcmul($up->data['up_fengsel_dusor'], self::DUSOR_PROFIT); // klarte vi det? $success = rand(0, 999) < $prob * 10; if ($success) { // penger man får for utbrytelsen $cash = round(max(0, 100 - $prob) / 100 * self::CASH_MAX); // sett som utbrytet $a = \Kofradia\DB::get()->exec("\n\t\t\t\tUPDATE users_players\n\t\t\t\tSET up_fengsel_time = " . (time() - 1) . ", up_fengsel_dusor_total_out = up_fengsel_dusor_total_out + up_fengsel_dusor, up_fengsel_dusor = 0\n\t\t\t\tWHERE up_id = {$up->id} AND up_fengsel_time = {$up->data['up_fengsel_time']} AND up_fengsel_dusor = {$up->data['up_fengsel_dusor']}"); if ($a == 0) { ess::$b->page->add_message('<user id="' . $up->id . '" /> er nok allerede brutt ut!', "error"); redirect::handle(); } $up->data['up_fengsel_time'] = time() - 1; $up->data['up_fengsel_dusor_total_out'] = bcadd($up->data['up_fengsel_dusor_total_out'], $up->data['up_fengsel_dusor']); $up->data['up_fengsel_dusor'] = 0; // oppdater antall utbrytninger og gi evt. penger \Kofradia\DB::get()->exec("\n\t\t\t\tUPDATE users_players\n\t\t\t\tSET up_fengsel_num_out_tries = up_fengsel_num_out_tries + 1, up_fengsel_num_out_success = up_fengsel_num_out_success + 1, up_cash = up_cash + {$cash} + {$dusor}, up_fengsel_dusor_total_in = up_fengsel_dusor_total_in + {$dusor}\n\t\t\t\tWHERE up_id = " . $this->up->id); $this->up->update_money(bcadd($cash, $dusor), true, false); // hendelse for spilleren som ble brutt ut $up->add_log("fengsel", $dusor_org > 0 ? $dusor_org : null, $this->up->id); $fengsel = $this->up->fengsel_rank($points, true); // penger, dusør og poeng vi mottar $mottok = array(); if ($cash > 0) { $mottok[] = game::format_cash($cash); } if ($dusor > 0) { $mottok[] = "dusøren på " . game::format_cash($dusor); } $mottok[] = game::format_num($points) . ' poeng'; // melding $msg = 'Du brøt ut <user id="' . $up->id . '" /> fra fengselet og mottok ' . sentences_list($mottok) . '.'; if ($fengsel > 0) { $msg .= ' Wanted nivået økte med ' . game::format_number($fengsel / 10, 1) . ' %.'; } ess::$b->page->add_message($msg); // logg putlog("LOG", "FENGSELUTBRYTNING: {$this->up->data['up_name']} brøt ut {$up->data['up_name']} fra fengsel (wait={$wait}, cash={$cash}, dusør={$dusor_org}, prob={$prob}, rank={$points})"); // rank $this->up->increase_rank($points); } else { // mislykket $fengsel = $this->up->fengsel_rank($points, false, true); // oppdater antall utbrytninger (kun forsøk) \Kofradia\DB::get()->exec("UPDATE users_players SET up_fengsel_num_out_tries = up_fengsel_num_out_tries + 1 WHERE up_id = " . $this->up->id); if ($fengsel > 0) { ess::$b->page->add_message('Mislykket! Wanted nivået økte med ' . game::format_number($fengsel / 10, 1) . ' %.'); } } // trigger $this->up->trigger("fengsel", array("success" => $success, "up" => $up, "wait" => $wait, "prob" => $prob, "points" => $points, "cash" => $success ? $cash : null, "dusor" => $dusor, "dusor_org" => $dusor_org)); $up->trigger("fengsel_affected", array("success" => $success, "up" => $this->up, "wait" => $wait, "prob" => $prob, "points" => $points, "cash" => $success ? $cash : null, "dusor" => $dusor, "dusor_org" => $dusor_org)); // energy $this->up->energy_use(self::ENERGY); redirect::handle(); }
/** * Sett ned helsen til spilleren etter skade utført av en annen spiller * @param int $miste_helse hvor mye helse som skal settes ned * @param player $up spilleren som forårsaker dette * @param int $attack_type hva slags angrep det var (0=drapsforsøk, 1=utpressing) * @param float $skadeprosent skadeprosenten ved et angrep * @param int $bullets antall kuler benyttet i angrep */ public function health_decrease($miste_helse, player $up, $attack_type, $skadeprosent = null, $params = array()) { // lås spillerene $up->lock(); $this->lock(); // allerede død? if (!$this->active) { $up->lock_commit(); $this->lock_commit(); return false; } $miste_helse = (int) $miste_helse; $attack_type = (int) $attack_type; // dør spilleren? if ($this->data['up_health'] <= $miste_helse) { // gi rankpoeng $rankpoeng = $up->health_calc_rankpoints($this, true, $skadeprosent); if ($rankpoeng > 0) { $rankpoeng = $this->calc_rankpoints_get($rankpoeng); $up->increase_rank($rankpoeng, false, true); } // oppdater ff-stats $this->attacked_ff_update("killed"); // drep offeret $ret = $this->dies(true, $up); if (!$ret) { $up->lock_commit(); $this->lock_commit(); return false; } // gi angriper pengene offeret hadde på hånden $cash = 0; if ($this->data['up_cash'] > 0) { \Kofradia\DB::get()->exec("UPDATE users_players SET up_cash = up_cash - {$this->data['up_cash']} WHERE up_id = {$this->id}"); \Kofradia\DB::get()->exec("UPDATE users_players SET up_cash = up_cash + {$this->data['up_cash']} WHERE up_id = {$up->id}"); $cash = $this->data['up_cash']; $this->data['up_cash'] = 0; $up->data['up_cash'] += $cash; } // øk telleren over antall drap \Kofradia\DB::get()->exec("UPDATE users_players SET up_attack_killed_num = up_attack_killed_num + 1 WHERE up_id = {$up->id}"); // øk telleren over antall drap i familien spilleren er medlem i $up->attack_ff_update("killed"); $ret = array_merge($ret, array("drept" => true, "rankpoeng" => $rankpoeng, "penger" => $cash)); } else { $ret = array(); // hent alle FF angriperen er medlem av eller nylig var medlem av $ff_ids = $this->get_ff_id_list(); // sett ny energi og helse for offeret $set = ""; $energi_mistet = $this->data['up_energy']; if ($skadeprosent !== null) { $r = 1 - 0.4 * $skadeprosent; $set = "up_energy = up_energy * {$r}, "; $this->data['up_energy'] = round($this->data['up_energy'] * $r); } $energi_mistet = $energi_mistet - $this->data['up_energy']; // lagre energi, helse og angriper-FF $time = time(); \Kofradia\DB::get()->exec("\n\t\t\t\tUPDATE users_players\n\t\t\t\tSET {$set}up_health = up_health - {$miste_helse},\n\t\t\t\t\tup_attacked_time = {$time}, up_attacked_up_id = {$up->id},\n\t\t\t\t\tup_attacked_ff_id_list = " . \Kofradia\DB::quote(implode(",", $ff_ids)) . ",\n\t\t\t\t\tup_health_ff_time = IF(up_health_ff_time IS NULL, up_health_ff_time, IF(up_health / up_health_max >= " . self::FF_HEALTH_LOW . ", IF(up_health_ff_time = 0, {$time}, up_health_ff_time), 0))\n\t\t\t\tWHERE up_id = {$this->id}"); $this->data['up_health'] -= $miste_helse; $this->data['up_attacked_time'] = $time; $this->data['up_attacked_up_id'] = $up->id; $ret['drept'] = false; $ret['rankpoeng'] = 0; $ret['rankpoeng_lost'] = 0; // sett ny beskyttelse på offeret $prot_mistet = ""; $ret['protection_replaced'] = false; if ($this->protection->data) { $prot_skadeprosent = $skadeprosent === null ? 0.02 : $skadeprosent; // bruk 2 % som skadeprosent hvis det ikke er angitt (utpressing) $prot_mistet = $this->protection->weakened($prot_skadeprosent); if ($prot_mistet === false) { $ret['protection_replaced'] = true; $prot_mistet = ""; } else { $prot_mistet = round($prot_mistet, 5); } } // rettet drapsforsøk? $rankpoeng = 0; if ($attack_type == self::ATTACK_TYPE_KILL) { // flytte til tilfeldig bydel $moved = false; if ($this->data['up_health'] / $this->data['up_health_max'] < self::HEALTH_MOVE_AUTO) { // finn en tilfeldig bydel $result = \Kofradia\DB::get()->query("SELECT id, name FROM bydeler WHERE active = 1 AND id != {$this->data['up_b_id']} ORDER BY RAND()"); $moved_from = array("id" => $this->data['up_b_id'], "name" => $this->bydel['name']); $moved = $result->fetch(); $this->data['up_b_id'] = $moved['id']; unset($this->bydel); \Kofradia\DB::get()->exec("UPDATE users_players SET up_b_id = {$moved['id']} WHERE up_id = {$this->id}"); } // mister penger $ret['penger'] = round($this->data['up_cash'] * $miste_helse / $this->data['up_health_max']); $extra = ""; if ($ret['penger'] > 0) { $up->data['up_cash'] = bcadd($up->data['up_cash'], $ret['penger']); $extra = ", up_cash = up_cash + {$ret['penger']}"; $this->data['up_cash'] = bcsub($this->data['up_cash'], $ret['penger']); \Kofradia\DB::get()->exec("UPDATE users_players SET up_cash = up_cash - {$ret['penger']} WHERE up_id = {$this->id}"); } // behandle etterlyst $ret['hitlist'] = etterlyst::player_hurt($this, $up, $miste_helse / $this->data['up_health_max']); // øk telleren over antall mislykkede drapsforsøk for angriper \Kofradia\DB::get()->exec("UPDATE users_players SET up_attack_damaged_num = up_attack_damaged_num + 1{$extra} WHERE up_id = {$up->id}"); // øk telleren over antall mislykkede drapsforsøk i familien spilleren er medlem i $up->attack_ff_update("damaged"); // oppdater ff-stats $this->attacked_ff_update("damaged"); // juster rankpoeng $rankpoeng_lost = $up->health_calc_rankpoints($this, false, $skadeprosent); if ($rankpoeng_lost > 0) { $rankpoeng = $this->calc_rankpoints_get($rankpoeng_lost); $up->increase_rank($rankpoeng, false, true, null, "attack"); $this->increase_rank(-$rankpoeng_lost, false, true, -$rankpoeng, "attack"); } // informer spilleren på e-post $email = new email(); $email->text = 'Hei, Din spiller ' . $this->data['up_name'] . ' har blitt angrepet av en annen spiller og du har blitt skadet. Spilleren har nå ' . game::format_num($this->get_health_percent(), 2) . ' % helse' . ($this->protection->data ? ', ' : ' og ') . game::format_num($this->get_energy_percent(), 2) . ' % energi' . ($this->protection->data ? ' og ' . game::format_num($this->get_protection_percent(), 2) . ' % beskyttelse' : '') . '. Pass på så du ikke risikerer at spilleren blør ihjel! -- www.kofradia.no'; $email->send($this->user->data['u_email'], "Din spiller {$this->data['up_name']} har blitt angrepet"); // hendelse for spilleren $note_data = array(round($miste_helse / $this->data['up_health_max'], 5), round($energi_mistet / $this->data['up_energy_max'], 5), $prot_mistet, $rankpoeng, round($this->data['up_health'] / $this->data['up_health_max'], 5), round($this->data['up_energy'] / $this->data['up_energy_max'], 5), $this->protection->data ? round($this->data['up_protection_state'], 5) : "", $this->data['up_points'], $moved ? urlencode($moved_from['name']) : "", $moved ? urlencode($moved['name']) : "", $ret['penger']); $this->add_log("attacked", implode(":", $note_data), 0); $ret['rankpoeng'] = $rankpoeng; $ret['rankpoeng_lost'] = $rankpoeng_lost; $ret['health_lost_p'] = $note_data[0]; $ret['energy_lost_p'] = $note_data[1]; $ret['protection_lost_p'] = $note_data[2]; $ret['health_lost'] = $miste_helse; $ret['energy_lost'] = $energi_mistet; $ret['health_new_p'] = $note_data[4]; $ret['energy_new_p'] = $note_data[5]; $ret['protection_new_p'] = $note_data[6]; } // så lite helse at spilleren mister medlemskap i familie/firma if ($this->data['up_health'] / $this->data['up_health_max'] < self::FF_HEALTH_LOW) { $ret = array_merge($ret, $this->release_relations_low_health(null, $up, true)); } } // behandle vitner // hvis det er en utpressing er det kun vitner hvis spilleren dør $vitner_id = array(); $vitner = array(); $vitner_log = array(); $r = rand(1, 100); if ($r >= 20 && ($ret['drept'] || $attack_type != self::ATTACK_TYPE_UTPRESSING)) { // antall vitner $antall = 1; if ($ret['drept']) { if ($r >= 40) { $antall++; } if ($r >= 60) { $antall++; } if ($r >= 80) { $antall++; } } else { if ($r >= 60) { $antall++; } } // hent ut tilfeldige vitner $timelimit = time() - 86400; // vitnet må ha vært pålogget siste 24 timene // hent ut tilfeldige vitner $result = \Kofradia\DB::get()->query("\n\t\t\t\tSELECT up_id\n\t\t\t\tFROM users_players\n\t\t\t\tWHERE up_access_level != 0 AND up_access_level < " . ess::$g['access_noplay'] . " AND up_b_id = {$up->data['up_b_id']} AND up_id NOT IN ({$up->id}, {$this->id}) AND up_last_online >= {$timelimit} AND up_brom_expire < " . time() . " AND up_fengsel_time < " . time() . "\n\t\t\t\tORDER BY RAND()\n\t\t\t\tLIMIT {$antall}"); while ($row = $result->fetch()) { $up_vitne = player::get($row['up_id']); $row = array("up" => $up_vitne, "visible" => rand(1, 100) >= 70); // send hendelse til vitne // drept:attack_type:ble_sett:offer_up_id (num = angriper) $up_vitne->add_log("vitne", ($ret['drept'] ? 1 : 0) . ":{$attack_type}:" . ($row['visible'] ? 1 : 0) . ":" . $this->id, $up->id); $vitner_id[] = $up_vitne->id; $vitner[] = $row; $vitner_log[] = array($up_vitne->id, $row['visible']); } } // hent medlemmer av familie til offeret og sjekk om de skal være vitner if ($ret['drept'] || $attack_type != self::ATTACK_TYPE_UTPRESSING) { // sett opp liste $ids = array(); $list = $this->get_ff_list(); foreach ($list as $row) { if ($row['ff_is_crew'] != 0 || $row['ff_type'] != ff::TYPE_FAMILIE) { continue; } $ids[] = $row['ff_id']; } if (count($ids) > 0) { $limit = 21600; // pålogget innen 6 timer $expire = time() - $limit; $result = \Kofradia\DB::get()->query("\n\t\t\t\t\tSELECT DISTINCT up_id, up_last_online\n\t\t\t\t\tFROM ff_members\n\t\t\t\t\t\tJOIN users_players ON ffm_up_id = up_id AND up_b_id = {$up->data['up_b_id']} AND up_last_online > {$expire}\n\t\t\t\t\tWHERE ffm_ff_id IN (" . implode(",", $ids) . ") AND ffm_status = " . ff_member::STATUS_MEMBER . " AND ffm_up_id NOT IN ({$this->id}, {$up->id})"); while ($row = $result->fetch()) { // er allerede vitne if (in_array($row['up_id'], $vitner_id)) { continue; } // beregn sannsynlighet $prob = min($limit, $row['up_last_online'] - $expire) / $limit * 0.8; // 80 % maks sannsynlighet hvis pålogget akkurat nå // sjekk sannsynlighet if (round($prob * 1000) < rand(1, 1000)) { continue; } $up_vitne = player::get($row['up_id']); $row = array("up" => $up_vitne, "visible" => rand(1, 100) >= 70); // send hendelse til vitne // drept:attack_type:ble_sett:offer_up_id (num = angriper) $up_vitne->add_log("vitne", ($ret['drept'] ? 1 : 0) . ":{$attack_type}:" . ($row['visible'] ? 1 : 0) . ":" . $this->id, $up->id); $vitner[] = $row; $vitner_log[] = array($up_vitne->id, $row['visible']); } } } $ret['vitner'] = $vitner; if ($params && is_array($params)) { $ret = array_merge($ret, $params); } // lagre logg $ret['bullets'] = isset($ret['bullets']) ? (int) $ret['bullets'] : 0; $this->attack_log($ret, $attack_type, $vitner_log, $up); // trigger for offer if (!$ret['drept'] && $attack_type == self::ATTACK_TYPE_KILL) { $this->trigger("attacked", array("attack" => $ret, "up" => $up)); } $up->lock_commit(); $this->lock_commit(); return $ret; }
/** * Utfør biltyveri */ public function biltyveri_utfor($option_id) { if (!isset($this->options[$option_id])) { throw new HSException("Ugyldig alternativ."); } $option = $this->options[$option_id]; // litt sannsynlighetsberegning $rand = rand(0, 1000); // test sannsynlighet $ret = array("success" => $rand <= $option['percent'] * 10); // traff vi på sannsynligheten? if ($ret['success']) { // hent alle bilene vi kan skaffe $result = \Kofradia\DB::get()->query("SELECT id, probability FROM gta WHERE min_rank <= " . $this->up->rank['number']); $biler = array(); $prob_total = 0; while ($row = $result->fetch()) { $prob_total += $row['probability']; $biler[$row['id']] = $row['probability']; } // finn en bil $rand = rand(1, $prob_total); $prob = 1; $bil = false; foreach ($biler as $id => $p) { $prob = $prob + $p; if ($rand < $prob) { // fant enhet $bil = $id; break; } } // hent bilen $result = \Kofradia\DB::get()->query("SELECT id, brand, model, min_rank, img_mini, probability FROM gta WHERE id = {$bil}"); // finn en tilfeldig bil bassert på sannsynligheten for bilen $bil = $result->fetch(); // beregn skade ut i fra sannsynligheten vi hadde $damage_min = 99 - floor($option['percent']) * (rand(1, 15) / 10); if ($damage_min < 0) { $damage_min = 0; } $damage_max = 99 - floor($option['percent']) * (rand(1, 10) / 10); if ($damage_max > 99) { $damage_max = 99; } if ($damage_min > $damage_max) { $damage = $damage_min; } $damage = rand($damage_min, $damage_max); // gi rankpoeng $ret['rank_change'] = $this->up->increase_rank(self::RANK_BILTYVERI); // gi bil \Kofradia\DB::get()->exec("INSERT INTO users_gta SET ug_up_id = " . $this->up->id . ", gtaid = {$bil['id']}, time = " . time() . ", b_id_org = " . $this->up->data['up_b_id'] . ", b_id = " . $this->up->data['up_b_id'] . ", damage = {$damage}"); $ret['gta'] = $bil; // finn en tekst? $result = \Kofradia\DB::get()->query("SELECT got_text FROM gta_options_text WHERE got_go_id = {$option['id']} ORDER BY RAND() LIMIT 1"); if ($row = $result->fetch()) { $replace_from = array("%bil%", "%skade%"); $replace_to = array("{$bil['brand']} {$bil['model']}", $damage); $ret['message'] = game::bb_to_html(str_replace($replace_from, $replace_to, $row['got_text'])); } else { $ret['message'] = "Du skaffet deg en <b>{$bil['brand']} {$bil['model']}</b> med <b>{$damage} %</b> skade!"; } } // wanted nivå $ret['wanted_change'] = $this->up->fengsel_rank(self::RANK_BILTYVERI, $ret['success']); // oppdater prosenter osv $increase = rand(0, $option['max_pos_change'] * 10) / 10; // for høy prosent? $percent = $option['percent']; if ($percent + $increase > $option['max_percent']) { $percent -= rand(0, $option['max_neg_change'] * 10) / 10; } else { $percent += $increase; } // ordne status if ($option['status_id']) { \Kofradia\DB::get()->exec("UPDATE gta_options_status SET percent = {$percent}, time_last = " . time() . ", count = count + 1" . ($ret['success'] ? ', success = success + 1' : '') . " WHERE id = {$option['status_id']}"); } else { \Kofradia\DB::get()->exec("INSERT INTO gta_options_status SET optionid = {$option['id']}, gos_up_id = " . $this->up->id . ", percent = {$percent}, time_last = " . time() . ", count = 1" . ($ret['success'] ? ', success = 1' : '')); } // energi $this->up->energy_use(self::ENERGY_BILTYVERI); // trigger $this->up->trigger("biltyveri", array("success" => $ret['success'], "option" => $option, "prob" => $option['percent'], "gta" => $ret['success'] ? $bil : null, "damage" => $ret['success'] ? $damage : null)); return $ret; }
/** * Formatter tekst for premie (og gi ut hvis spesifisert) */ protected function prize($give = false) { // mulige premier: // * cash // * points // * bullets $params = new params($this->a->data['ac_prize']); $text = array(); // cash if ($cash = $params->get("cash")) { if ($give) { $this->up->update_money($cash); } $text[] = game::format_cash($cash); } // points if ($points = $params->get("points")) { if ($give) { $this->up->increase_rank($points); } $text[] = game::format_num($points) . " rankpoeng"; } // kuler if ($bullets = $params->get("bullets")) { $bullets = (int) $bullets; // har vi plass til noen kuler? if ($this->up->weapon) { $kap = $this->up->weapon ? $this->up->weapon->data['bullets'] : 0; $free = $kap - $this->up->data['up_weapon_bullets'] - $this->up->data['up_weapon_bullets_auksjon']; $bullets = max(0, min($free, $bullets)); if ($bullets > 0) { if ($give) { // gi kuler \Kofradia\DB::get()->exec("UPDATE users_players SET up_weapon_bullets = up_weapon_bullets + {$bullets} WHERE up_id = {$this->up->id}"); $this->up->data['up_weapon_bullets'] += $bullets; } $text[] = fwords("%d kule", "%d kuler", $bullets); } } } return sentences_list($text); }