Help admin chat
#1

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;
}
Reply
#2

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'?
Reply
#3

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
Reply
#4

"(colore, const string[])"
You're using that function wrong.
Reply
#5

Well there's nothing wrong with the code. So there's probably an issue somewhere else.
Reply
#6

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[])
Reply
#7

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...
Reply
#8

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).
Reply
#9

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)
Reply
#10

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)
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)