I'm not really sure what you actually ended up with (the last post that said "this is how I'm doing it" doesn't actually show your solution). Anyways, I wrote a version for fun:
Code:
stock GetCompassString(Float:fAngle, count, szString[], len)
{
static szCompassStrings[24][4] = {"N", "15", "30", "NE", "60", "75", "E", "105", "120", "SE", "150", "165", "S", "195", "210", "SW", "240", "255", "W", "285", "300", "NW", "330", "345"}
new iCenterIndex = floatround(fAngle / 15.0) % sizeof szCompassStrings
new iStart = iCenterIndex - count / 2
new iStop = iStart + count
new curlen = 0, iIndex
for( new i = iStart; i < iStop; i++ )
{
iIndex = (i < 0 ? i + sizeof szCompassStrings : i) % sizeof szCompassStrings
if( curlen <= len )
{
curlen += formatex(szString[curlen], len - curlen, " %s", szCompassStrings[iIndex])
}
}
trim(szString)
}
__________________