/ignore (playerid)
#1

Hey guys. I want make a command about /ignore (playerid) for my pm system. Is it possible? If it is possible, How can I make this?
Reply
#2

Make a boolean:

Код:
new bool:ignore[MAX_PLAYERS][MAX_PLAYERS];
Initialize it OnPlayerConnect:

Код:
for(new i=0; i< MAX_PLAYERS; i++) ignore[playerid][i] = false;
Then use it in your /ignore and /pm commands so when ignore[receiver][sender] is true the message isn't sent.
Reply
#3

That still leaves the question of how to save the ignore command(which I am assuming is also part of the question). I am going to assume you use MySQL for saving-- I'd recommend using duplicate entries(which is what you can commonly find Vince arguing about when people don't use it).

An example of it can be found here:
https://sampforum.blast.hk/showthread.php?tid=505081
Reply
#4

Why to save it? It only uses the id of the player and is valid until he disconnects. Then we have to re-initialize the variable so next player with the same id will not be ignored. I assume that he wants to know if it is possible and how...
Reply
#5

He means having a list of ignored players for a certain id, imo that's a better way of doing it.
Reply
#6

Quote:
Originally Posted by Luis-
Посмотреть сообщение
He means having a list of ignored players for a certain id, imo that's a better way of doing it.
I thought he'd want it to save so you can basically void my post there.
Reply
#7

Quote:
Originally Posted by alexus
Посмотреть сообщение
Make a boolean:

Код:
new bool:ignore[MAX_PLAYERS][MAX_PLAYERS];
Initialize it OnPlayerConnect:

Код:
for(new i=0; i< MAX_PLAYERS; i++) ignore[playerid][i] = false;
Then use it in your /ignore and /pm commands so when ignore[receiver][sender] is true the message isn't sent.
Код:
dcmd_pm(playerid, params[])
{
        new pID, text[128], string[128];
        if(sscanf(params, "us", pID, text)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /pm (nick/id) (message) - Enter a valid Nick / ID");
        if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");
        if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot PM yourself.");
        format(string, sizeof(string), "%s (%d) is not accepting private messages at the moment.", PlayerName(pID), pID);
        if(pInfo[pID][NoPM] == 1) return SendClientMessage(playerid, COLOR_RED, string);
        format(string, sizeof(string), "PM to %s: %s", PlayerName(pID), text);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        format(string, sizeof(string), "PM from %s: %s", PlayerName(playerid), text);
        SendClientMessage(pID, COLOR_YELLOW, string);
        pInfo[pID][Last] = playerid;
        return 1;
}
This is my pm command how can i /ignore (playerid) system? Please help me.
Reply
#8

Код:
dcmd_pm(playerid, params[])
{
        new pID, text[128], string[128];
        if(sscanf(params, "us", pID, text)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /pm (nick/id) (message) - Enter a valid Nick / ID");
        if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");
        if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot PM yourself.");
        format(string, sizeof(string), "%s (%d) is not accepting private messages at the moment.", PlayerName(pID), pID);
        if(pInfo[pID][NoPM] == 1) return SendClientMessage(playerid, COLOR_RED, string);
	// here
	if(ignore[pID][playerid] == true) return SendClientMessage(playerid, COLOR_RED, "That player rejects your /pm");

        format(string, sizeof(string), "PM to %s: %s", PlayerName(pID), text);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        format(string, sizeof(string), "PM from %s: %s", PlayerName(playerid), text);
        SendClientMessage(pID, COLOR_YELLOW, string);
        pInfo[pID][Last] = playerid;
        return 1;
}
You have to set your /ignore [id] command. Have you already done it?
Reply
#9

Quote:
Originally Posted by alexus
Посмотреть сообщение
Код:
dcmd_pm(playerid, params[])
{
        new pID, text[128], string[128];
        if(sscanf(params, "us", pID, text)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /pm (nick/id) (message) - Enter a valid Nick / ID");
        if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");
        if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot PM yourself.");
        format(string, sizeof(string), "%s (%d) is not accepting private messages at the moment.", PlayerName(pID), pID);
        if(pInfo[pID][NoPM] == 1) return SendClientMessage(playerid, COLOR_RED, string);
	// here
	if(ignore[pID][playerid] == true) return SendClientMessage(playerid, COLOR_RED, "That player rejects your /pm");

        format(string, sizeof(string), "PM to %s: %s", PlayerName(pID), text);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        format(string, sizeof(string), "PM from %s: %s", PlayerName(playerid), text);
        SendClientMessage(pID, COLOR_YELLOW, string);
        pInfo[pID][Last] = playerid;
        return 1;
}
You have to set your /ignore [id] command. Have you already done it?

Код:
dcmd_ignore(playerid, params[])
{
        #pragma unused params
        if(pInfo[playerid][NoPM] == 0)
        {
            pInfo[playerid][NoPM] = 1;
            SendClientMessage(playerid, COLOR_YELLOW, "You are no longer accepting private messages.");
        }
        else
        {
            pInfo[playerid][NoPM] = 0;
            SendClientMessage(playerid, COLOR_YELLOW, "You are now accepting private messages.");
        }
}
This is my ignore command but I want /ignore (playerid)
Reply
#10

I named it /ignoreid so you can still use /ignore when you want to ignore "all"

Код:
dcmd_ignoreid(playerid, params[])
{
	if(sscanf(params, "u", params[0])) return SendClientMessage(playerid, COLOR_RED, "USAGE: /ignoreid [id] - Enter a valid id");
	new string[128], sender = strval(params);
	if(ignore[playerid][sender] == true)
	{
		ignore[playerid][sender] == false;
		format(string,sizeof(string),"YOU ACCEPT {FFFFFF}private messages from id %d",sender);
		SendClientMessage(playerid, COLOR_GREEN, string);
	}
	else
	{
		ignore[playerid][sender] == true;
		format(string,sizeof(string),"YOU REJECT {FFFFFF}private messages from id %d",sender);
		SendClientMessage(playerid, COLOR_RED, string);
	}
	return 1;
}
I assume that you have COLOR_GREEN defined. If not, add it:
Код:
#define COLOR_GREEN	0x00A000FF
Good luck!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)