Chat... why isn't this working?
#1

Code:
new
       MsgStr[128];

stock SendMessageToAll(text[])
{
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	    if(Player[i][pLoggedIn] == 1)
	    {
	        if(strlen(text) >= 128)
	        {
	            new
	                FirstString[128],
	                SecondString[128];
	                
				strmid(FirstString, text, 0, 124);
				strmid(SecondString, text, 124, 248);

	            format(MsgStr, sizeof(MsgStr), "%s...", FirstString);
				SendClientMessage(i, -1, MsgStr);
	            format(MsgStr, sizeof(MsgStr), "...%s", SecondString);
				SendClientMessage(i, -1, MsgStr);
			}
			else
			{
				SendClientMessage(i, -1, text);
			}
		}
	}
	return 1;
}

public OnPlayerText(playerid, text[])
{
	if(Player[playerid][pLoggedIn] == 0)
	{
	    SendErrorMessage(playerid, "You MUST complete the tutorial before you can send or recieve any messages!");
	}
	else
	{
		format(MsgStr, sizeof(MsgStr), ""#Yellow"["#Orange"World"#Yellow"]["#White"%s "#Orange"%s"#Yellow"("#Orange"%d"#Yellow")]: "#Orange"%s", \
		Player[playerid][pTitle], Player[playerid][pRoleplayName], playerid, text);
		SendMessageToAll(MsgStr);
	}
	return 0;
}
The code is above.

I compiled and no errors...

I go in-game and test by typing "BlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahB lahBlahBlahBlahBlah"

What I get when I test in-game...
"[World][Player Elbert_Hutchinson(0)]: BlahBlahBlahBlah"
And nothing else even though I obviously posted a bigger message than that...
Reply
#2

Most probably because all those embedded colours are stored in the string. Try making your string bigger/larger.
Reply
#3

Yes thank you, that was my problem. I figured it out before you posted, but thanks anyways. +rep to you sir. =]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)