PM the last User you pmed
#1

Hello, how to make an command to pm the last user you write with it? I dont know how.
Reply
#2

Use a PVar with the last ID you pmed and then make a command, /reply or something.
Reply
#3

Store the last id you sent a PM into a variable, and write a command like /reply that sends the private message to the id stored in that variable.
Reply
#4

My variable is that:

Код:
if(pInfo[targetid][pPM]
		{
Can you give me an simple example, please?
Reply
#5

pawn Код:
// Global variable
new
    Last_PM_From[ MAX_PLAYERS ]
;

// OnPlayerConnect
Last_PM_From[ playerid ] = -1;

// Command
if( Last_PM_From[ playerid ] == -1 ) return SendClientMessage( playerid, -1, "You did not recieve any PM to reply back!" );
if( Last_PM_From[ playerid ] == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "That player is not online anymore!" );
// code...
SendClientMessage( ast_PM_From[ playerid ], color_here, message_here );
Oh and when you recieve a message, assign to the variable the id of the player.
Reply
#6

thanks but how to assign the variable of the id of the player?
Reply
#7

pawn Код:
CMD:pm( playerid, params[ ] )
{
    new
        id,
        msg[ 64 ]
    ;
    if( sscanf( params, "rs[64]", id, msg ) ) return SendClientMessage( playerid, -1, "Usage: /pm <ID/Part Of Name> <message>" );
    if( id == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "That player is not online" );
    new
        pm_msg[ 128 ],
        name1[ MAX_PLAYER_NAME ],
        name2[ MAX_PLAYER_NAME ]
    ;
    GetPlayerName( playerid, name1, MAX_PLAYER_NAME );
    GetPlayerName( id, name2, MAX_PLAYER_NAME );
    format( pm_msg, sizeof( pm_msg ), "PM From %s (%d): %s", name1, playerid, msg );
    SendClientMessage( id, -1, pm_msg );
    format( pm_msg, sizeof( pm_msg ), "PM To %s (%d): %s", name2, id, msg );
    SendClientMessage( playerid, -1, pm_msg );
   
    Last_PM_From[ id ] = playerid;
    return 1;
}
Reply
#8

well, my command is so:

Код:
CMD:pm(playerid,params[])
{
	new targetid,message[256],pmstring[256];
    if(pInfo[playerid][IsPlayerMuted] == 1) {
    SendClientMessage(playerid,-1,""chat""COL_ADMINCMD" {8DD7FF}You Are Muted!"); return 1; }
 	if(sscanf(params,"us[256]", targetid, message)) return SendClientMessage(playerid,-1,""chat" /pm [playerid] [message]");
	if(pInfo[playerid][pLogged] == 1)
	{
		if(pInfo[targetid][pPM] == 0)
		{
			format(pmstring,sizeof(pmstring),""chat""COL_RED" {FFF1AF}[PM][%s][%d]: %s",PlayerName(playerid),playerid,message);
			SendClientMessage(targetid,-1,pmstring);
			format(pmstring,sizeof(pmstring),""chat""COL_RED" {CFCFCF}[PM Sent][%s][%d]: %s",PlayerName(playerid),playerid,message);
			SendClientMessage(playerid,-1,pmstring);
		}
		else {
			SendClientMessage(playerid,-1,""chat""COL_YELLOW" This player dont accepting private messages [PM's].");
		}
	}
	return 1;
}
how can i make that with my variable "pPM"?
Reply
#9

pPM is for toggling the PMs, right? So, you cannot use it for the last id too.

Make a variable to store the last id and use it like I showed you on my example:
pawn Код:
Last_PM_From[ targetid ] = playerid;
// Change "Last_PM_From[ targetid ]" to your variable's name
Reply
#10

Should i make that
Код:
Last_PM_From[ targetid ] = playerid;
in the normal pm command or in the /r command to answer the last user which i pmed?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)