[分享]聊天室頭銜及讓玩家自行更改頭銜(聊天室v1.6)

WOG設定安裝教學

版主: 涅魂, 簫哥

leo199345
 
文章: 198
註冊時間: 2006-01-18 9:32 pm

[分享]聊天室頭銜及讓玩家自行更改頭銜(聊天室v1.6)

文章leo199345 » 2007-08-10 11:36 pm

先說明
暫時只在聊天室v1.6試過
ajax+php版不知道
另外,小弟處男之作,,多多支持 :D

預覽圖:
圖檔
[hr]

安裝前請先安裝遊戲管理台聊天室 Ver 1.6

在資料庫增加
代碼: 選擇全部
ALTER TABLE `wog_player` ADD `p_chatname` VARCHAR( 64 ) NOT NULL DEFAULT [color=red]'預設頭銜'[/color];"
ADD `p_chatcolor` VARCHAR( 15 ) NOT NULL DEFAULT [color=red]'預設顏色'[/color];"


打開chat.php
尋找
代碼: 選擇全部
$p=$DB_site->query_first('SELECT p_id,p_name,p_g_id,t_id FROM wog_player WHERE p_id='.$user_id);


改成
代碼: 選擇全部
$p=$DB_site->query_first('SELECT p_id,p_name,p_g_id,t_id,p_chatname,p_chatcolor FROM wog_player WHERE p_id='.$user_id);


尋找
代碼: 選擇全部
case 1:      //全體+其他
default:
$export_title='<a href=javascript:parent.yesname("'.$p['p_name'].'")>'.$p['p_name'].'</a> 說:';
break;


改成
代碼: 選擇全部
case 1:      //全體+其他
default:
$export_title='<b><font color="'.$p['p_chatcolor'].'">『'.$p['p_chatname'].'』</font></b><a href=javascript:parent.yesname("'.$p['p_name'].'")>'.$p['p_name'].'</a> 說:';
break;


打開acpmain.php
在function admin_player()內
尋找
代碼: 選擇全部
<tr>
<td class="b1">玩家密碼:<?=$getuadmin[p_password];?> <input class='text' size="8" value="<?=$getuadmin[p_password];?>" name="pass"><br>
 ★請輸入4~8字內的半形英數。</td>
</tr>


後面,加上
代碼: 選擇全部
<tr>
<td class="b1">玩家聊天頭銜:<?=$getuadmin[p_chatname];?><input class='text' size="8" value="<?=$getuadmin[p_chatname];?>" name="p_chatname"><br>
色碼:<?=$getuadmin[p_chatcolor];?><input class='text' size="8" value="<?=$getuadmin[p_chatcolor];?>" name="p_chatcolor">
</td>
</tr>


在function admin_player_sub內
尋找
代碼: 選擇全部
$d_item_id = $_POST["d_item_id"];


下面,加上
代碼: 選擇全部
$p_chatname = $_POST["p_chatname"];
$p_chatcolor = $_POST["p_chatcolor"];


尋找
代碼: 選擇全部
,p_sat_name='".$p_sat_name."'


後面,加上
代碼: 選擇全部
,p_chatname='".$p_chatname."',p_chatcolor='".$p_chatcolor."'


完成,有問題請發問!

[hr]
讓會員自行更改頭銜
打開wog_act.php,找
代碼: 選擇全部
         case "kill":
            $wog_act_class->kill();
         break;


下加
代碼: 選擇全部
         case "ch_chat":
         $wog_act_class->ch_chat($HTTP_COOKIE_VARS["wog_cookie"]);
         break;

儲存,關閉

打開wog_act_chara.php,找
代碼: 選擇全部
   function get_password($email)
   {
   ........
   }


下加
代碼: 選擇全部
function ch_chat($user_id)
{
   global $DB_site,$_POST,$wog_arry,$wog_act_class;
   $ch_chat_money=0; //更換頭銜費用
   $p=$DB_site->query_first("select p_money from wog_player where p_id=".$user_id."");
   if($p[p_money]<$ch_chat_money){
   alertWindowMsg("金錢不足,最少需要$ch_chat_money"); 
   }else{
      $DB_site->query("update wog_player set p_chatname='".$_POST["temp_id"]."',p_chatcolor='".$_POST["temp_id2"]."',p_money=p_money-".$ch_chat_money." where p_id=".$user_id);
      showscript("parent.job_end(25)");
   }
}

儲存,關閉

打開wog.js,在適當位置加上
代碼: 選擇全部
<input type="button" value="更換聊天頭銜" onClick="parent.ch_chat()">



代碼: 選擇全部
function p1()
{
....
}


下加
代碼: 選擇全部
function ch_chat()
{
   var f=parent.wog_view.document;
   message_cls();
   f.write(temp_table1);
   f.write('<form action="wog_act.php" method="post" target="mission">');
   f.write('<tr><td>頭銜 <input type="text" name="name" size="3" maxlength="3"></td></tr>');
   f.write('<tr><td>色碼 <input type="text" name="color" size="6" maxlength="6"></td></tr>');
   f.write('<tr><td><img src="http://www.marybutterworth.net/rgb.gif"></td></tr>');
   f.write('<tr><td><input type="button" value="確定改頭銜" onClick="parent.act_click(\'chara\',\'ch_chat\',this.form.name.value,this.form.color.value)"></td></tr>');
   f.write('</form>');
   f.write(temp_table2);
}



代碼: 選擇全部
function job_end()
{
......
}


裡面順序加入
代碼: 選擇全部
s[25]="聊天室頭銜已更改!";


儲存,關閉

註:所有美化工作請按照自已的wog來更改

如有問題歡迎提出

涅魂 寫:<u>積分 +4</u>

分享修改

at 2007-08-11 05:34 pm



最後由 leo199345 於 2008-01-18 10:19 pm 編輯,總共編輯了 5 次。

a0936157248
 
文章: 61
註冊時間: 2005-07-16 9:56 pm

文章a0936157248 » 2007-08-11 1:46 pm

這種功能不錯唷@@ 只是不曉得能不能發揮在公會頭銜上面.. 因為工會頭銜只有好看沒辦法在聊天室出現><




涅魂
 
文章: 4463
註冊時間: 2004-01-04 11:17 am
來自: Taiwan
性別: 男生

文章涅魂 » 2007-08-11 5:37 pm

嗯,好文章,雖然沒辦法測試,但還是謝謝LEO的分享囉

而這若要跟公會頭銜合併的話也很簡單,在聊天室中加入判斷玩家頭銜的設定就可以了~


圖檔

leo199345
 
文章: 198
註冊時間: 2006-01-18 9:32 pm

[分享]玩家自行修改頭銜

文章leo199345 » 2008-01-18 8:23 pm

打開wog_act.php,找
代碼: 選擇全部
         case "kill":
            $wog_act_class->kill();
         break;


下加
代碼: 選擇全部
         case "ch_chat":
         $wog_act_class->ch_chat($HTTP_COOKIE_VARS["wog_cookie"]);
         break;

儲存,關閉

打開wog_act_chara.php,找
代碼: 選擇全部
   function get_password($email)
   {
   ........
   }


下加
代碼: 選擇全部
function ch_chat($user_id)
{
   global $DB_site,$_POST,$wog_arry,$wog_act_class;
   $ch_chat_money=0; //更換頭銜費用
   $p=$DB_site->query_first("select p_money from wog_player where p_id=".$user_id."");
   if($p[p_money]<$ch_chat_money){
   alertWindowMsg("金錢不足,最少需要$ch_chat_money"); 
   }else{
      $DB_site->query("update wog_player set p_chatname='".$_POST["temp_id"]."',p_chatcolor='".$_POST["temp_id2"]."',p_money=p_money-".$ch_chat_money." where p_id=".$user_id);
      showscript("parent.job_end(25)");
   }
}

儲存,關閉

打開wog.js,在適當位置加上
代碼: 選擇全部
<input type="button" value="更換聊天頭銜" onClick="parent.ch_chat()">



代碼: 選擇全部
function p1()
{
....
}


下加
代碼: 選擇全部
function ch_chat()
{
   var f=parent.wog_view.document;
   message_cls();
   f.write(temp_table1);
   f.write('<form action="wog_act.php" method="post" target="mission">');
   f.write('<tr><td>頭銜 <input type="text" name="name" size="3" maxlength="3"></td></tr>');
   f.write('<tr><td>色碼 <input type="text" name="color" size="6" maxlength="6"></td></tr>');
   f.write('<tr><td><img src="http://www.marybutterworth.net/rgb.gif"></td></tr>');
   f.write('<tr><td><input type="button" value="確定改頭銜" onClick="parent.act_click(\'ch\',\'ch_chat\',this.form.name.value,this.form.color.value)"></td></tr>');
   f.write('</form>');
   f.write(temp_table2);
}



代碼: 選擇全部
function job_end()
{
......
}


裡面順序加入
代碼: 選擇全部
s[25]="聊天室頭銜已更改!";


儲存,關閉

註:所有美化工作請按照自已的wog來更改

如有問題歡迎提出

原文已更新




回到 精華區

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 3 位訪客