마인크래프트 연동

마인크래프트 연동

QA

마인크래프트 연동

본문

마인크래프트 서버와 연동을 해서 페이지 이동시 명령어가 입력되는것 까지 확인했습니다.

근데 문제는 홈페이지 포인트를 마인크래프트 서버 포인트로 변환하는데, 오류가 걸려서요

변수를 어떻게 써야할지 모르겠어요..

 

point_inco_update (출금 완료시 페이지)


<?php
include_once('./_common.php');
include_once(G5_CAPTCHA_PATH.'/captcha.lib.php');
require_once("WebsenderAPI.php"); // Load Library
if ($is_guest)
    alert("로그인 후 이용해 주세요.", "/bbs/login.php");
if (!chk_captcha()) {
    alert('자동등록방지 숫자가 틀렸습니다.');
}
$mb = get_member($me_recv_mb_id);
$max_point = 999999999;
$wsr = new WebsenderAPI("서버아이피","비밀번호","포트"); // HOST , PASSWORD , PORT
if ($point > $max_point)
    alert('최대 출금 한도는 '.number_format($max_point).'P 입니다.');
if ($member['mb_point'] < $point)
    alert('포인트가 부족합니다.');
insert_point($member['mb_id'], "-".$point, "서버내 포인트로 ".number_format($point)."P 를 출금했습니다.", '@passive', $member['mb_id'], $member['mb_id'].'-'.uniqid(''));
$wsr->sendCommand("eco give" $member['mb_id'] $point);
$wsr->sendCommand("say" $member['mb_id'] "으로" $point "포인트");
    
alert('정상적으로 출금이 완료되었습니다.', "https://sybank.pw");
?>

 

여기서 API는


<?php
class WebsenderAPI{
    
    public $timeout = 30;
    var $host;
    var $password;
    var $port;
    var $socket;
    
    public function __construct($host, $password, $port){
        $this->host = gethostbyname($host);
        $this->password = $password;
        $this->port = $port;
    }
    public function __destruct(){
        if($this->socket)
            $this->disconnect();
    }
    public function connect(){
        @$this->socket = fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
        if(!$this->socket) return false;
        @$this->writeRawByte(1);
        @$this->writeString(hash("SHA512", $this->readRawInt().$this->password));
        return $this->readRawInt() == 1 ? true: false;
    }
    
    /*
    *   -> event is cancelled or command not entered this method msut be return false.
    */
    public function sendCommand($command){
        $this->writeRawByte(2);
        $this->writeString(base64_encode($command));
        return $this->readRawInt() == 1 ? true: false;
    }
    
    /*
    *   -> event is cancelled this method must be return false.
    */
    public function sendMessage($message){
        $this->writeRawByte(4);
        $this->writeString(base64_encode($message));
        return $this->readRawInt() == 1 ? true: false;
    }
    
    public function disconnect(){
        if(!$this->socket) return false;
        return $this->writeRawByte(3) ? true: false;
    }
    
    private function writeRawInt($i){
        @fwrite($this->socket, pack("N", $i), 4);
    }
    private function writeRawByte($b){
        @fwrite($this->socket, strrev(pack("C", $b)));
    }
    private function writeString($string){
        $array = str_split($string);
        $this->writeRawInt(count($array));
        foreach($array as &$cur){
            $v = ord($cur);
            $this->writeRawByte((0xff & ($v >> 8)));
            $this->writeRawByte((0xff & $v));
        }
    }
    private function readRawInt(){
        $a = $this->readRawByte();
        $b = $this->readRawByte();
        $c = $this->readRawByte();
        $d = $this->readRawByte();
        $i = ((($a & 0xff) << 24) | (($b & 0xff) << 16) | (($c & 0xff) << 8) | ($d & 0xff));
        if($i > 2147483648)
             $i -= 4294967296;
        return $i;
    }
        
    private function readRawByte(){
        $up = unpack("Ci", fread($this->socket, 1));
        $b = $up["i"];
        if($b > 127)
            $b -= 256;
        return $b;
    }
    
}
?>

입니다. 이걸 어떻게 써야지 함께 작동할까요..?

 

포인트 출금 페이지는

https://sybank.pw/bbs/point_inco.php

입니다.

 

로그인 하라고 뜨면

ttest

test1234

하시면 돼요!

$wsr->sendCommand("eco give" $member['mb_id'] $point);
$wsr->sendCommand("say" $member['mb_id'] "으로" $point "포인트");

이부분을 수정하면 될듯한데.. 이부분을 빼고 하면 작동이 돼요.. (포인트 빠져나가는것 까진)

이 질문에 댓글 쓰기 :

답변 1

헉 가입했네요 테스트 아이디 있었군요

 

bbs/memo.php 파일 쪽지보낼시 포인트차감 확인해서 그대로 쿼리 날려도 될듯한데요 

포인트 차감까지는 확인했는데..
$wsr->sendCommand("eco give" $member['mb_id'] $point);
$wsr->sendCommand("say" $member['mb_id'] "으로" $point "포인트");
이 부분이 안돼요.. 마인크래프트 라는 서버와 연동해서 포인트 차감되면서 함께 명령어도 입력되게끔 하는건데.. 이거를 다른식으로 작성해야 할것 같아서요..

답변을 작성하시기 전에 로그인 해주세요.
전체 0 | RSS
QA 내용 검색
  • 개별 목록 구성 제목 답변작성자조회작성일
  • 질문이 없습니다.

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT