• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] How do I get a percentage?
#1
Hello, I would like to know how to get the percentage of a figure, so far I have tried this:



Code:
new percentage1 = 10;

new percentage2 = 8000;



CMD:cent(playerid, params[])

{

? ? new string[256];

? ? format(string, sizeof(string), "The result was %d", percentage1%percentage2);

? ? SendClientMessage(playerid,-1,string);

? ? return 1;

}



but it does not work (it gives me the figure of 10). Does anyone know how to do it correctly? thanks!
  Reply
#2
(percentage2 * percentage1) / 100
Using Pawn.CMD?

If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
  Reply
#3
(2020-11-25, 07:40 PM)Pinch Wrote: (percentage2 * percentage1) / 100



Excellent thanks!
  Reply
#4
100/full*amount
Check out Desolation Roleplay, where zombie AI and scavenging is bothered by player bandits!


  Reply


Forum Jump: