Server Help

Bot Questions - PlayerList & Zone Pop uploaded to Site

BDwinsAlt - Tue Nov 22, 2005 7:19 pm
Post subject: PlayerList & Zone Pop uploaded to Site
How do i get a list of players and the size of the list and upload it to my website, then when the user opens the page an updated list appears showing the Player's in the Main arena and the number of players thier are.

TWCore(java) and PHP Code plz. icon_cool.gif

P.S. i think i can get the list of players and size, im just to lazy.
Kitsune (^) - Tue Nov 22, 2005 7:28 pm
Post subject: Hrm.
Mebbe just get all the players to type something random, and turn on logging, and upload that to your site? >.<
BDwinsAlt - Tue Nov 22, 2005 7:28 pm
Post subject:
-SLAP-
Kitsune (^) - Tue Nov 22, 2005 7:38 pm
Post subject: >.<
OUCH! Bd, check your messages.
D1st0rt - Tue Nov 22, 2005 7:46 pm
Post subject:
Request the arena list in BotAction then add up the numbers
BDwinsAlt - Tue Nov 22, 2005 7:54 pm
Post subject:
Then how do i upload to server the number of players in the arena and which ones they are?
Kitsune (^) - Tue Nov 22, 2005 7:59 pm
Post subject: >.<
I'm retarded when it comes to bots and FTP.

How do i upload stuff to my site? <- Using CUTEftp
BDwinsAlt - Tue Nov 22, 2005 8:27 pm
Post subject:
icon_confused.gif . I got arena size ez. m_botAction.getArenaSize();

I just need the stupid uploading files in java.
Solo Ace - Wed Nov 23, 2005 1:28 am
Post subject:
You're too lazy to do something, which is why you ask for help here? Go away, stupid troll.
D1st0rt - Wed Nov 23, 2005 3:58 am
Post subject:
I would think probably the easiest thing to do if the bot doesn't run on the same server as the website would be to save it to a mysql database that you could read from some php script. Another thing you could do is save the information to a file on the bot computer and have the website computer read that.

Kitsune, stop talking. Having a bot (or person every time the number of players in an arena changes... shudder) use CuteFTP is up there in "Bad ideas I have heard". Have to give you props for trying, though biggrin.gif

Also, just because pi appears to repeat forever does not prove the concrete existence of infinity, and certainly not that "life is infinite", whatever that means. Again, nice try biggrin.gif
Dr Brain - Wed Nov 23, 2005 9:40 am
Post subject:
Pi and e are transcendentals. They transcend the algebra of the rationals. Doesn't prove infinity exists any more than 1/3 = 0.33333... does.

The universe is finite. A finite object cannot contain an infinite one. Life is finite. Even thermodynamics says the universe will end eventually.
Cyan~Fire - Wed Nov 23, 2005 11:35 am
Post subject:
And just because infinity exists doesn't mean life is.

But we should ask: is the bot setup on the same server as the website?
BDwinsAlt - Wed Nov 23, 2005 1:25 pm
Post subject:
No the bot is running on my home pc, the server is running on a linux server somewhere else. We have unlimited mysql but it only allows connections with the prefix staff. The prefix when i connect is my ip then all the other info so it does not allow a connection. How do i fix that.

I have CPanel X.
Kitsune (^) - Wed Nov 23, 2005 1:29 pm
Post subject: Well.
That was mean. icon_sad.gif Since when is the universe finite? Can you prove it?
Cyan~Fire - Wed Nov 23, 2005 2:03 pm
Post subject:
@BDwins: What do you mean "only allows connections with the prefix staff"? You mean the username? If so, it should be easy to setup TWCore to login like that.

@Kitsune: oops, made a type, read again. icon_razz.gif
BDwinsAlt - Wed Nov 23, 2005 2:08 pm
Post subject:
When i try and connect to mysql it uses (lets pretend my actual wan ip is 127.0.0.1)

127-0-0-1@staff_dbname......

I think i figured out how to fix it, but right now all i need is the java code to upload the data into the table and the php code to read the data.
Purge - Wed Nov 23, 2005 2:10 pm
Post subject:
Kitsune (^) wrote:
That was mean. icon_sad.gif Since when is the universe finite? Can you prove it?


