Error money per distance
#1

As the title says i want to give a player an amount of money per distance. this is the code but is not working

pawn Код:
distance = floatround(GetDistanceBetweenPoints(Position[0],Position[1], Position[2], gRandomPizza[rand][0], gRandomPizza[rand][1], gRandomPizza[rand][2]), floatround_round);
                    if(PlayerInfo[playerid][pPizzaSkill] == 1) pizzaprize[playerid] = random(15) + distance*(8/1000);
Reply
#2

Integer divided by integer will remain integer. As such 8/1000 will simply yield 0. And as we all know, anything multiplied by 0 yields 0. The result will not be automatically converted to a floating point number. Instead of rounding the distance, round the final result.
Reply
#3

And can you help me doing that, you explained something good but i still can't solve this
Reply
#4

Up ? please
Reply
#5

An integer division rounds the result to floor.

8/1000 is 0.008, which turns into 0 (integer division > floor)

I don't know in what range you want the amount to be, but try something like: (random(15) + 1) + (distance / 2)
Reply
#6

I want the player to get something like 20$ - 2000 meters. how is this possible. cuz if distance = 2000 / 2 = 1000 + random 15+1 which gives me 1000+$
Reply
#7

Try this
PHP код:
pizzaprize[playerid] = floatround(floatadd(float(random(15)), floatmul(float(distance), 0.008)), floatround_round); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)