Chat... why isn't this working? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Chat... why isn't this working? (
/showthread.php?tid=278434)
Chat... why isn't this working? -
Elbert_Hutchinson - 22.08.2011
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...
Re: Chat... why isn't this working? -
Hiddos - 22.08.2011
Most probably because all those embedded colours are stored in the string. Try making your string bigger/larger.
Re: Chat... why isn't this working? -
Elbert_Hutchinson - 22.08.2011
Yes thank you, that was my problem. I figured it out before you posted, but thanks anyways. +rep to you sir. =]