• Possible to make server query like: GetPlayers( )? (PHP-Source-Query-Class)
    6 replies, posted
Possible to make server query like: GetPlayers( )? (PHP-Source-Query-Class) For example it should return some information like roles of players or current number of round.
Not unless you write your own socket plugin / console command that you run so you can parse it's output. Make yourself a Lua script that outputs a json string containing all players and their roles / number of rounds (whatever that may be), and let it run when you type a specific console command. Make it a serverside console command so clients can't run it. Then, use RCon to send that command and read it's output, parse it to an array using $array = json_decode($string, TRUE) and there you go. edit: Thinking of what I said here, I struggled parsing the output of console "status" command, while I ran my community. I parsed this from 13 servers, every minute. What a struggle, could have done it simpler, without using so much resources :')
[QUOTE=Cyberuben;45824975]Not unless you write your own socket plugin / console command that you run so you can parse it's output. Make yourself a Lua script that outputs a json string containing all players and their roles / number of rounds (whatever that may be), and let it run when you type a specific console command. Make it a serverside console command so clients can't run it. Then, use RCon to send that command and read it's output, parse it to an array using $array = json_decode($string, TRUE) and there you go. edit: Thinking of what I said here, I struggled parsing the output of console "status" command, while I ran my community. I parsed this from 13 servers, every minute. What a struggle, could have done it simpler, without using so much resources :')[/QUOTE] parsing is no problem, but output... i guess it's BINary plugin, right?
[QUOTE=Koji6ac9H;45827642]parsing is no problem, but output... i guess it's BINary plugin, right?[/QUOTE] [QUOTE=Cyberuben;45824975]Not unless you write your own socket plugin / console command that you run so you can parse it's output. [b]Make yourself a Lua script that outputs a json string containing all players and their roles / number of rounds (whatever that may be), and let it run when you type a specific console command. Make it a serverside console command so clients can't run it. Then, use RCon to send that command and read it's output, parse it to an array using $array = json_decode($string, TRUE) and there you go.[/b] edit: Thinking of what I said here, I struggled parsing the output of console "status" command, while I ran my community. I parsed this from 13 servers, every minute. What a struggle, could have done it simpler, without using so much resources :')[/QUOTE] You don't have to write yourself a module if you do what I told you...
[QUOTE=Cyberuben;45827702]You don't have to write yourself a module if you do what I told you...[/QUOTE] oh ok, but how to catch convar value from Rcon command?
[QUOTE=Koji6ac9H;45827929]oh ok, but how to catch convar value from Rcon command?[/QUOTE] You already knew you could use the PHP-Source-Query-Class, so why don't you look at the RCon Example they provide you? [url=https://github.com/xPaw/PHP-Source-Query-Class/blob/master/RconExample.php]Here[/url] they show you exactly how it works and how to catch it's output.
[QUOTE=Cyberuben;45827966]You already knew you could use the PHP-Source-Query-Class, so why don't you look at the RCon Example they provide you? [url=https://github.com/xPaw/PHP-Source-Query-Class/blob/master/RconExample.php]Here[/url] they show you exactly how it works and how to catch it's output.[/QUOTE] Oh Thank you! I did it!
Sorry, you need to Log In to post a reply to this thread.