SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 23/02/2013, 08:13 PM   #1
Jstylezzz
High-roller
 
Jstylezzz's Avatar
 
Join Date: Sep 2011
Location: Netherlands
Posts: 1,835
Reputation: 1550
Default Textdraw width help

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
Jstylezzz is offline   Reply With Quote
Old 23/02/2013, 08:16 PM   #2
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,529
Reputation: 554
Default Re: Textdraw width help

http://forum.sa-mp.com/showthread.php?t=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)
Misiur is offline   Reply With Quote
Old 23/02/2013, 08:28 PM   #3
Jstylezzz
High-roller
 
Jstylezzz's Avatar
 
Join Date: Sep 2011
Location: Netherlands
Posts: 1,835
Reputation: 1550
Default Re: Textdraw width help

Quote:
Originally Posted by Misiur View Post
http://forum.sa-mp.com/showthread.php?t=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
Jstylezzz is offline   Reply With Quote
Old 23/02/2013, 08:37 PM   #4
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,529
Reputation: 554
Default Re: Textdraw width help

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
Misiur is offline   Reply With Quote
Old 23/02/2013, 08:48 PM   #5
Jstylezzz
High-roller
 
Jstylezzz's Avatar
 
Join Date: Sep 2011
Location: Netherlands
Posts: 1,835
Reputation: 1550
Default Re: Textdraw width help

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
Jstylezzz is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Possible bug width SetTimerEx ? zSuYaNw Scripting Help 1 01/10/2012 08:32 PM
Textdraw not width of screen. Deal-or-die Scripting Help 4 11/07/2012 04:56 AM
How to increase/decrease the width/height of a textdrawbox? NoZ Scripting Help 9 06/03/2012 03:44 AM
[Help] Problem width switch DarkScripter Scripting Help 3 04/03/2012 07:57 PM
Dialog Width spd_sahil Scripting Help 1 18/01/2012 02:13 PM


All times are GMT. The time now is 10:34 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.