SA-MP Forums Archive
Problem with Ratio - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem with Ratio (/showthread.php?tid=114442)



Problem with Ratio - thiaZ_ - 19.12.2009

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 ?


Re: Problem with Ratio - saiberfun - 19.12.2009

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


Re: Problem with Ratio - _[HuN]_Epsilon_ - 19.12.2009

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

Simple, but i should work


Re: Problem with Ratio - thiaZ_ - 19.12.2009

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.


Re: Problem with Ratio - saiberfun - 19.12.2009

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


Re: Problem with Ratio - _[HuN]_Epsilon_ - 19.12.2009

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