~armagetronad-dev/armagetronad/tools-php-client-trunk-work

« back to all changes in this revision

Viewing changes to armagetron-php-client.php

  • Committer: Armanelgtron
  • Date: 2021-04-20 16:28:58 UTC
  • Revision ID: armanelgtron@gmail.com-20210420162858-kbfl2j9486pc4h6j
PHP 8 compatibility and fix doChat to only need one argument

Show diffs side-by-side

added added

removed removed

Lines of Context:
235
235
        public $options;
236
236
        public $uri;
237
237
 
 
238
        function __construct($host, $port) {
 
239
                $this->serverinfo($host, $port);
 
240
        }
 
241
 
238
242
        function serverinfo($host, $port) {
239
243
                $this->host = $host;
240
244
                $this->port = $port;
487
491
                }
488
492
        }
489
493
 
 
494
        function __construct($host, $port=4534) {
 
495
                $this->connection($host, $port);
 
496
        }
 
497
 
490
498
        function connection($host, $port=4534) {
491
499
                $this->host = $host;
492
500
                $this->hostip = gethostbyname($host);
631
639
                $this->onChat($playerid, $text);
632
640
                return true;
633
641
        }
634
 
        function doChat($playerid, $text) {
635
 
                if (!isset($text))
 
642
        function doChat($playerid, $text=null) {
 
643
                if ($text === null)
636
644
                {
637
645
                        $text = $playerid;
638
646
                        $playerid = $this->playerid;
811
819
}
812
820
 
813
821
class bot extends connection {
 
822
        function __construct($host, $port, $nick=null, $message=null) {
 
823
                $this->bot($host, $port, $nick, $message);
 
824
        }
 
825
 
814
826
        function bot($host, $port, $nick, $message) {
815
827
                $this->connection($host, $port);
816
828
                $this->nick = $nick;
852
864
}
853
865
 
854
866
class scores extends connection {
 
867
        function __construct($host, $port=4534) {
 
868
                $this->scores($host, $port);
 
869
        }
 
870
 
855
871
        function scores($host, $port=4534) {
856
872
                $this->connection($host, $port);
857
873
                $this->doLogin();