25.02.2014, 03:55
I wrote this for my GM:
It also tries to take into account the possibility of HEX colors being embedded into the string. I noticed that it would cut the string in bad places (i.e. in the middle of a HEX color code) and would screw it all up. The function works like a charm though!
pawn Код:
stock real_SendClientMessage(playerid, COLOR, string[], size = sizeof(string))
{
new
szString2[128],
bool:iSplit;
if(strlen(string) > 128)
{
new
szLastHexColor[9],
iStartPosition;
while((iStartPosition = strfind(string, "{", true, iStartPosition)) != -1)
{
strmid(szLastHexColor, string, iStartPosition, iStartPosition+8);
iStartPosition += 8;
}
strmid(szString2, string, 128, 256);
strdel(string, 128, 256);
strcat(string, " ..", size);
strins(szString2, " .. ", 0);
if(!isnull(szLastHexColor)) strins(szString2, szLastHexColor, 0);
iSplit = true;
}
if(iSplit) SendClientMessage(playerid, COLOR, string), SendClientMessage(playerid, COLOR, szString2);
else SendClientMessage(playerid, COLOR, string);
return 1;
}
