Do you use strins, format or strcat, etc. to modify the text[] in OnPlayerText?
I had this problem and everything works fine after copying the text string into another, and then odify it with something like strins, etc.. I think the problem is getting the size of an unknown-sized string in the sizeof function of strins.
Example:
pawn Код:
public OnPlayerText(playerid,text[])
{
new name[MAX_PLAYER_NAME],string[128];
GetPlayerName(playerid,name,sizeof(name));
strins(text,"[Chat]",0,sizeof(text));
//Bugged because the server will never know the size of the string text
format(string,sizeof(string),"%s: {FFFFFF}%s",name,text);
SendClientMessageToAll(GetPlayerColor(playerid),string);
return 0;
}
Change to:
pawn Код:
public OnPlayerText(playerid,text[])
{
new name[MAX_PLAYER_NAME],string[128] = "";//You must initialize it if you use strcat
GetPlayerName(playerid,name,sizeof(name));
strcat(string,text);
strins(string,"[Chat]",0,sizeof(text));
//Works fine because the server knows the size of the string "string" this time
format(string,sizeof(string),"%s: {FFFFFF}%s",name,string);
SendClientMessageToAll(GetPlayerColor(playerid),string);
return 0;
}
Or directly:
pawn Код:
public OnPlayerText(playerid,text[])
{
new name[MAX_PLAYER_NAME],string[128];
//You don't need to initialize it this time, GetPlayerName will do it
GetPlayerName(playerid,string,sizeof(string));
strcat(string,": {FFFFFF}[Chat]");
strcat(string,text);
SendClientMessageToAll(GetPlayerColor(playerid),string);
return 0;
}