Math problem on gametext ! -
Amine_Mejrhirrou - 28.11.2012
Problem is simple !
When i'm using this script In game it alwase shows 0.0% !
i don't kno what is the correct format
Код:
if(Objectif[playerid] < 50){format(string,sizeof(string),"loading~n~ %.1f %",100 * Objectif[playerid] /50);}
if(Objectif[playerid] < 100){format(string,sizeof(string),"loading~n~ %.1f %",100 * Objectif[playerid] /100);}
GameTextForPlayer(playerid, string, 3000, 4);
Re: Math problem on gametext ! -
Dragony92 - 28.11.2012
Do you defined Objectif[playerid] as float or integer?
You need to define it as float... new Float:Objectif[MAX_PLAYERS];
Re : Math problem on gametext ! -
Amine_Mejrhirrou - 28.11.2012
ok thnks ++rep !
Re : Math problem on gametext ! -
Amine_Mejrhirrou - 28.11.2012
but if i do float and i'musing Objectif in other fucntions ! is this gonna afect them in something
Re: Math problem on gametext ! -
maramizo - 28.11.2012
You'll have to load it as %.f in all of your functions, as it is a float.
%d and %i are for integers.
Re: Math problem on gametext ! -
GiamPy. - 29.11.2012
Quote:
Originally Posted by maramizo
You'll have to load it as %.f in all of your functions, as it is a float.
%d and %i are for integers.
|
You still can use %i on float values using the floatround function.
Re: Math problem on gametext ! -
Dragony92 - 29.11.2012
Or you can just change it for GameTextForPlayer, make new local variable...
new Float:something;
something = float (Objectif[playerid]);
Than use variable "smoething" in GameTextForPlayer...
Re: Math problem on gametext ! -
[ABK]Antonio - 29.11.2012
You only need the second if statement. The second one is the only one that will every go off. The reason for that is that you're re-formating the string if it's less than 100. If it's less than 50, it's less than 100.
What kind of numbers is Objectif[playerid] carrying?
Re: Math problem on gametext ! -
maramizo - 29.11.2012
Whatsup with people and stating the obvious.
I was giving him a fact, no need to criticize facts.