Help admin chat -
BlackEvils - 17.05.2015
Whats wrong 0 error on pawno compile but when i try it doesen't work
public OnPlayerText(playerid, text[])
{
new string[256];
if(text[0] == '@' && PlayerInfo[playerid][Admin] >= 1)
{
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
format(string,sizeof(string),"[{FFFFFF}ADMINCHAT{8080FF}] %s(%d): %s",playername,playerid,text[1]);
SendMessageToGangMembers(PlayerInfo[playerid][Admin],string);
}
return 0;
}
forward SendMessageToGangMembers(colore,const string[]);
public SendMessageToGangMembers(colore,const string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) == 1)
if(PlayerInfo[i][Admin] >= 1)
SendClientMessage(i, colore, string);
}
return 1;
}
Re: Help admin chat -
Threshold - 18.05.2015
Try this:
pawn Код:
public OnPlayerText(playerid, text[])
{
if(text[0] == '@' && PlayerInfo[playerid][Admin])
{
new playername[MAX_PLAYER_NAME], string[144];
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "[{FFFFFF}ADMINCHAT{8080FF}] %s(%d): %s", playername, playerid, text[1]);
SendMessageToGangMembers(PlayerInfo[playerid][Admin], string);
return 0;
}
return 1; // Should this be 1 or 0?
}
forward SendMessageToGangMembers(colore, const string[]);
public SendMessageToGangMembers(colore, const string[])
{
for(new i = 0, j = GetPlayerPoolSize(); i < j; ++i) // If you're using 0.3.7, otherwise 'for(new i = 0; i < MAX_PLAYERS; i++)'
{
if(!IsPlayerConnected(i)) continue;
if(PlayerInfo[i][Admin]) SendClientMessage(i, colore, string);
}
return 1;
}
What do you mean by 'it doesn't work'?
Re: Help admin chat -
BlackEvils - 18.05.2015
Quote:
Originally Posted by Threshold
Try this:
pawn Код:
public OnPlayerText(playerid, text[]) { if(text[0] == '@' && PlayerInfo[playerid][Admin]) { new playername[MAX_PLAYER_NAME], string[144]; GetPlayerName(playerid, playername, sizeof(playername)); format(string, sizeof(string), "[{FFFFFF}ADMINCHAT{8080FF}] %s(%d): %s", playername, playerid, text[1]); SendMessageToGangMembers(PlayerInfo[playerid][Admin], string); return 0; } return 1; // Should this be 1 or 0? }
forward SendMessageToGangMembers(colore, const string[]); public SendMessageToGangMembers(colore, const string[]) { for(new i = 0, j = GetPlayerPoolSize(); i < j; ++i) // If you're using 0.3.7, otherwise 'for(new i = 0; i < MAX_PLAYERS; i++)' { if(!IsPlayerConnected(i)) continue; if(PlayerInfo[i][Admin]) SendClientMessage(i, colore, string); } return 1; }
What do you mean by 'it doesn't work'?
|
Don't work. i type @text and don't send the message in admin chat and on pawno compiler i don't have warns/errors
Re: Help admin chat -
J0sh... - 18.05.2015
"(colore, const string[])"
You're using that function wrong.
Re: Help admin chat -
Threshold - 18.05.2015
Well there's nothing wrong with the code. So there's probably an issue somewhere else.
Re: Help admin chat -
J0sh... - 18.05.2015
Quote:
Originally Posted by Threshold
Well there's nothing wrong with the code. So there's probably an issue somewhere else.
|
SendMessageToGangMembers(PlayerInfo[playerid][Admin], string);
forward SendMessageToGangMembers(colore, const string[]);
public SendMessageToGangMembers(colore, const string[])
Re: Help admin chat -
Threshold - 18.05.2015
Your point? There is nothing wrong there. Apart from the fact that he's using PlayerInfo[playerid][Admin] as the color, but that wouldn't stop it from sending...
Re: Help admin chat -
Konstantinos - 18.05.2015
Quote:
Originally Posted by Jamester
SendMessageToGangMembers(PlayerInfo[playerid][Admin], string);
forward SendMessageToGangMembers(colore, const string[]);
public SendMessageToGangMembers(colore, const string[])
|
Okay, he used the player's level instead of color. The level is an integer and so is the color, it'd just send it with black color.
What Threshold posted is correct, if it doesn't send any message, then you're clearly not an admin (PlayerInfo[playerid][Admin] is 0).
Re: Help admin chat -
J0sh... - 18.05.2015
Quote:
Originally Posted by Konstantinos
Okay, he used the player's level instead of color. The level is an integer and so is the color, it'd just send it with black color.
What Threshold posted is correct, if it doesn't send any message, then you're clearly not an admin (PlayerInfo[playerid][Admin] is 0).
|
I actually never knew that. You learn something new every week.
Thanks for the heads up.
In my code I have && pInfo[playerid][Admin] >=1
And you're just checking the integer comparing it to nothing? (I might not know this also)
Re: Help admin chat -
Konstantinos - 18.05.2015
Quote:
Originally Posted by Jamester
In my code I have && pInfo[playerid][Admin] >=1
And you're just checking the integer comparing it to nothing? (I might not know this also)
|
When it doesn't have a value to be compared with, it checks if it's not 0.
if (!pInfo[playerid][Admin]) -> if level is 0
if (pInfo[playerid][Admin]) -> if level is not 0 (so it's any other number)