本帖最后由 MBirds 于 2008-10-14 13:15 编辑
本人主要是用于学习,商业使用请使用原版
以下代码可能存在BUG问题 希望能够跟大家一起学习交流解决
解决方法:
在com_slave.php加上:
//-------------------积分兑换设置----------------
if($op=="credit"){
$sidebar = 1;
if($_POST[submitcredit]){
$credit = $_POST[credit];
$credits = $credit*50;
if ( !empty( $credit ) and ( $credit > 0 ) and ( $credits <= $space[credit] ) )
{
//增加金钱
$query = "UPDATE ".tname('com_slave_main')." SET cash = cash+".$credits." WHERE uid=".$space[uid];
$_SGLOBAL['db']->query($query);
//减少积分
$query = "UPDATE ".tname('space')." SET credit = credit-".$credit." where uid =".$space[uid];
$_SGLOBAL['db']->query($query);
showmessage(comlang('credit_successful'), "component.php?com=slave&op=credit", 1);
}
else if ( $credits > $space[credit] )
{
showmessage('credits_balance_insufficient');
}
else
{
showmessage('showcredit_error');
}
}
$user = comSlaveGetUserInfo($space[uid]);
}
修改com_slave.htm文件:
<div class="c_header a_header">
<a href="?com=slave"><img src="<!--{avatar($space[uid],small)}-->" alt="$space[username]" class="avatar" /></a>
<h1>$SConfig[gamename]</h1>
<span class="spacelink">我的现金:$SConfig[dollar_sign] $myinfo[cash] 拥有积分:$space[credit] 个积分</span>
</div>
<div class="tabs_header">
<a href="?com=invite&app=slave" class="t_combutton">邀请好友(可获得 $SConfig[dollar_sign] $invite_amount)</a>
<ul class="tabs">
<li $active[main]><a href="?com=slave">首页</a></li>
<!--{if $op=="action"}-->
<li class="active"><a href="?com=slave&op=action&uid=$uid">任务</a></li>
<!--{/if}-->
<li $active[market]><a href="?com=slave&op=market">奴隶市场</a></li>
<li $active[rank]><a href="?com=slave&op=rank">排行榜</a></li>
<li $active[setup]><a href="?com=slave&op=setup">游戏设置</a></li>
<li $active[credit]><a href="?com=slave&op=credit">积分兑换</a></li> <li $active[help]><a href="?com=slave&op=help">帮助</a></li>
</ul>
</div>
<!--{if $op=="credit"}-->
<div class="slave_block" style="padding:10px 20px 30px 20px;">
<div class=c_form>
<table cellspacing="0" cellpadding="0" class="formtable">
<tr><th>拥有现金:</th><td><span class="money">$SConfig[dollar_sign] $myinfo[cash]</span></td></tr>
<tr><th>拥有积分:</th><td><span class="num">$space[credit]</span></td></tr>
<tr><th>兑换规则:</th><td>兑换 $SConfig[dollar_sign]500 ,需要积分数:10</td></tr>
<form action="component.php?com=slave&op=credit" method="POST">
<tr><th>兑换积分:</th><td><input type="text" name="credit" value="1" size="5"> </td></tr>
<tr><th> </th><td><input type=submit name="submitcredit" value="兑换" class="submit">
<input type=button name="submit" value="取消" class="submit" onclick="javascript:history.back()">
</td></tr>
</table>
<br>
<b>积分交易一旦提交不可恢复,请确定无误后再进行操作,积分减少会影响到您的会员级别</b>
</div>
</div>
<!--{/if}-->*红色表示要加的内容
以下是第三张效果图片显示要修改的代码:
在com_slave.php加上:
//-------------------积分兑换----------------
if($op=="credit"){
$sidebar = 1; //打开右侧栏
if($_POST[submitcredit]){
$code=$_POST['code']; //买入或卖出
$credit=intval(trim($_POST['credit'])); //用户输入数值
$credits = $credit*50;
$creditss = $credit/50;
if (!$credit||empty($_POST['credit'])|| $_POST['credit']<1 ||strlen($_POST['credit'])>8) showmessage(_comlang($credit_err));
if ($code=='xianjin') {
//增加金钱
$query = "UPDATE ".tname('com_slave_main')." SET cash = cash+".$credits." WHERE uid=".$space[uid];
$_SGLOBAL['db']->query($query);
//减少积分
$query = "UPDATE ".tname('space')." SET credit = credit-".$credit." where uid =".$space[uid];
$_SGLOBAL['db']->query($query);
showmessage(comlang('xianjin_successful'), "component.php?com=slave&op=credit", 3);
}elseif($code=='jifen') {
//减少金钱
$query = "UPDATE ".tname('com_slave_main')." SET cash = cash-".$credit." WHERE uid=".$space[uid];
$_SGLOBAL['db']->query($query);
//增加积分
$query = "UPDATE ".tname('space')." SET credit = credit+".$creditss." where uid =".$space[uid];
$_SGLOBAL['db']->query($query);
showmessage(comlang('jifen_successful'), "component.php?com=slave&op=credit",3);
}
}
}
修改com_slave.htm文件:
<div class="c_header a_header">
<a href="?com=slave"><img src="<!--{avatar($space[uid],small)}-->" alt="$space[username]" class="avatar" /></a>
<h1>$SConfig[gamename]</h1>
<span class="spacelink">我的现金:$SConfig[dollar_sign] $myinfo[cash] 拥有积分:$space[credit] 个积分</span>
</div>
<div class="tabs_header">
<a href="?com=invite&app=slave" class="t_combutton">邀请好友(可获得 $SConfig[dollar_sign] $invite_amount)</a>
<ul class="tabs">
<li $active[main]><a href="?com=slave">首页</a></li>
<!--{if $op=="action"}-->
<li class="active"><a href="?com=slave&op=action&uid=$uid">任务</a></li>
<!--{/if}-->
<li $active[market]><a href="?com=slave&op=market">奴隶市场</a></li>
<li $active[rank]><a href="?com=slave&op=rank">排行榜</a></li>
<li $active[setup]><a href="?com=slave&op=setup">游戏设置</a></li>
<li $active[credit]><a href="?com=slave&op=credit">积分兑换</a></li> <li $active[help]><a href="?com=slave&op=help">帮助</a></li>
</ul>
</div>
<!--{if $op=="credit"}-->
<div class="slave_block" style="padding:10px 20px 30px 20px;">
<div class=c_form>
<table cellspacing="0" cellpadding="0" class="formtable">
<tr><th>拥有现金:</th><td><span class="money">$SConfig[dollar_sign] $myinfo[cash]</span></td></tr>
<tr><th>拥有积分:</th><td><span class="num">$space[credit]</span></td></tr>
<tr><th>兑换规则:</th><td>1积分=50现金/50现金=1积分</td></tr>
<form action="component.php?com=slave&op=credit" method="POST">
<tr><th>输入数量:</th><td><input type="text" name="credit" value="1" size="10"> </td></tr>
<tr><th>兑换类型:</th><td><input name="code" type="radio" value="xianjin" checked>现金 <input name="code" type="radio" value="jifen">积分 </td></tr>
<tr><th> </th><td><input type=submit name="submitcredit" value="兑换" class="submit">
<input type=button name="submit" value="取消" class="submit" onclick="javascript:history.back()">
</td></tr>
</form>
</table>
<br>
<b>积分交易一旦提交不可恢复,请确定无误后再进行操作,积分减少会影响到您的会员级别</b>
</div>
</div>
<!--{/if}-->
另外在components/slave/language.php的
'license_error' => '本插件只授权于一个域名使用,如有任何问题请联系插件作者,谢谢!',
后面加上:
'credit_err' => '请输入兑换数量',
'credit_round_err' => '请输入\\1 的整倍数',
'xianjin_successful' => '兑换现金成功!',
'jifen_successful' => '兑换积分成功!',
*红色表示要修改添加部分
效果图:
|