OnPlayerText - 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: OnPlayerText (
/showthread.php?tid=615159)
OnPlayerText -
Tass007 - 18.08.2016
Hey guys, I'm trying to make it so that if a player is admin they see the global chat as
Name [Player's ID]: Text
If the player is not admin it's displayed as
Name: Text
Here is my code.
PHP код:
public OnPlayerText(playerid, text[])
{
new string[200];
if(PlayerInfo[playerid][pAdmin] >= 1)
{
format(string, sizeof(string), "%s {FFFFFF}[%d]: %s", GetName(playerid), playerid, text);
ABroadCast(GetPlayerColor(playerid), string, 1);
}
else if(PlayerInfo[playerid][pAdmin] == 0)
{
format(string,sizeof(string), "%s: %s", GetName(playerid), text);
SendClientMessageToAll(GetPlayerColor(playerid), string);
}
return 1;
}
Do I need to make a stock that doesn't display the message to admins?
Re: OnPlayerText -
Marricio - 18.08.2016
You're checking if the player that is writing the text IS admin or not, and we're not trying to achieve that (from what I understood). We need to do that for players receiving the message.
Can you show us your ABroadCast function code?
Re: OnPlayerText - iLearner - 18.08.2016
new GetName[24];
GetPlayerName(playerid, GetName, sizeof(GetName));
maybe?
Re: OnPlayerText -
Marricio - 18.08.2016
Not GetName(), I mean ABroadCast, so we can add what you need based in the function you're already using.
Re: OnPlayerText -
sampkinq - 18.08.2016
Код:
public OnPlayerText(playerid, text[])
{
new string[200];
if(PlayerInfo[playerid][pAdmin] >= 1)
{
format(string, sizeof(string), "%s {FFFFFF}[%d]: %s", GetName(playerid), playerid, text);
ABroadCast(GetPlayerColor(playerid), string, 1);
}
else
{
format(string,sizeof(string), "%s: %s", GetName(playerid), text);
SendClientMessageToAll(GetPlayerColor(playerid), string);
return 0;
}
return 0;
}
Re: OnPlayerText -
Stinged - 18.08.2016
Код:
public OnPlayerText(playerid, text[])
{
new string[145], color = GetPlayerColor(playerid);
GetPlayerName(playerid, string, 25);
format(string, sizeof (string), "%s [%d]: {FFFFFF}%s", string, playerid, text);
for (new i, j = GetPlayerPoolSize(); i <= j; i++)
{
if (!IsPlayerConnected(i))
continue;
if (PlayerInfo[i][pAdmin] > 0)
{
SendClientMessage(i, color, string);
continue;
}
SendPlayerMessageToPlayer(i, playerid, text);
}
return 0;
}
Re: OnPlayerText -
Tass007 - 19.08.2016
Thank you @Stinged it worked.