Jump to content
MakeWebGames

Mining Mod


TheMasterGeneral

Recommended Posts

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.

Link to comment
Share on other sites

[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.

Link to comment
Share on other sites

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 by TheMasterGeneral
See last line.
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

before.jpg.e35960456e555e4e820501af4aca9166.jpg

after.jpg.f80f8010c57f28d9048ea2d00e263910.jpg

Link to comment
Share on other sites

  • 2 weeks later...

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 by TheMasterGeneral
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...