Who's online plugin

Post here if you need help setting up your server, etc.
User avatar
Light
Reverse Outside Corner Grinder
Posts: 1667
Joined: Thu Oct 20, 2011 2:11 pm

Re: Who's online plugin

Post by Light »

A question to Lover .. sorry to hijack thread, but it sorta applies.

Since you seem to be the only one around that actually cares for PHP scripts much, do you think it would be a good idea for me to put up my plugin system? It's just a small function loop, but it works pretty nice and you can add/remove parts of the script with no hassle. It would be easy to have users that don't really know anything about PHP be able to use scripts made by whoever made scripts for it.

So far I have ..
The main script.
A players plugin that keeps track of players names, ips, and who's actually playing. Also a count of each.
A custom commands script.
Arena size based on number of players.
Tail size based on number of people alive. (gets longer as people die)

I have a couple other scripts, but I don't want to give them out. So, they are pretty basic scripts, but the players plugin would be a big help to people learning to script as well. The only thing I wonder is if anyone else would care to make plugins for it, and if people would actually use it over like Afro's scripts or something they can just copy/paste into the folder and use. The plugins are about as easy, but you have to add them in the order you want them to execute.
User avatar
Light
Reverse Outside Corner Grinder
Posts: 1667
Joined: Thu Oct 20, 2011 2:11 pm

Re: Who's online plugin

Post by Light »

trevor wrote:Ok, could you explain pre tags? Tonight is my first time working with php. Other than that line of code I have I My post, what do I need?
HTML <pre></pre> tags. They will make the output monospaced so it shows correctly lined up as intended.
User avatar
trevor
Average Program
Posts: 52
Joined: Fri Nov 23, 2012 8:45 am
Location: The Internet
Contact:

Re: Who's online plugin

Post by trevor »

Code: Select all

<pre>
     <?php include("123.45.67.890/players.txt") ?>
</pre>
Like this?
User avatar
LOVER$BOY
Match Winner
Posts: 731
Joined: Thu Jan 24, 2008 12:46 pm

Re: Who's online plugin

Post by LOVER$BOY »

Light wrote:A question to Lover .. sorry to hijack thread, but it sorta applies.

Since you seem to be the only one around that actually cares for PHP scripts much, do you think it would be a good idea for me to put up my plugin system? It's just a small function loop, but it works pretty nice and you can add/remove parts of the script with no hassle. It would be easy to have users that don't really know anything about PHP be able to use scripts made by whoever made scripts for it.

So far I have ..
The main script.
A players plugin that keeps track of players names, ips, and who's actually playing. Also a count of each.
A custom commands script.
Arena size based on number of players.
Tail size based on number of people alive. (gets longer as people die)

I have a couple other scripts, but I don't want to give them out. So, they are pretty basic scripts, but the players plugin would be a big help to people learning to script as well. The only thing I wonder is if anyone else would care to make plugins for it, and if people would actually use it over like Afro's scripts or something they can just copy/paste into the folder and use. The plugins are about as easy, but you have to add them in the order you want them to execute.
Your not hijacking anything here at the moment :P Although, I too mostly make changes appropriately to the basis of my linking in the game code as well to support my php code.

mmm... well, seems to me there's no problem with that. It would be great to help the new people learning to script which is exactly what your aiming for as I notice. Good to see someone else, other than me, willing to share scripts they've made for the people to use easily and not go to the trouble of learning everything from scratch :D

I have my own scripts and they are far advanced and they run in the same line as the tron's game code (I inadvertently wrote the scripts like that).

Code: Select all

<pre>
     <?php include("http://123.45.67.890/players.txt"); ?>
</pre>
Don't forget the ";" at the end :)

I still think it's much easier to use curl_ functions as they are easier to handle and can report errors with the HTTP_REQUEST_CODE.
Last edited by LOVER$BOY on Tue Feb 05, 2013 6:52 am, edited 1 time in total.
Image
User avatar
Light
Reverse Outside Corner Grinder
Posts: 1667
Joined: Thu Oct 20, 2011 2:11 pm

Re: Who's online plugin

Post by Light »

I kind'a responded a min ago without thinking though. You don't want to use include() for that. You would probably just use file_get_contents() for such a small file, and echo it out. Technically you can include() it, but not what you're looking for.

Also, you don't use the IP because it's a local file. Just ..

Code: Select all

echo '<pre>' . utf8_encode(file_get_contents("/var/www/players.txt")) . '</pre>';
User avatar
LOVER$BOY
Match Winner
Posts: 731
Joined: Thu Jan 24, 2008 12:46 pm

Re: Who's online plugin

Post by LOVER$BOY »

Light wrote:I kind'a responded a min ago without thinking though. You don't want to use include() for that. You would probably just use file_get_contents() for such a small file, and echo it out. Technically you can include() it, but not what you're looking for.

Also, you don't use the IP because it's a local file. Just ..

Code: Select all

echo '<pre>' . utf8_encode(file_get_contents("/var/www/players.txt")) . '</pre>';
It's quicker to handle that way than include. Include is usually used when loading in objects and variables from a php file.
Image
User avatar
Light
Reverse Outside Corner Grinder
Posts: 1667
Joined: Thu Oct 20, 2011 2:11 pm

