onex Posted February 15, 2010 Posted February 15, 2010 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? Quote
AlabamaHit Posted February 15, 2010 Posted February 15, 2010 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.. Quote
Magictallguy Posted February 15, 2010 Posted February 15, 2010 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; } Quote
Jordan Palmer Posted February 15, 2010 Posted February 15, 2010 GREATWay to do is how Alabama says.. Â However there are a few ways off doing this. Â Limiting user's one train per day will not do you any favours though. So think about it >,< Quote
onex Posted February 15, 2010 Author Posted February 15, 2010 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. Quote
Jordan Palmer Posted February 15, 2010 Posted February 15, 2010 I'm no expert on gaming, However I do know limiting the time people try is bad and won't help your userbase grow >,< :whistling: Quote
CJ - Twitch Posted February 15, 2010 Posted February 15, 2010 I know I wouldn't play a game like that. Maybe 5 trains a day but not 1. ;( Quote
onex Posted February 15, 2010 Author Posted February 15, 2010 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. Quote
Magictallguy Posted February 15, 2010 Posted February 15, 2010 As the game grows, so do the stats - it's inevitable. Limiting the trains seems like a good idea in principle, but you could also/just limit the amount gained from training Quote
onex Posted February 15, 2010 Author Posted February 15, 2010 Magictallguy = I can live with that, what part of gym code handles the % or amount per training? Thanks. Quote
Magictallguy Posted February 16, 2010 Posted February 16, 2010 By default, it's the $gain variable. Search for it in the gym.php and edit the formula Quote
Jordan Palmer Posted February 16, 2010 Posted February 16, 2010 I think we'd all agree with that rather then limiting amount of trains :wacko: Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.