SA-MP Forums Archive
How to make /r (Reply PM Command) - 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: How to make /r (Reply PM Command) (/showthread.php?tid=354961)



How to make /r (Reply PM Command) - Uberanwar - 28.06.2012

Hey Guys know how to make /r (reply pm command)? with textdraws like (PM Received, PM Sent)? I'm new in scripting so I want to learn how to make it.
This is my PM ''script''
PHP код:
dcmd_pm(playerid,params[])
{
    new 
string[128];
    new 
ID;
    new 
cmdreason[100];
    if(
sscanf(params"us[100]"IDcmdreason))
    {
        
SendClientMessage(playerid,COLOR_ERROR,"USAGE: /pm (Player Name/ID) (Message)");
        return 
1;
    }
    if(
IsMuted[playerid] == 1)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You are Muted. You Cannot Use This Command");
        return 
1;
    }
    if(
udb_Exists(PlayerName(playerid)) && !PLAYERLIST_authed[playerid])
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You must login before you can talk");
        return 
1;
    }
    if(!
IsPlayerConnected(ID))
    {
        
format(stringsizeof(string), "The Player ID (%d) is not connected to the server.",ID);
        
SendClientMessage(playerid,COLOR_ERROR,string);
        return 
1;
    }
    
format(stringsizeof(string), "PM Sent to: %s (%d): %s",PlayerName(ID),ID,cmdreason);
    
SendClientMessage(playerid,COLOR_YELLOW,string);
    
    
format(stringsizeof(string), "PM From: %s (%d) %s",PlayerName(playerid),playerid,cmdreason);
    
SendClientMessage(ID,COLOR_YELLOW,string);
    
    
format(stringsizeof(string), "3[PM] From %s (%d) to %s (%d): %s",PlayerName(playerid),playerid,PlayerName(ID),ID,cmdreason); // [0] <jacob> hi
    
IRC_GroupSay(gGroupAdminID,IRC_ADMINCHANNEL,string);
    
    
SpamStrings[playerid] ++;
    
PlayerPlaySound(ID,1085,0.0,0.0,0.0);
    return 
1;




Re: How to make /r (Reply PM Command) - Deal-or-die - 28.06.2012

Try This.

pawn Код:
dcmd_r(playerid,params[]) return dcmd_pm(playerid, params);



Re: How to make /r (Reply PM Command) - Uberanwar - 28.06.2012

Quote:
Originally Posted by Deal-or-die
Посмотреть сообщение
Try This.

pawn Код:
dcmd_r(playerid,params[]) return dcmd_pm(playerid, params);
Where to put that?


Re: How to make /r (Reply PM Command) - Deal-or-die - 28.06.2012

Basically anywhere under the OnPlayerCommand Section
Either Above or Below this command will do just fine.

Or just copy and paste this.
pawn Код:
dcmd_pm(playerid,params[])
{
    new string[128];
    new ID;
    new cmdreason[100];
    if(sscanf(params, "us[100]", ID, cmdreason))
    {
        SendClientMessage(playerid,COLOR_ERROR,"USAGE: /pm (Player Name/ID) (Message)");
        return 1;
    }
    if(IsMuted[playerid] == 1)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You are Muted. You Cannot Use This Command");
        return 1;
    }
    if(udb_Exists(PlayerName(playerid)) && !PLAYERLIST_authed[playerid])
    {
        SendClientMessage(playerid,COLOR_ERROR,"You must login before you can talk");
        return 1;
    }
    if(!IsPlayerConnected(ID))
    {
        format(string, sizeof(string), "The Player ID (%d) is not connected to the server.",ID);
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    format(string, sizeof(string), "PM Sent to: %s (%d): %s",PlayerName(ID),ID,cmdreason);
    SendClientMessage(playerid,COLOR_YELLOW,string);
   
    format(string, sizeof(string), "PM From: %s (%d) %s",PlayerName(playerid),playerid,cmdreason);
    SendClientMessage(ID,COLOR_YELLOW,string);
   
    format(string, sizeof(string), "3[PM] From %s (%d) to %s (%d): %s",PlayerName(playerid),playerid,PlayerName(ID),ID,cmdreason); // [0] <jacob> hi
    IRC_GroupSay(gGroupAdminID,IRC_ADMINCHANNEL,string);
   
    SpamStrings[playerid] ++;
    PlayerPlaySound(ID,1085,0.0,0.0,0.0);
    return 1;
}
dcmd_r(playerid,params[]) return dcmd_pm(playerid, params);



