Join 307,099 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,026 people online right now. Registration is fast and FREE... Join Now!
hi everyone, I'm developing a browser game travian/ikariam-like for my last assignment in my college right now, but I'm stuck at the time countdown. I still don't know how to make the time is still tik-ing while the user is offline, I try to connect the database with windows base program like delphi but still no use. someone can help me?? thanks
Note : if you guys have some article that can help can you please send to raven.kurogane [at] Gmail [dot] com. thanks very much
hi everyone, I'm developing a browser game travian/ikariam-like for my last assignment in my college right now, but I'm stuck at the time countdown. I still don't know how to make the time is still tik-ing while the user is offline, I try to connect the database with windows base program like delphi but still no use. someone can help me?? thanks
Note : if you guys have some article that can help can you please send to raven.kurogane [at] Gmail [dot] com. thanks very much
Well like mentioned before, cron jobs typically control the whole time factor of things when it comes to game world stuff happening to inactive or disconnected players (resources being accumulated). But don't think of it so much as time passing while being off line as much as the time that has passed since the user last was on being calculated.
So what do I mean by that? Lets say you were last on at noon on a Friday. Instead of saying that a user must know about every second between then and the following noon on Saturday, think of it as when the user logs on at noon on Saturday that you calculate the time now minus the time of the past and you can say that the user hasn't been on for 24 hours.
Meanwhile things like resources have been accumulating every hour (because of cron) and attacks were made at random intervals.
Your cron job would run a script to update real world resources every hour, adding to your account while you are offline. Attacks are made at 4pm on Friday and again on 2am Saturday. When the user logs in you can tell the user that based on the current time - time they were last logged in that X number of resources have been added/subtracted and 2 attacks had occurred. If they leave again and login 10 minutes later you could say that no resources had been added and no attacks have occurred.
I hope I am making sense with this.
To get something like this running you have to timestamp important events and attach it to the user in some way (typically an account that links back to the user's account table) and then your cron job which is running your world resource allocation. Your cron job has only one purpose, take a snapshot of the world and modify resources. The user's actions will dictate what has happened to the user based on the time they were last active.
This post has been edited by Martyr2: 23 Feb, 2008 - 07:28 PM
I'm sorry still not get in to the cron job part. do you meant with cron job, is like an action-time-based script that handle all of the time module at the game ? yeah ..... my friend tell me that too, pehaps the time system can be handle by record the time when user logoff so when user login I can calculate how many time have been pass and I can decide how many resource user get, which building has been done. but I think that it can be done one side, I mean if the time is for two sides like Attacking someone, I think it still can't solve the problem. thanks
I'm sorry still not get in to the cron job part. do you meant with cron job, is like an action-time-based script that handle all of the time module at the game ? yeah ..... my friend tell me that too, pehaps the time system can be handle by record the time when user logoff so when user login I can calculate how many time have been pass and I can decide how many resource user get, which building has been done. but I think that it can be done one side, I mean if the time is for two sides like Attacking someone, I think it still can't solve the problem. thanks
I have provided a link to what cron jobs are, so scroll up this thread to see the link and check it out. Cron jobs are a system task, not related to the actual game code. It will just run a game script which will handle manipulating player data.
Now as far as the record time for an event, it doesn't necessarily have to be just when the login and logoff but anytime a page is refreshed and the PHP code is executed. Timestamping an event can set the event "in stone". Just like it would in history. This is a fixed point in time that can be seen by either side of a two-side game. If the person attacking attacks a person, the actual attack would have the timestamp. The player that was attacked would see the attack happened 2 secs, 2 minutes, 2 days ago etc. The attacker would see that they attacked 2 secs, 2 minutes, 2 days ago.
Lets say 5 minutes later both the attacked and the attacker refresh their page. There would be a calculation in the page to take the time now - the timestamp of the attack and see that it happened 5minutes 2secs, 7 minutes, or 2 days and 5 minutes ago.
Timestamping the actual event again makes it a fixed point and that both sides of a conflict or such will see it to their own relative time. So tinker around with the concept. This is the mechanism used in many online games. Especially turn based games. You have to know when an event had taken place and how long ago it took place since you can't be online all the time. This setup will also allow you to form a history log of attacks and events.
Atm I have a game name... I will start using Freehostia untill i have enough money for a payd one.. But i have the scripts and i got the tip to upload them.. So i logged in on Freehostia.. my account and uploaded my "Crime" Script.
But when i clicked on it.. It said "Page Could Not Be Found"
I have a website that is a virtual pet community which has various PHP games that members can play to gain points, etc.
I am very interested in your post and would love to learn how to script games.
One thing I have in mind is currently members can only battle against enemies that I upload to the community. What I would like to do is set it up so members can battle against each others pets and send each other battle requests. It would also be good to have a league table that rates its members.
Is there anyone out there that could help me? It would involve adding to a system and database that is already in place.
Atm I have a game name... I will start using Freehostia untill i have enough money for a payd one.. But i have the scripts and i got the tip to upload them.. So i logged in on Freehostia.. my account and uploaded my "Crime" Script.
But when i clicked on it.. It said "Page Could Not Be Found"
So i dont know what to do
If you successfully uploaded a script to your host, it is just a matter of knowing where your script is located and typing in the URL. If you are getting the page could not be found error, you either mistyped the name or need to change the URL to reflect your script. I would first check your capitalization of the file name and make sure it exactly matches what you uploaded as well as your spelling. Second I would make sure you are typing in the correct address to get to your account and your page.
I have a website that is a virtual pet community which has various PHP games that members can play to gain points, etc.
I am very interested in your post and would love to learn how to script games.
One thing I have in mind is currently members can only battle against enemies that I upload to the community. What I would like to do is set it up so members can battle against each others pets and send each other battle requests. It would also be good to have a league table that rates its members.
Is there anyone out there that could help me? It would involve adding to a system and database that is already in place.
Thanks
Justin
Something like this could be accomplished through the use of a table which would keep track of the battle requests. When a user makes a request, you would add a line to a table which would track things like who sent the request (their id), who the message is for (their id), a date the request was launched (so you know keep track of how old the request is and time limits for the person to respond), a special unique request ID, and any details about who is doing the battle and with what pets.
When the person being attacked then logs in, their page can read battle requests and presented with a button to accept the challenge. The battle can then engage and as soon as battle is over, resources are divided and the request is cleared from the table.
Think of it as a queue for battle. When both parties agree on the battle, it then happens and at the end the request is removed from the queue. This will allow a person to essentially battle, end the battle, click for another request and jump into battle again with another party.
If you look earlier in this thread, links were provided to sites which show how to use cron to setup game events. All you need to do is just have the scheduled jobs run scripts at specific times of day etc.
hi,i make simple RPG php game,but i confuse about quest... can you help me what i must do first?like table that i must make or else thanks... ( sorry my english bad )
For beginners here is a simple webgame called catch-a-thief. If u r serious about game development this kind of game is a good place to start. <?php include "thiefcss.php"; ?> <div id='ca'> <?php $img = ""; $mess =""; $array = array("Jewellery_Store" , "Art_Gallery" , "Bank" , "Museum" , "Trade_Show"); $thifee = array("Prison" , "Little_Old_Ladies_House"); $new = array_merge($array, $thifee); if (!isset ($_GET['thief']) ) { $img ='beg.jpg'; $guess = '0'; $mess = "<h4>The thief moves around quickly see if you can either catch him or put him behind bars, if you manage to pick the same location as the thief, you catch him, if he lands in prison you win, but if he gets into the little old ladies house you lose</h4>"; shuffle($array); $thief = $array['0']; echo "$thief"; } else if (isset($_GET['thief']) ) { if ($_GET['thief'] == $_GET['yourpick']) { $img ='caught.jpg'; $mess = "<a href='catchthief.php'>You have caught the thief,play again</a><br />"; } else if ($_GET['thief'] == 'Prison') { $img ='cops.jpg'; $mess ="<h2>You Have put the thief behind bars, you win</h2><a href='catchthief.php'>Play again!!<a/><br />"; } else if ($_GET['thief'] == 'Little_Old_Ladies_House') { $img ='beg.jpg'; $mess ="<H2>The Thief is in the Little Old Ladies House, you lose</h2><a href='catchthief.php'>Play again!!<a/><br />"; } else
{ echo "<b>Thief's present location $_GET[thief]<br />"; $img = 'beg.jpg'; $mess = "The thief is on the move your time is running out";
For everybody who is looking for a good host for their games which has cron jobs, take a look at www.novahost.org. I used it for my game and it has a very good uptime, although it's free (don't want to advertise, just helping out the people who are looking for a host.
And for anybody who is trying to start making a game, you have to plan it very carefully and preferrably use a CVS system, especially if you are working with other people. I made an OK game I would say, in almost a year... so be prepared for long nights of hard work and lots of coffee...
Hello everyone! Well Im working on a text based games atm, I have got a WAMP Server (Includes MySQL, PHP, Apache etc) but I have encountered some problem and confused with the database on the MyAdmin part of local host. I have just been learning php for sometime and created a login script. It works fine, but I have no idea how to get it in the database and get it running (for practice) so I can continue further. I have tried loads of times but it shows an error (in the database) etc...
If you lot understood me lol, Help would be apreciated.
I have tried loads of times but it shows an error (in the database) etc...
What commands did you use and what errors did you get? Without more information it is hard to tell what is wrong.
in PHP:
CODE
<?php // we connect to example.com and port 3307 $link = mysql_connect('example.com:3307', 'mysql_user', 'mysql_password'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($link);
// we connect to localhost at port 3307 $link = mysql_connect('127.0.0.1:3307', 'mysql_user', 'mysql_password'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($link); ?>
WARS OF CAQUSANDRA, mmorgp, has begun, I'll post the code as I go along, but I would love a little help, perhaps when it is finished a tutorial might be in it.
In the beginning when the world had only begun to learn, in the beginning when man had only begun to learn... survival was the key, .. survival of the fittest meant that unless you committed yourself to the art of living you would be left behind. The old world has set its sights on conquering the blight of caqusandra, are you up to the challenge.
[code] mysql table, please crit it, this is the basis for the game, good planning here will save a lot of time.
<?php include "config.php"; $query = "CREATE TABLE multi(id SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), userp VARCHAR(10), password VARCHAR(19), loc TEXT, avatar TEXT, tokens VARCHAR(100), weapons VARCHAR(100), wars VARCHAR(50), position VARCHAR(50), hunt VARCHAR(50), loot VARCHAR(50), maps VARCHAR(100), strategy TEXT, bal VARCHAR(100), history TEXT, other1 TEXT, other2 TEXT, other3 VARCHAR(100), other4 VARCHAR(255), other5 VARCHAR(100), other6 VARCHAR(100))"; print "running query"; mysql_query($query, $link) or die ("CREATE TABLE error: " . mysql_error()); mysql_close($link); ?>[code]
My name is Jeff. I am not sure if I am in the right area or not. But my question I wanted to out forth, was I have spent a good deal of 2 years learning everything from simple html to php, to css and now java. I find myself stuck alot of times because I have to work through errors on my own and sometimes it takes days if not weeks for me to figure them out. So what I wanted to know is there a site where I can go to test the codes in action prior to uploading to my site. Or if anyone can tell me how to use dreamweaver to test on local server before uploading.