GithubHelp home page GithubHelp logo

php-open-game-protocol-client's Introduction

PHP OGP (Open Game Protcol) Client

This is a fork of official PHP OGP client (http://open-game-protocol.org/download.php) for latest version of PHP.

This SDK allow you to retrieve server status of your game server in real time.

Usefull for Onset servers (https://mtxserv.com/onset-server).

Usage

The port is the query port of server (port - 1).

<?php

require_once 'ogp.php';

$ogp = new \OGP\OGP('127.0.0.1', 27015);
if(!$ogp->getStatus()) {
    die("Error: ".$ogp->error);
}

var_dump(
  $ogp->serverInfo,
  $ogp->players,
  $ogp->rules,
  $ogp->teams,
  $ogp->addons,
  $ogp->limits,
  $ogp->ping
);

BBCode in hostname

<?php

require_once 'ogp.php';

function parseBBCodeHostname($text)
{
    $text = str_replace('?', '', $text);

    $find = array(
        '~\[g\](.*?)\[/g\]~s',
        '~\[b\](.*?)\[/b\]~s',
        '~\[i\](.*?)\[/i\]~s',
        '~\[u\](.*?)\[/u\]~s',
        '~\[c=(.*?)\](.*?)\[/c\]~s',
    );
    
    $replace = array(
        '<b>$1</b>',
        '<b>$1</b>',
        '<i>$1</i>',
        '<span style="text-decoration:underline;">$1</span>',
        '<span style="color:$1;">$2</span>',
    );
    
    return preg_replace($find,$replace,$text);
}


$ogp = new \OGP\OGP('127.0.0.1', 27015);
if(!$ogp->getStatus()) {
    die("Error: ".$ogp->error);
}

echo parseBBCodeHostname($ogp->serverInfo['HostName']);

Games

More

php-open-game-protocol-client's People

Contributors

sdieunidou avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

php-open-game-protocol-client's Issues

Error with UTF8 hostname / gamemode (Onset)

With the servername and gamemode

[g]๐ŸŒด [c=#00ff00]Horizon[/c] [c=red]Prototype[/c] [c=yellow]Labs[/c] ๐Ÿ—ฝ [b]LIT AF[/b] ๐Ÿšฌ๐Ÿ”ฅ [i]ะฑะปัั‚ัŒ[/i] ๐Ÿ”ซ + ๐Ÿ’Š = ๐Ÿšจ [u][b]NOICE[/b][/u] OK come on in ๐Ÿ‘€[/g]

OGP return:

[g]? [c=#00ff00]Horizon[/c] [c=red]Prototype[/c] [c=yellow]Labs[/c] ? [b]LIT AF[/b] ?? [i]?????[/i] ? + ? = ? [u][b]NOICE[/b][/u] OK come on in ?[/g]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.