Jump to content
MakeWebGames

Randomizing users


UCC
 Share

Recommended Posts

So I have a new gang mod. Without going into boring details, Gang A can cause negative affect to Gang B. However, Gang A may have 3 members where Gang B has 20 members. It's not fair that Gang A can cause more carnage than Gang B due to the difference in member counts.

I could do something like

Select * from users where Gang = Gang B LIMIT 3

However.... Every time Gang A attacked, the same 3 members of Gang B would be harmed. (the first 3 user_ids.

How can I randomize which 3 gang user records are pulled in my query?

Link to comment
Share on other sites

Re: Randomizing users

 

My first thought would be to make an array with each of the user's ID, then do a rand from 1 to the largest value in the array, and do that 3 times or something like that... When I get home I'll give it a shot.

Hey, that does sound like a good idea!  I'm not that familiar with PHP arrays.  Any sample code you could throw at me would be useful.  Even something real basic (3-5 lines) would help.

Create array from : Select userid from users

Pick random userid from array

Print userid

I could take it from there.

Link to comment
Share on other sites

Re: Randomizing users

 

Select * from users where Gang = Gang B ORDER BY RAND() LIMIT 3

thats to order it randomly, i didn't really understand the question though XD

yet again, deception proves his genius, using one line of code for every 20 of mine *smacks him*

Link to comment
Share on other sites

  • 2 months later...
  • 8 months later...

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.

 Share

×
×
  • Create New...