[TUTs] k.Mission v1.0.1

  Bài viết hay nhất1
First topic message reminder :

Code: k.Missionv1.0.1
Written by: K. - KirigayaKazuto
Description: Mod được lấy ý tưởng từ Mod của vBulletin, nhằm cho các member lười post bài có hứng thú để post bài.
Phiên bản: Hiện giờ mới ứng dụng trên Invision, mình sẽ tiếp tục làm cho punBBphpBB3
Note:
Code chỉ post trên DEVs hoặc ChinhPhục, không sao chép bài viết đi nơi khác.

Những người đã tham gia phiên bản thử nghiệm: @NCat, @tanvking, @bucnong1

Show một vài hình ảnh của Mod:
Trước khi hoàn thành:
[You must be registered and logged in to see this image.]
Sau khi hoàn thành:
[You must be registered and logged in to see this image.]
Click để hiện nội dung:
[/color]

Phiên bản hiện tại: Invision

--- Bài viết hướng dẫn chưa cụ thể ---

B1 APC > Display > Templates > Quản Lý Tổng Thể > overall_header
Chèn xuống dưới </body>
Code:
<div id="kMission_overlay">
  <div id="kMission">
    <h2>Nhiệm vụ hôm nay <img id="kMiss_Close" src="http://i.imgur.com/Ca5rZ51.png" title="Đóng" /></h2><br />
    <div id="kMission_row">
      <div class="missionrow" id="mission_post">
        Gửi <strong>3</strong> bài
        <div class="right"><strong></strong>/<strong></strong></div>
      </div>
      <div class="missionrow" id="mission_repu">
        Kiếm <strong>7</strong> vàng
        <div class="right"><strong></strong>/<strong></strong></div>
      </div>
    </div>
    <br />
    <div class="endmiss_wait endmiss" id="missioncheck"><strong>Hoàn thành!!</strong></div>
    <div id="kmdata"></div>
  </div>
</div>

B2 APC > Display > Pictures and Colors > Colors > CSS Stylesheet
Code:
/* k.Mission v1.0.1 by Kirigaya Kazuto - devs.forumvi.com */#kMission_overlay{position:fixed;z-index:999;left:0;top:0;width:100%;height:100%;display:none;background:rgba(0,0,0,0.7);}
#kMission{padding:10px;width:40%;background:#fff;box-shadow:0 0 0.5em #000;border:1px solid #aaa;margin:15% auto;min-width:500px;}
#kMission h2{font-size:15px;line-height:normal;font-weight:bold;padding:0 5px;color:#699;border-bottom:2px solid;}
#kMission .missionrow{padding:10px 2px;border-bottom:1px solid #aaa;font-size:13px;color:#ff0000;}
#kMission .endmiss{width:40%;text-align:center;margin:0 auto;font-size:14px;border:1px solid;padding:5px 5px 5px 30px;}
#kMission .endmiss_wait{color:#333;background:url(http://i.imgur.com/zEYqdjo.png) no-repeat left 15px center #ddd;}
#kMission .endmiss_ok{cursor:pointer;color:#363;background:url(http://i.imgur.com/8Fo4pLO.png) no-repeat left 15px center #DFC;}
#kMission .endmiss_give{cursor:pointer;color:#F90;background:url(http://i.imgur.com/D7uCD7k.png) no-repeat left 15px center #FDA;}
#kMission_new{position:fixed;top:100px;left:15px;cursor:pointer;}
#kMission img#kMiss_Close{cursor:pointer;float:right;}

B3 Tạo 1 profield mới như sau:
Spoiler:
Xem và ghi nhớ ID của field này.
Vd: Nguyên ID của field là profile_field_2_2
2 là ID của field

B4 Tạo 1 subforum mới và chỉnh số tiền nhận được như sau:
Spoiler:

B4,5 Tạo 1 topic mới trong forum vừa tạo, ghi nhớ ID topic.
Vd: Link topic này là: [You must be registered and logged in to see this link.]
Thì 628 là ID topic.

B5 APC > Modules > HTML & JAVASCRIPT > Javascript codes management > Tạo 1 js mới
  • Title * : k.Mission
  • Placement : In all the pages
  • Javascript Code * :
    Code:
    /* kMission by K. (KirigayaKazuto) - devs.forumvi.com */
    function viTime(time) {
      var a = (new Date(time)).toString().split(/\s/);
      return a[2] + "/" + {
        Jan: "01",
        Feb: "02",
        Mar: "03",
        Apr: "04",
        May: "05",
        Jun: "06",
        Jul: "07",
        Aug: "08",
        Sep: "09",
        Oct: "10",
        Nov: "11",
        Dec: "12"
      }[a[1]] + "/" + a[3] + " " + a[4]
    }
    $(function () {
      var endmiss_f = '0'; // ID topic nhận nhiệm vụ
      var today_post = '10'; // Số post nhiệm vụ hôm nay
      var today_repu = '4'; // Số thanks phải nhận để hoàn thành
      $('#kmdata').load('/u' + _userdata.user_id + ' #field_id2 .field_uneditable', function () {
        $(this).hide();
        var a = $('#kmdata .field_uneditable').text(); // Lấy data
        var b = a.split('|'); // Phân chia data
        var c = _userdata.user_posts; // Lấy số post
        var d = _userdata.point_reputation; // Lấy số repu
        var e = Math.round(c - b[0]); // Hôm nay đã làm bao nhiêu
        var f = Math.round(d - b[1]); // Hôm nay đã làm bao nhiêu
        $('#kMission').each(function () {
          $(this).find('#mission_post .right strong:first').append(e);
          $(this).find('#mission_repu .right strong:first').append(f);
          $(this).find('#mission_post .right strong:last').append(today_post);
          $(this).find('#mission_repu .right strong:last').append(today_repu);
          // Check nhiệm vụ
          if (e >= today_post) {
            $('#mission_post').css('color', '#363').append('<img src="http://i.imgur.com/8Fo4pLO.png" class="missionok" />');
          }
          if (f >= today_repu) {
            $('#mission_point').css('color', '#363').append('<img src="http://i.imgur.com/8Fo4pLO.png" class="missionok" />');
          }
          // Kiểm tra tiến độ
          var missok = $('#kMission').find('.missionok').length;
          // Xong nhiệm vụ
          if (missok == 2) {
            $('#missioncheck').removeClass('endmiss_wait').addClass('endmiss_ok');
          }
          // Xong/Chưa xong
          var kmissimg_new = 'http://i.imgur.com/d7W6Sti.gif',
               kmissimg = 'http://i.imgur.com/oi3s3Cj.png';
          if (_userdata.session_logged_in = "1") {
            $('#K-masthead').after('<div id="kMission_new"><img src="' + kmissimg_new + '" /></div>');
          }
          // Thời gian
          var nowtime = $('.current-time').text(), // Time hiện tại
            nowtimes = nowtime.split(': '), // Split time
            nowtimevi = viTime(nowtimes[1]), // Việt hóa time (by zzBaivong)
            nowtimevi0 = b[2], //Time đã làm của ngày hôm qua
            misstimes1 = nowtimevi.split(' '); // Split Time
          // Hôm nay đã xong
          if (misstimes1[0] == nowtimevi0) {
            $(this).html('<h2>Bạn đã hoàn thành nhiệm vụ<img id="kMiss_Close" src="http://i.imgur.com/Ca5rZ51.png" title="Đóng" /></h2><br /><br /><center><strong>Bạn đã hoàn thành nhiệm vụ hôm nay!<br />Hãy ghé lại vào ngày mai nhé!!</strong></center><br /><br />');
            $('#kMission_new').find('img').attr('src', kmissimg);
          }
          // Chưa có nhiệm vụ
          if (a == 0) {
            $('#missioncheck').removeClass('endmiss_wait');
            $('#missioncheck').addClass('endmiss_give');
            $('#missioncheck').find('strong').replaceWith('<strong>Nhận nhiệm vụ</strong>');
            $(this).find('h2').html('Bạn chưa nhận nhiệm vụ <img id="kMiss_Close" src="http://i.imgur.com/Ca5rZ51.png" title="Đóng" />');
            $('#kMission_row').html('<br /><br /><center><strong>Bạn chưa bắt đầu nhận nhiệm vụ!<br />Hãy nhận nhiệm vụ để có phần thưởng mỗi ngày nhé!</strong></center><br /><br />');
          }
          // Đóng / Mở nhiệm vụ
          $('#kMission_new').click(function () {
            $('body').addClass('kOvH');
            $('#kMission_overlay').show();
          });
          $('#kMiss_Close').click(function () {
            $('body').removeClass('kOvH');
            $('#kMission_overlay').hide();
          });
          // Nhận tiền nhiệm vụ
          $('#missioncheck.endmiss_give').click(function () {
            $.post("/ajax_profile.forum?jsoncallback=?", {
              id: "2",
              user: _userdata.user_id,
              active: "1",
              content: '[["profile_field_2_2", "' + c + '|' + d + '"]]',
              tid: $("#qjump input[name='tid']").val()
            }, {}, "json").done(function (data) {
              alert('Đã nhận');
            }).fail(function () {
              alert('Lỗi! Liên hệ với BQT để biết thêm thông tin hoặc báo lỗi!');
            }).always(function () {
              window.location.href = window.location;
            });
          });
          $('#missioncheck.endmiss_ok').click(function () {
            $.post("/ajax_profile.forum?jsoncallback=?", {
              id: "2", // ID của field
              user: _userdata.user_id,
              active: "1",
              content: '[["profile_field_2_2", "' + c + '|' + d + '|' + misstimes1[0] + '"]]', // ID của field
              tid: $("#qjump input[name='tid']").val()
            }, {}, "json").done(function (data) {
              alert('Bạn đã hoàn thành nhiệm vụ hôm nay!');
              alert('Đã nhận 500Gold, hãy quay lại vào ngày mai nhé!!');
            }).fail(function () {
              alert('Lỗi! Liên hệ với BQT để biết thêm thông tin hoặc báo lỗi!');
            }).always(function () {
              window.location.href = window.location;
            });
            $.post("/post", {
              mode: "reply",
              t: endmiss_f,
              message: "[Đã hoàn thành nhiệm vụ ngày]",
              post: "Send"
            });
          });
        });
      });
    });


