PM Reply command
#1

To this PM command. I want to make the Reply command (/reply [text]). When someone writes the command /reply directly responsible, not to write long /pm [playerid] [text]

Код:
	if(strcmp(cmd, "/pm", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, GRAY, "USE: /pm [playerid] [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, GRAY, "USE: /pm [playerid] [text]");
						return 1;
					}
					for(new i = 0; i < MAX_PLAYERS; i++)
					{
						if(IsPlayerConnected(i))
						{
							format(string, sizeof(string), "* PM from %s(ID: %d): %s", PlayerName(playerid), playerid, (result));
							SendClientMessage(giveplayerid, YELLOW, string);
						}
					}
					format(string, sizeof(string), "* PM for %s(ID: %d): %s", giveplayer, giveplayerid, (result));
					SendClientMessage(playerid,  YELLOW, string);
					return 1;
				}
			}
			else
			{
					format(string, sizeof(string), "%d is not active player.", giveplayerid);
					SendClientMessage(playerid, GRAY, string);
			}
		}
		return 1;
	}
Reply
#2

I'm not going to write the code for you while you have that horrid strtok command processor in use, but I'll explain a method of doing it:

Set a PVar when someone sends a PM to the person who should be receiving it, store the ID of the person who just sent the PM in the pvar, and in /reply, check the PVar and use the ID as the new receipient of the PM for /reply.

Clear the PVar when either of the players log off.
Reply
#3

I don't know how to write this code. If any of this forum to write code, because I'm a beginner.
Reply
#4

up..
Edit: I do not know exactly what you mean with this Set a Pvar
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)