Check width of string?
Is there a way to measure the width of a string?
I have a HUD display aligned on the right side of the screen, and would like to keep a set margin from the right. Simply hard-coding it a certain distance away is not ideal. Thanks! |
Re: Check width of string?
http://www.amxmodx.org/funcwiki.php?go=func&id=35
This will tell you how long a string is. If you're curious (or if I'm just being an ass and you already knew), what this function does is check each cell of the array until it encounters an integer value of zero, since strings in pawn are actually arrays of integers that correspond to ASCII values. Ex: PHP Code:
|
Re: Check width of string?
@up
Quote:
|
Re: Check width of string?
lol, okay so lets be big kids and pretend it said format.
|
Re: Check width of string?
Apparently, the OP doesn't know much about Pawn/AMXX scripting.
Therefore, he/she would think that anything you post is correct. If you always post correct code, there won't be any problems for new scripters. |
Re: Check width of string?
Thanks for the help, but I am not looking for the length in characters. I am looking for a width of the characters combined ('w' and 'i' dont share the same width)
See http://www.thescarms.com/dotnet/MeasureString.aspx for an example of what I mean. Thanks! |
Re: Check width of string?
In that case... I believe part of one of my plugins (not submitted) had a hud on the right side of the screen. I'm pretty sure it just let me right justify it, and that's all you need to worry about. Don't have the code with me (travelling) so I can't copy pasta for you... sorry.
I just looked at the funcwiki and I have no idea what you would do to accomplish this. |
Re: Check width of string?
I didnt know they had a right justify! Currently im using
set_hudmessage(red, green, blue, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1) and const Float:HUD_STATS_X = 0.92 const Float:HUD_STATS_Y = 0.9 To get to the right side |
Re: Check width of string?
Man, I wish I could tell you how I had done it...
|
| All times are GMT -4. The time now is 09:13. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.