Chat problem -
dholmes7512 - 16.04.2012
Alright, I would much appreciate it if someone could help me out here.
My chat uses Smartchat, but it works perfectly fine until you make a long enough line which makes it split. Then making the message repeat itself.
Код:
public OnPlayerText(playerid, text[])
{
new string[128];
if(IsPlayerConnected(playerid))
{
new Hour, Minute, Second;
gettime(Hour, Minute, Second);
format(SCSString, sizeof(SCSString), "%s says: %s",RPName(playerid),text);
SCGeneral(playerid,SCSString,5,7,10,13,15,SWhite,SChat1,SChat2,SChat3,SChat4);
new pName[24];
GetPlayerName(playerid,pName,24);
format(string,sizeof(string),"[%02d:%02d:%02d]%s Says: %s",Hour,Minute,Second,pName,text);
SaveIn("ChatLog.txt",string);
SCAnim(playerid,text,at);
return 0;
}
return 1;
}
So for example, if the name was John Doe, once the line is too long it repeats itself like this:
John Doe: Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-
-aaaaaaaaaaaaaaaaaaa
John_Doe: Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaa
It may be due to my RPName code which is:
Код:
stock RPName(playerid)
{
new string[24];
GetPlayerName(playerid,string,24);
new str[24];
strmid(str,string,0,strlen(string),24);
for(new i = 0; i < MAX_PLAYER_NAME; i++)
{
if (str[i] == '_') str[i] = ' ';
}
return str;
}
Another problem I am getting is when I also have any of my other chats such as /b, and it is also long, it goes onto the next line and then says 'SERVER: Unknown Command'.
The code:
Код:
CMD:b(playerid,params[])
{
if(isnull(params)) return SendClientMessage(playerid,USAGE,"[USAGE:] /b [TEXT]");
format(SCSString, sizeof(SCSString), "(([%d] %s: %s))",playerid,RPName(playerid),params); SCGeneral(playerid,SCSString,20,0,0,0,0,COLOR_FADE,COLOR_FADE,COLOR_FADE,COLOR_FADE,COLOR_FADE);
new Hour, Minute, Second;
new sendername[MAX_PLAYER_NAME];
new result[96];
new string[258];
gettime(Hour, Minute, Second);
format(string,sizeof(string),"[%02d:%02d:%02d]%s Says: %s",Hour,Minute,Second,sendername,result);
SaveIn("LocalOocChat.txt",string);
return 1;
}
How it looks:
(([0] John Doe: Aaaaaaaaaaaaaaaaaaa-
-aaaaaaaaaaaa))
SERVER: Unknown Command
Could someone please help, I will give them Rep because this is much needed.
Re: Chat problem -
.FuneraL. - 16.04.2012
Place return 0; only at the end of his OnPlayerText
Re: Chat problem -
dholmes7512 - 16.04.2012
Fixed it with this:
Код:
stock RPName(playerid)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));
for(new i;i<strlen(pname);i++)
{
if(pname[i] == '_') pname[i] = ' ';
}
return pname;
}
Thanks for the help though, +Rep.