SA-MP Forums Archive
reply - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: reply (/showthread.php?tid=639537)



reply - Loinal - 19.08.2017

PHP Code:
CMD:r(playeridparams[])
{
    new 
str2[256], msg2[280];
    if(
sscanf(params,"s[256]",str2)) return SendClientMessage(playerid,COLOR_MESSAGE_YELLOW,"USAGE: /r [Message]");
    
    if(
LastSender[playerid] == -1)
    {
        
SendClientMessage(playeridCOLOR_RED"* You have got no private messages since you have joined the server.");
    }
    else
    {
    }
    return 
1;

Thats my reply command my brain stopped to work here just confused

PHP Code:
   format(msg,sizeof(msg),"* PM sent to %s (ID: %d): %s",GetName(id),id,str2);
   
SendClientMessage(playerid,0xFF0000F,msg);
   
format(msg,sizeof(msg),"* PM From %s (ID: %d): %s",GetName(playerid),playerid,str2);
   
SendClientMessage(id,0xFF0000F,msg);
   
SendClientMessage(id0xFF0000F,"* Use /r to reply.");
   
format(msg,sizeof(msg),"3,5* PM from %s (ID :%d) to %s (ID: %d): %s",GetName(playerid),playerid,GetName(id),id,str2);
   
IRC_GroupSay(groupID,IRC_oCHANNEL,msg);
   
LastSender[id] = playerid
Thats the pm command

i just need it to get the name of the other id and my id and sends the message


Re: reply - HoussemGaming - 19.08.2017

Why you use new LastSender[MAX_PLAYERS]; ?
Just use new LastSender;


Re: reply - iLearner - 19.08.2017

Can u explain what's the problem

Houssem, its advised to say nothing rather then saying bs.


Re: reply - Vince - 19.08.2017

In all honesty you should probably create a function with the PM code:
Code:
SendPrivateMessage(fromplayerid, toplayerid)
That then handles the actual sending of the PM. In your command you can then call this single function with "playerid" and "id" and in the reply command you do the same thing except you replace "id" with "LastSender[playerid]".

Quote:
Originally Posted by HoussemGaming
View Post
Why you use new LastSender[MAX_PLAYERS]; ?
Because not every player communicates with the same person.

And oh, one more thing: it is much better to use INVALID_PLAYER_ID instead of -1 or 9999 or some other arbitrary value. Makes it just a tad bit clearer what's going on.


Re: reply - Loinal - 19.08.2017

Quote:
Originally Posted by iLearner
View Post
Can u explain what's the problem

Houssem, its advised to say nothing rather then saying bs.
Problem is i can't get the name and the id of the sender and the one who receive the pm


Re: reply - DimaShift - 19.08.2017

new str2[256], msg2[280];

max 144


Re: reply - AngeloBrand98 - 19.08.2017

Here is my /pm and /pmreply commad, i hope its usefully as well (Already tested on my server and all good)

Code:
CMD:pm(playerid, params[])
{
	new tmp[256], giveplayerid, giveplayer[25], playername[25],string[256];
	if(adlvl[playerid] < 1 && supportmembers[playerid] == 0) return 0;
	GetPlayerName(giveplayerid, giveplayer, MAX_PLAYER_NAME);
	if (sscanf(params, "us[128]", giveplayerid, tmp)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /pm [playerid] [message]");
	if (!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_RED, "Error: Inactive player id!");
    if (giveplayerid == playerid) return SendClientMessage(playerid, COLOR_RED, "Error: You can't send private message to your self!");
	GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
	GetPlayerName(giveplayerid, giveplayer, MAX_PLAYER_NAME);
	format(string, sizeof(string), "{E6E600}PM received from %s(%d): %s", playername, playerid, tmp);
	SendClientMessage(giveplayerid, COLOR_YELLOW, string);
	SendClientMessage(giveplayerid, COLOR_YELLOW, "You can use /pmreply [text] for fast reply.");
	format(string,sizeof(string), "{FFFF00}PM sent to %s(%d): %s", giveplayer, giveplayerid, tmp);
	SendClientMessage(playerid, COLOR_WHITE, string);
	PlayerPlaySound(giveplayerid, 1056, 0.0, 0.0, 0.0);
	SetPVarInt(giveplayerid, "GotPM", 1);
	SetPVarInt(giveplayerid, "PmId", playerid);
	return 1;
}


CMD:pmreply(playerid, params[])
{
	new id = GetPVarInt(playerid, "PmId");
	new tmp[256], str[1080], name[MAX_PLAYER_NAME], pname[MAX_PLAYER_NAME];
	if(GetPVarInt(playerid, "GotPM") == 0) return SendClientMessage(playerid, COLOR_RED, "Error: No one pmmed you to send an reply.");
	if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "The person that pmed you has CUTTOFF");
	if(sscanf(params, "s", tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pmreply [message]");
	GetPlayerName(id, pname, sizeof(pname));
	GetPlayerName(playerid, name, sizeof(name));
	format(str, sizeof(str), "{FFFF00}PM delivered to %s(%d): %s",pname, id, tmp);
	SendClientMessage(playerid, COLOR_YELLOW, str);
	format(str, sizeof(str), "{E6E600}PM received from %s(%d): %s", name, playerid, tmp);
	SendClientMessage(id, COLOR_YELLOW, str);
	PlayerPlaySound(id, 1056, 0.0, 0.0, 0.0);
	SetPVarInt(playerid, "GotPM", 0);
	SetPVarInt(playerid, "PmId", -1);
	return 1;
}