Jump to content
MakeWebGames

Recommended Posts

Posted

I would like to change the Gym to only allow training once per day, could someone tell me what I need to find and what needs changing

to do this? Or is it possable to change to one train per level a player gains?

Posted

Do something like this..

Make a table called daily_train

3 fields

daily_train_id

daily_train_userid

daily_train_time

 

Add this query to your gym page for after they train.

 

$daily_check = sprintf("SELECT daily_train_id FROM daily_train WHERE daily_train_userid = %u",abs(@intval($ir['userid'])));
$check = $db->query($daily_check);
if($db->num_rows($check) > 0)
{
$daily = sprintf("UPDATE daily_train SET daily_train_time = unix_timestamp() WHERE daily_train_userid = %u",abs(@intval($ir['userid'])));
$db->query($daily);
}
else
{
$daily = sprintf("INSERT INTO daily_train VALUES('', %u, unix_timestamp())",abs(@intval($ir['userid'])));
$db->query($daily);
}

 

Now to check at the top of the page (gym) add this

 

$allow_train_sprint = sprintf("SELECT daily_train_time FROM daily_train WHERE daily_train_userid = %u",abs(@intval($ir['userid'])));
$allow_train = $db->query($allow_train_sprint);
$allow_t = $db->fetch_row($allow_train);
if($allow_t['daily_train_time'] < time() - 86400)
{
printf('Sorry, you can only train once a day.');
printf('[url="index.php"]> Go Home[/url]');
$h->endpage();
exit();
}

 

This is made very quick, and untested..

Posted

The abs() and intval() on the number coming from the database is not required - and is pretty much a waste of space ;)

 

$check = $db->query(sprintf("SELECT daily_train_id FROM daily_train WHERE (daily_train_userid = %u)", $ir['userid']));
if($db->num_rows($check)) {
$db->query(sprintf("UPDATE daily_train SET daily_train_time = %u WHERE (daily_train_userid = %u)", time(), $ir['userid']));
} else {
   $db->query(sprintf("INSERT INTO daily_train VALUES ('', %u, %u)", $ir['userid'], time()));
}

 

$allow_train = $db->query(sprintf("SELECT daily_train_time FROM daily_train WHERE (daily_train_userid = %u)", $ir['userid']));
$allow_t = $db->fetch_row($allow_train);
if($allow_t['daily_train_time'] < time() - 86400) {
   echo 'Sorry, you can only train once a day.
[url="index.php"]> Go Home[/url]';
   $h->endpage();
   exit;
}
Posted

Thanks for help on this and the codes to change.

 

Jordan = I am open to suggestions, I just didn't think a player should train and get extreamly high stats, and be not leveled much.

I not sure long term game would still work right with a level 10 with 5000 Str because they was able to train 40 times a day. That is what

I had in my mind at time of trying to figure a way around gaining too much training.

Posted

I can see the point, but wouldn't the player at some point have huge stats and it be too easy for player to fight, pvp, gvg. ?

I am re-looking at this, for best way to do it, without damage of game. 5 trains per day....mmmm.. maybe 1 per hour, or 4 per day might work, I just

don't know yet. The goal is to keep from gaining huge amount of stats without making effort to play.

I know of one game that allowed players to train all time, and a few of them only came to get stats and would logoff until they could train again.

resulting in a level 5 with stats that could not be matched by most unless they also trained and leveled too.

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