number of characters in a string
Moderator: InsideQC Admins
3 posts
• Page 1 of 1
number of characters in a string
it´s possible to get the number of characters in a string? i need to know how many characters there are in a string (spaces included) to center the string in a specific location in the screen
thanks in advance!!
hi, I am nahuel, I love quake and qc.
-

Nahuel - Posts: 492
- Joined: Wed Jan 12, 2011 8:42 pm
- Location: mar del plata
Re: number of characters in a string
- Code: Select all
float(string s) strlen = #114; /* Part of FRIK_FILE, FTE_STRINGS, ZQ_QC_STRINGS*/
-

gnounc - Posts: 424
- Joined: Mon Apr 06, 2009 6:26 am
Re: number of characters in a string
small note, strlen only works for centering strings when the font is a fixed width. also, it does not understand colour codes so you might want to strip those first.
If you're writing csqc/menu code, the following builtin is a better option, but is not supported in ssqc (where fonts are not known).
float(string text, float usecolours, optional vector fontsize) stringwidth = #327;
Calculates the width of the text in virtual pixels. If usecolours is 1, markup that does not affect the displayed string width will be ignored (so generally pass 1 for that).
If the fontsize is not specified, '8 8 0' will be assumed.
If you're writing csqc/menu code, the following builtin is a better option, but is not supported in ssqc (where fonts are not known).
float(string text, float usecolours, optional vector fontsize) stringwidth = #327;
Calculates the width of the text in virtual pixels. If usecolours is 1, markup that does not affect the displayed string width will be ignored (so generally pass 1 for that).
If the fontsize is not specified, '8 8 0' will be assumed.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest