Little help with sending message to admins
#1

Hello, i've been working on a report command, and i have got it all working, when the player reports, it files in the logs, but it should also send a message to all online admins, but it don't, could you please take a look at it.

Code

Код:
CMD:report(playerid, params[])
{
    new reason[128];
    if(sscanf(params, "us[128]", ID, reason)) return SCM(playerid, red, "--- /report <ID> <Reason> ---");
    new string[150], sender[MAX_PLAYER_NAME], receiver[MAX_PLAYER_NAME];
    GetPlayerName(playerid, sender, sizeof(sender));
    GetPlayerName(ID, receiver, sizeof(receiver));
    format(string, sizeof(string), "(report): %s(%d) has reported %s(%d) for %s", sender, playerid, receiver, ID, reason);
    SendReportToAdmins(string);
    ReportLog(playerid, string);
    return 1;
}
Код:
stock SendReportToAdmins(msg[])
{
    new string[128];
    format(string, sizeof(string), "(Report) %s", msg);
    for(new i; i < GetMaxPlayers(); i++)
    {
        if(pInfo[i][Adminlevel] < 1)
        {
            SCM(i, red, string);
        }
    }
}
If you could help me with that, it would be great! thank you!

I also want to know how to do something like this, when a player connects to the server it sends a message to players like
"Name has joined the server"
But i wanted to keep that the same, but if the player is admin it says
Name has joined the server (IP) So only admins can see the line with IP on it, if you could help me with that, it would be great, thank you! i will rep anyone who helps too!
Reply
#2

If 'i' player is 'AdminLevel' greater than or equal to 1
pawn Код:
stock SendReportToAdmins(msg[])
{
    new string[144];
    format(string, sizeof(string), "(Report) %s", msg);
    for(new i; i < GetMaxPlayers(); i++)
    {
        if(pInfo[i][Adminlevel] >= 1)
        {
            SCM(i, red, string);
        }
    }
}
Reply
#3

I'd suggest using foreach.

Anyways, you're only showing the message to people LOWER than level 1, I think you want it to be higher than instead.
Reply
#4

Quote:

If 'i' player is 'AdminLevel' greater than or equal to 1
pawn Code:
stock SendReportToAdmins(msg[])
{
new string[144];
format(string, sizeof(string), "(Report) %s", msg);
for(new i; i < GetMaxPlayers(); i++)
{
if(pInfo[i][Adminlevel] >= 1)
{
SCM(i, red, string);
}
}
}

Ah, nice one, thanks for the help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)