Float but still int
#1

Hi guys, I have problem with setting a value to a var(Float). I'm making sign up system with some background vars for IC character. I declared enum with int and float vars. But for float vars value is always like int value(0.000, 1.000 or 2.000). I don't know why, here's a code and debug text for one var(it's same problem for other float vars from _HRP_kENUM

Код:
#define _HRP_RANDOM(%0,%1) \
 (random(%1-(%0))+%0)


enum _HRP_kENUM
{
 _kID,
 _kZaporka[129],
 _kMail[31],
 Float:_kMetabolizam,
 Float:_kPotrebaZaVodom,
 Float:_kBrzinaOpijanja, <-- this var
 Float:_kBrzinaDrogiranja,
 Float:_kJacinaUdarca,
 Float:_kBrzinaRastaKose,
 _kKod[15]
};
new _HRP_Korisnik[MAX_PLAYERS]          [_HRP_kENUM];


 new _ran = _HRP_RANDOM(5, 75);
 _HRP_Korisnik[_playerid][_kBrzinaOpijanja] = (_ran / (_HRP_kOstalaMasa{_playerid} + _HRP_kMisicnaMasa{_playerid} + _HRP_kMasaSala{_playerid}));
 printf("al %f, random %d masa %d", _HRP_Korisnik[_playerid][_kBrzinaOpijanja], _ran, _HRP_kOstalaMasa{_playerid} + _HRP_kMisicnaMasa{_playerid} + _HRP_kMasaSala{_playerid});
Quote:

[06.11.2015. 22:36:42] al 1.000000, random 73 masa 59

Result is 1.237. I changed _HRP_RANDOM with var _ran so I can debug random value.
Reply
#2

Also I tried with manual numbers and I still get 0.000... Here's code

Код:
	new _ran = _HRP_RANDOM(5, 75);
	_HRP_Korisnik[_playerid][_kBrzinaOpijanja] = /*_HRP_RANDOM(5, 75)*/ 61 / 95 /*(_HRP_kOstalaMasa{_playerid} + _HRP_kMisicnaMasa{_playerid} + _HRP_kMasaSala{_playerid})*/;
	printf("al %f, random %d masa %d", _HRP_Korisnik[_playerid][_kBrzinaOpijanja], _ran, _HRP_kOstalaMasa{_playerid} + _HRP_kMisicnaMasa{_playerid} + _HRP_kMasaSala{_playerid});
Also I use rBits for some vars but not for these Float vars
Reply
#3

I don't really know what you are trying to do, but I myself had some issues with giving a random number ( which is int) to a Float ( my results were .. some high number), there are functions like float(); , your best bet is probably turn every int into float or save them all in an int var, then turn the variable to float and put it equal to your float.
Reply
#4

I try to do sign up system with background settings for IC character(eg. weight, height, drug sensitivity etc...).. I'll try with your idea, thanks
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)