Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] How do I get a percentage?

 
  • 0 Vote(s) - 0 Average
Pawn How do I get a percentage?
Ryder Sixz
Offline

Burgershot Member
Posts: 28
Threads: 10
Joined: Nov 2020
Reputation: 0
Location: San Andreas
#1
2020-11-25, 06:46 PM
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!
Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#2
2020-11-25, 07:40 PM
(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.
Ryder Sixz
Offline

Burgershot Member
Posts: 28
Threads: 10
Joined: Nov 2020
Reputation: 0
Location: San Andreas
#3
2020-11-25, 08:42 PM
(2020-11-25, 07:40 PM)Pinch Wrote: (percentage2 * percentage1) / 100

Excellent thanks!
Awide
Offline

Burgershot Member
Posts: 62
Threads: 5
Joined: Sep 2019
Reputation: 5
#4
2020-11-25, 08:48 PM
100/full*amount
Desolation Roleplay has closed. You can download the gamemode here: https://www.burgershot.gg/showthread.php?tid=2272
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode