tltneon / lgsl

LGSL v6.2.1/v7.0.0 for PHP 5.4-8.3+ (Live Game Server List): online status for CS2 (Source Query), Discord, FiveM, Rust, SA:MP, GMOD, Minecraft, Teamspeak and 200+ more games!
GNU General Public License v3.0
152 stars 48 forks source link

export a game queries on class for standalone use #101

Closed Pok4 closed 2 years ago

Pok4 commented 2 years ago

I want to have a class to querying a servers from my script. (module similar to lgsl but with different design) I'd like to have a class wich can query games like tf2,css,cs1.6,csgo,minecraft,samp and ts3.

I can write one on my own, but i wonder if you have a one... I see lgsl_protocol, but its large and take a lot of time to make the things working..

If you have, please, write and share with us :)

Pok4 commented 2 years ago

sorry for duplicates, my internet connection is drop at a time..

TacTicTow commented 2 years ago

If you want a game server status program with the query protocols in their own file, I would suggest uing GameQ. It does that. LGSL has always used a single file for all query protocols. It is easy enough to work with once you get used to using the search feature of the editor you use. When I need to jump to a particular protocol, I might jump to just the number part like "_05" would take me to the 05 query protocol.

Pok4 commented 2 years ago

Thank you.

tltneon commented 2 years ago

Hello @Pok4 ! Easiest way is to use lgsl_query_live function

<?php
  include('lgsl/lgsl_files/lgsl_class.php');
  $result = lgsl_query_live('urbanterror', '176.9.28.206', 27971, 27971, 0, "sep");
  print_r($result); // there is will be an array of result of querying
?>
Pok4 commented 2 years ago

Thank you, @tltneon, i will test it tomorrow and i will write :) I know about gameq class but he make mistakes sometimes... I will test this one and i'm gonna to report whats the results is :)

PS: Can i just take lgsl_class.php without other files, it will work alone ?

edit: i see this: require $lgsl_file_path."lgsl_config.php"; require $lgsl_file_path."lgsl_protocol.php";

on top, but i will make the tests anyway :)

tltneon commented 2 years ago

If you want to use single file, use lgsl_protocol.php (but it causes 1 warning :) )

<?php
  include('lgsl_protocol.php');
  $result = lgsl_query_live('urbanterror', '176.9.28.206', 27971, 27971, 0, "sep");
  print_r($result); // there is will be an array of result of querying
?>
Pok4 commented 2 years ago

i can give you a suggestion to fix lgsl_protocol warning, find: $lgsl_config['timeout'] = intval($lgsl_config['timeout']); and change it to:

if(isset($lgsl_config['timeout'])) {
        $lgsl_config['timeout'] = intval($lgsl_config['timeout']);
    } else {
        $lgsl_config['timeout'] = 0;
    }

i tested it... When you use the class, it will get the value from lgsl_config.php, when you use protocol - the value is 0 it fixes the warning.