SA-MP Forums Archive
*** I can't name topics well! - 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: *** I can't name topics well! (/showthread.php?tid=388482)



*** I can't name topics well! - MaDK1LLA - 28.10.2012

Hey guys I'm going to ask some n00bish questions here. But what I want to find out will require more than searching. Anyway Here is what I would like to ask.

I want to get a percentage from a string. For example

String which I called TeamHealth which may vary depending on the amount of players. So TeamHealth holds the total health of all the players.

Now I want to work out (let's say) 67% of that value

Код:
        if (TeamHealth == <67%>)
        {
trigger event
        }

And last I want to know how to make an orange textdraw because I'm using ~r~~y~ and that does not work.


Re: Simple Question - czel - 29.10.2012

Not sure if there is a way to work out a percentage through a function, but you can do it mathematically.

Max HP (divided by) HP (multiplied by) 100 = %

So you could do something like this:

pawn Код:
new
    Float:Health,
    percentage = 100/Health*100;
But, the max health you can have (normally) is 100 so if you have 67/100 HP then it's 67%.


Re: Simple Question - MaDK1LLA - 30.10.2012

Thanks for the start I'll use *0.67 for my percent working out to keep it efficient