Lưu ý Thông số:
Code:
  var endmiss_f = '0'; // ID topic nhận nhiệm vụ
  var today_post = '10'; // Số post nhiệm vụ hôm nay
  var today_repu = '4'; // Số thanks phải nhận để hoàn thành
Code:
        $.post("/ajax_profile.forum?jsoncallback=?", {
          id: "2", // ID của field
          user: _userdata.user_id,
          active: "1",
          content: '[["profile_field_2_2", "' + c + '|' + d + '"]]', // ID của field
          tid: $("#qjump input[name='tid']").val()
        }

Sửa 0 trong endmiss_f = '0' thành ID topic vừa tạo
10 là số post phải hoàn thành hôm nay
4 là số thanks phải nhận hôm nay.
Sửa 2 trong dòng:
Code:
          id: "2", // ID của field
thành ID field của bạn.

Sửa profile_field_2_2 trong đoạn
Code:
          content: '[["profile_field_2_2", "' + c + '|' + d + '"]]', // ID của field
thành nguyên id của field

© K. - devs.forumvi.com
  Bài viết hay nhất26
PunBB khó làm là bởi nó phức tạp hơn mình tưởng =)) Nếu lấy time từ máy thì sẽ có những thành viên "ranh ma" bug (đổi ngày giờ trên máy để tiếp tục nhiệm vụ)
Vì Invision có time sẵn ở dưới nên mình làm được, còn các Version còn lại đang tìm hiểu
The author of this message was banned from the forum - See the message
The author of this message was banned from the forum - See the message
  Bài viết hay nhất29
Mình đọc đi đọc lại vẫn k hiểu bài này @@ áp dụng nó là gì
The author of this message was banned from the forum - See the message
  Bài viết hay nhất31

phutu01 wrote:Mình đọc đi đọc lại vẫn k hiểu bài này @@ áp dụng nó là gì

Kiểu như: "Hôm nay lười vãi, chán vãi, chả muốn viết bài gì cả"
Nhưng thấy có nhiệm vụ "À há, kiếm tý Gold chơi nào"
  Bài viết hay nhất32
Cũng thú vị đấy <3
  Bài viết hay nhất33
thank u :D
  Bài viết hay nhất34
Like mạnh cho ý tưởng toẹt vời của bác lun, mong phiên bản bunbb nhóe :)
  Bài viết hay nhất35
You cannot reply to topics in this forum