24.02.2018, 11:07
(
Последний раз редактировалось kingmk; 24.02.2018 в 14:01.
)
Quote:
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 |
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; }
Код:
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. }
I didn't test the code, sorry if i wrong something