PHP Code:
stock Seperate_Digital_Categories(const charSeperator=' ', const szString[], szValue[], len)
{
new iStrLen = strlen(szString), index = -1, iCounts;
while( ++index < iStrLen )
{
if(!isdigit(szString[ index ]))
{
continue;
}
iCounts++;
}
if(!iCounts)
{
return false;
}
const CATEGORY_SIZE = 3;
new iSkip = (iCounts % CATEGORY_SIZE), iCategory = CATEGORY_SIZE - iSkip;
index = -1;
iCounts = 0;
while( ++index < iStrLen )
{
if(!isdigit(szString[ index ]))
{
continue;
}
if(++iCounts)
{
if(iCounts > len)
{
szValue[ iCounts-1 ] = szString[ index ];
break;
}
szValue[ iCounts-1 ] = szString[ index ];
if((++iCategory % CATEGORY_SIZE) == 0)
{
iCounts++;
szValue[ iCounts-1 ] = charSeperator;
}
}
}
return true;
}
Tested works fine !
Output:-
Code:
test_cmd "Hello 500 and 999 + 464567"
OUTPUT: 500 999 464 567
TEST CODE :-
Spoiler
PHP Code:
#include <amxmodx>
public plugin_init()
{
register_concmd("test_cmd", "test_clcmdadd");
}
public test_clcmdadd(id)
{
new szString[32], szOutPut[64];
read_args(szString, charsmax(szString));
remove_quotes(szString);
Seperate_Digital_Categories(.szString=szString, .szValue=szOutPut, .len=charsmax(szOutPut));
server_print("OUTPUT: %s", szOutPut);
}
__________________