Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7012795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:18:08+00:00 2026-05-27T22:18:08+00:00

This question might seem a bit bizarre, but… I run a mafia style game

  • 0

This question might seem a bit bizarre, but…

I run a mafia style game site scripted in PHP. When players do crimes, theres a chance they’ll get a ‘drop’, lets say a new weapon.

How I have it working at the moment is each crime they do, I run a rand() out of 10, and if it hits 10 then I randomly select a row from the firearms_db table, and give them that.

What I’d like to do though, is make it so each weapon has a different percentage rate of ‘dropping’- so the more powerful and expensive ones will drop less, and the cheap ones will drop frequently. At the moment you’ve got just as much chance of getting a cheap one as you are an expensive one.

Does anyone have any ideas how I could go about adding this? Would I need to add another field to the firearms_db with a drop rate value and then work with that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:18:09+00:00Added an answer on May 27, 2026 at 10:18 pm

    You could try adding a column to the table that ranks the weapons some way. For example, you could have a rocket_launcher rated at 10, while a toothpick is rated as 2.

    The database table could look like this:

    +---------------------------------+
    |    weapon           |  rating   |
    |    rocket_launcher  |  10       |
    |    toothpick        |  2        |
    +---------------------------------+
    

    You could do a rand() out of ten. Let’s say you store the result in res. Then, query the database:

    SELECT * FROM weapons WHERE rating <= res
    

    If res is 7, then you will only get toothpick. If res is 10, you will get both toothpick and rocket_launcher.

    You could then randomly pick the weapon to give, out of the ones from the query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might seem a bit like a do-my-homework-for-me question (and it is), but I
This might seem like a trivial question, but I'm a bit muddled in my
This question might not seem programming related at first, but let me explain. I'm
This might seem an easy question for some, but I am struggling with it.
This might seem like a stupid question I admit. But I'm in a small
This might seem like a weird question, but bear with me. I'd like to
Ok sorry this might seem like a dumb question but I cannot figure this
I know this might seem a controversial question but it really is not meant
This might be a simple question, but i can't seem to grasp it. I
This question might seem very specific but I am in need of some ideas

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.