Textdraw width help
#1

Hi everyone,

I made some progress bars with normal textdraws (since I couldn't find any easy to use progress bar includes), but now I have to find some formula to calulate the width of a textdraw, corresponding to the percentage given.

Example:

Testvalue = 100.0
Textdraw width = 55.000

Testvalue = 27.432
Textdraw width =

The textdraw width goes from 55 to 5, so it can decrease by maximum 50.
Now, can anyone think of a formula to get the width with the Testvalue?
Or, can someone tell me a better way to do it?

Thanks in advance
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=113443 - easy to use

I think what you need are proportions (you call them that in english?)

current_width = max_width * (current_value / max_value)
Reply
#3

Quote:
Originally Posted by Misiur
View Post
https://sampforum.blast.hk/showthread.php?tid=113443 - easy to use

I think what you need are proportions (you call them that in english?)

current_width = max_width * (current_value / max_value)
I think they're called proportions yeah..
I tried that progress bar include already, but my compiler crashes if I create a bar, so I can't use that
Thanks for your formula thing, I will try to play around with that

EDIT: I tried your formula, and it works when I log in for the first time, after that, it isn't getting updated (checked with a command to set everything to 100).
Could this be because I need to destroy the textdraw and create it again?
Idk, until I find a good solution I will try to get that progress bar thing to work
Reply
#4

Oh, and if Testvalue is simply percentage, then it will be
current_width = max_width * (Testvalue / 100)

@edit:
Currently I'm learning about textdraws too, I don't know when they are updated, but I think you have to destroy it and recreate :c
Reply
#5

Yeah, was already afraid of that :P
Anyways, I changed some stuff in the include, and it works
Thanks alot for the suggestion, else I wouldn't tried it again I think :P

Good luck with the textdraw stuff
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)