How can I obtain VCMP master list information from other clients??

Started by Chicken, Feb 20, 2022, 08:07 AM

Previous topic - Next topic

Chicken

How can I get the  of servers name, online players name and IP addresses in the VCMP masterlist from other clients

habi

Not understood. You are running a server and want to obtain list of other servers ??

Chicken

Quote from: habi on Feb 20, 2022, 12:54 PMNot understood. You are running a server and want to obtain list of other servers ??
I want to make a website, how to get the server status on the website

habi

If you are building a website and you want the list of players name in the website there is a way. You will get the name of your server, gamemode, version and list of players playing in the server.
You have to create a udp socket in your website code. Are you scripting in php?
From this udp socket you have to send exactly two packets to the VCMP server you are running.
You must have port forwarding done already.
If so, VCMP Server will reply to this query with information mentioned on top.
Consider How can I send data with PHP to an IP address via UDP?

Chicken

Quote from: habi on Feb 21, 2022, 04:50 AMIf you are building a website and you want the list of players name in the website there is a way. You will get the name of your server, gamemode, version and list of players playing in the server.
You have to create a udp socket in your website code. Are you scripting in php?
From this udp socket you have to send exactly two packets to the VCMP server you are running.
You must have port forwarding done already.
If so, VCMP Server will reply to this query with information mentioned on top.
Consider How can I send data with PHP to an IP address via UDP?

So what should I do is use socket to send data to the server and then let the server return data to the website?

Chicken

Quote from: habi on Feb 21, 2022, 04:50 AMIf you are building a website and you want the list of players name in the website there is a way. You will get the name of your server, gamemode, version and list of players playing in the server.
You have to create a udp socket in your website code. Are you scripting in php?
From this udp socket you have to send exactly two packets to the VCMP server you are running.
You must have port forwarding done already.
If so, VCMP Server will reply to this query with information mentioned on top.
Consider How can I send data with PHP to an IP address via UDP?

There are few ways to use socket plugins in VCMP. Can you tell me which events and functions should I use?

habi

Sure. add socket04rel64 to server.cfg
Then, in your main.nut after the bottom line or in onScriptLoad add
s<-NewSocket(dataReceived);Before this, somewhere you must define dataReceived function.
function dataReceived( data )
{
print("Received data: "+data+"\n");
if(data=="players")
s.Send(GetPlayerCount()+"");
}
Try and tell what Happened

Ref:Ref: wiki NewSocket

Xmair

I don't really understand what you really mean but if you want to make something such as a server browser, here's what you need to do:

Firstly, you make a GET request to a master list URL (I usually use https://master.thijn.ovh/). This returns a JSON array of servers. You are provided with each announced server's IP, port and official status.

Afterwards, you loop through the server list received from the master list and you send a UDP packet to each of them. There's more information about this in the following wiki page:
http://wiki.thijn.ovh/index.php?title=Query_Mechanism

The page is pretty self explanatory but if you still face issues, you can always use a reference such as:
https://github.com/BigETI/SAMPLauncherNET/blob/master/SAMPLauncherNET/Source/SAMPLauncherNET/Core/Server.cs

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Chicken

Quote from: habi on Feb 21, 2022, 11:36 AMSure. add socket04rel64 to server.cfg
Then, in your main.nut after the bottom line or in onScriptLoad add
s<-NewSocket(dataReceived);Before this, somewhere you must define dataReceived function.
function dataReceived( data )
{
print("Received data: "+data+"\n");
if(data=="players")
s.Send(GetPlayerCount()+"");
}
Try and tell what Happened

Ref:Ref: wiki NewSocket
Do I want to use Socket.Start(port,maxConn)??

Chicken

Quote from: habi on Feb 21, 2022, 11:36 AMSure. add socket04rel64 to server.cfg
Then, in your main.nut after the bottom line or in onScriptLoad add
s<-NewSocket(dataReceived);Before this, somewhere you must define dataReceived function.
function dataReceived( data )
{
print("Received data: "+data+"\n");
if(data=="players")
s.Send(GetPlayerCount()+"");
}
Try and tell what Happened

Ref:Ref: wiki NewSocket
used your method and didn't return a value

Chicken

Quote from: Xmair on Feb 21, 2022, 12:04 PMI don't really understand what you really mean but if you want to make something such as a server browser, here's what you need to do:

Firstly, you make a GET request to a master list URL (I usually use https://master.thijn.ovh/). This returns a JSON array of servers. You are provided with each announced server's IP, port and official status.

Afterwards, you loop through the server list received from the master list and you send a UDP packet to each of them. There's more information about this in the following wiki page:
http://wiki.thijn.ovh/index.php?title=Query_Mechanism

The page is pretty self explanatory but if you still face issues, you can always use a reference such as:
https://github.com/BigETI/SAMPLauncherNET/blob/master/SAMPLauncherNET/Source/SAMPLauncherNET/Core/Server.cs
It's the same as you said, but I took out the IP and port and there is no way to convert it to the server name and the names of all online players

Chicken

Quote from: Chicken on Feb 21, 2022, 12:10 PM
Quote from: Xmair on Feb 21, 2022, 12:04 PMI don't really understand what you really mean but if you want to make something such as a server browser, here's what you need to do:

Firstly, you make a GET request to a master list URL (I usually use https://master.thijn.ovh/). This returns a JSON array of servers. You are provided with each announced server's IP, port and official status.

Afterwards, you loop through the server list received from the master list and you send a UDP packet to each of them. There's more information about this in the following wiki page:
http://wiki.thijn.ovh/index.php?title=Query_Mechanism

The page is pretty self explanatory but if you still face issues, you can always use a reference such as:
https://github.com/BigETI/SAMPLauncherNET/blob/master/SAMPLauncherNET/Source/SAMPLauncherNET/Core/Server.cs
It's the same as you said, but I took out the IP and port and there is no way to convert it to the server name and the names of all online players
Quote from: Xmair on Feb 21, 2022, 12:04 PMI don't really understand what you really mean but if you want to make something such as a server browser, here's what you need to do:

Firstly, you make a GET request to a master list URL (I usually use https://master.thijn.ovh/). This returns a JSON array of servers. You are provided with each announced server's IP, port and official status.

Afterwards, you loop through the server list received from the master list and you send a UDP packet to each of them. There's more information about this in the following wiki page:
http://wiki.thijn.ovh/index.php?title=Query_Mechanism

The page is pretty self explanatory but if you still face issues, you can always use a reference such as:
https://github.com/BigETI/SAMPLauncherNET/blob/master/SAMPLauncherNET/Source/SAMPLauncherNET/Core/Server.cs
Quote from: Xmair on Feb 21, 2022, 12:04 PMI don't really understand what you really mean but if you want to make something such as a server browser, here's what you need to do:

Firstly, you make a GET request to a master list URL (I usually use https://master.thijn.ovh/). This returns a JSON array of servers. You are provided with each announced server's IP, port and official status.

Afterwards, you loop through the server list received from the master list and you send a UDP packet to each of them. There's more information about this in the following wiki page:
http://wiki.thijn.ovh/index.php?title=Query_Mechanism

The page is pretty self explanatory but if you still face issues, you can always use a reference such as:
https://github.com/BigETI/SAMPLauncherNET/blob/master/SAMPLauncherNET/Source/SAMPLauncherNET/Core/Server.cs
I probably understand, is it possible to get the server name by sending a data packet whose protocol is UDP and whose format is byte set 32+strlen to the server IP and port?

habi

Quote from: Chicken on Feb 21, 2022, 12:05 PMDo I want to use Socket.Start(port,maxConn)??
Yes.
s<-NewSocket(dataReceived)
s.Start( 5192, 12 );
Then from website create socket and  connect to your server using port 5192.

Xmair

Quote from: Chicken on Feb 21, 2022, 12:17 PMI probably understand, is it possible to get the server name by sending a data packet whose protocol is UDP and whose format is byte set 32+strlen to the server IP and port?
Yes it is possible to get the server name by sending a UDP dgram packet. However I don't think you understand how to parse the result properly so I would suggest you to just use premade code. Fleka did something a few years ago: https://forum.vc-mp.org/?topic=5530.msg39171#msg39171

One small thing to note is you should try changing the magic to 'VCMP' instead of 'MP04' since back when I was coding a browser, some servers wouldn't work if you used 'MP04' as magic.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Chicken

Quote from: Xmair on Feb 22, 2022, 11:12 AM
Quote from: Chicken on Feb 21, 2022, 12:17 PMI probably understand, is it possible to get the server name by sending a data packet whose protocol is UDP and whose format is byte set 32+strlen to the server IP and port?
Yes it is possible to get the server name by sending a UDP dgram packet. However I don't think you understand how to parse the result properly so I would suggest you to just use premade code. Fleka did something a few years ago: https://forum.vc-mp.org/?topic=5530.msg39171#msg39171

One small thing to note is you should try changing the magic to 'VCMP' instead of 'MP04' since back when I was coding a browser, some servers wouldn't work if you used 'MP04' as magic.
I understand what you mean, but now there is a question, how should I convert hex and bytes to each other