- 积分
- 52327
- 威望
- 258
- 魅力
- 268
- 经验
- 34413
- 热心度
- 37
- 注册时间
- 2006-7-9
- 最后登录
- 2024-8-28
- 主题
- 408
- 回帖
- 9896
- 精华
- 19
- 阅读权限
- 200
TA的每日心情 | 开心 2020-9-19 16:27 |
---|
签到天数: 7 天 连续签到: 1 天 [LV.3]火元素使者
管理员
风侠
- 积分
- 52327
|
一楼是源码.
我希望将抢劫金额和罚款金额,均与抢劫和被抢抢劫双方的携带金额发生联系. 从根源上杜绝套白狼.
- <?php
- if(!defined('IN_DISCUZ') || !defined('IN_BLACKBAND')) {
- exit('Access Denied');
- }
- // 是否够体力
- if ($band_user[stamina] < $rob_user_required_sta) {
- showmessage("你的体力不足{$rob_user_required_sta}点, 无法打劫, 你可以去消遣娱乐中心恢复体力或者系统会根据一定时间自动恢复相应的体力. 请返回.");
- }
- // 两次打劫时间间隔
- if ($time_now - $band_user[last_rob_time] < $rob_user_interval) {
- $time = $rob_user_interval - ($time_now - $band_user[last_rob_time]);
- showmessage("注意了, 两次打劫别人的时间间隔是". $rob_user_interval ."秒, 请你再休息". $time ."秒再继续打劫!请返回");
- }
- $victim_name = trim($victim_name);
- // 随机抽取会员
- if ($rand_member) {
- $query = $db->query("SELECT m.username,m.uid FROM {$tablepre}blackband b,{$tablepre}members m WHERE b.uid=m.uid AND m.uid<>{$discuz_uid} ORDER BY rand() LIMIT 1");
- $tmp_user = $db->fetch_array($query);
- $victim_name = $tmp_user[username];
- $victim_uid = $tmp_user[uid];
- }
- if (empty($victim_name)) {
- showmessage('请输入要打劫的用户名称. 请返回');
- }
- if (strcmp(strtolower($victim_name), strtolower($discuz_user)) == 0) {
- showmessage('你打劫自己? 世界上还有这回事...汗...请返回');
- }
- $query = $db->query("SELECT m.{$cash_extcredit},m.uid,m.groupid FROM {$tablepre}blackband b,{$tablepre}members m WHERE m.username='$victim_name' AND m.uid=b.uid");
- $victim = $db->fetch_array($query);
- if ($victim == NULL) {
- showmessage('你输入的用户名称不正确, 此用户可能不存在, 或者没有加入黑道游戏. 请返回.');
- }
- $victim_uid = $victim[uid];
- $query = $db->query("SELECT b.stamina,m.band_id FROM {$tablepre}blackband b
- LEFT JOIN {$tablepre}bb_member m ON m.member_uid=b.uid WHERE b.uid={$victim_uid}");
- $tmp = $db->fetch_array($query);
- $victim_sta = $tmp[stamina];
- if ($victim_sta == NULL) {
- $victim_sta = 100;
- }
- if ($tmp[band_id] == $band_user[band_id] && $tmp[band_id] != NULL) {
- showmessage('你打劫自己的同门? 不是吧? 被老大知道了把你T出社团, 做人要厚道啊. 乱来是不行滴. 请返回.');
- }
- $query = $db->query("SELECT out_jail_time FROM {$tablepre}blackband where uid='{$victim['uid']}'");
- $out_jail_time = $db->result($query,0);
- if($out_jail_time > $time_now){
- showmessage($victim_name .'现在还在牢里面蹲着呢..怎么打劫他? 小伙子, 吃饱饭就歇会..连坐牢的人也打劫? 搞不好你也要在里面蹲~~你要打劫的人还有'. ($out_jail_time - $time_now) .'秒
- 才能出狱. 请返回');
- }
- // 受保护的用户组
- if ($victim[groupid] == $protect_group) {
- showmessage ('你不能打劫此用户, 可能该用户所在的用户组受到系统的保护.','blackband.php');
- }
- // 受保护的用户
- $protect_user_ary = explode(',', strtolower(trim($protect_users)));
- if (in_array(strtolower($victim_name), $protect_user_ary)) {
- showmessage('你不能打劫此用户, 该用户已经受到系统的保护.','blackband.php');
- }
- $query = $db->query("SELECT last_robbed_time FROM {$tablepre}bb_victim WHERE uid='{$victim['uid']}'");
- $victim_tmp = $db->fetch_array($query);
- //打劫冷却时间
- if ($victim_tmp != NULL) {
- if (($time_now - $victim_tmp[last_robbed_time]) < $user_robbed_interval) {
- $time = $user_robbed_interval- ($time_now - $victim_tmp[last_robbed_time]);
- showmessage('你现在不能打劫'. $victim_name .', 他才刚被人打劫过, 做人要厚道~~(注意: 该居民被打劫后, '. $user_robbed_interval .'秒内不允许再被打劫.请等待'. $time .'秒.)','blackband.php');
- }
- } else {
- $db->query("INSERT INTO {$tablepre}bb_victim (uid,last_robbed_time,robbed_amount,robbed_times) VALUES ('{$victim['uid']}',0,0,0)");
- }
-
- // 开始打劫
- /***********/
- //取得受害者现金的百分比
- $victim_cash = $victim[$cash_extcredit];
- //打劫受害者的现金是否随机抽取
- if ($rob_rate_rand == 1) {
- $rob_user_rate = rand(1,$rob_user_rate);
- }
- //增加多少声望.
- if ($ruar_rand) {
- $rob_user_add_sw = rand(1,$rob_user_add_sw);
- }
- //减少声望.
- if ($rumr_rand) {
- $rob_user_minus_sw = rand(1,$rob_user_minus_sw);
- }
- // 取整打劫的金额
- $rob_cash = intval($victim_cash * ($rob_user_rate/100));
- // 打劫完毕清理
- $db->query("UPDATE {$tablepre}blackband SET rob_times=rob_times+1,get_info=0,last_rob_time={$time_now} WHERE uid=$discuz_uid");
- // 受害者记录
- $db->query("UPDATE {$tablepre}bb_victim SET last_robbed_time={$time_now}, robbed_times=robbed_times+1, robbed_amount=robbed_amount+{$rob_cash} WHERE uid={$victim['uid']}");
- // 受害者身上没钱
- if ($rob_cash <= 0) {
- // 受害者记录
- $db->query("UPDATE {$tablepre}bb_victim SET last_robbed_time={$time_now}, robbed_times=robbed_times+1 WHERE uid={$victim['uid']}");
- showmessage("真倒霉..打劫<b>{$victim_name}</b>时才发现原来他身上已经没有{$money_title}了, 汗..真亏了.....", "blackband.php");
- }
-
- $minus_ss_rate = 0;
- //保镖
- $query = $db->query("SELECT b.guard_end_time,g.minus_ss_rate,g.name FROM {$tablepre}blackband b,{$tablepre}bb_guard g WHERE b.uid={$victim['uid']} AND b.guard_end_time>{$time_now} AND b.guard_id=g.id");
- $victim_guard = $db->fetch_array($query);
- if ($victim_guard != NULL && ($victim_guard[guard_end_time] > $time_now)) {
- $minus_ss_rate = $victim_guard[minus_ss_rate];
- }
- $rob_time = date('n月j日G:i', $time_now);
- if ($my_weapon == NULL) {
- $use_weapon = '徒手';
- } else {
- $use_weapon = '使用'. $my_weapon_name;
- }
- $db->query("UPDATE {$tablepre}blackband SET stamina=stamina-{$rob_user_required_sta} WHERE uid=$discuz_uid");
- $success = false;
- // 分3种情况判断是否成功.
- if ($band_user[stamina] > $victim_sta) {
- if (rand(1,100) < (100-$more_sta_difficulty-$minus_ss_rate+$my_weapon[minus_difficulty])) {
- $success = true;
- }
- } else if ($band_user[stamina] == $victim_sta) {
- if (rand(1,100) < (100-$equal_sta_difficulty-$minus_ss_rate+$my_weapon[minus_difficulty])) {
- $success = true;
- }
- } else {
- if (rand(1,100) < (100-$less_sta_difficulty-$minus_ss_rate+$my_weapon[minus_difficulty])) {
- $success = true;
- }
- }
- // 打劫成功
- if ($success) {
- $msg = "打劫 {$victim_name} <font color=green><b>成功</b></font>, 真是一件太轻松的事情了.";
- $msg .= "
- ";
- $msg .= "# 共打劫{$rob_cash}{$money_unit}.
- ";
- $msg .= "# 打劫消耗体力{$rob_user_required_sta}点.
- ";
- $log = "$discuz_user 于<font color=#333333>{$rob_time}</font>{$use_weapon}打劫 $victim_name {$rob_user_rate}%{$money_title}(约{$rob_cash}{$money_unit}) <font color=green><b> 成 功 </b></font>.";
- //是否随机增加声望,100为必加
- if (rand(1,100) <= $add_sw_occur_rate) {
- if ($rob_user_add_sw > 0) {
- $db->query("UPDATE {$tablepre}blackband SET sw=sw+$rob_user_add_sw WHERE uid=$discuz_uid");
- $log .= '<font color=blue>[声望+'. $rob_user_add_sw .']</font>';
- $msg .= "# 声望上升{$rob_user_add_sw}点.
- ";
- }
- }
- $db->query("UPDATE {$tablepre}blackband SET rob_amount=rob_amount+{$rob_cash},last_ss_time={$time_now} WHERE uid=$discuz_uid");
-
- //受害者损失现金
- $db->query("UPDATE {$tablepre}members SET $cash_extcredit=$cash_extcredit-$rob_cash WHERE username='$victim_name'");
-
- $db->query("INSERT INTO {$tablepre}bb_log (uid,victim_uid,rob_time,log) VALUES ('$discuz_uid','{$victim[uid]}','{$time_now}','{$log}')");
-
- //发送信息给受害者
- sendpm($victim[uid],"你被{$discuz_user}打劫了{$rob_user_rate}%{$money_title}(约{$rob_cash}{$money_unit}).","小贼{$discuz_user}在{$rob_time}打劫你{$rob_user_rate}%{$cash_title}(约{$rob_cash}{$money_unit}), 以后要注意不要放太多现金在身上哦~ 你还不赶快去抢回他报仇~~",$discuz_uid,$discuz_user);
-
-
- //上缴给社团
- $bm_query = $db->query("SELECT bm.band_id,b.band_bonus FROM {$tablepre}bb_member bm,{$tablepre}bb_band b WHERE bm.member_uid='{$discuz_uid}'");
- $bm = $db->fetch_array($bm_query);
- $band_id = $bm['band_id'];
- $band_bonus = $bm['band_bonus'];
- $actual_amount = $rob_cash;
- if ($band_id > 0) {
- $pay_amount = intval($rob_cash * ($band_bonus/100));
- $actual_amount = $rob_cash - $pay_amount;
- $db->query("UPDATE {$tablepre}bb_member SET paid_amount=paid_amount+{$pay_amount} WHERE member_uid='{$discuz_uid}' AND band_id='{$band_id}'");
- $db->query("UPDATE {$tablepre}bb_band SET bonus_amount=bonus_amount+{$pay_amount} WHERE id='{$band_id}'");
- $msg .= "# <font color=green>上缴{$pay_amount}{$money_unit}给社团</font>";
- }
- $db->query("UPDATE {$tablepre}members SET $cash_extcredit=$cash_extcredit+$actual_amount WHERE uid=$discuz_uid");
- showmessage($msg,'blackband.php?mode=rob_user&item=self');
- } else {
- //打劫失败后的3种情况
- $rand_rate = rand(1,100);
- // 出狱费用
- if ($rujt_rand) {
- $rob_user_jail_time = rand(1,$rob_user_jail_time);
- }
-
- // 出院费用
- if ($ruht_rand) {
- $rob_user_hosp_time = rand(1,$rob_user_hosp_time);
- }
- if ($rand_rate < $ra_rate) {
- //逃跑的几率
- //逃跑成功需要的体力
- if ($rss_rate) {
- $ra_ss_sta = rand(1,$ra_ss_sta);
- }
- if ($band_user[stamina]-$rob_user_required_sta < $ra_ss_sta) {
- // 逃跑时体力不够, 被抓进监狱
- //坐牢
- if ($rujt_rand) {
- $rob_user_jail_time = rand(1,$rob_user_jail_time);
- }
- $out_jail_time = $rob_user_jail_time * 60 + $time_now;
- $out_jail_time_txt = date('n月j日 H:i', $out_jail_time);
- $msg = "打劫 {$victim_name} <font color=red><b>失败</b></font>, 你的行为被警察发现了, 逃跑时由于体力不足被警察抓到, 你已经被送进监狱!";
- $msg .= "
- ";
- $log = "$discuz_user 于<font color=#333333>{$rob_time}</font>{$use_weapon}打劫 $victim_name <font color=red><b>失败</b></font>坐牢{$rob_user_jail_time}分钟.";
- //坐牢是否减声望
- $minus_sw_occur_rate_rand = rand(1,100);
- if ($minus_sw_occur_rate_rand <= $minus_sw_occur_rate) {
- if ($rob_user_minus_sw >0) {
- $db->query("UPDATE {$tablepre}blackband SET sw=sw-$rob_user_minus_sw WHERE uid=$discuz_uid");
- $log .= '[<font color=red>声望-'. $rob_user_minus_sw .'</font>]';
- $msg .= "# 声望减少{$rob_user_minus_sw}点.
- ";
- }
- }
- $msg .= "# 打劫消耗体力{$rob_user_required_sta}点.
- ";
- $msg .= "# 坐牢{$rob_user_jail_time}分钟.
- ";
- $msg .= "# 你必须等到{$out_jail_time_txt}才能出狱.
- ";
- //坐牢是否罚款
- if ($jail_penalty_rate > 0) {
- if ($jail_penalty_rate_rand) {
- $jail_penalty_rate = rand(1,$jail_penalty_rate);
- }
- $penalty_amount = intval($GLOBALS[$cash_extcredit] * $jail_penalty_rate/100);
- $db->query("UPDATE {$tablepre}members SET {$cash_extcredit}={$cash_extcredit}-{$penalty_amount} WHERE uid={$discuz_uid}");
- $msg .= "# 并罚款{$penalty_amount}{$money_unit}.";
- $log .= "[<font color=red>罚款{$penalty_amount}{$money_unit}</font>]";
- }
-
- //纪事
- $db->query("INSERT INTO {$tablepre}bb_log (uid,victim_uid,rob_time,log) VALUES ('$discuz_uid', '{$victim[uid]}','{$time_now}','{$log}')");
-
- //坐牢没收全部东西
- $db->query("UPDATE {$tablepre}blackband SET weapon_id=0,out_jail_time={$out_jail_time},out_jail_fee={$out_jail_fee} WHERE uid=$discuz_uid");
- showmessage($msg,'blackband.php?mode=jail');
- } else {
- //逃跑成功, 减少逃跑成功需要的体力
- $msg = "打劫 {$victim_name} <font color=red><b>失败</b></font>, 逃跑成功!";
- $msg .= "
- ";
- $msg .= "# 打劫消耗体力{$rob_user_required_sta}点.
- ";
- $msg .= "# 为逃避追捕, 体力消耗{$ra_ss_sta}点.
- ";
- $msg .= "# 以上共消耗体力". ($rob_user_required_sta+$ra_ss_sta) ."点.
- ";
- $log = "$discuz_user 于<font color=#333333>{$rob_time}</font>{$use_weapon}打劫 $victim_name <font color=red><b>失败</b></font>逃跑了.";
- if ($minus_ss_rate > 0) {
- $msg .= "# 由于{$victim_name}身边有<b>{$victim_guard[name]}</b>保镖保护.
- ";
- $log .= "[<font color=green>{$victim_name}有保镖{$victim_guard[name]}保护</font>]";
- }
- $db->query("INSERT INTO {$tablepre}bb_log (uid,victim_uid,rob_time,log) VALUES ('$discuz_uid', '{$victim[uid]}','{$time_now}','{$log}')");
-
- //减少体力
- $db->query("UPDATE {$tablepre}blackband SET stamina=stamina-{$ra_ss_sta} WHERE uid=$discuz_uid");
- showmessage($msg,'blackband.php');
- }
- } elseif ($rand_rate < $ra_rate+$jail_rate) {
- //坐牢
- if ($rujt_rand) {
- $rob_user_jail_time = rand(1,$rob_user_jail_time);
- }
- $out_jail_time = $rob_user_jail_time * 60 + $time_now;
- $out_jail_time_txt = date('n月j日 H:i', $out_jail_time);
- $msg = "打劫 {$victim_name} <font color=red><b>失败</b></font>, 你的行为被警察发现了, 逃跑时由于体力不足被警察抓到, 你已经被送进监狱!";
- $msg .= "
- ";
- $log = "$discuz_user 于<font color=#333333>{$rob_time}</font>{$use_weapon}打劫 $victim_name <font color=red><b>失败</b></font>坐牢{$rob_user_jail_time}分钟.";
- //坐牢是否减声望
- $minus_sw_occur_rate_rand = rand(1,100);
- if ($minus_sw_occur_rate_rand <= $minus_sw_occur_rate) {
- if ($rob_user_minus_sw >0) {
- $db->query("UPDATE {$tablepre}blackband SET sw=sw-$rob_user_minus_sw WHERE uid=$discuz_uid");
- $log .= '[<font color=red>声望-'. $rob_user_minus_sw .'</font>]';
- $msg .= "# 声望减少{$rob_user_minus_sw}点.
- ";
- }
- }
- $msg .= "# 打劫消耗体力{$rob_user_required_sta}点.
- ";
- $msg .= "# 坐牢{$rob_user_jail_time}分钟.
- ";
- $msg .= "# 你必须等到{$out_jail_time_txt}才能出狱.
- ";
- //坐牢是否罚款
- if ($jail_penalty_rate > 0) {
- if ($jail_penalty_rate_rand) {
- $jail_penalty_rate = rand(1,$jail_penalty_rate);
- }
- $penalty_amount = intval($GLOBALS[$cash_extcredit] * $jail_penalty_rate/100);
- $db->query("UPDATE {$tablepre}members SET {$cash_extcredit}={$cash_extcredit}-{$penalty_amount} WHERE uid={$discuz_uid}");
- $msg .= "# 并罚款{$penalty_amount}{$money_unit}.";
- $log .= "[<font color=red>罚款{$penalty_amount}{$money_unit}</font>]";
- }
-
- $db->query("INSERT INTO {$tablepre}bb_log (uid,victim_uid,rob_time,log) VALUES ('$discuz_uid', '{$victim[uid]}','{$time_now}','{$log}')");
- //坐牢没收全部东西
- $db->query("UPDATE {$tablepre}blackband SET weapon_id=0,out_jail_time={$out_jail_time},out_jail_fee={$out_jail_fee} WHERE uid=$discuz_uid");
- showmessage($msg,'blackband.php?mode=jail');
- } else {
- //住院
- if ($ruht_rand) {
- $rob_user_hosp_time = rand(1,$rob_user_hosp_time);
- }
- $out_hosp_time = $rob_user_hosp_time * 60 + $time_now;
- $out_hosp_time_txt = date('n月j日 H:i', $out_hosp_time);
- //医院
- $msg = "打劫 {$victim_name} <font color=red><b>失败</b></font>, 由于在警察追捕过程中, 你身受重伤, 被送进医院治疗.";
- $msg .= "
- ";
- $msg .= "# 打劫消耗体力{$rob_user_required_sta}点.
- ";
- $msg .= "# 住院{$rob_user_hosp_time}分钟.
- ";
- $msg .= "# 你必须等到{$out_hosp_time_txt}才能出院.
- ";
-
- $log = "$discuz_user 于<font color=#333333>{$rob_time}</font>{$use_weapon}打劫 $victim_name <font color=red><b>失败</b></font>住院{$rob_user_hosp_time}分钟.";
-
- $db->query("INSERT INTO {$tablepre}bb_log (uid,victim_uid,rob_time,log) VALUES ('$discuz_uid', '{$victim[uid]}','{$time_now}','{$log}')");
-
- $db->query("UPDATE {$tablepre}blackband SET out_hosp_time={$out_hosp_time},out_hosp_fee={$out_hosp_fee} WHERE uid=$discuz_uid");
- showmessage($msg,'blackband.php?mode=hosp');
- }
- }
- ?>
复制代码 |
|