Divide amount equally, automatically.
#1

I'm putting an import/export thing into my script, and they have to type in the amount to export. And I have to divide that equally depending on how many countries they have listed.

It could be:
- 3 Countries
- 6 Countries
- 9 Countries
- 12 Countries
- 15 Countries
- 18 Countries
- 20 Countries

I need to know how to automatically divide the amount they type in, because selecting countries will be in another dialog. It could be an even, or an odd number. And if it's an odd number, then I need to automatically divide it into very similar numbers.

Thanks.
Reply
#2

Quote:
Originally Posted by stormchaser206
Посмотреть сообщение
And I have to divide that equally depending on how many countries they have listed.
what you could do is keep a variable which holds the amount of countries for each player and just divide that with the amount they type infor the export thingy

something like...
pawn Код:
//in your explor dialog
new amount;//that's the export thing initialized by players
countries[playerid];//the number of countries, 15 for example

//now we just do something like
new Float:result = amount / countries[playerid];
//result now holds the amount every country should get

well, not 100% sure if that's what you wanted, since it's that simple.
Reply
#3

Quote:
Originally Posted by CutX
Посмотреть сообщение
what you could do is keep a variable which holds the amount of countries for each player and just divide that with the amount they type infor the export thingy

something like...
pawn Код:
//in your explor dialog
new amount;//that's the export thing initialized by players
countries[playerid];//the number of countries, 15 for example

//now we just do something like
new Float:result = amount / countries[playerid];
//result now holds the amount every country should get

well, not 100% sure if that's what you wanted, since it's that simple.
Yes, that's exactly what I wanted, thank you! So now I just put the result onto each country to export, right?
Reply
#4

Quote:
Originally Posted by stormchaser206
Посмотреть сообщение
Yes, that's exactly what I wanted, thank you! So now I just put the result onto each country to export, right?
ye, that's how you gonna do it.
decide 4 yourself what you gonna do if it's an odd number
or if you gonna round it upwords or downwards if it's something like 13.35
Reply
#5

Quote:
Originally Posted by CutX
Посмотреть сообщение
ye, that's how you gonna do it.
decide 4 yourself what you gonna do if it's an odd number
or if you gonna round it upwords or downwards if it's something like 13.35
That's the problem... I don't know how to round it on here.
Reply
#6

Quote:
Originally Posted by stormchaser206
Посмотреть сообщение
That's the problem... I don't know how to round it on here.
use floatround()
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)