How to get players'online time and how to distribute leaves automatically?

Results 1 to 9 of 9
  1. #1
    Valued Member wxk0248 is offline
    MemberRank
    Jan 2015 Join Date
    114Posts

    Support How to get players'online time and how to distribute leaves automatically?

    I found a private server called LMS Forsaken World, which introduced you will receive 250 Leaves for every hour spent online.(500 on weekends)"

    Is anyone know how to get players'online time and how to distribute leaves automatically?

    I know that automatic leaf distribution can be achieved through sql, but how does it relate to online time?


  2. #2
    Novice denval is offline
    MemberRank
    Dec 2013 Join Date
    4Posts

    Re: How to get players'online time and how to distribute leaves automatically?

    You can write a script in php or another language that will read online once per hour and send sql queries. You can get online by sending a request to gdeliveryd. Query structure can be obtained with gdeliveryd.Here is the structure online:
    PROTOCOL_GMLISTONLINEUSER = 0x160,

    struct __cppobj GMListOnlineUser: Protocol{
    int64_t gmroleid;
    unsigned int localsid;
    int handler;
    Octets cond;};

    struct __cppobj GMListOnlineUser_Re: Protocol{
    int retcode;
    int64_t gmroleid;
    unsigned int localsid;
    int handler;
    GMPlayerInfoVector userlist;};

    struct __cppobj GMPlayerInfo: Rpc :: Data{
    int userid;
    int64_t roleid;
    int linkid;
    unsigned int localsid;
    int gsid;
    char status;
    Octets name;};

    You can see about the example of the game perfect world
    Main Page — Perfect World Develop Wiki

  3. #3
    Valued Member wxk0248 is offline
    MemberRank
    Jan 2015 Join Date
    114Posts

    Re: How to get players'online time and how to distribute leaves automatically?

    I tried the ReadPacket and WritePacket by php . It didn't seem to work properly in FW.I don't know what went wrong.
    I test this example Код класса PHP для работы с пакетами — Perfect World Develop Wiki

    packet_class.php
    Code:
    <?// "Packet Class PW".// By JonMagon (Desmond Hume)class ReadPacket {	public $data, $pos; 	function __construct($obj = null){		$this->data = $obj->response;	} 	public function ReadBytes($length){		$value = substr($this->data, $this->pos, $length);		$this->pos += $length; 		return $value;	} 	public function ReadUByte(){		$value = unpack("C", substr($this->data, $this->pos, 1));		$this->pos++; 		return $value[1];	} 	public function ReadFloat(){		$value = unpack("f", strrev(substr($this->data, $this->pos, 4)));		$this->pos += 4; 		return $value[1];	} 	public function ReadUInt32(){		$value = unpack("N", substr($this->data, $this->pos, 4));		$this->pos += 4; 		return $value[1];	} 	public function ReadUInt16(){		$value = unpack("n", substr($this->data, $this->pos, 2));		$this->pos += 2; 		return $value[1];	} 	public function ReadOctets(){		$length = $this->ReadCUInt32();		$value  = unpack("H*", substr($this->data, $this->pos, $length));		$this->pos += $length; 		return $value[1];	} 	public function ReadUString(){		$length = $this->ReadCUInt32(); 		$value  = iconv("UTF-16", "UTF-8", substr($this->data, $this->pos, $length)); // LE?		$this->pos += $length; 		return $value;	} 	public function ReadPacketInfo(){		$packetinfo['Opcode'] = $this->ReadCUInt32();		$packetinfo['Length'] = $this->ReadCUInt32(); 		return $packetinfo;	} 	public function Seek($value){		$this->pos += $value;	} 	public function ReadCUInt32(){		$value = unpack("C", substr($this->data, $this->pos, 1));		$value = $value[1];		$this->pos++; 		switch ($value & 0xE0) {			case 0xE0:				$value = unpack("N", substr($this->data, $this->pos, 4));				$value = $value[1];				$this->pos += 4;				break;			case 0xC0:				$value = unpack("N", substr($this->data, $this->pos - 1, 4));				$value = $value[1] & 0x1FFFFFFF;				$this->pos += 3;				break;			case 0x80:			case 0xA0:				$value = unpack("n", substr($this->data, $this->pos - 1, 2));				$value = $value[1] & 0x3FFF;				$this->pos++;				break;		} 		return $value;	}}class WritePacket {	public $request, $response, $passestablished = false, $getresponse = true; 	public function WriteBytes($value){		$this->request .= $value;	} 	public function WriteUByte($value){		$this->request .= pack("C", $value);	} 	public function WriteFloat($value){		$this->request .= strrev(pack("f", $value));	} 	public function WriteUInt32($value){		$this->request .= pack("N", $value);	} 	public function WriteUInt16($value){		$this->request .= pack("n", $value);	} 	public function WriteOctets($value){		if (ctype_xdigit($value))			$value = pack("H*", $value);		$this->request .= $this->CUInt(strlen($value));		$this->request .= $value;	} 	public function WriteUString($value, $coding = "UTF-16LE"){		$value = iconv("UTF-8", $coding, $value);		$this->request .= $this->CUInt(strlen($value));		$this->request .= $value;	} 	public function Pack($value){		$this->request = $this->CUInt($value) . $this->CUInt(strlen($this->request)) . $this->request;	} 	public function Unmarshal(){		return $this->CUInt(strlen($this->request)) . $this->request;	} 	public function Send($address, $port){		$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); 		if (socket_connect($socket, $address, $port)) {			socket_set_block($socket); 			if ($this->passestablished)				socket_recv($socket, $trash, 1024, 0); 			$send = socket_send($socket, $this->request, 131072, 0); 			if ($this->getresponse)				$recv = socket_recv($socket, $this->response, 131072, 0); 			socket_set_nonblock($socket);			socket_close($socket); 			return true;		} else return false;	} 	public function WriteCUInt32($value){		$this->request .= $this->CUInt($value);	} 	private function CUInt($value){		if ($value <= 0x7F)			return pack("C", $value);		else if ($value <= 0x3FFF)			return pack("n", ($value | 0x8000));		else if ($value <= 0x1FFFFFFF)			return pack("N", ($value | 0xC0000000));		else			return pack("C", 0xE0) . pack("N", $value);	}}?>
    GetRoleNameByRoleId.php
    Code:
    <? //=====脚本由Mcncc.com - 这家伙很懒汉化 =====//  //=====For MySQL Database=====//	include("packet_class.php");		$Data = '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />	<form action=GetRoleNameByRoleId.php method=post>	 RoleId: <input type=text name=login><br><br>	<input type=submit name=submit value="go">	</form>';			if (isset($_POST['login']))		{						$Login = $_POST['login'];						$Login = StrToLower(Trim($Login));						if (empty($Login))			{			    echo "All fields is empty.";			}							elseif (ereg("[^0-9]", $Login, $Txt))				{					echo "RoleId error.";				}			else 				{					$GetRoleBase = new WritePacket();					$GetRoleBase -> WriteUInt32(-1); // always					$GetRoleBase -> WriteUInt32($Login); // userid					$GetRoleBase -> Pack(0xBC5); // opcode										echo "get RoleId:".$Login;					if (!$GetRoleBase -> Send("192.168.200.100", 29400)) // send to gamedbd					{						echo "error";						return;					}										$GetRoleBase_Re = new ReadPacket($GetRoleBase); // reading packet from stream						$packetinfo = $GetRoleBase_Re -> ReadPacketInfo(); // read opcode and length					$GetRoleBase_Re -> ReadUInt32(); // always									echo $GetRoleBase_Re -> ReadUInt32(); // retcode					$GetRoleBase_Re -> ReadUByte(); // version					$GetRoleBase_Re -> ReadUInt32(); // id					echo $GetRoleBase_Re -> ReadUString(); // show rolename				}							}	echo $Data;?>

  4. #4
    JD | Web Developer mrosenov is offline
    MemberRank
    Jun 2012 Join Date
    BulgariaLocation
    556Posts

    Re: How to get players'online time and how to distribute leaves automatically?

    Quote Originally Posted by wxk0248 View Post
    I tried the ReadPacket and WritePacket by php . It didn't seem to work properly in FW.I don't know what went wrong.
    I test this example Код класса PHP для работы с пакетами — Perfect World Develop Wiki

    packet_class.php
    Code:
    <?// "Packet Class PW".// By JonMagon (Desmond Hume)class ReadPacket {	public $data, $pos; 	function __construct($obj = null){		$this->data = $obj->response;	} 	public function ReadBytes($length){		$value = substr($this->data, $this->pos, $length);		$this->pos += $length; 		return $value;	} 	public function ReadUByte(){		$value = unpack("C", substr($this->data, $this->pos, 1));		$this->pos++; 		return $value[1];	} 	public function ReadFloat(){		$value = unpack("f", strrev(substr($this->data, $this->pos, 4)));		$this->pos += 4; 		return $value[1];	} 	public function ReadUInt32(){		$value = unpack("N", substr($this->data, $this->pos, 4));		$this->pos += 4; 		return $value[1];	} 	public function ReadUInt16(){		$value = unpack("n", substr($this->data, $this->pos, 2));		$this->pos += 2; 		return $value[1];	} 	public function ReadOctets(){		$length = $this->ReadCUInt32();		$value  = unpack("H*", substr($this->data, $this->pos, $length));		$this->pos += $length; 		return $value[1];	} 	public function ReadUString(){		$length = $this->ReadCUInt32(); 		$value  = iconv("UTF-16", "UTF-8", substr($this->data, $this->pos, $length)); // LE?		$this->pos += $length; 		return $value;	} 	public function ReadPacketInfo(){		$packetinfo['Opcode'] = $this->ReadCUInt32();		$packetinfo['Length'] = $this->ReadCUInt32(); 		return $packetinfo;	} 	public function Seek($value){		$this->pos += $value;	} 	public function ReadCUInt32(){		$value = unpack("C", substr($this->data, $this->pos, 1));		$value = $value[1];		$this->pos++; 		switch ($value & 0xE0) {			case 0xE0:				$value = unpack("N", substr($this->data, $this->pos, 4));				$value = $value[1];				$this->pos += 4;				break;			case 0xC0:				$value = unpack("N", substr($this->data, $this->pos - 1, 4));				$value = $value[1] & 0x1FFFFFFF;				$this->pos += 3;				break;			case 0x80:			case 0xA0:				$value = unpack("n", substr($this->data, $this->pos - 1, 2));				$value = $value[1] & 0x3FFF;				$this->pos++;				break;		} 		return $value;	}}class WritePacket {	public $request, $response, $passestablished = false, $getresponse = true; 	public function WriteBytes($value){		$this->request .= $value;	} 	public function WriteUByte($value){		$this->request .= pack("C", $value);	} 	public function WriteFloat($value){		$this->request .= strrev(pack("f", $value));	} 	public function WriteUInt32($value){		$this->request .= pack("N", $value);	} 	public function WriteUInt16($value){		$this->request .= pack("n", $value);	} 	public function WriteOctets($value){		if (ctype_xdigit($value))			$value = pack("H*", $value);		$this->request .= $this->CUInt(strlen($value));		$this->request .= $value;	} 	public function WriteUString($value, $coding = "UTF-16LE"){		$value = iconv("UTF-8", $coding, $value);		$this->request .= $this->CUInt(strlen($value));		$this->request .= $value;	} 	public function Pack($value){		$this->request = $this->CUInt($value) . $this->CUInt(strlen($this->request)) . $this->request;	} 	public function Unmarshal(){		return $this->CUInt(strlen($this->request)) . $this->request;	} 	public function Send($address, $port){		$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); 		if (socket_connect($socket, $address, $port)) {			socket_set_block($socket); 			if ($this->passestablished)				socket_recv($socket, $trash, 1024, 0); 			$send = socket_send($socket, $this->request, 131072, 0); 			if ($this->getresponse)				$recv = socket_recv($socket, $this->response, 131072, 0); 			socket_set_nonblock($socket);			socket_close($socket); 			return true;		} else return false;	} 	public function WriteCUInt32($value){		$this->request .= $this->CUInt($value);	} 	private function CUInt($value){		if ($value <= 0x7F)			return pack("C", $value);		else if ($value <= 0x3FFF)			return pack("n", ($value | 0x8000));		else if ($value <= 0x1FFFFFFF)			return pack("N", ($value | 0xC0000000));		else			return pack("C", 0xE0) . pack("N", $value);	}}?>
    GetRoleNameByRoleId.php
    Code:
    <? //=====脚本由Mcncc.com - 这家伙很懒汉化 =====//  //=====For MySQL Database=====//	include("packet_class.php");		$Data = '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />	<form action=GetRoleNameByRoleId.php method=post>	 RoleId: <input type=text name=login><br><br>	<input type=submit name=submit value="go">	</form>';			if (isset($_POST['login']))		{						$Login = $_POST['login'];						$Login = StrToLower(Trim($Login));						if (empty($Login))			{			    echo "All fields is empty.";			}							elseif (ereg("[^0-9]", $Login, $Txt))				{					echo "RoleId error.";				}			else 				{					$GetRoleBase = new WritePacket();					$GetRoleBase -> WriteUInt32(-1); // always					$GetRoleBase -> WriteUInt32($Login); // userid					$GetRoleBase -> Pack(0xBC5); // opcode										echo "get RoleId:".$Login;					if (!$GetRoleBase -> Send("192.168.200.100", 29400)) // send to gamedbd					{						echo "error";						return;					}										$GetRoleBase_Re = new ReadPacket($GetRoleBase); // reading packet from stream						$packetinfo = $GetRoleBase_Re -> ReadPacketInfo(); // read opcode and length					$GetRoleBase_Re -> ReadUInt32(); // always									echo $GetRoleBase_Re -> ReadUInt32(); // retcode					$GetRoleBase_Re -> ReadUByte(); // version					$GetRoleBase_Re -> ReadUInt32(); // id					echo $GetRoleBase_Re -> ReadUString(); // show rolename				}							}	echo $Data;?>
    Thats, because you're using packets for PW I think there are not much difference, but still other game tho :D
    Also if I'm not wrong the currently online accounts should be listed in your MySQL database under the table "point" or "online"
    About the online rewards you can try this script Hourly Script

  5. #5
    Novice denval is offline
    MemberRank
    Dec 2013 Join Date
    4Posts

    Re: How to get players'online time and how to distribute leaves automatically?

    I do not understand how you got to this code, below I dropped the files for 1 day. Every script launch runs through there, the ego can be launched via cron once an hour.
    packet_class.php

    1 day

    config_db.php

    1day

    GetRoleNameByRoleId.php

    1 day


    I advise you to correct the part that works with mysql. and if someone is not lazy and rewrite a little code put below in the post

  6. #6
    Valued Member wxk0248 is offline
    MemberRank
    Jan 2015 Join Date
    114Posts

    Re: How to get players'online time and how to distribute leaves automatically?

    Thank you very much,it's worked。I find packet_class.php in http://pwdev.ru/index.php/Main_Page 。It seems to be used for PW, not FW

    - - - Updated - - -

    Quote Originally Posted by denval View Post
    I do not understand how you got to this code, below I dropped the files for 1 day. Every script launch runs through there, the ego can be launched via cron once an hour.
    packet_class.php

    1 day

    config_db.php

    1day

    GetRoleNameByRoleId.php

    1 day


    I advise you to correct the part that works with mysql. and if someone is not lazy and rewrite a little code put below in the post
    1.pngI found another problem,how to send the parameters like "GRoleInventory"?

    - - - Updated - - -

    Quote Originally Posted by mrosenov View Post
    Thats, because you're using packets for PW I think there are not much difference, but still other game tho :D
    Also if I'm not wrong the currently online accounts should be listed in your MySQL database under the table "point" or "online"
    About the online rewards you can try this script Hourly Script
    thx,this is also a solution。There may be a problem,when you need to shut down the server to update something, the database table fields seem to be too late to update.

  7. #7
    Novice denval is offline
    MemberRank
    Dec 2013 Join Date
    4Posts

    Re: How to get players'online time and how to distribute leaves automatically?

    I told Visha that a site as an example of working with a script can be taken, the very structure and how to send data should be taken from services like gamedbd or gdeliveryd. Below is a structure for sending mails
    struct __cppobj GRoleInventory : Rpc::Data{
    int id;
    int pos;
    __int16 reserved1;
    __int16 count;
    __int16 reserved2;
    __int16 max_count;
    Octets data;
    int proctype;
    int client_size;
    int expire_date;
    int guid1;
    int guid2;
    };

    struct __cppobj SysSendMail : Protocol{
    unsigned int tid;
    int sysid;
    unsigned __int8 sys_type;
    int64_t receiver;
    Octets title;
    Octets context;
    GRoleInventory attach_obj;
    unsigned int attach_money;
    };

    PROTOCOL_SYSSENDMAIL = 0x1076

    On that site of the structure for the game pw, if you need to play, the fw will have to be manually searched and used.

  8. #8
    Valued Member wxk0248 is offline
    MemberRank
    Jan 2015 Join Date
    114Posts

    Re: How to get players'online time and how to distribute leaves automatically?

    Quote Originally Posted by denval View Post
    I told Visha that a site as an example of working with a script can be taken, the very structure and how to send data should be taken from services like gamedbd or gdeliveryd. Below is a structure for sending mails
    struct __cppobj GRoleInventory : Rpc::Data{
    int id;
    int pos;
    __int16 reserved1;
    __int16 count;
    __int16 reserved2;
    __int16 max_count;
    Octets data;
    int proctype;
    int client_size;
    int expire_date;
    int guid1;
    int guid2;
    };

    struct __cppobj SysSendMail : Protocol{
    unsigned int tid;
    int sysid;
    unsigned __int8 sys_type;
    int64_t receiver;
    Octets title;
    Octets context;
    GRoleInventory attach_obj;
    unsigned int attach_money;
    };

    PROTOCOL_SYSSENDMAIL = 0x1076

    On that site of the structure for the game pw, if you need to play, the fw will have to be manually searched and used.
    2.pngYeah, I know how to get the structure of FW.Thanks very much,i've tried to send an email successfully.
    Last edited by wxk0248; 19-04-19 at 04:42 PM.

  9. #9
    Valued Member wxk0248 is offline
    MemberRank
    Jan 2015 Join Date
    114Posts

    Re: How to get players'online time and how to distribute leaves automatically?

    Quote Originally Posted by denval View Post
    I told Visha that a site as an example of working with a script can be taken, the very structure and how to send data should be taken from services like gamedbd or gdeliveryd. Below is a structure for sending mails
    struct __cppobj GRoleInventory : Rpc::Data{
    int id;
    int pos;
    __int16 reserved1;
    __int16 count;
    __int16 reserved2;
    __int16 max_count;
    Octets data;
    int proctype;
    int client_size;
    int expire_date;
    int guid1;
    int guid2;
    };

    struct __cppobj SysSendMail : Protocol{
    unsigned int tid;
    int sysid;
    unsigned __int8 sys_type;
    int64_t receiver;
    Octets title;
    Octets context;
    GRoleInventory attach_obj;
    unsigned int attach_money;
    };

    PROTOCOL_SYSSENDMAIL = 0x1076

    On that site of the structure for the game pw, if you need to play, the fw will have to be manually searched and used.
    I found a new problem to ask you.In "RoleList",how to pass the parameters of the pointer type,like "Protocol::Manager *manager"?
    3.jpg



Advertisement