TheMasterGeneral Posted November 23, 2014 Share Posted November 23, 2014 Alrighty, so I put together a little mining mod. It should be rather secured. Features: -Minimum levels for mining in different mines. -Mining level/experience. -Status bars. -Ability to buy more power. First, create mine.php mine.php You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Save, exit, upload! Now, create a file called staff_mine.php staff_mine.php You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Save, exit, upload! Finally... Execute this SQL SQL You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. I've tested it just before uploading and it all works. Quote Link to comment Share on other sites More sharing options...
Samurai Legend Posted November 23, 2014 Share Posted November 23, 2014 This is great! I love it. I always wanted someething like this! But you made it! Thanks man thank you so much! Quote Link to comment Share on other sites More sharing options...
TheMasterGeneral Posted November 23, 2014 Author Share Posted November 23, 2014 You're welcome. I spent about 2 hours making it and testing. Easily my biggest coding for MCCodes. Quote Link to comment Share on other sites More sharing options...
Sim Posted November 23, 2014 Share Posted November 23, 2014 [MENTION=70574]TheMasterGeneral[/MENTION] Here's how you can cut your filesize down and a little easier to read: A lot of these are fairly similar. You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. I would remove the echo, item_add, and query and add them after the select case like this: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. I would also move around other repetitive stuff. Quote Link to comment Share on other sites More sharing options...
TheMasterGeneral Posted November 23, 2014 Author Share Posted November 23, 2014 (edited) There's a lot of repeating cases, just because I wanted certain outcomes to be more probable than others. I'm not 100% sure how to make something probable without adding more possibilities. I remember seeing something elsewhere looking like case 50 < 60 or something. Someone wanna link me to a mod that uses cases like that? I'd be willing to rewrite the mod to be a lot smaller. Edit: I'm also thinking I could probably add the cases into the global file and have the random selection to call upon cases 1 through X in the global file. Its so I only have to name the cases once. I actually think that might be a bit more efficient, until I get the cases like I said earlier. Edited November 23, 2014 by TheMasterGeneral See last line. Quote Link to comment Share on other sites More sharing options...
Sim Posted November 23, 2014 Share Posted November 23, 2014 Do it like this: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. at end of select case area You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Quote Link to comment Share on other sites More sharing options...
TheMasterGeneral Posted November 23, 2014 Author Share Posted November 23, 2014 Thanks Sim, but hopefully you won't burn me at the stake for trying it a different way. I dropped the file size from 37kb to about 20kb. Which still seems like a lot, but its a bit better than 37kb. I plan on changing the overall make-up of the mod before Thanksgiving. My plans are to make it so the action?mine calling are calling upon the mine_globals file, which will cut down even more on space. I didn't do it this time around because I wanted to push out an "optimized" mod before anyone really adopts it. :P Quote Link to comment Share on other sites More sharing options...
Veramys Posted November 23, 2014 Share Posted November 23, 2014 I wouldn't give the ability to buy more power. That's just me though. Nice mod. Quote Link to comment Share on other sites More sharing options...
TheMasterGeneral Posted November 24, 2014 Author Share Posted November 24, 2014 Buying power is limited to one set (10 power) per mining level. So no one can go crazy and buy all the power at once. Regardless, if you didn't want the option to buy power, I believe you should just be able to remove the link on the default function and everything should work fine. Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted November 24, 2014 Share Posted November 24, 2014 Why require files when they are already "required". If you reauire the mine globals at the top of the file that should be good enough and just declare the variables in the global keyword. But if you do choose to require it multiple times I would use require_once() Quote Link to comment Share on other sites More sharing options...
TheMasterGeneral Posted November 24, 2014 Author Share Posted November 24, 2014 Good question Kyle! Thanks! I had chose to require the mine_globals file multiple times because of this: [ATTACH=CONFIG]1747[/ATTACH] (Before removing the repeated require code. [ATTACH=CONFIG]1748[/ATTACH] And after. At the time I was first coding it, I was really looking for functionality over "optimization" (I throw that term around loosely, btw) To fix the issue above, I could just do $mglobal=require_once('mine_globals.php'); and then add into the globals query, $mglobal; I think that'd work, right? Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted November 24, 2014 Share Posted November 24, 2014 It's basically the same thing. If you just require it at the top you will be fine but just add the variables that you are using into the global keyword like the $place variable inside one of the mine_level_1() function for example. By me personally, I would have created a class out of it Quote Link to comment Share on other sites More sharing options...
Samurai Legend Posted November 24, 2014 Share Posted November 24, 2014 Creating the items will be great with Snikos crafting mod! Quote Link to comment Share on other sites More sharing options...
TheMasterGeneral Posted December 5, 2014 Author Share Posted December 5, 2014 (edited) I'd hate to bump my own thread, but, I've altered the function (mine_power_buy) it was exploitable and I fixed that. It was my lazy coding the first time around. Lol. If you don't care to find the function in the OP, have it here as well. Overwrite your mine_power_buy function. You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. I HIGHLY suggest patching the old version to this one. The old version allowed users to input negative values and GAIN labour, at the cost of losing mining power (Which, went heavily into the negative anyway) Edited December 5, 2014 by TheMasterGeneral Quote Link to comment Share on other sites More sharing options...
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.