Little Help
#1

Today I made my PM system which is little bugged.I don`t see problem.PM is working but when Admin need to see the message it`s not displeyed.I don`t know why.
Here is the code:
pawn Код:
CMD:pm(playerid, params [ ] )
{
    if(IsPlayerConnected(playerid)) //This one checks if the player is connected to the server or not.
    {
        new pID, Message[60],playername[MAX_PLAYER_NAME],targetName[MAX_PLAYER_NAME],string[128],string2[128]; // defining the pID which will hold the Player's ID. Message will hold the message and playername will hold the name of the player that sends it, also target to the target
        if(sscanf(params, "us[60]", pID, Message)) return SendClientMessage(playerid, 0xAFAFAFAA, ""embed_yellow"Usage"embed_white": /pm [PlayerID/PlayerName] [Message]"); // Checks if the player has filed in both params if not it will return a error message with Color Grey
        if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xAFAFAFAA, ""embed_red"[ERROR] "embed_white"Invalid Player"); // Checks if the player he attemps to send to is invalid if not it will send and error message
        if(PMEnabled[playerid] == 0) return SendClientMessage(playerid, 0xAFAFAFAA, ""embed_red"[ERROR] "embed_white"PM Is Disabled"); // This checks if the PMs are toggled off
        GetPlayerName(pID, targetName, sizeof(targetName)); // Gets the Name of The Target 1st param and stores it in targetName
        GetPlayerName(playerid, playername, sizeof(playername));
        format(string, sizeof(string), ""embed_red"[PM] "embed_white"From "embed_sw"%s"embed_white":%s", playername, Message); // Will format the string the first %s is the name of the guy who sent pm second %s in the Message
        format(string2, sizeof(string2), ""embed_red"[PM] "embed_white"Sent to "embed_sw"%s"embed_white":%s", targetName, Message); // The same as above but this time it shows the name off the player you sent it to
        SendClientMessage(playerid, 0xFFFF00AA, string2); // Sends a message to the player who sent the PM
        SendClientMessage(pID, 0xFFFF00AA, string); // Sends a Message to Target
        //if(UserStats[playerid][Admin] == 5 || UserStats[pID][Admin] == 5) return 1;
        format(string, 128,""embed_white"[PM]"embed_sw"%s(%i) "embed_white"to "embed_sw"%s(%i)"embed_white": "embed_orange"%s", UserStats[playerid][Name], playerid,UserStats[pID][Name], pID, Message);
        foreach(Player, i)
        {
            if(UserStats[i][Admin] > 3)
            {
                if(i != playerid && i != pID)
                {
                    SendClientMessage(i, blue, string);
                }
            }
        }
    }
    return 1;
}
Reply
#2

Looks like you didn't loop through Max players.
That might be the reason why the pm isn't being send to admins.
Reply
#3

Quote:
Originally Posted by [xB]Lordz
Посмотреть сообщение
Looks like you didn't loop through Max players.
That might be the reason why the pm isn't being send to admins.
But I use foreach(Player, i).

PS:I try with loop and still same problem.
Reply
#4

If you send a PM to someone, you won't see it as an admin.
pawn Код:
CMD:pm(playerid, params [ ] )
{
    new pID, Message[60]; // defining the pID which will hold the Player's ID. Message will hold the message and playername will hold the name of the player that sends it, also target to the target
    if(sscanf(params, "us[60]", pID, Message)) return SendClientMessage(playerid, 0xAFAFAFAA, ""embed_yellow"Usage"embed_white": /pm [PlayerID/PlayerName] [Message]"); // Checks if the player has filed in both params if not it will return a error message with Color Grey
    if(pID == INVALID_PLAYER_ID || !IsPlayerConnected(pID)) return SendClientMessage(playerid, 0xAFAFAFAA, ""embed_red"[ERROR] "embed_white"Invalid Player"); // Checks if the player he attemps to send to is invalid if not it will send and error message
    if(PMEnabled[playerid] == 0) return SendClientMessage(playerid, 0xAFAFAFAA, ""embed_red"[ERROR] "embed_white"PM Is Disabled"); // This checks if the PMs are toggled off
    new playername[MAX_PLAYER_NAME],string[128];
    GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
    format(string, sizeof(string), ""embed_red"[PM] "embed_white"From "embed_sw"%s"embed_white":%s", playername, Message); // Will format the string the first %s is the name of the guy who sent pm second %s in the Message
    SendClientMessage(pID, 0xFFFF00FF, string);
    GetPlayerName(pID, playername, MAX_PLAYER_NAME);
    format(string, sizeof(string), ""embed_red"[PM] "embed_white"Sent to "embed_sw"%s"embed_white":%s", playername, Message); // The same as above but this time it shows the name off the player you sent it to
    SendClientMessage(playerid, 0xFFFF00AA, string); // Sends a message to the player who sent the PM
    format(string, sizeof(string),""embed_white"[PM]"embed_sw"%s(%i) "embed_white"to "embed_sw"%s(%i)"embed_white": "embed_orange"%s", UserStats[playerid][Name], playerid,UserStats[pID][Name], pID, Message);
    foreach(Player, i)
    {
        if(UserStats[i][Admin] > 3)
        {
            if(i != playerid && i != pID)
            {
                SendClientMessage(i, blue, string);
            }
            else continue;
        }
        else continue;
    }
    return 1;
}
Reply
#5

You can also use a stock like this :
pawn Код:
stock MessageToAdmins3(color, const message[])
{
    for(new i; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i) && UserStats[playerid][Admin] >=3(i))
    {
        SendClientMessage(i, color, message);
    }
    return 1;
}
So for every message to Level 3 admins, you can use this stock.

pawn Код:
CMD:pm(playerid, params [ ] )
{
    new pID, Message[60]; // defining the pID which will hold the Player's ID. Message will hold the message and playername will hold the name of the player that sends it, also target to the target
    if(sscanf(params, "us[60]", pID, Message)) return SendClientMessage(playerid, 0xAFAFAFAA, ""embed_yellow"Usage"embed_white": /pm [PlayerID/PlayerName] [Message]"); // Checks if the player has filed in both params if not it will return a error message with Color Grey
    if(pID == INVALID_PLAYER_ID || !IsPlayerConnected(pID)) return SendClientMessage(playerid, 0xAFAFAFAA, ""embed_red"[ERROR] "embed_white"Invalid Player"); // Checks if the player he attemps to send to is invalid if not it will send and error message
    if(PMEnabled[playerid] == 0) return SendClientMessage(playerid, 0xAFAFAFAA, ""embed_red"[ERROR] "embed_white"PM Is Disabled"); // This checks if the PMs are toggled off
    new playername[MAX_PLAYER_NAME],string[128];
    GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
    format(string, sizeof(string), ""embed_red"[PM] "embed_white"From "embed_sw"%s"embed_white":%s", playername, Message); // Will format the string the first %s is the name of the guy who sent pm second %s in the Message
    SendClientMessage(pID, 0xFFFF00FF, string);
    GetPlayerName(pID, playername, MAX_PLAYER_NAME);
    format(string, sizeof(string), ""embed_red"[PM] "embed_white"Sent to "embed_sw"%s"embed_white":%s", playername, Message); // The same as above but this time it shows the name off the player you sent it to
    SendClientMessage(playerid, 0xFFFF00AA, string); // Sends a message to the player who sent the PM
    format(string, sizeof(string),""embed_white"[PM]"embed_sw"%s(%i) "embed_white"to "embed_sw"%s(%i)"embed_white": "embed_orange"%s", UserStats[playerid][Name], playerid,UserStats[pID][Name], pID, Message);
    MessageToAdmins3(blue, string);
    return 1;
}
Reply
#6

pawn Код:
stock MessageToAdmins3(color, const message[])
{
    for(new i; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(UserStats[i][Admin] >= 3)
            {
                SendClientMessage(i, color, message);
            }
        }
    }
    return 1;
}
And congratulations on 1000 posts.
Reply
#7

Quote:
Originally Posted by [xB]Lordz
Посмотреть сообщение
You can also use a stock like this :
pawn Код:
stock MessageToAdmins3(color, const message[])
{
    for(new i; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i) && UserStats[playerid][Admin] >=3(i))
    {
        SendClientMessage(i, color, message);
    }
    return 1;
}
So for every message to Level 3 admins, you can use this stock.

pawn Код:
CMD:pm(playerid, params [ ] )
{
    new pID, Message[60]; // defining the pID which will hold the Player's ID. Message will hold the message and playername will hold the name of the player that sends it, also target to the target
    if(sscanf(params, "us[60]", pID, Message)) return SendClientMessage(playerid, 0xAFAFAFAA, ""embed_yellow"Usage"embed_white": /pm [PlayerID/PlayerName] [Message]"); // Checks if the player has filed in both params if not it will return a error message with Color Grey
    if(pID == INVALID_PLAYER_ID || !IsPlayerConnected(pID)) return SendClientMessage(playerid, 0xAFAFAFAA, ""embed_red"[ERROR] "embed_white"Invalid Player"); // Checks if the player he attemps to send to is invalid if not it will send and error message
    if(PMEnabled[playerid] == 0) return SendClientMessage(playerid, 0xAFAFAFAA, ""embed_red"[ERROR] "embed_white"PM Is Disabled"); // This checks if the PMs are toggled off
    new playername[MAX_PLAYER_NAME],string[128];
    GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
    format(string, sizeof(string), ""embed_red"[PM] "embed_white"From "embed_sw"%s"embed_white":%s", playername, Message); // Will format the string the first %s is the name of the guy who sent pm second %s in the Message
    SendClientMessage(pID, 0xFFFF00FF, string);
    GetPlayerName(pID, playername, MAX_PLAYER_NAME);
    format(string, sizeof(string), ""embed_red"[PM] "embed_white"Sent to "embed_sw"%s"embed_white":%s", playername, Message); // The same as above but this time it shows the name off the player you sent it to
    SendClientMessage(playerid, 0xFFFF00AA, string); // Sends a message to the player who sent the PM
    format(string, sizeof(string),""embed_white"[PM]"embed_sw"%s(%i) "embed_white"to "embed_sw"%s(%i)"embed_white": "embed_orange"%s", UserStats[playerid][Name], playerid,UserStats[pID][Name], pID, Message);
    MessageToAdmins3(blue, string);
    return 1;
}
Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
pawn Код:
stock MessageToAdmins3(color, const message[])
{
    for(new i; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(UserStats[i][Admin] >= 3)
            {
                SendClientMessage(i, color, message);
            }
        }
    }
    return 1;
}
And congratulations on 1000 posts.
It`s work guys..Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)