Jump to content

Please help me with this.


Maciek20

Recommended Posts

I would like to have a script on my website about MMORPG TIBIA. If someone could write script which will show on my website information if player is online/offline I would be thankful.

 

Script would take information about player who I would to see if hes online/offline on my page from there:

 

http://www.tibia.com/community/?subtopic=whoisonline&world=Mythera

 

 

Thanks for help.

Link to comment
Share on other sites

Since I like some exercise now and then, I wrote it for you. It's pretty simple: You load in the page in question, and check whether the given player name is present or not.

 

<?php
$playerName = 'Name here';
$world = 'Mythera';
$url = 'http://www.tibia.com/community/?subtopic=whoisonline&world='.$world;
$pageString = file_get_contents($url);
if (strpos($pageString, $playerName) !== false) {
	echo $playerName, ' is online in ', $world, '.';
} else {
	echo $playerName, ' is offline in ', $world, '.';
}
?>

 

Edit: Be aware that the page we're loading is around 241 KB in size. May take a little while.

Link to comment
Share on other sites

Oops, realized I made some mistakes, this should work as intended:

 

<?php
$playerName = 'Name here';
$playerName = str_replace(' ', '&#160;', $playerName);
$world = 'Mythera';
$url = 'http://www.tibia.com/community/?subtopic=whoisonline&world='.$world;
$pageString = file_get_contents($url);
if (strpos($pageString, '">'.$playerName.'</A>') !== false) {
	echo $playerName, ' is online in ', $world, '.';
} else {
	echo $playerName, ' is offline in ', $world, '.';
}
?>

 

Edit: Argh! The forum is wrecking my ampersand on line 2 in the code. It should read

 

$playerName = str_replace(' ', '&#160;', $playerName);

Link to comment
Share on other sites

Oops, realized I made some mistakes, this should work as intended:

 

<?php
$playerName = 'Name here';
$playerName = str_replace(' ', '\ ', $playerName);
$world = 'Mythera';
$url = 'http://www.tibia.com/community/?subtopic=whoisonline&world='.$world;
$pageString = file_get_contents($url);
if (strpos($pageString, '">'.$playerName.'</A>') !== false) {
	echo $playerName, ' is online in ', $world, '.';
} else {
	echo $playerName, ' is offline in ', $world, '.';
}
?>

 

Ya really shouldn't just make scripts for people who can't be bothered to do it themselves or pay a freelance, because then other people will ask assuming that we will help do the same for them etc.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.