Re: Who's online plugin

Post by Light »

LOVER$BOY wrote:I still think it's much easier to use curl_ functions as they are easier to handle and can report errors with the HTTP_REQUEST_CODE.
It's not a local file? I wouldn't bother with cURL for a local file, but if you're putting this on a different host, then yeah you should probably use cURL, or file_get_contents will still work, but I prefer cURL for quite a few reasons.

By the way, file_get_contents does work on remote hosts.
http://lightron.no-ip.org/test.php

Code: Select all

<?php echo file_get_contents("http://google.com"); ?>
User avatar
LOVER$BOY
Match Winner
Posts: 731
Joined: Thu Jan 24, 2008 12:46 pm

Re: Who's online plugin

Post by LOVER$BOY »

Light wrote:
LOVER$BOY wrote:I still think it's much easier to use curl_ functions as they are easier to handle and can report errors with the HTTP_REQUEST_CODE.
It's not a local file? I wouldn't bother with cURL for a local file, but if you're putting this on a different host, then yeah you should probably use cURL, or file_get_contents will still work, but I prefer cURL for quite a few reasons.

By the way, file_get_contents does work on remote hosts.
http://lightron.no-ip.org/test.php

Code: Select all

<?php echo file_get_contents("http://google.com"); ?>
Odd... I'll look into my configuration. Maybe I made an error when I was adjusting the offline hosts I was playing around with.
Image
User avatar
trevor
Average Program
Posts: 52
Joined: Fri Nov 23, 2012 8:45 am
Location: The Internet
Contact:

Re: Who's online plugin

Post by trevor »

Light wrote:
LOVER$BOY wrote:I still think it's much easier to use curl_ functions as they are easier to handle and can report errors with the HTTP_REQUEST_CODE.
It's not a local file? I wouldn't bother with cURL for a local file, but if you're putting this on a different host, then yeah you should probably use cURL, or file_get_contents will still work, but I prefer cURL for quite a few reasons.

By the way, file_get_contents does work on remote hosts.
http://lightron.no-ip.org/test.php

Code: Select all

<?php echo file_get_contents("http://google.com"); ?>
Nope, the website is hosted separately from the game server.
User avatar
Light
Reverse Outside Corner Grinder
Posts: 1667
Joined: Thu Oct 20, 2011 2:11 pm

Re: Who's online plugin

Post by Light »

Make sure you don't have any spam protection or anything set up per IP, because you'll be downloading the file constantly from the same address. Also, I would still go with what I posted above over the include, but it's up to you. Once you add other elements to the page, you'll realize why. d:
User avatar
LOVER$BOY
Match Winner
Posts: 731
Joined: Thu Jan 24, 2008 12:46 pm

Re: Who's online plugin

Post by LOVER$BOY »

trevor wrote:
Light wrote:
LOVER$BOY wrote:I still think it's much easier to use curl_ functions as they are easier to handle and can report errors with the HTTP_REQUEST_CODE.
It's not a local file? I wouldn't bother with cURL for a local file, but if you're putting this on a different host, then yeah you should probably use cURL, or file_get_contents will still work, but I prefer cURL for quite a few reasons.

By the way, file_get_contents does work on remote hosts.
http://lightron.no-ip.org/test.php

Code: Select all

<?php echo file_get_contents("http://google.com"); ?>
Nope, the website is hosted separately from the game server.
Heh, yet again I was right :P

Anyway, then the solution to that is to have paste a shortcut of the players.txt in your webroot folder and using the curl functions to loading data in from you server web.
Light wrote:Make sure you don't have any spam protection or anything set up per IP, because you'll be downloading the file constantly from the same address. Also, I would still go with what I posted above over the include, but it's up to you. Once you add other elements to the page, you'll realize why. d:
It's a safety advice and I also urge you to be careful with it :)
Image
User avatar
trevor
Average Program
Posts: 52
Joined: Fri Nov 23, 2012 8:45 am
Location: The Internet
Contact:

Re: Who's online plugin

Post by trevor »

So something like:

Code: Select all

<pre>
     <?php echo file_get_contents("myip/players.txt"); ?>
</pre>
Correct?
Last edited by trevor on Tue Feb 05, 2013 7:10 am, edited 1 time in total.
User avatar
LOVER$BOY
Match Winner
Posts: 731
Joined: Thu Jan 24, 2008 12:46 pm

Re: Who's online plugin

Post by LOVER$BOY »

trevor wrote:So something like:

Code: Select all

<pre>
     <?php file_get_contents("myip/players.txt"); ?>
</pre>
Correct?
Correct!

Oh! Don't forget the "http://" before your "myip".
Last edited by LOVER$BOY on Tue Feb 05, 2013 7:10 am, edited 1 time in total.
Image
User avatar
Light
Reverse Outside Corner Grinder
Posts: 1667
Joined: Thu Oct 20, 2011 2:11 pm

Re: Who's online plugin

Post by Light »

Pretty sure you have to echo it, but yeah.
User avatar
trevor
Average Program
Posts: 52
Joined: Fri Nov 23, 2012 8:45 am
Location: The Internet
Contact:

Re: Who's online plugin

Post by trevor »

So no need for the echo command I edited in there right after posting?
Never mind.
Post Reply