Jump to content
MakeWebGames

[mccodes v2] Find random items while playing the game...


Recommended Posts

Posted

Looking good, Two things tho

$fia = (int) mt_rand(1,99);

rand() and mt_rand() will always give an int.

And rand(), i belive i have read, is better for dealing with small numbers, thereofre faster. :)

Posted

Thanks for the tip Danny.

Ok, I got a math question here.

If were trying to get two random numbers between 1 and 99 to match, is that a 1 in 9801 chance?

  • 1 year later...
Posted

$fia=(int) rand(10,99);

$fib=(int) rand(10,99);

I think this is right, correct me if I'm wrong, but the chance of finding an item is 89 * 89. So users have a 1 in 7921 chance.

If you want to make it easier, make the gap smaller, if you want them to have less of a chance, increase the gap between the numbers. Simple

  • 2 weeks later...
Posted

RE:

:D Very Awesome my testers absolutely love this, I have edited it a bit so that there is only 2 very important items in the game, and I only use this on Random Fridays! Great Work ! Thank you ! :cool:

  • 1 month later...
Posted

Sounds like a great mod gonna try it :) Oracle love your idea with the random Fridays would you share your edited code ? Iam new and still learning not good with coding:( yet! lol

  • 10 months later...
Posted

I know this thread is about a year. but yes Here is the code.

//-- Finding items query

$fia=(int) rand(1,2);

$fib=(int) rand(2,3);

if($fia == $fib)

{

$iq=$db->query("SELECT * FROM items WHERE itmbuyable=1 ORDER BY rand() LIMIT 1",$c);

$r=$db->fetch_row($iq);

$item=$r['itmid'];

$userid=$ir['userid'];

$db->query("INSERT INTO inventory VALUES ('', $item, $userid, 1)",$c);

event_add($userid,"While passing through (INSERT NAME OF YOUR GAME HERE) You Found A {$r['itmname']} HAPPY FRIDAY!.",$c);

}

This should work

Posted
I know this thread is about a year. but yes Here is the code.

//-- Finding items query

$fia=(int) rand(1,2);

$fib=(int) rand(2,3);

if($fia == $fib)

{

$iq=$db->query("SELECT * FROM items WHERE itmbuyable=1 ORDER BY rand() LIMIT 1",$c);

$r=$db->fetch_row($iq);

$item=$r['itmid'];

$userid=$ir['userid'];

$db->query("INSERT INTO inventory VALUES ('', $item, $userid, 1)",$c);

event_add($userid,"While passing through (INSERT NAME OF YOUR GAME HERE) You Found A {$r['itmname']} HAPPY FRIDAY!.",$c);

}

This should work

You're unable to view this code.

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

Do something like that if you want it to be on a certain day

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