OnPlayerText Problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnPlayerText Problem (
/showthread.php?tid=629061)
OnPlayerText Problem -
IceBilizard - 19.02.2017
Hello everyone today i having an issue in my script at OnPlayerText i am using chat colors for my server but if any player choose a color from chat color dialog its sending message like this
1 line with color message and after that sending in white color i am getting confused check my code and try to help me out about the problem.
Code of OnPlayerText
PHP код:
for (new i = 0; i < PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
if(dini_Isset(AddDirFile(dir_userfiles, playername), "CColor"))
{
if (PlayerIgnored[i][playerid] == 0)
{
format(string,sizeof(string), "%s[%d]: {%s}%s", string, playerid, dini_Get(AddDirFile(dir_userfiles, playername), "CColor"), text);
SendPlayerMessageToPlayer(i, playerid, string);
}
}
else
{
if (PlayerIgnored[i][playerid] == 0)
{
format(string,sizeof(string), "[%d]: %s", playerid, text);
SendPlayerMessageToPlayer(i, playerid, string);
}
}
}
}
Respuesta: OnPlayerText Problem -
Eloy - 19.02.2017
PHP код:
// Define when to split the text into another line!
#define EX_SPLITLENGTH 118
stock SendSplitMessage(playerid, color, final[])
{
new buffer[EX_SPLITLENGTH+5];
new len = strlen(final);
if(len>EX_SPLITLENGTH)
{
new times = (len/EX_SPLITLENGTH);
for(new i = 0; i < times+1; i++)
{
strdel(buffer, 0, EX_SPLITLENGTH+5);
if(len-(i*EX_SPLITLENGTH)>EX_SPLITLENGTH)
{
strmid(buffer, final, EX_SPLITLENGTH*i, EX_SPLITLENGTH*(i+1));
format(buffer, sizeof(buffer), "%s ...", buffer);
}
else
{
strmid(buffer, final, EX_SPLITLENGTH*i, len);
}
SendClientMessage(playerid, color, buffer);
}
}
else
{
SendClientMessage(playerid, color, final);
}
}
Usage
PHP код:
SendSplitMessage(playerid, color, msg);