Private Message System
#1

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
Reply
#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
#3

Quote:
Originally Posted by kingmk
Посмотреть сообщение
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

Код:
public 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
        {
             new message = strlen(inputtext);
             SendDialogMessage(playerid, LastMessage[playerid], message);
        }
        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
i need /pm command now
Reply
#4

Quote:
Originally Posted by Cezar98
Посмотреть сообщение
i need /pm command now
Код:
CMD:pm(playerid, params[])
{
       if(IsPlayerAdmin(playerid)) //Check if is player admin
       {
              new id, message[150];
              if(sscanf(params, "us[150]", id, message)) return SendClientMessage(playerid, COLOR_WHITE,"Usage: /pm [PlayerID] [Message]");
              SendDialogMessage(playerid, id, message);
       }
       return 1;
}
I didn't test the code, sorry if i wrong something
Reply
#5

Quote:
Originally Posted by kingmk
Посмотреть сообщение
Код:
CMD:pm(playerid, params[])
{
       if(IsPlayerAdmin(playerid)) //Check if is player admin
       {
              new id, message[150];
              if(sscanf(params, "us[150]", id, message)) return SendClientMessage(playerid, COLOR_WHITE,"Usage: /pm [PlayerID] [Message]");
              SendDialogMessage(playerid, id, message);
       }
       return 1;
}
I didn't test the code, sorry if i wrong something
http://www.imgx.ro/view.php?id=241045

http://www.imgx.ro/fullview.php?id=241046

http://www.imgx.ro/fullview.php?id=241048
Reply
#6

Post your code here instead of screenshots.
Reply
#7

replace message = strlen(inputtext); with;

Код:
new message[150];
format(message, sizeof(message), "%s", inputtext);
or just do this
Код:
SendDialogMessage(playerid, LastMessage[playerid], inputtext);
Mybad, sorry. If u wanna check if the player pressed just ENTED, with no text, you can check it with strlen(inputtext) > 0;
Reply
#8

Why'd you try something here? Just search 'filterscripts' section...you'll find lots of PM systems.
Reply
#9

Pm with dialogs is too much of a work for a player really. Think of switching it. Use sscanf for your pm system and make a blockpm command by using pvars so when i pm you and you block pm towards me when you recieve pm from me, it wont show you the message. Its really easy and at most 10 lines of simple scripting.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)