![]() |
Home Community Mys-Script Creative Off-Topic |
|
![]() |
|
Thread Tools | Display Modes |
#1
|
||||
|
||||
![]()
I know this code to work in Mysidia 1.3.4, because in classes/class_member.php, a certain public function changecash($amount) exists and also because in the Admin CP, Widgets and Modules can be made. Please look for these in older versions of Mysidia before beginning. ^^ As always, make backups of your files.
First of all, you will need jQuery included in your template files. If it is not, or you're not sure, please open up your template.tpl and observe the space before the end of the </body>. If you need a link to jQuery, it is hosted via CDN, so all you need to do is add this line: Code:
<script src="//cdn.jsdelivr.net/jquery/1.10.0/jquery.min.js"></script> PHP Code:
PHP Code:
Now, log into your Admin CP and create a new Widget named 'giftbox'. If you name it anything else, you'll be calling it with that name. (Later we'll be calling this widget with {$giftbox}.) Set the Controller Level to 'all', the Widget Order to '50', and Widget Status to 'enabled'. Next you'll be making a Module with a Parent Widget of 'giftbox', which you just made. You should be able to name the module whatever you like. For amusement's sake, I named mine 'WrappingPaper'. I'm pretty sure the name here will not matter. The Required Userlevel should be 'member'. Module HTML Code: Code:
<style>.giftbox {text-align: center;} .blankbox {background: url(http://fc05.deviantart.net/fs70/f/2014/099/4/f/small_giftbox_by_kyttias-d7dqg9o.png); border: 0px; background-size: 100% 100%; width: 60px; height: 50px;} .blankbox:hover {background: url(http://fc05.deviantart.net/fs70/f/2014/099/4/f/small_giftbox_by_kyttias-d7dqg9o.png); border: 0px; background-size: 100% 100%; width: 60px; height: 50px;} </style> <form id="giftbox" action="giftbox" name="giftbox" method="post" role="form"> <input type="hidden" value="500" name="amount" /> <button class="blankbox" id="submit" value="submit" name="submit" type="submit">*</button> </form> <div id="result"></div> <script> $(function () { $('.giftbox').animate({'height':'55px'}); var frm = $('#giftbox'); frm.submit(function (ev) { $.ajax({ type: frm.attr('method'), url: frm.attr('action'), data: frm.serialize(), success: function (data) { $( "#giftbox" ).css("display","none"); $amount = $('#giftbox').find( 'input[name=\"amount\"]' ).val(); $( "#result" ).html( "Gained "+$amount+" CURRENCY!" ); $cashonhand = $('.cashonhand:first').text(); $newcash = Number($cashonhand)+Number($amount); $('.cashonhand').text($newcash); $('.giftbox').animate({ height: 0, opacity: 0 }, { duration: 2000 }); } }); ev.preventDefault(); }); }); </script> Technically, from the code above, the style css you can just add to your stylesheet. You'll recognize that this is where you should change the image of the box. Lastly, look at the form itself, see this? Code:
<input type="hidden" value="500" name="amount" /> Module PHP Code: PHP Code:
All done! Open up your template and it's template.tpl file and place {$giftbox} to test it out. As you'll see, anywhere {$giftbox} exists, a box will show that you can click. Now that you have this power in your hands, I know you'll only want your giftbox to show on special circumstances. (I assume) you can use it on your own custom pages, and you can also write scripts. If you'd like that giftbox to show up 5% of the time, this can go in your template (or on a custom page): Code:
{if rand(0,100) <= 5} {$giftbox} {/if} ![]() Question time! - Savvy viewers, how could I go about modifying the php function to deliver an item to the player's inventory? What about an egg directly into their owned adoptables table? - Are there issues with it appearing on custom pages? I haven't made any/haven't tried to use Smarty variables in them. (( If you think this was awesome, you can always donate to my PayPal e-mail address, which is my username here @gmail.com. ^^ It'll go towards getting my cat a cool tower to play on. ))
__________________
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; 07-16-2014 at 03:05 PM. |
#2
|
||||
|
||||
![]()
This is amazing! I will probably add this! Is there any way to either a) make the currency obtained fluctuate (rand function?), or b) put items in there? Thank you!
__________________
Avatar courtesy of Doll Divine. |
#3
|
||||
|
||||
![]()
^ I'll work on making one that fluctuates. Like... you'll get a random amount between 500 and 2000?
Items I'm not sure on yet. I've got some time in the next few weeks, so I'm hoping to develop something like that.
__________________
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; 07-16-2014 at 03:01 PM. |
#4
|
||||
|
||||
![]()
Yeah, that's what I mean. Can we just use the rand function?
Thank you! That will be fun.
__________________
Avatar courtesy of Doll Divine. |
#5
|
||||
|
||||
![]()
This is untested, but, to change the value from '500' to 'random' on the form:
Code:
<input type="hidden" value="random" name="amount" /> PHP Code:
__________________
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; 07-16-2014 at 03:51 PM. |
#6
|
||||
|
||||
![]()
Okay, just tested it out with the randomizer and I got about 1000 each time. By the way, I've found out that it only gives you the money if you click on it.
But anyway, it works perfectly! Thank you!
__________________
Avatar courtesy of Doll Divine. |
#7
|
|||
|
|||
![]()
1.3.3 does not have a working widget system so it can only work with 1.3.4 btt (at least, a non-basic editable widget system, to my knowledge) Also is there any way that you can supply this in 'non-module' format for those of us with the slightly defunct version? :)
|
#8
|
||||
|
||||
![]()
Well, I downloaded 1.3.3 and tried things for several hours and couldn't replicate what I'd done. I can randomly echo out giftbox or not on every page the sidebar exists (all of them), but not place it anywhere conveniently (it sits at the top of the page before the header where it echos out, not even in the sidebar itself, and it refuses to append anywhere else, despite my attempts), or on any particular page. Someone else will have to make an attempt.
__________________
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; 07-18-2014 at 06:42 PM. |
#9
|
|||
|
|||
![]()
Hey this is an awesome addition! Thanks for this!
Just a little help getting it fully implemented would be awesome! You are quite skilled at what you do here. I followed all the directions and upon trying to create the module for the widget I am met with the following error: Warning: require(../inc/config.php): failed to open stream: No such file or directory in /home/paradi17/public_html/classes/class_initializer.php on line 97 Warning: require(../inc/config.php): failed to open stream: No such file or directory in /home/paradi17/public_html/classes/class_initializer.php on line 97 Fatal error: require(): Failed opening required '../inc/config.php' (include_path='.:/opt/alt/php55/usr/share/pear:/opt/alt/php55/usr/share/php') in /home/paradi17/public_html/classes/class_initializer.php on line 97 Any help deciphering this would be great :) Thanks again! -Chipz |
#10
|
||||
|
||||
![]()
Confirm that the error does not exist when the module is not being called. (ie, Remove {$giftbox} from your template. Is the error gone?) If the error isn't gone, it's nothing to do with this. If it's gone, then make sure the name is correct. (Again, as stated in the tutorial, if you named it anything else, you'll be calling it with that name.)
Otherwise... eh, this was one of my first mods. ![]()
__________________
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. |
![]() |
Tags |
cash, changecash, currency, giftbox, random |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help !! Shops not appearing é.è | kitty08 | Feedback and Suggestions | 3 | 12-31-2014 11:15 AM |
Second Currency and Currency icon | Rovick | Suggestions and Feature Requests | 14 | 11-11-2014 05:29 PM |
Site appearing blank? | Pear | Questions and Supports | 18 | 11-09-2014 04:50 PM |
Giving pets a Gender | Arianna | Mys v1.1.x Mods | 64 | 11-24-2010 01:45 AM |
Eggs randomly displayed | Quillink | Questions and Supports | 11 | 01-30-2009 03:08 AM |
What's New? |
What's Hot? |
What's Popular? |