Custom OnPlayerText(for teams) - 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: Custom OnPlayerText(for teams) (
/showthread.php?tid=444373)
Custom OnPlayerText(for teams) -
Mattakil - 16.06.2013
ive got it set so when you type normal text, it sends to your team, but for some reason, it also sends globally, and I cant understand that because it returns 0 like it should
here is the command
pawn Код:
public OnPlayerText(playerid, text[])
{
new message[128];
format(message, sizeof(message), "[Team Chat] %s {%d}: %s", GetName(playerid), playerid, text);
foreach (new i : Player)
{
if(GetPlayerTeam(i) == GetPlayerTeam(playerid))
{
SCM(i, COLYELLOW, message);
return 1;
}
}
return 0; //should stop the problem, no?
}
I also get no errors or warnings.
Re: Custom OnPlayerText(for teams) -
OrMisicL - 16.06.2013
That:
pawn Код:
SCM(i, COLYELLOW, message);
return 1;
will only send the message for the first player in the sender team and then send it globally, cuz simply adding "return" will break out of the loop and exit the function, returning 1 will make the server broadcast the message, so remove the "return 1" line
also using "return 0" at the end of the function will indeed stop the message from being sent globally
Re: Custom OnPlayerText(for teams) -
Mattakil - 16.06.2013
that worked, thanks mate