Problem with Ratio
#1

Hello guys, i have a strange problem...

pawn Код:
stock Ratio(input1,input2)
{
    if(input1 > 0 && input2 > 0)
    {
        new output;
        output = input1 / input2;
        return output;
    }
    else return false;
}
thats my ratio code, it should divide 2 values and return the result.

then i wanted to put that in a string to test it:

pawn Код:
new Joinstr[128];
    format(Joinstr,sizeof(Joinstr),"-PlayerJoin | %s connected to the San Andreas Wars (Rank: %.2f)",pName(playerid),Ratio(12,6));
    SendClientMessageToAll(THIAZ_GREY,Joinstr);
i just wanted to test it so don't be hard.

but it always returns 0

my example was input1 = 12 and input2 = 6
12/6 = 2



anyone knows what to do ?
Reply
#2

Quote:
Originally Posted by thiaZ_
Hello guys, i have a strange problem...

pawn Код:
stock Ratio(input1,input2)
{
    if(input1 > 0 && input2 > 0)
    {
        new output;
        output = input1 / input2;
        return output;
    }
    else return false;
}
thats my ratio code, it should divide 2 values and return the result.

then i wanted to put that in a string to test it:

pawn Код:
new Joinstr[128];
    format(Joinstr,sizeof(Joinstr),"-PlayerJoin | %s connected to the San Andreas Wars (Rank: %.2f)",pName(playerid),Ratio(12,6));
    SendClientMessageToAll(THIAZ_GREY,Joinstr);
i just wanted to test it so don't be hard.

but it always returns 0

my example was input1 = 12 and input2 = 6
12/6 = 2



anyone knows what to do ?
its about values
you need to change input1 and 2 to Floats..
best is to make a new one for Floats so u got one for variables AND floats
Reply
#3

#define divide(%1,%2) %1/%2

Simple, but i should work
Reply
#4

Quote:

Personal Message (Online)


Re: Problem with Ratio
« Reply #1 on: Today at 12:20:39 PM »

its about values
you need to change input1 and 2 to Floats..
best is to make a new one for Floats so u got one for variables AND floats Grin

ok my new code is

pawn Код:
stock Ratio(Float:input1,Float:input2)
{
    if(input1 > 0 && input2 > 0)
    {
      new Float:output;
      output = input1 / input2;
        return float:output;
    }
    else return false;
}
that works perfectly

example = 12/5 = 2.4


__________________________

but i have another problem too, i don't want to create a new topic because of that.

i want to get the players with the highest points, if the players are online it'd be easy but i want to get the points from all players and compare them. i thought about creating a dini file, but i don't know exactly how to do that.

edit: i know how to create dini files and load values etc from them, but i mean getting the highest value from a dini.
Reply
#5

well thats a bit advanced i think u should learn a bit more iguess...
or request it at the script request thread

and np i always like to help..
Reply
#6

Quote:
Originally Posted by thiaZ_
Quote:

Personal Message (Online)


Re: Problem with Ratio
« Reply #1 on: Today at 12:20:39 PM »

its about values
you need to change input1 and 2 to Floats..
best is to make a new one for Floats so u got one for variables AND floats Grin

ok my new code is

pawn Код:
stock Ratio(Float:input1,Float:input2)
{
    if(input1 > 0 && input2 > 0)
    {
      new Float:output;
      output = input1 / input2;
        return float:output;
    }
    else return false;
}
that works perfectly

example = 12/5 = 2.4


__________________________
Use mine, that is faster, shorter and better
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)