Jump to content
MakeWebGames

Travel Timer. Wait for the train. LITE V1 V2


Agon

Recommended Posts

I got this idea from another old game I worked on.

Users could travel, but they had to wait for the train, plane, bus to arrive.

So the idea is. If you travel using the monorail.php, you have a travel timer that makes you wait X amount of minutes before you can travel again. For example, you travel to another city and it makes it so you have to wait ten minutes before you can travel again.

Why? Here's the fun part... Two players have a rivalry and attack each other all the time. This encourages a game of cat and mouse, where the weaker player is hopping from city to city to avoid attack, and the attacking player has to try to time it just right to get into that location at the same time.

The idea popped into my mind, so I figured I'd post it over here to keep reference on it.

Thanks!

Link to comment
Share on other sites

I might attempt this later, but I think this is what your trying to say.

Run this query in your database:

[mysql]ALTER TABLE `users` ADD `traveltime` INT(11) NOT NULL[/mysql]

Then add a query in monorail.php, (where the location changing query is, don't have the file open so I can't say) that updates the `traveltime` row when they travel to another place. :

$updateTravelTime = "UPDATE `users` SET `traveltime` = `traveltime`+ 10 WHERE `userid` = $userid";
mysql_query($updateTravelTime);

 

Then add this in the appropriate place:

$selectTravelTime = "SELECT `traveltime` FROM `users` WHERE `userid` = $userid";
$do_selectTravelTime = mysql_query($selectTravelTime);
$traveltime = mysql_fetch_assoc($do_selectTravelTime);

 

Now underneath all that, the IF statement:

 if($ir['traveltime'] > 0) {
echo 'Sorry, you have to wait $traveltime minutes before you can travel again!';
$h->endpage();
exit;
} 

 

Now, in cron_minute.php add:

$minusTravelTime = "UPDATE `users` SET `traveltime` = `traveltime` - 1 WHERE `userid` = $userid";
mysql_query($minusTravelTime);

 

This is untested, I simply wrote it in this reply box. I didn't have the file open so I dunno if it will work. Let me know if you decide to try it, I'll be glad to help if it doesn't.

Link to comment
Share on other sites

testing on V2

monorail.php

$selectTravelTime = "SELECT `traveltime` FROM `users` WHERE `userid` = $userid";
$do_selectTravelTime=$db->query($selectTravelTime);
$traveltime=$db->fetch_row($do_selectTravelTime);
if($ir['traveltime'] > 0) {
echo 'Sorry, you have to wait $traveltime minutes before you can travel again!';
$h->endpage();
exit;
} 

 

$updateTravelTime = "UPDATE `users` SET `traveltime` = `traveltime`+ 10 WHERE `userid` = $userid";
$db->query($updateTravelTime);

 

cron_minute.php

$db->query("UPDATE users SET traveltime=traveltime-1 WHERE traveltime>0");

 

Got it working on V2 with this, except one thing.

It prints "Sorry, you have to wait $traveltime minutes before you can travel again!"

instead of displaying the minutes.

Not sure why.

Link to comment
Share on other sites

lol all i did was add '.$ir['traveltimer'].'

also you dont need this

$selectTravelTime = "SELECT `traveltime` FROM `users` WHERE `userid` = $userid";
$do_selectTravelTime=$db->query($selectTravelTime);
$traveltime=$db->fetch_row($do_selectTravelTime);

as it is preselected in $ir

Link to comment
Share on other sites

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.   Paste as plain text instead

  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...