Home Community Mys-Script Creative Off-Topic |
|
|
Thread Tools | Display Modes |
#1
|
||||
|
||||
Mod In Progress - Community Interaction Bonuses
And by interactions, I mean visiting/clicking adoptables. To encourage user participation and interest in others, of course! When site-wide a grand total of x interactions has been in a day, everyone will reap the benefits!
Bare with me on my rambling... this is just a feature I want, and I'm a ways off from fully implementing it, so I'm using this space to jot down some pseudo-code. It's all hypothetical at this point, but with some feedback, this will become a rather nice mod. Please don't attempt to follow my instructions unless you've read through them and somewhat understand what you're doing. Only people who think they grasp what's going on and think they can attempt to help should continue. This is not a mod yet, and not production ready! First, we set up space in the database (I'll be using the levels_settings table) to store timestamp and expiration date columns. (Feel free to replace the default with whatever today's date is. The format will be Y-m-d, for example, 2014-11-14.) Code:
ALTER TABLE `adopts_levels_settings` ADD `timestamp` DATE NOT NULL DEFAULT '0000-00-00' ; ALTER TABLE `adopts_levels_settings` ADD `expires` DATE NOT NULL DEFAULT '0000-00-00' ; Using the following code, the day's total interactions made by all users will be tallied, and effect will turn on if this total is above a certain threshold (currently >=2). The effect will expire at midnight the day its timestamp turns on, and the effects (not currently supplied) will turn off. Again, currently, there is no actual effect taking place, just a placeholder, ready to take on some code to launch. But I do supply a way of rendering a quick check as to whether the system is working. Conditions to activate and de-activate bonus effects will be checked on every page load. The code I'll supply below can go into class_template.php - since it will always run one each page. I've placed at the bottom of the inside of private function assignTemplateVars(). I'm sure there's better placement for all this, but... it's where I tend to test my code, ahaha. PHP Code:
Things I need help with now: 1 - I want more complicated requirements than just hitting a daily threshold that expires at midnight. I need to find the total number of interactions in a range of dates, between $timestamp and $today, for an effect that builds over several days worth of interactions until a threshold is finally met. Help constructing a database query that's a Mysidia equivalent to this query format would be nice. 2 - I also want effects to dismiss themselves if it is past exactly 24 hours from their creation, not just if it is the next day/past midnight. So I will need to change how I am storing the date format. Would anyone be willing to test this out for me? 3 - No function actually takes place, currently, but the possibilities could include temporary boosts such as increased currency yield from visiting adoptables, and for adoptables have an increased click (exp) rate from visits. More complex implementations might feature shop discounts or everyone receiving a bit of additional currency/an item. I would love some direction on how to make these happen, to speed this along into becoming an actual mod. 4 - I would love some general feedback on how to improve and optimize my existing code. Where it's stored, if it should all be in a giant function, and other tips and such. 5 - This sort of thing is best fine tuned to cater to the exact size of your site. If you expect a lot of interactions, you may want to set the bar high. If you're a new site, you'll want it to be quite low. Therefore, help implementing it into a feature that can be controlled from the admin panel would be amazing. 6 - I also need to know what versions of Mysidia this will/won't work with. I don't know just much has changed between versions, ahaha...
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it. Last edited by Kyttias; 11-11-2014 at 10:29 PM. |
#2
|
||||
|
||||
Interesting! I will try to answer what I can!
Quote:
PHP Code:
Quote:
PHP Code:
Quote:
levelup.php - click() PHP Code:
Quote:
Since this will take a few lines, I'd move the code you already have in assignTemplateVars() to a separate private function but in the same file and call that function somewhere inside assignTemplateVars(). This is just for organization though, separating big functions into smaller ones makes the code more readable (Code Refactoring - Method Extraction) I'd also use && instead of 'and' xD Number 5, you can create a new settings page just for those or add those settings to an existing page too. Add the fields you want (range of days? bonuses?) to a form then after submiting it update the database with those values If it gets to a point where you want to define many different bonuses (money, clicks, discounts...), maybe create a new table just for those bonuses? Number 6, I can't really help with sorry :/
__________________
asp.net stole my soul. Last edited by IntoRain; 11-12-2014 at 05:11 AM. |
#3
|
||||
|
||||
*high fives* Beautiful teamwork, IntoRain! Thanks again~
I want to test out a few more things, get those additions added in, and then once that's done I'll write up a cleaner post here... and once I get the adminCP version working, I'll release it as an actual mod in a thread in the proper area. I actually wrote up quite a fun list of features I want last night, since it all seems within my grasp now. There's a lot of new data I'd like to be collecting from user activities, so I may in fact be making my own table afterall. :: plans of more data to track :: total sitewide interactions (pet visits) (weekly) total individual user interactions (pet visit) (daily, each day, weekly) total number of pound rescues by individual user (ever) total amount of currency spent by all users (weekly) total amount of currency spent by individual user (ever) total owned adoptables (user and sitewide, ever) most owned (popular) adoptable (user and sitewide, currently) Part of it's just displaying fun facts so the admin has a view of their site's progression (as in, these would be great stats to show on the opening page of the adminCP, especially if totals are tracked daily! could make a cute chart~), but these things can also be put to real use in regards to rewarding the community for being active (in a way extremely similar to my opening post - timestamping!).
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it. Last edited by Kyttias; 11-12-2014 at 02:05 PM. |
#4
|
||||
|
||||
Happy to help! :D good luck with the rest of the mod, it looks very interesting!
__________________
asp.net stole my soul. |
#5
|
||||
|
||||
So how does this one go now? Are you encountering some issues?
__________________
Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site. |
#6
|
||||
|
||||
Well I got some work done re-factoring the code. I've made the timestamps down to the hour:min:sec, created a table just for bonus data, and made it an independent function/method.
- New instructions (so far) are as follows: Open phpMyAdmin to access your MySQL database. Open up the database for Mysidia. On the left hand side there should be a long list of tables for Mysidia, with the prefix that you put in during your initial install. The default prefix is adopts_. If your prefix is different, you will want to change it in two places in the code below. Now, look to right side, at the top. The second tab, between Structure and Search, should be SQL. Open this up, and paste in the following code to run, then press "Go". Code:
CREATE TABLE IF NOT EXISTS `adopts_kyt_bonuses` ( `id` int(10) unsigned NOT NULL, `bonus_name` varchar(20) NOT NULL, `bonus_type` varchar(20) NOT NULL, `status` varchar(5) NOT NULL, `amount` varchar(20) NOT NULL, `timestamp` varchar(20) NOT NULL, `expiration` varchar(20) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `adopts_kyt_bonuses` (`id`, `bonus_name`, `bonus_type`, `status`, `amount`, `timestamp`, `expiration`) VALUES (1, 'Bonus1', 'Type1', 'off', '2', '2014-11-17 16:33:07', '2014-11-18 17:06:41'); INSERT INTO `adopts_kyt_bonuses` (`id`, `bonus_name`, `bonus_type`, `status`, `amount`, `timestamp`, `expiration`) VALUES (2, 'Bonus2', 'Type2', 'off', '6', '2014-11-17 21:49:59', '2014-11-18 22:23:33') You will now be able to find the table we created, adopts_kyt_bonuses, in the list on the left. If you open it up, you should see a table that looks like this: *Disclaimer: Sometimes I'll be calling things functions, other times I'll be referring to things as methods. However, methods are just functions found inside a class. *thumbs up* Onward! Open up ~/classes/class_template.php. We're going to be creating a new method called checkCommunityBonuses(). To start, we'll add it to the method used to construct the template, that way it knows to run. If you haven't modified this file, in version 1.3.4, you'll find public function __construct(Path $path) at around line 62. Inside this method that constructs the template, after the list of other functions it knows it needs to run, add in: PHP Code:
PHP Code:
Assuming IntoRain's modification to levelup.php mentioned in a post above works out just fine (replacing of course the line linking to the effect in the database), we'll be doing something similar to that. Exact instructions for this part aren't written up yet, aha. - Things I need help with now: 1 - You'll see that in the construct method for the template I'm calling the checkCommunityBonuses() function I made with a parameter holding the bonus name. Obviously not ideal at this point! I need to make another function that pulls from the database the number of bonuses that exist, loop through them, and then call checkCommunityBonuses() for each of them. ( And it's much too late tonight for my brain to want to do that.) 2 - H-how do I make Smarty variables with a variable in the name? *nervous laugh* I left the code in there from last time (give or take a few tweaks) but it'll only pull up data from the last bonus it came across, I'm sure. I want to make an admin panel here, so telling users they have to go in and make these variables by hand is... not ideal. Obviously, they'll want to be able to customize the contents of these -- rather than reading off hard data they could put in an image and a tooltip to represent the bonus being on or off. 3 - So. New settings to add the AdminCP... Man, would I appreciate some pointers here. I'll figure it out later given enough time, but I don't have any specific questions right now because I haven't even begun to peer down that rabbit hole. This is on my to-do list... 4 - The modifications to levelup.php - so, what if we've got multiple bonuses going on? And, what if I create room in the database for the bonus clicks and currency so users can do that in the adminCP? I don't know how many bonuses a site owner might create, but I would know their settings for bonus clicks and currency, then. 5 - Eh, should I just forgo the adminCP business, since there's going to be so much to do by hand, anyway?
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it. |
#7
|
||||
|
||||
Sorry, I've been busy lately and couldn't reply earlier x.x
When creating a table, you can set your ID to be a primary key and auto_increment. That way you don't need to add an id manually when inserting a new row, it will increment the ID's for you Quote:
So, basically you can call your function like this: PHP Code:
PHP Code:
Quote:
assigning: PHP Code:
PHP Code:
Quote:
I can be more specific when you go into making the admincp pages ^^ Quote:
I advise just finishing the feature itself and worrying about the admincp after you have everything finished. As long as the values are in the database, it should be simple to find a way to change them ^^
__________________
asp.net stole my soul. |
#8
|
||||
|
||||
Wow.. I know this is 2 years late but this seems like an absolutely brilliant way of rewarding users... was it ever finished, or progressed further than this? It would be amazing if a mod like this came out sometime!
|
Tags |
bonus, clicks, community, interaction, mod |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
The community here is brilliant! | CallumCharlton | Newcomer Center | 3 | 03-11-2015 10:29 AM |
Opinions on Progress | RoconzaArt | Art Gallery | 9 | 01-20-2011 10:38 PM |
Which is best open source community software? | chriskrich878 | Other Chat | 3 | 11-23-2010 09:06 PM |
Still a work in Progress | MyBBSkinz | Adoptables Sites Showcase | 7 | 08-31-2008 08:13 AM |
Urm Yeah mybb community forums | Ajof | Other Chat | 5 | 06-29-2008 04:12 PM |
What's New? |
What's Hot? |
What's Popular? |