Private Message System
#2

Quote:
Originally Posted by Cezar98
Посмотреть сообщение
Hi, how can i create a private message system for my samp server like this:

1. If player type /pm in chat to show this dialog
/pm command - http://www.imgx.ro/fullview.php?id=241038

dialog - http://www.imgx.ro/fullview.php?id=241039

2. else if player type /pm and player id or name in chat to show this:
command - http://www.imgx.ro/fullview.php?id=241040

dialog - http://www.imgx.ro/fullview.php?id=241041

3. else if player type /pm and player and message the message will be sent successfully to player like this:
command: - http://www.imgx.ro/fullview.php?id=241043

dialog - http://www.imgx.ro/fullview.php?id=241044
You can make a function to show up the message in a dialog.

Ex:
Код:
#define DIALOG_MESSAGE_PM 1234
#define DIALOG_MESSAGE_REPLY_PM 1235

new LastMessage[MAX_PLAYERS]; //This will remember the playerid who sended u the last message.
Код:
hook OnPlayerConnect(playerid)
{
     LastMessage[playerid] = -1;
     return 1;
}

hook OnPlayerDisconnect(playerid)
{
     LastMessage[playerid] = -1;
     return 1;
}
Код:
forward SendDialogMessage(playerid, id, message[]);
public SendDialogMessage(playerid, id, message[])
{
      new titleString[60];
      new stringInfo[100];

      format(titleString, sizeof(titleString), "New PM from %s (%d)", GetPlayerName(playerid), playerid);
      format(stringInfo, sizeof(stringInfo), "You have received a new PM from %s\n%s", GetPlayerName(playerid), message);

      ShowPlayerDialog(id, DIALOG_MESSAGE_PM, DIALOG_STYLE_MSGBOX, "titleString, stringInfo, "Reply", "Close");

      LastMessage[id] = playerid;
      return 1;
}
Then u check it on OnDialogResponse

Код:
hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_MESSAGE_PM)
    {
        if(response) // If they clicked 'Reply' or pressed enter
        {
             ShowPlayerDialog(playerid, DIALOG_MESSAGE_REPLY_PM, DIALOG_STYLE_INPUT, "Replay PM", "Enter your message gere:", "Send Reply", "Close");
        }
        return 1; 
    }
     if(dialogid == DIALOG_MESSAGE_REPLY_PM)
    {
        if(response) // If they clicked 'Reply' or pressed enter
        {
             SendDialogMessage(playerid, LastMessage[playerid], inputtext);
        }
        return 1; 
    }
    return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}
Hope u understood the methode i explain u, good luck to create the system.
I didn't test the code, sorry if i wrong something
Reply


Messages In This Thread
Private Message System - by Cezar98 - 24.02.2018, 11:00
Re: Private Message System - by kingmk - 24.02.2018, 11:07
Re: Private Message System - by Cezar98 - 24.02.2018, 11:20
Re: Private Message System - by kingmk - 24.02.2018, 11:23
Re: Private Message System - by Cezar98 - 24.02.2018, 11:59
Re: Private Message System - by jasperschellekens - 24.02.2018, 12:13
Re: Private Message System - by kingmk - 24.02.2018, 13:58
Re: Private Message System - by Astralis - 24.02.2018, 18:53
Re: Private Message System - by grymtn - 24.02.2018, 19:54

Forum Jump:


Users browsing this thread: 2 Guest(s)