Re: How to make /r (Reply PM Command) - MP2 - 28.06.2012

He doesn't want /r to re-direct to /pm. /r means reply, as in you type '/r hello' and it sends 'hello' to whomever PM'd you last.

All you need to do is store the playerid of the last player that PMed you in an array.


Re: How to make /r (Reply PM Command) - Deal-or-die - 28.06.2012

Ahh, good point, blah, I knew that in my head was just ... Nevermind -.-


Re: How to make /r (Reply PM Command) - [KHK]Khalid - 28.06.2012

pawn Код:
// top
new LastSender[MAX_PLAYERS]; // a player global var to store the id of the last pm sender

// Under OnPlayerConnect, when they connect set it to -1 which means they didn't receiver any messages
LastSender[playerid] = -1;

// then put this into your pm command
LastSender[ID] = playerid; // means the last one who sent a pm to "ID" is "playerid"

// So now you can make a reply command .. /reply [message] and use the LastSender var to know
// who was the last player who sent this player a pm.

dcmd_reply(playerid, params[])
{
        new ID = LastSender[playerid];
        // also you can check if the var equals to -1 then return an error message.
        if(ID == -1) return SendClientMessage(playerid, -1, "You didn't receiver any pms!");
        /*
            Your command stuff
        */

        // And when your done formatting the message and everything send this message to ID
        SendClientMessage(ID, -1, TheFormattedMessage);
        return 1;
}



Re: How to make /r (Reply PM Command) - [MM]RoXoR[FS] - 28.06.2012

Create a variable which stores id of player who sended last PM
pawn Код:
new ReplyId[MAX_PLAYERS];
Now, when player connects
pawn Код:
ReplyId[playerid] = INVALID_PLAYER_ID;
Under PM Command
pawn Код:
//add this where you send pm.
ReplyId[targetid] = playerid;//id of the target.
Now for reply
pawn Код:
dcmd_r(playerid,params[])
{
new targetid = ReplyId[playerid];
//All the PM stuff and after you send the PM.
ReplyId[targetid] = playerid;
}



Re: How to make /r (Reply PM Command) - Uberanwar - 28.06.2012

[QUOTE=HellSphinX;1951993][PAWN]
// top
new LastSender[MAX_PLAYERS]; // a player global var to store the id of the last pm sender

// Under OnPlayerConnect, when they connect set it to -1 which means they didn't receiver any messages
LastSender[playerid] = -1;

// then put this into your pm command
LastSender[ID] = playerid; // means the last one who sent a pm to "ID" is "playerid"

// So now you can make a reply command .. /reply [message] and use the LastSender var to know
// who was the last player who sent this player a pm.

dcmd_reply(playerid, params[])
{
new ID = LastSender[playerid];
// also you can check if the var equals to -1 then return an error message.
if(ID == -1) return SendClientMessage(playerid, -1, "You didn't receiver any pms!");
/*
Your command stuff
*/
// And when your done formatting the message and everything send this message to ID
SendClientMessage(ID, -1, TheFormattedMessage);
return 1;
}


PHP код:
C:\Users\sofie's\Desktop\CCNRRPG\gamemodes\SFCRRPG.pwn(4175) : error 017: undefined symbol "TheFormattedMessage"
C:\Users\sofie'
s\Desktop\CCNRRPG\gamemodes\SFCRRPG.pwn(4166) : warning 203symbol is never used"params"
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
1 Error

Here's the script 4166 - 4175
PHP код:
dcmd_r(playeridparams[])
{
        new 
ID LastSender[playerid];
        
// also you can check if the var equals to -1 then return an error message.
        
if(ID == -1) return SendClientMessage(playerid, -1"You didn't receiver any pms!");
        
/*
            Your command stuff
        */
        // And when your done formatting the message and everything send this message to ID
        
SendClientMessage(ID, -1TheFormattedMessage);
        return 
1;




Re: How to make /r (Reply PM Command) - [KHK]Khalid - 28.06.2012

You have to make the command I just gave you some hints not the full command.