|
Limit clicks/day to 10, for each pet?
|
|
02-04-2010, 05:24 PM
Post: #1
|
|||
|
|||
|
Limit clicks/day to 10, for each pet?
I want to do this a) to stop Yarolds people buying 100pets and lvling them all to max that day and b) to add a sense of realism (so they dont grow old in a day).
My idea was to add two columns to the "owned_adoptables" table: "date" and "clickstoday" or to that effect.Then I would edit the levelup.php script so that each click would check to see if "$date" is the current date and what "$clickstoday" is. If the date is wrong it will update the date (to the current date) and set "$clickstoday" back to naught. If the date is right and "$clickstoday" is under 11 I will have it run the normal procedure and add 1 to the field. I just wanted to run this by you guys to see if you see any immediate problems? Such as, is the date variable going to be the same for everyone? Or can someone in Australia click the pet, then an American (thus resetting the $date, since it's probably different) and the Australian being able to click it again...? Or otherwise, do you have a better system? It doesn't seam that hard to code. :\ |
|||
|
02-05-2010, 08:12 AM
Post: #2
|
|||
|
|||
|
RE: Limit clicks/day to 10, for each pet?
The date would go by the server's date, so whatever time zone the server your site is on will determine the date that is used for all users. I don't see why this wouldn't work.
Brandon Rusnak - RusnakWeb Admin and Founder A New Version of the MyBB Multiforums Mod is on the way! More details here. MyAdopts - Free Adoptables Site Hosting powered by Rusnak PHP Adoptables Lead, follow or get out of the way. |
|||
|
02-05-2010, 06:24 PM
(This post was last modified: 02-05-2010 06:26 PM by Quillink.)
Post: #3
|
|||
|
|||
|
RE: Limit clicks/day to 10, for each pet?
Code: if ($clickdate != date('Y-m-d')) { $newdate = date('Y-m-d'); $newctd= $ctd + 1; $addclicks = 1; } This is the code I've flung together based on what I thought would work. Does anyone who actually know php see what's wrong with it..? $newctd (which stands for "clicks today") is working fine, but for some reason $newdate keeps returning "1". Thanks, if anyone can help me.
|
|||
|
02-06-2010, 12:36 AM
Post: #4
|
|||
|
|||
|
RE: Limit clicks/day to 10, for each pet?
You haven't set your date vaiable to begin with.
Sea Mystic Grove |
|||
|
02-06-2010, 05:13 AM
Post: #5
|
|||
|
|||
|
RE: Limit clicks/day to 10, for each pet?
Hmm but it's used earlier to write to the "voters" table? (I mean $date, which doesn't work if I replace all the date('Y-m-d') with it. $date = date('Y-m-d') as it is)
Did you guys want to peer at the whole php file? It's pretty unorganised since I cut out the commentation (trying to cut down on bandwidth :\ ) but it's readable. P.S. I purposely made the comments so they wouldn't affect my script while I asked for help.
|
|||
|
02-06-2010, 11:14 AM
Post: #6
|
|||
|
|||
|
RE: Limit clicks/day to 10, for each pet?
Another idea, why not just use the vote-voters table? It tracks the date and adoptable ID each time someone votes for a pet. Just run a query on that table that selects all records for the current date and the adoptable ID and if the number of records returned is greater than 10 then prevent leveling.
Brandon Rusnak - RusnakWeb Admin and Founder A New Version of the MyBB Multiforums Mod is on the way! More details here. MyAdopts - Free Adoptables Site Hosting powered by Rusnak PHP Adoptables Lead, follow or get out of the way. |
|||
|
02-06-2010, 01:44 PM
(This post was last modified: 02-06-2010 02:13 PM by Quillink.)
Post: #7
|
|||
|
|||
|
RE: Limit clicks/day to 10, for each pet?
:o
Lol. Trust me to pick the abstract, complex way right off the bat. I'll definitely do that Brandon, thanks for suggesting it. ![]() EDIT: It's really hard to see if it's working, but does this look functionable to you guys? Code: $query = "SELECT * FROM ".$prefix."vote_voters WHERE adoptableid='$id' and date = '$date'"; |
|||
|
02-07-2010, 08:10 AM
Post: #8
|
|||
|
|||
RE: Limit clicks/day to 10, for each pet?
(02-06-2010 01:44 PM)Quillink Wrote: :o It looks like it should work, but why not just check if you should add the click or not and if not just don't do the database queries and instead show the user an error message. On a large site there's no need to run unnecessary queries. ![]() You'll be able to tell if it is working too that way.
Brandon Rusnak - RusnakWeb Admin and Founder A New Version of the MyBB Multiforums Mod is on the way! More details here. MyAdopts - Free Adoptables Site Hosting powered by Rusnak PHP Adoptables Lead, follow or get out of the way. |
|||
|
02-08-2010, 11:37 AM
(This post was last modified: 02-08-2010 12:23 PM by Quillink.)
Post: #9
|
|||
|
|||
|
RE: Limit clicks/day to 10, for each pet?
I thought I needed the query to check the number of rows in the votes table? Sorry Brandon, but could you show me an example..? :S
EDIT: Is this what you meant? Code: $query = "SELECT * FROM ".$prefix."vote_voters WHERE adoptableid='$id' and date = '$date'";This way it doesn't bother with the other queries if the click limit's already been reached.
|
|||
|
02-09-2010, 06:35 AM
Post: #10
|
|||
|
|||
|
RE: Limit clicks/day to 10, for each pet?
Yeah, something like your last post is what I meant, so you're not running the level up procedure if the pet can't be leveled anyway.
Brandon Rusnak - RusnakWeb Admin and Founder A New Version of the MyBB Multiforums Mod is on the way! More details here. MyAdopts - Free Adoptables Site Hosting powered by Rusnak PHP Adoptables Lead, follow or get out of the way. |
|||
|
« Next Oldest | Next Newest »
|

Search
Member List




