Jump to content

Rand not working


thefollower

Recommended Posts

Either my maths sucks (which it does normally) lol or I've got the logic wrong here cos the result isn't doing what its suppose to!

 

Its meant to add a % ($X) to a value which is($AttackHit).

$AttackHit = 3;

$X = array();
			$X[] = '2';
			$X[] = '1';
			$X[] = '5';
			$X[] = '5';
			$X[] = '3';

		$XKey = array_rand($X);
		$x = $X[$XKey];
$TotalAttackHit = $AttackHit*($x/100);
}

Echo $TotalAttackHit;

 

The echo shows "0", so I am not sure what happened. But what is meant to happen is the % which is $X is meant to be "added" ontop "AttackHit" which becomes $ToalAttackHit.

 

It turns out as 0 all the time though.

Link to comment
https://forums.phpfreaks.com/topic/80700-rand-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.