Jump to content
MakeWebGames

Rob a Local Dealer/The Corner


JasonTB

Recommended Posts

Rob a Local Dealer:

This mod allows your members to rob a dealer once a day.

There are three dealers weed, crack and heroin dealer.

Depending on a chance the dealer can kill the player and put them in the hospital for 20 mins.

The Corner:

Where users have a chance to sell the drugs they took but also can get busted or robbed for their drugs.

Run SQL: Copy Below or PasteBIN

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

 

Create file robdealer.php: Copy Below or PasteBIN

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

 

Create file corner.php: Copy Below or PasteBIN

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

 

Edit Your Day Cron File: Copy Below or PasteBIN

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

 

This is the first mod I've ever made so if there is things I can tweak please let me know.

I tested it and didn't find anything wrong but like I said this is my first mod ever so there maybe some flaws.

Edit Notes:

Added in the little security check NonStopCoding Suggested

Also fixed it so user cant sell negative amount of drugs

Added and cleaned up spots as G7470 Suggested

Link to comment
Share on other sites

Nice mod glad to see people still contributing to forum there is some things you could change to make the mod better

1. Instead of adding to the cluttered users table you could create a new table called drugs which will give you easier adding of future drugs.

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

using this option you would need to create some kind of formula for the users skill or could even be a new stat

2. Security issue in the corner.php you are allowing a user to post data and it has not been checked number 1 rule is never trust anything your users send you always check that its the correct data

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

you would need to make a check to see if there actually posting anything using the empty function

Just a few things i noticed from taking a quick look hope this input helps you in some way

Edited by NonStopCoding
Link to comment
Share on other sites

Nice mod glad to see people still contributing to forum there is some things you could change to make the mod better

1. Instead of adding to the cluttered users table you could create a new table called drugs which will give you easier adding of future drugs.

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

using this option you would need to create some kind of formula for the users skill or could even be a new stat

2. Security issue in the corner.php you are allowing a user to post data and it has not been checked number 1 rule is never trust anything your users send you always check that its the correct data

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

you would need to make a check to see if there actually posting anything using the empty function

Just a few things i noticed from taking a quick look hope this input helps you in some way

Thanks for the input man I add in what you mention and also you made me think what if they could add a negative number so I look into fixing that also

Link to comment
Share on other sites

Some suggestions/feedback from what I see:

1) Indentation - when reading code, it is very difficult to follow when the code is not indented in a way that is easy to read. Usually, the code inside of a {} block is indented within said block in order to quickly show other developers where the block starts and ends.

2) Try to avoid the large else {} blocks when possible as blocks that are larger than a normal desktop screen are difficult to follow. You could essentially end the page and exit if one of the validation checks fail.

3) Following with point 2, as of now, you're displaying that they can't do something (for example they're in the hospital), yet you're not preventing them from actually doing any of the actions on the page.

4) Be careful with setting columns to text without any sort of marker to indicate that it is in fact text. I see this in your code for hospreason. If that works, I'm honestly a little surprised, but nonetheless, surround that text with apostrophes or something to dictate it as such.

And for a more advanced approach:

5) Set your error messages to an error variable. For example, something like this:

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

This way, the user will see all of the error messages at once and will not keep trying over and over again with different error messages each time.

6) Initialize variables at the start of a code block where that variable will become useful. For example, on robdealer.php, you're setting the steal values at the beginning of the file, but if they didn't select an action yet, setting them is completely useless. Just keep that in mind.

I know reading through this is a lot, but creating a mod in and of itself is a great start, and I commend you for that. Just take these suggestions into consideration for updating this mod as well as for future mods and/or code that you write. :)

~G7470

Link to comment
Share on other sites

Some suggestions/feedback from what I see:

1) Indentation - when reading code, it is very difficult to follow when the code is not indented in a way that is easy to read. Usually, the code inside of a {} block is indented within said block in order to quickly show other developers where the block starts and ends.

2) Try to avoid the large else {} blocks when possible as blocks that are larger than a normal desktop screen are difficult to follow. You could essentially end the page and exit if one of the validation checks fail.

3) Following with point 2, as of now, you're displaying that they can't do something (for example they're in the hospital), yet you're not preventing them from actually doing any of the actions on the page.

4) Be careful with setting columns to text without any sort of marker to indicate that it is in fact text. I see this in your code for hospreason. If that works, I'm honestly a little surprised, but nonetheless, surround that text with apostrophes or something to dictate it as such.

And for a more advanced approach:

5) Set your error messages to an error variable. For example, something like this:

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

This way, the user will see all of the error messages at once and will not keep trying over and over again with different error messages each time.

6) Initialize variables at the start of a code block where that variable will become useful. For example, on robdealer.php, you're setting the steal values at the beginning of the file, but if they didn't select an action yet, setting them is completely useless. Just keep that in mind.

I know reading through this is a lot, but creating a mod in and of itself is a great start, and I commend you for that. Just take these suggestions into consideration for updating this mod as well as for future mods and/or code that you write. :)

~G7470

Thank you for the suggests. I believe I understood it all and made the changes you suggested to both files.

 

4) Be careful with setting columns to text without any sort of marker to indicate that it is in fact text. I see this in your code for hospreason. If that works, I'm honestly a little surprised, but nonetheless, surround that text with apostrophes or something to dictate it as such.

~G7470

On robdealer.php it did work without apostrophes but when I did it for corner.php the query would fail because the word "on" so I implemented on there not thinking I did the same on robdealer.php but thank you for pointing those few things out.

Link to comment
Share on other sites

  • 1 month later...

Thanks for the input man I add in what you mention and also you made me think what if they could add a negative number so I look into fixing that also

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

Here are some of the functions used

http://php.net/manual/en/function.isset.php

http://php.net/manual/en/function.ctype-digit.php

http://php.net/manual/en/function.abs.php

http://php.net/manual/en/function.intval.php

Hope this helps

 

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