[PHP]Any way to have a direct refrence to the output of php?

Post here if you need help setting up your server, etc.
Post Reply
7Priest7
On Lightcycle Grid
Posts: 14
Joined: Sat Dec 11, 2010 5:26 pm

[PHP]Any way to have a direct refrence to the output of php?

Post by 7Priest7 »

I do not have direct control of the config files as I use external hosting...
Is it possible to have CONSOLE_MESSAGE or other similar variables reference the output of PHP?

My purpose of doing so would be a random bible verse displayed each round...
However I can think of many other uses for this...

Thanks for any effort made to answer,
Alex
User avatar
AI-team
Shutout Match Winner
Posts: 1020
Joined: Tue Jun 23, 2009 6:17 pm
Location: Germany/Munich
Contact:

Re: [PHP]Any way to have a direct refrence to the output of php?

Post by AI-team »

I am not quite sure whether I understood you correct but you if I did you can do it this way

Code: Select all

<?php
$nl = "\n":
echo "CONSOLE_MESSAGE SomeBibleVerse $nl";
?>
  
 
"95% of people believe in every quote you post on the internet" ~ Abraham Lincoln
 
 
7Priest7
On Lightcycle Grid
Posts: 14
Joined: Sat Dec 11, 2010 5:26 pm

Re: [PHP]Any way to have a direct refrence to the output of php?

Post by 7Priest7 »

AI-team wrote:I am not quite sure whether I understood you correct but you if I did you can do it this way

Code: Select all

<?php
$nl = "\n":
echo "CONSOLE_MESSAGE SomeBibleVerse $nl";
?>
Nope...
Not what I need to know...
I know PHP very well...

My question was how to insert the echoed content into the configuration files if I don't have access, If it is even possible...

I do thank you for attempting to answer though <3

Alex

EDIT: If you are familiar with php I basically want to know if there is a arma version of file_get_contents(external url);
User avatar
AI-team
Shutout Match Winner
Posts: 1020
Joined: Tue Jun 23, 2009 6:17 pm
Location: Germany/Munich
Contact:

Re: [PHP]Any way to have a direct refrence to the output of php?

Post by AI-team »

Do you have no access at all or just no access to the config files?
  
 
"95% of people believe in every quote you post on the internet" ~ Abraham Lincoln
 
 
User avatar
Jip
Round Winner
Posts: 397
Joined: Sat Sep 26, 2009 5:32 pm

Re: [PHP]Any way to have a direct refrence to the output of php?

Post by Jip »

In the config Folder of your server you can create a file "cmd". Then start your server like that:

Code: Select all

#!/bin/bash

main="/home/armagetron/servers/server_2/"
cmd="${main}cmd"
bin="/home/armagetron/0.2.8/bin/armagetronad-dedicated"
var="${main}var/"
cfg="${main}settings/"
log="${main}log/server_2.log"

tail -f ${cmd} | (while true; do $bin --userconfigdir $cfg --vardir $var; done) >> $log
You can send commands to the server via the cmd file. Like:

Code: Select all

$echo "SAY hi!" >> cmd
Then you can write a php script what parses the ladderlog.txt and do some actions and send the commands to the cmd file.

Code: Select all

#!/usr/bin/php
<?php
while (true) {
        $line = explode(' ', trim(fgets(STDIN, 512)), 2); // split into 2 parts
    // Every new round actions
    if ($line[0] == "NEW_ROUND")
    {
         $ret = do_something();
         send_to_cmd_file($ret);
    }
}
function send_to_cmd_file($text)
{
    //open CMD file and write commands to it.
}
?>
Then start the parser like that:

Code: Select all

#!/bin/bash

ladderlog="/home/armagetron/servers/server_2/var/ladderlog.txt"
cmd="/home/armagetron/servers/server_2/cmd"

tail -f -n0 -s0.01 $ladderlog | ./parser.php
When you want to parse NEW_ROUND messages, you need to set LADDERLOG_WRITE_NEW_ROUND 1 in your server config.

Look also here:
http://www.crazy-tronners.com/wiki/index.php/Ladderlog

EDIT:
you dont need a cmd file. You also can start the server and parser at the same time:

Code: Select all

#!/bin/bash

main="/home/armagetron/servers/server_2/"
cmd="${main}cmd"
bin="/home/armagetron/0.2.8-sty+ct/bin/armagetronad-dedicated"
parser="/home/armagetron/servers/parser/onslaught.php"
var="${main}var/"
ladderlog="${var}ladderlog.txt"
cfg="${main}settings/"
log="${main}log/server_2.log"

tail -n0 -f -s 0.01 $ladderlog | $parser | (while true; do $bin --userconfigdir $cfg --vardir $var; done) >> $log
User avatar
kyle
Reverse Outside Corner Grinder
Posts: 1876
Joined: Thu Jun 08, 2006 3:33 pm
Location: Indiana, USA, Earth, Milky Way Galaxy, Universe, Multiverse
Contact:

Re: [PHP]Any way to have a direct refrence to the output of php?

Post by kyle »

it would be best to use everytime.cfg if he has access to it then each round it will spam you with bible quotes instead of introgame, NEW_ROUND comes right before start, people won't see it then :P
Image
User avatar
Jip
Round Winner
Posts: 397
Joined: Sat Sep 26, 2009 5:32 pm

Re: [PHP]Any way to have a direct refrence to the output of php?

Post by Jip »

Yea, NEW_ROUND was only meant for example. You just can do that for every ladderlog message like PLAYER_ENTERED, DEATH_SUICIDE, GAME_TIME etc.
7Priest7
On Lightcycle Grid
Posts: 14
Joined: Sat Dec 11, 2010 5:26 pm

Re: [PHP]Any way to have a direct refrence to the output of php?

Post by 7Priest7 »

Right now I only have access via a web form...
The web form has a Authentication method that would be a pain to surpass via a php file...

Anyhow I emailed Luke requesting some other form of access...
So I hope he can give and then problem solved...


Well thanks all for trying to help
User avatar
kyle
Reverse Outside Corner Grinder
Posts: 1876
Joined: Thu Jun 08, 2006 3:33 pm
Location: Indiana, USA, Earth, Milky Way Galaxy, Universe, Multiverse
Contact:

Re: [PHP]Any way to have a direct refrence to the output of php?

Post by kyle »

you should have ssh with same username/password/server

then you should be able to make a bot to do the scripting
Image
User avatar
compguygene
Adjust Outside Corner Grinder
Posts: 2346
Joined: Thu Aug 21, 2008 12:09 pm
Location: Cleveland, Ohio
Contact:

Re: [PHP]Any way to have a direct refrence to the output of php?

Post by compguygene »

You would be far better served to purchase VPS service from luke-jr http://lightfoot.dashjr.org/?page=vps Although this would involve you building your own server binary, you would be able to use the PHP scripting that has been shown to you in this forum thread.
Armagetron: It's a video game that people should just play and enjoy :)
https://bit.ly/2KBGYjvCheck out the simple site about TheServerPharm
Post Reply