Hey, do anyone know if it's possible to add a "count down" to each thing, like it's only possible to accept a quest every 15min. etc?
*Cooldown
Example 2: If you go into the "Inn" it restores all your health but it's only possible to visit the inn to get full health every hour.. etc.
Anyone know?, Please tell me
That also include if it's possible to make the system update every 10 sec. or something.
Thank you,
Huezzer
			
			
									
						
										
						Countdown
Re: Countdown
You can save a time stamp for when the action occurred and then compare it to the current time stamp when they try again - if it's after the allotted time then let them do whatever, etc.
Believe hall's has a game with something like this..urban realms?
Are you wanting the system to update every 10 seconds for the count down timer? If that, using a time stamp check on say when they visit the inn page would be a lot more efficient like I described up top. But you could have it update 10 seconds if needed, but usually more simple and better ways to solve things
			
			
									
						
										
						Believe hall's has a game with something like this..urban realms?
Are you wanting the system to update every 10 seconds for the count down timer? If that, using a time stamp check on say when they visit the inn page would be a lot more efficient like I described up top. But you could have it update 10 seconds if needed, but usually more simple and better ways to solve things

Re: Countdown
Well I think you could use cronjobs to run a script every x mins. I think halls made a video showing how to use them. But I guess it got a limit for 10min minimum.
			
			
									
						
							Orgullo Catracho
			
						Re: Countdown
http://php.net/time
			
			
									
						
							Code: Select all
function doAction()
{
    // done action
    echo "Did action at " . time();
    // update player action time
    mysql_query("UPDATE `users` SET `action_timestamp` = '" . time() .  "'");
}
function allowedToDoAction()
{
    global $userArray;
    $seconds = 60; // 1 minute
    $actionAllowedTime = $userArray['action_timestamp'] + $seconds; // 1 minute
    return $actionAllowedTime < time();
}
$userQuery = mysql_query("SELECT * FROM `users` WHERE `id` = '" . (int)$_SESSION['user_id'] . "'");
$userArray = mysql_fetch_assoc($userQuery);
if( allowedToDoAction() )
{
    doAction();
}
else
{
    echo "Not allowed to do action";
}
 Fighting for peace is declaring war on war. If you want peace be peaceful.
			
						- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Countdown
Chris rocks....Plain and simple.
			
			
									
						
										
						Re: Countdown
Hey, Thank you! But I only got one question about this code:
How do I know how to use it?, I mean where I need to put it in?, in a code like Inn.php
Don't know if you know what I mean but I mean when I want the "countdown" to be when I go into the inn.php in-game, like 3h countdown to next time until I can "rest" their again.
By the way: I've got players, and id, how can I change the it to halls settings?
Thanks, Andrew
			
			
									
						
										
						Code: Select all
function doAction()
{
    // done action
    echo "Did action at " . time();
    // update player action time
    mysql_query("UPDATE `users` SET `action_timestamp` = '" . time() .  "'");
}
function allowedToDoAction()
{
    global $userArray;
    $seconds = 60; // 1 minute
    $actionAllowedTime = $userArray['action_timestamp'] + $seconds; // 1 minute
    return $actionAllowedTime < time();
}
$userQuery = mysql_query("SELECT * FROM `users` WHERE `id` = '" . (int)$_SESSION['user_id'] . "'");
$userArray = mysql_fetch_assoc($userQuery);
if( allowedToDoAction() )
{
    doAction();
}
else
{
    echo "Not allowed to do action";
}
 Don't know if you know what I mean but I mean when I want the "countdown" to be when I go into the inn.php in-game, like 3h countdown to next time until I can "rest" their again.
By the way: I've got players, and id, how can I change the it to halls settings?
Thanks, Andrew


