- Joined
- Sep 29, 2008
- Messages
- 804
- Reaction score
- 219
The best thing to showcase my invention is--you guessed it! A video! This is how my invention functions, I'm sure you humans are smart enough to figure it out without me needing to explain it in great detail.
Nonetheless, there will be the handful of you "snails" out there that don't quite grasp what it is! It's essentially a recreation of the original MapleStory's Marvel Machine! Spend some money, get some items in return--a website gachapon if you will.
You may be thinking... "Spiegelmann, you're a horrible and ruthless person! You're probably the Black Mage himself!"
While it may be true [STRIKE]that I'm the Black Mage[/STRIKE] that I like to use people for money, this time... I want to try something new. Give something away for free! Why are you complaining? You don't like free? Free is my kind of price. Also, the code is messy and it was rushed to completion.
Onwards, ho! Let's get on to integrating this invention into MapleBit and your server.
Prerequisites: Must have a version with the 'Rewards' system (in video) already available.
Getting the files
First, you need to get the files! This would be a pain in the butt if I were to post the code for each and every single one of them.
Add the files to the corresponding folders in the .zip, (if a file is in the assets folder, add it in the assets folder).
Modifying it so it works for you
Now, time to modify the files!
sources/ucp/main.php
assets/config/afuncs.php
Working on the database!
Ok, now, we need to work on the database side. Again, the prerequisites are that you must have a working rewards system. If you don't know or aren't sure, please refer to the video above where I get the item from a list. Also, you can check out the Rewards system when GMS has a Hot Day.
If your rewards can't be shared with your entire account (only limited to one character), please continue. Otherwise, skip this following spoiler and move on to the next one.
Table for Marvel Prize History
Wasn't that fun? Last step! The source!
I'm really tired at the moment and I can't be of much help with this one. Basically, all you do is look for the 'try' statements for every single method that executes an sql query for the Rewards system. An example would be updateReward() (I think!). Copy the try statement, paste it right under and change it so that it would work correctly for the reward_account table you added earlier. Also, remember, instead of id, it should be accountid because otherwise it would add the character id.
I MAY HAVE MISSED SOMETHING, PLEASE DON'T HESITATE TO ASK. IF YOU HAVE QUESTIONS, PLEASE KEEP IT IN THE HELP SECTION, THANKS.
First, you need to get the files! This would be a pain in the butt if I were to post the code for each and every single one of them.
You must be registered to see links
Add the files to the corresponding folders in the .zip, (if a file is in the assets folder, add it in the assets folder).
Modifying it so it works for you
Now, time to modify the files!
sources/ucp/main.php
After
Add
---
After
Add
PHP:
<li><a href=\"?base=ucp&page=ticket\">Tickets</a></li>
PHP:
<li><a href=\"?base=ucp&page=marvel\">Marvel Machine</a></li>
After
PHP:
}elseif($ucp == "characters"){
include('sources/ucp/characters.php');
PHP:
}elseif($ucp == "marvel"){
include('sources/ucp/marvel.php');
After (optional, this will work pretty much anywhere else within reason)
Add
DO NOT FORGET TO ADD THE PROPER URL PATH FOR $url_path IF YOU AREN'T USING THE ROOT DIRECTORY
PHP:
function ago($time)
{
$periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");
$lengths = array("60","60","24","7","4.35","12","10");
$now = time();
$difference = $now - $time;
$tense = "ago";
for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
$difference /= $lengths[$j];
}
$difference = round($difference);
if($difference != 1) {
$periods[$j].= "s";
}
return "$difference $periods[$j] ago";
}
PHP:
/*maplefreak26 Marveltastic Spectacular Begin*/
function getPrice($nxorvp) { //get the price for marvel
$nx_price = 4900;
$vp_price = 2;//vote point price (not functional)
$basePriceNX = $nx_price;
$basePriceVP = $vp_price;
if ($nxorvp == "nx") {
$price = $basePriceNX;
}
if ($nxorvp == "vp") {
$price = $basePriceVP;
}
return $price;
}
function getName($itemID, $fordisplay) { //lol, version 4 of this, a bit more efficient than the previous
$url_path = "";//must add trailing slash
$data = file_get_contents("http://".$_SERVER['HTTP_HOST']."/".$url_path."sources/marvel/getItem?id=".$itemID."");
if ($fordisplay == false) {
$data_escaped = addslashes($data);
} else {
$data_escaped = $data;
}
return $data_escaped;
}
function generateCSCode() {//supposed to be used for Cash Shop code generation, but used for identifying the item instead because Cash Shop doesn't work
$characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = 'SMS';//[S]piegelmann's [M]arveltastic [S]pectacular
for ($i = 0; $i < 15; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
function doTheMath($currentNX, $price) {//simple calculation for price
$result1 = $currentNX - $price;
return $result1;
}
function createPassword($length) {//blabla
$chars = "abcdefghijkmnopqrstuvwxyz023456789";
srand((double)microtime()*1000000);
$i = 0;
$pass = '' ;
while ($i <= ($length - 1)) {
$num = rand() % 33;
$tmp = substr($chars, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
/* Marveltastic Spectacular End */
Ok, now, we need to work on the database side. Again, the prerequisites are that you must have a working rewards system. If you don't know or aren't sure, please refer to the video above where I get the item from a list. Also, you can check out the Rewards system when GMS has a Hot Day.
If your rewards can't be shared with your entire account (only limited to one character), please continue. Otherwise, skip this following spoiler and move on to the next one.
Please verify that it is the exact same (other than aid and identifier) with your existing rewards table, modify it accordingly.
(PS: I know, I know, with a little more work, I could've made it so that the entire account reward could've been read from the existing rewards table but being inefficient is what I do best.)
Code:
CREATE TABLE `rewards_account` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`aid` int(11) NOT NULL,
`start` bigint(20) NOT NULL DEFAULT '-1',
`end` bigint(20) NOT NULL DEFAULT '-1',
`type` int(11) NOT NULL DEFAULT '0',
`itemId` int(11) NOT NULL DEFAULT '0',
`mp` int(11) NOT NULL DEFAULT '0',
`meso` int(11) NOT NULL DEFAULT '0',
`exp` int(11) NOT NULL DEFAULT '0',
`desc` text NOT NULL,
`identifier` varchar(18) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
Execute this!
Code:
CREATE TABLE `marvel_history` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`accid` int(11) NOT NULL,
`date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`exp_date` bigint(20) NOT NULL DEFAULT '0',
`item_id` int(11) NOT NULL DEFAULT '0',
`is_for_reward` int(11) NOT NULL DEFAULT '0',
`coupon_code` int(11) NOT NULL DEFAULT '0',
`identifier` varchar(18) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
I'm really tired at the moment and I can't be of much help with this one. Basically, all you do is look for the 'try' statements for every single method that executes an sql query for the Rewards system. An example would be updateReward() (I think!). Copy the try statement, paste it right under and change it so that it would work correctly for the reward_account table you added earlier. Also, remember, instead of id, it should be accountid because otherwise it would add the character id.
I MAY HAVE MISSED SOMETHING, PLEASE DON'T HESITATE TO ASK. IF YOU HAVE QUESTIONS, PLEASE KEEP IT IN THE HELP SECTION, THANKS.
Have fun, you filthy peasants.
maplefreak26's Note: This release is for the Xmas Challenge, I'm aware that I didn't formally accept it but hey, at least I released something, right? Anyway, the code for this is messy and very incomplete. I released this to get any other developers to help fix it up and improve it. You're free to use this, modify it in any way you see fit without any credits though it would be appreciated.
Speaking of credits, I'd like to personally thank Dynamik; and Tsundere for giving me motivational support and all kinds of help to do these kinds of things. Thanks!
I'm also really tired. I'm staying up waay too late as I'm writing this and just realized that this is my 1000th post. How fitting!
Attachments
You must be registered for see attachments list