help with create a reply command
#1

To this PM command. I want to make the Reply command (/reply [text]). /reply command to respond directly to the sender. To get the player ID and player write /reply [text], but he understood their Player ID.
Sorry for my bad English.

Код:
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


Forum Jump:


Users browsing this thread: 1 Guest(s)