Considering the universe is still expanding, it's finite.
BDwinsAlt - Wed Nov 23, 2005 2:46 pm
Post subject:
I got the bot connecting to the database. I think i can make it upload information to it. Then ill google to see how to read info from sql in php.
BDwinsAlt - Wed Nov 23, 2005 4:51 pm
Post subject:
Umm anyone know how to send an Int to the table "Hot"?
I can't seem to get it to INSERT or UPDATE anything.
Anonymous - Wed Nov 23, 2005 7:13 pm
Post subject:
Tutorial: How to display zone population on a webpage using TWCore, PHP and MySQL

Here is an example table structure what is needed:

Code: Show/Hide

CREATE TABLE `tblZonePopulation` (
  `fnZonePopulationId` int(10) NOT NULL auto_increment,
  `fnNumberOfPlayers` int(10) NOT NULL default '0',
  `ftPlayers` text NOT NULL,
  `fdDate` datetime default CURRENT_TIMESTAMP,
  PRIMARY KEY  (`fnZonePopulationId`)
);


Then we need the bot to send data to the table.

Code: Show/Hide

int numberOfPlayers = m_botAction.getArenaSize();
String players;

if (numberOfPlayers > 0) {
    Iterator i = m_botAction.getPlayerIterator();

    while (i.hasNext()) {
        if (players != null) {
            players += ", ";
        }
        players += Tools.addSlashesToString(((Player)i.next()).getPlayerName());
    }
} else {
    players = "The zone is empty.";
}

String query = "INSERT INTO tblZonePopulation (fnNumberOfPlayers, ftPlayers) VALUES ('" + numberOfPlayers + "', '" + players + "')";

m_botAction.SQLBackgroundQuery("yourconnectionname", null, query);


And finally the PHP code

Code: Show/Hide

<b>Zone Population</b><br>
<?
$dbh = mysql_connect ("yourhost", "yourusername", "yourpassword") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("yourdatabase");

$query = "SELECT fnNumberOfPlayers, ftPlayers FROM tblZonePopulation ORDER BY fnZonePopulationId DESC LIMIT 0, 1";
$result = mysql_query($query);

if (mysql_num_rows($result) > 0) {
    ?>Number of Players: <? echo row[0]; ?><br>
    Players: <? echo row[1];
} else {
    echo "Zone Population unavailable.";
}

mysql_free_result($result);
mysql_close($dbh);


OK, it wasn't really a tutorial as I didn't explain much but it's more or less selfexplanatory. I didn't test any part of the code so it is very likely there are errors and such, but it was meant as an example and finding bugs is good practice!
Anonymous - Wed Nov 23, 2005 7:33 pm
Post subject:
Oops.. rushed the PHP part a bit :(

Code: Show/Hide

<b>Zone Population</b><br>
<?
$dbh = mysql_connect ("yourhost", "yourusername", "yourpassword") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("yourdatabase");

$query = "SELECT fnNumberOfPlayers, ftPlayers, fdDate FROM tblZonePopulation ORDER BY fnZonePopulationId DESC LIMIT 0, 1";
$result = mysql_query($query);

if (mysql_num_rows($result) > 0) {
    $row = mysql_fetch_assoc($result);
    echo "Number of Players: " . row[0]; . "<br> Players: " . row[1] . "<br> Last Updated: " . row[2];
} else {
    echo "Zone Population unavailable.";
}

mysql_free_result($result);
mysql_close($dbh);
?>


Should be a bit better
BDwinsAlt - Wed Nov 23, 2005 8:17 pm
Post subject:
Parse error: parse error, unexpected '[', expecting ',' or ';' in /home/staff/public_html/zone.php on line 11
BDwinsAlt - Wed Nov 23, 2005 8:52 pm
Post subject:
Also i looked at the table size with phpAdmin thing, nothing is changing. It's not even being used. icon_eek.gif
Bak - Sat Nov 26, 2005 2:35 pm
Post subject:
infinate things can expand too. Prove the universe is finite.
D1st0rt - Sun Nov 27, 2005 2:23 am
Post subject:
I never said the universe was finite, I said that pi does not prove the existance of infinity or that "life is infinite"
Muskrat - Sun Nov 27, 2005 12:50 pm
Post subject:
The universe is only as finite to us as how far light can have come to us since .... the beginning.
D1st0rt - Mon Nov 28, 2005 5:25 pm
Post subject:
Until we develop Warp 9 capability that is. Then light gets pwnt.

Some people have a lot of time on their hands:
http://www.ex-astris-scientia.org/warp/warp3.htm
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group