Get 10% of something?
#1

For example

new bankmoney = 50000;

How i get 10% of the bank money ?
Reply
#2

To work out a percentage you can simply do

(value/100)*10


That will give you 10% of something.

Here's a tutorial: https://sampforum.blast.hk/showthread.php?tid=415164
Reply
#3

erm,try
new total = (0.1 * bankmoney);
Reply
#4

Quote:
Originally Posted by xTURBOx
Посмотреть сообщение
erm,try
new total = (0.1 * bankmoney);
You will also have to make the variable value Float type or use the float round function.
Reply
#5

Or just use

value / 10
Reply
#6

Quote:
Originally Posted by AmigaBlizzard
Посмотреть сообщение
Or just use

value / 10
Lol dude pls go back in you childhood and learn some maths. /10 is 10 times less. He asked 10%. So valule*10/100.

An example.
Код:
new Money = 10000;
GivePlayerMoney(playerid, -(money*10/100));
This will -1000 to player.
Reply
#7

Quote:
Originally Posted by fuckingcruse
Посмотреть сообщение
Lol dude pls go back in you childhood and learn some maths. /10 is 10 times less.
Well, look at this example:
PHP код:
printf("10 procent of 500 are: %i",(500/100)*10);
printf("10 procent of 500 are: %i",500/10); 


Both are working.
Reply
#8

Quote:
Originally Posted by fuckingcruse
Посмотреть сообщение
Lol dude pls go back in you childhood and learn some maths. /10 is 10 times less. He asked 10%. So valule*10/100.

An example.
Код:
new Money = 10000;
GivePlayerMoney(playerid, -(money*10/100));
This will -1000 to player.
DAT MATH O_O
Reply
#9

Quote:
Originally Posted by fuckingcruse
Посмотреть сообщение
Lol dude pls go back in you childhood and learn some maths. /10 is 10 times less. He asked 10%. So valule*10/100.

An example.
Код:
new Money = 10000;
GivePlayerMoney(playerid, -(money*10/100));
This will -1000 to player.
Lol, I was one of the best in math at school. Only when they started using LaPlace Transform formulas I gave up, this was too hard for me, transforming an entire electronic schematic diagram into one formula and doing some frequency calculations on them.

Your suggestion gives the same result:
value * 10/100 = value * 1/10 = (value * 1) / 10 = value / 10 = value * 0.1

It's all the same.
You can even have "value * 1000 / 10000" and have the same result.

Your example also says exactly the same.

Money = 10000
At the end, it gives -1000 (also 10 times less and negative because of the minus sign).
Reply
#10

Quote:
Originally Posted by fuckingcruse
Посмотреть сообщение
Lol dude pls go back in you childhood and learn some maths. /10 is 10 times less. He asked 10%. So valule*10/100.
LOL. Calling someone out on their math even though it is correct. Percent literally means "per hundred" (at least in French). Thus if you want 10% you want 10/100. Simplify to 1/10.

value x 1 / 10

If you know your order of operations you know that multiplication goes before division, so therefore it simply becomes

value / 10
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)