Sending signal to server from game Created 3 years ago2021-08-26 15:22:34 UTC by Duvo Duvo

Created 3 years ago2021-08-26 15:22:34 UTC by Duvo Duvo

Posted 3 years ago2021-08-26 15:22:34 UTC Post #345895
Ok, here's a tough one, but I just need to know if it's possible to do this. if you know how then that's an added bonus.

I am teaching myself React JS at the moment and I need to make a few web applications. I'd also like to learn more about modding half-life, so I'm using this as an opportunity to work on both.

For my project, I have a basic multiplayer game. I am also hosting a website. I need to send a signal to the server for the website whenever a player wins a match. the website will then send a signal to the people using the website, showing that someone just won a match, and who.

I think that I can do this by using web sockets. My train of thought right now is that I'll have to import a library for socket communication into my mod's binary file, and then link it to the game's function for ending matches. once that signal is sent to the server I can handle the rest, I just need to relay a message from the game to an IP somehow.
Posted 3 years ago2021-08-29 18:15:30 UTC Post #345902
I assume you will be using HLDS, in that case you will need a back-end service to collect information from the server and communicate back to it if needed. Since HLDS lacks any sort of web standardized communication (http, websockets etc...) doing it from the front-end is not possible.

I've done a similar thing years ago using built in HLDS features: logaddress and rcon.
If you issue this command to the server (via config or console)
logaddress <ip> <port>
The server will start sending its logs to the IP and port you specified, logs come in as UDP packets so you will need some sort of listener ready to go.
e.g. https://npm.io/package/hlds-log
The core of all the HLDS log readers is the regex used to parse the logs, so essentially you can use any language you like.

RCON can be used to send/receive commands from the server (to kick someone, change map etc...)
Something like https://www.npmjs.com/package/rcon though plenty of different implementations exist.

If you have custom features they have to log output to the server console for this method to work.
rufee rufeeSledge fanboy
Posted 3 years ago2021-08-30 06:38:45 UTC Post #345903
Rufee, this is more than I could have hoped for. thank you so much.

I'm going to begin experimenting with this, and I will document it here once I make some headway
Posted 3 years ago2021-08-31 07:15:22 UTC Post #345905
Hello. You could try Google Firebase Realtime Database and from the game save some information/data to the database. Then in your front-end project you check the changes that happened in this database. I don't know how it looks in React but you probably need to write some lines of code in lifecycle hooks. I create pages in Vue 3 and there is onMounted().

I have never yet connected to firebase from a project written in C++ but I think it could be an interesting idea.

https://firebase.google.com/docs/database/cpp/start?hl=en
Firebase C++ SDK: https://firebase.google.com/download/cpp
Posted 3 years ago2021-08-31 12:20:18 UTC Post #345906
that's an interesting prospect, though I've never used firebase before
You must be logged in to post a response.