Raised This Month: $ Target: $400
 0% 

Center Strings


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KyleS
SourceMod Plugin Approver
Join Date: Jul 2009
Location: Segmentation Fault.
Old 05-09-2014 , 09:47   Re: Center Strings
Reply With Quote #1

PHP Code:
stock CenterString(String:sBuffer[], outlen, const String:sInput[], inlen = -1)
{
    static const 
String:sTokenHack[] = "%%%us%%s%%%us";
    
decl String:sTempBuff[24];

    if (
inlen == -1)
    {
        
inlen strlen(sInput);
    }

    
inlen = (outlen >> 1) - (inlen >> 1);

    
FormatEx(sTempBuffsizeof(sTempBuff), sTokenHackinleninlen);
    return 
Format(sBufferoutlensTempBuff""sInput"");

atcprintf doesn't appear to support %*s, so we have that horrible static const at the top (and double format). Anyways, hopefully this helps someone
KyleS is offline
Reply



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 23:21.


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