public OnPlayerPrivmsg(playerid, recieverid, text[])
{
if(ServerInfo[ReadPMs] == 1 && AccInfo[playerid][Level] != ServerInfo[MaxAdminLevel])
{
//==============================================================================
// Send PM
//==============================================================================
new string[256];
new pReciever[MAX_PLAYER_NAME];
GetPlayerName(playerid, string, sizeof(string));
GetPlayerName(recieverid, pReciever, sizeof(pReciever));
format(string, sizeof(string), "|- PM: %s To %s: %s", string, pReciever, text);
for (new a = 0; a < MAX_PLAYERS; a++)
if(IsPlayerConnected(a) && (AccInfo[a][Level] >= ServerInfo[MaxAdminLevel]) && a != playerid)
Inter_SendClientMessage(a, grey, string);
#if PM_CHAT_LOG == true
SaveIn("AdmChatLog",string);
#endif
}
//==============================================================================
// Muted
//==============================================================================
if(AccInfo[playerid][Muted] == 1)
{
new string[256];
AccInfo[playerid][MuteWarnings]++;
if(AccInfo[playerid][MuteWarnings] < ServerInfo[MaxMuteWarnings])
{
format(string, sizeof(string),"|- ATTENTION: You are Muted! Cannot talk (Warnings: %d/%d) -|",AccInfo[playerid][MuteWarnings],ServerInfo[MaxMuteWarnings]);
Inter_SendClientMessage(playerid,red,string);
}
else
{
Inter_SendClientMessage(playerid,red,"|- You have been Automatically Kicked. | Reason: Exceeding Mute Warnings -|");
GetPlayerName(playerid, string, sizeof(string));
format(string, sizeof(string),"|- Player %s (Id:%d) has been Automatically Kicked. | Reason: Exceeding Mute Warnings -|", string, playerid);
Inter_SendClientMessageToAll(lightred,string);
SaveIn("KickLog",string);
Kick(playerid);
}
return 0;
}
#if EnablePM_Cmd == true
new string[256],playername[MAX_PLAYER_NAME];
format(string,sizeof(string),"|- PM: Message to '%s(%d)': \"%s\" -|",PmReceiver,PMplayer1,text);
Inter_SendClientMessage(playerid,0x00A765AA,string);
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string),"|- PM: Message from: %s(%d): \"%s\" -|",playername,playerid,text);
Inter_SendClientMessage(recieverid,0x00A765AA,string);
#endif
return 1;
}
//==============================================================================
// PM Command
//==============================================================================
#if EnablePM_Cmd == true
CMD:pm(playerid,params[])
{
new giveplayerid, inputtext[256];
if (sscanf(params, "us", giveplayerid, inputtext)) return Inter_SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /pm [PlayerID] [Message]");
if(giveplayerid == playerid) return
Inter_SendClientMessage(playerid, red, "ERROR: You can't send PM to yourself!");
if(!(IsPlayerConnected(giveplayerid) && giveplayerid != INVALID_PLAYER_ID)) return
Inter_SendClientMessage(playerid, red, "ERROR: Player not Connected!");
PMplayer1 = giveplayerid;
GetPlayerName(giveplayerid, PmReceiver, sizeof(PmReceiver));
OnPlayerPrivmsg(playerid, giveplayerid, inputtext);
/* new string[128];
format(string,sizeof(string),"PM To: \"%s(%d)\" \n\nType the message to send:", PmReceiver, PMplayer1);
ShowPlayerDialog(playerid,DIALOG_TYPE_PM,DIALOG_STYLE_INPUT,"PrivateMessage",string,"Send!","Cancel");*/
return 1;
}
#endif
#include <sscanf2>
#include <zcmd>
new ReplyID[MAX_PLAYERS]; //Top of your script.
public OnPlayerConnect(playerid)
{
ReplyID[playerid] = -1;
}
//Now I will do the commands both in ZCMD, using Sscanf as I don't work with anything else myself.
command(pm, playerid, params[])
{
new id, message[128], string[256];
if(sscanf(params, "us[128]", id, message)) return SendClientMessage(playerid, 0xFFFFFFA, "Server: /pm [playerid] [message]");
else
{
format(string, sizeof(string), "[PM From %s] %s (To reply, use /r)", pName(playerid), message);
SendClientMessage(playerid, 0xFFFFFFFF, string);
ReplyID[id] = playerid;
format(string, sizeof(string), "[PM to %s] %s", pName(id), message);
SendClientMessage(playerid, 0xFFFFFFFF, string);
}
return 1;
}
command(r, playerid, params[])
{
if(ReplyID[playerid] == -1) return SendClientMessage(playerid, 0xFFFFFF, "Nobody has sent you a Private Message.");
if(sscanf(params, "s[128]", message)) return SendClientMessage(playerid, 0xFFFFFFFF, "Server: /r [message]");
{
format(string, sizeof(string), "[PM From %s] %s (To reply, use /r)", pName(playerid), message);
SendClientMessage(playerid, 0xFFFFFFFF, string);
ReplyID[ReplyID[playerid]] = playerid;
format(string, sizeof(string), "[PM to %s] %s", message);
SendClientMessage(playerid, 0xFFFFFFFF, string);
ReplyID[playerid] = -1;
}
return 1;
}
stock pName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
Easy.
Do it like this. pawn Код:
That should work. If not, please tell me your errors. |
new message;