Help with command +1 rep
#1

Hello guys I want to make command to ingnore а player in pm not all here is my pm command

pawn Код:
if(strcmp(cmd, "/pm", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(gPlayerLogged[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_GREY, "   You havent logged in yet!");
                return 1;
            }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /pm [playerid/PartOfName] [text]");
                return 1;
            }
            giveplayerid = strval(tmp);
            if (IsPlayerConnected(giveplayerid))
            {
                if(giveplayerid != INVALID_PLAYER_ID)
                {
                    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                    new length = strlen(cmdtext);
                    while ((idx < length) && (cmdtext[idx] <= ' '))
                    {
                        idx++;
                    }
                    new offset = idx;
                    new result[256];
                    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                    {
                        result[idx - offset] = cmdtext[idx];
                        idx++;
                    }
                    result[idx - offset] = EOS;
                    if(!strlen(result))
                    {
                        SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /pm [playerid/PartOfName] [text]");
                        return 1;
                    }
                    format(string, sizeof(string), "* PM from %s(ID: %d): %s", PlayerName(playerid), playerid, (result));
                    SendClientMessage(giveplayerid, COLOR_YELLOW, string);
                    format(string, sizeof(string), "* PM to %s(ID: %d): %s", giveplayer, giveplayerid, (result));
                    SendClientMessage(playerid,  COLOR_YELLOW, string);//to6o
                    for(new i = 0; i < MAX_PLAYERS; i++)
                    {
                        if(IsPlayerConnected(i))
                        {
                            if(PlayerInfo[i][pAdmin] >= 1)
                            {
                                if(PlayerInfo[i][aTog] == 1)
                                {
                                    format(string, sizeof(string), "* PM from %s[%d] to %s[%d]: %s", PlayerName(playerid), playerid, giveplayer, giveplayerid, (result));
                                    SendClientMessage(i,  COLOR_YELLOW, string);//to6o
                                }
                            }
                        }
                    }
                    return 1;
                }
            }
            else
            {
                    format(string, sizeof(string), "   %d is not an active player.", giveplayerid);
                    SendClientMessage(playerid, COLOR_GRAD1, string);
            }
        }
        return 1;
    }
Reply
#2

BUMP
Reply
#3

Put this on the top of your script.
pawn Код:
new Ignore[MAX_PLAYERS][MAX_PLAYERS];

Put this under OnPlayerConnect.
pawn Код:
for(new i=0; i<MAX_PLAYERS; i++)
{
    Ignore[playerid][i] = 0;
}
Command: /ignore
pawn Код:
if(strcmp(cmd, "/ignore", true) == 0)
{
    new playerb;
    if(IsPlayerConnected(playerid))
    {
        if(gPlayerLogged[playerid] == 0)
        {
            SendClientMessage(playerid, COLOR_GREY, "   You havent logged in yet!");
            return 1;
        }
        tmp = strtock(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /ignore [playerid/PartOfName]");
            return 1;
        }
        playerb = strval(tmp);
        if(!IsPlayerConnected(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
        if(Ignore[playerid][playerb]) return SendClientMessage(playerid, COLOR_GREY, "Player is already ignored.");
        Ignore[playerid][playerb] = 1;
        SendClientMessage(playerid, COLOR_WHITE, "Player ignored.");
    }
    return 1;
}
Command: /unignore
pawn Код:
if(strcmp(cmd, "/unignore", true) == 0)
{
    new playerb;
    if(IsPlayerConnected(playerid))
    {
        if(gPlayerLogged[playerid] == 0)
        {
            SendClientMessage(playerid, COLOR_GREY, "   You havent logged in yet!");
            return 1;
        }
        tmp = strtock(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /unignore [playerid/PartOfName]");
            return 1;
        }
        playerb = strval(tmp);
        if(!IsPlayerConnected(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
        if(!Ignore[playerid][playerb]) return SendClientMessage(playerid, COLOR_GREY, "Player is not ignored.");
        Ignore[playerid][playerb] = 0;
        SendClientMessage(playerid, COLOR_WHITE, "Player unignored.");
    }
    return 1;
}
Command: /pm
pawn Код:
if(strcmp(cmd, "/pm", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        if(gPlayerLogged[playerid] == 0)
        {
            SendClientMessage(playerid, COLOR_GREY, "   You havent logged in yet!");
            return 1;
        }
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /pm [playerid/PartOfName] [text]");
            return 1;
        }
        giveplayerid = strval(tmp);
        if (IsPlayerConnected(giveplayerid))
        {
            if(giveplayerid != INVALID_PLAYER_ID)
            {
                if(Ignore[giveplayerid][playerid]) return SendClientMessage(playerid, COLOR_GREY, "Player is ignoring you.");
                if(Ignore[playerid][giveplayerid]) return SendClientMessage(playerid, COLOR_GREY, "You are ignoring that player.");
                GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                new length = strlen(cmdtext);
                while ((idx < length) && (cmdtext[idx] <= ' '))
                {
                    idx++;
                }
                new offset = idx;
                new result[256];
                while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                {
                    result[idx - offset] = cmdtext[idx];
                    idx++;
                }
                result[idx - offset] = EOS;
                if(!strlen(result))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /pm [playerid/PartOfName] [text]");
                    return 1;
                }
                format(string, sizeof(string), "* PM from %s(ID: %d): %s", PlayerName(playerid), playerid, (result));
                SendClientMessage(giveplayerid, COLOR_YELLOW, string);
                format(string, sizeof(string), "* PM to %s(ID: %d): %s", giveplayer, giveplayerid, (result));
                SendClientMessage(playerid,  COLOR_YELLOW, string);//to6o
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i))
                    {
                        if(PlayerInfo[i][pAdmin] >= 1)
                        {
                            if(PlayerInfo[i][aTog] == 1)
                            {
                                format(string, sizeof(string), "* PM from %s[%d] to %s[%d]: %s", PlayerName(playerid), playerid, giveplayer, giveplayerid, (result));
                                SendClientMessage(i,  COLOR_YELLOW, string);//to6o
                            }
                        }
                    }
                }
                return 1;
            }
        }
        else
        {
                format(string, sizeof(string), "   %d is not an active player.", giveplayerid);
                SendClientMessage(playerid, COLOR_GRAD1, string);
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)