This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

VFormat and any:... Not Working


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Spirrwell
Member
Join Date: Jul 2013
Old 11-19-2014 , 06:43   VFormat and any:... Not Working
Reply With Quote #1

Hi! What I'm trying to do is create a PrintCenterTextAll type function that omits a given client, and for the sake of getting to the point, here is that function:

Code:
PrintCenterTextOmit(omitClient, const String:format[], any:...)
{
	new String:formattedString[strlen(format) + 255];
	VFormat(formattedString, sizeof(formattedString), format, 3);
	for (new i = 0; i < MaxClients; i++)
	{
		if (IsValidClient(i) && i != omitClient)
		{
			PrintCenterText(i, formattedString);
			//PrintCenterText(i, "Blablabla");
		}
	}
}
By setting omitClient to -1, this function should behave just like PrintCenterTextAll. And it works just like it's supposed to, as you can see in the commented out line I tested it to make sure it filters the client properly.

However the issue seems to be with formatting the string using the any:... parameter. I do get a warning with VFormat: warning 224: indeterminate array size in "sizeof" expression (symbol "")

Basically, when I use: PrintCenterText(i, formattedString);

it prints nothing.

If I use formattedString[512], it works just fine. So the issue is in using strlen and as the warning specifies, the length seems to be indeterminable. However, I followed the guide here on the wiki:

https://wiki.alliedmods.net/Format_C...n_Format-Class

So why doesn't it work?
Spirrwell is offline
 



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

Forum Jump


All times are GMT -4. The time now is 15:21.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode