예제 #1
0
function remove_buddy_from_list()
{
    global $uid;
    global $fuid;
    if (is_buddy($uid, $fuid)) {
        del_buddy($uid, $fuid);
        del_buddy($fuid, $uid);
        del_buddy_invite($fuid, $uid);
        send_ticker_from_to($uid, $fuid, "w", "removed you from his/her buddylist");
    } else {
        echo "<center>User's not your buddy!</center>";
    }
}
예제 #2
0
function proc_broadcast_msg()
{
    global $uid;
    $sth = mysql_query("select u.id from users u, alliance a where u.alliance = a.id and " . $uid . " in (a.leader, a.forminister, a.milminister, a.devminister)");
    if (!$sth || !mysql_num_rows($sth)) {
        show_error("ERR::PROC BROADCAST");
        return false;
    }
    while ($allies = mysql_fetch_array($sth)) {
        send_ticker_from_to($uid, $allies["id"], "w", $_POST["message"]);
    }
}
 function sell_commit($trade_number, $price, $fail_chance)
 {
     // Resourcen von der Tradestation entfernen und geld gutschreiben
     $resource = get_resource_name($this->stockmarket);
     if ($trade_number >= $this->amount) {
         $stocks_to_sell = $this->amount;
         $sth = mysql_query("DELETE FROM stockmarket_orders WHERE uid=" . $this->uid . " AND stockmarket = '" . $this->stockmarket . "' AND time = '" . $this->time . "' AND type=" . SELL_ORDER);
     } else {
         $stocks_to_sell = $trade_number;
         $sth = mysql_query("UPDATE stockmarket_orders SET amount = amount - " . $stocks_to_sell . ", time = time WHERE uid=" . $this->uid . " AND stockmarket = '" . $this->stockmarket . "' AND time = '" . $this->time . "' AND type=" . SELL_ORDER);
     }
     if (!$sth) {
         show_error("ERROR::DELETE / UPDATE BUY ORDER");
         return false;
     }
     $credit_uid = $this->uid;
     $failed = $this->transaction_fails($fail_chance);
     // FAIL CHANCE
     if ($failed) {
         $credit_uid = $this->get_random_trade_uid();
     }
     $sth = mysql_query("UPDATE ressources SET money = money + " . $stocks_to_sell * $price . " WHERE uid=" . $credit_uid);
     if (!$sth) {
         show_error("ERROR::PAY SELLER");
         return false;
     }
     $sth = mysql_query("UPDATE tradestations set " . $resource . " = " . $resource . " - " . $stocks_to_sell . " WHERE uid=" . $this->uid);
     if (!$sth) {
         show_error("ERROR::REMOVE RES FROM STATION");
         return false;
     }
     $trade_number -= $stocks_to_sell;
     $this->amount -= $stocks_to_sell;
     if ($failed && $credit_uid != $this->uid) {
         send_stockmarket_ticker($this->uid, "SIR! Our files say that we have SOLD: " . $stocks_to_sell . " units of " . get_resource_name($this->stockmarket) . " for " . $price . " &euro; each!<br> <strong>But we have never recieved the money!</strong>");
         send_ticker_from_to(false, $credit_uid, "w", "Sir! " . $price * $stocks_to_sell . " &euro; from a trade transaction seems to be misleaded to us! Lucky, isn't it?");
     } else {
         if ($this->amount > 0) {
             send_stockmarket_ticker($this->uid, "PARTIAL SOLD: " . $stocks_to_sell . " units of " . get_resource_name($this->stockmarket) . " for " . $price . " &euro; each.");
         } else {
             send_stockmarket_ticker($this->uid, "COMPLETE SOLD: " . $stocks_to_sell . " units of " . get_resource_name($this->stockmarket) . " for " . $price . " &euro; each.");
         }
     }
     return $trade_number;
 }