SA-MP Forums Archive
Get 10% of something? - 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)
+--- Thread: Get 10% of something? (/showthread.php?tid=600002)



Get 10% of something? - Metharon - 02.02.2016

For example

new bankmoney = 50000;

How i get 10% of the bank money ?


Re: Get 10% of something? - FreAkeD - 02.02.2016

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


Re: Get 10% of something? - xTURBOx - 02.02.2016

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


Re: Get 10% of something? - Cypress - 02.02.2016

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.


Re: Get 10% of something? - AmigaBlizzard - 02.02.2016

Or just use

value / 10


Re: Get 10% of something? - fuckingcruse - 02.02.2016

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.



Re: Get 10% of something? - Mencent - 02.02.2016

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.


Re: Get 10% of something? - PrO.GameR - 02.02.2016

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


Re: Get 10% of something? - AmigaBlizzard - 11.02.2016

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


Re: Get 10% of something? - Vince - 11.02.2016

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