CMD:pm(playerid, params[])
{
if(IsPlayerConnected(playerid)) // Checks if the Player IS connected
{
new pID, Message[60], username[MAX_PLAYER_NAME], targetName[MAX_PLAYER_NAME], string[128], string2[128], query[600];
if(sscanf(params, "us[60]", pID, Message)) return SendClientMessage(playerid, COLOR_GOLD, "[REDMIN] PM Error: /pm <playerID or playername> <message>");
if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GOLD, "[REDMIN]PM Error: Invalid Player");
if(PMEnabled == 0) return SendClientMessage(playerid, 0xAFAFAFAA, "PM Is Disabled");
GetPlayerName(pID, targetName, sizeof(targetName));
GetPlayerName(playerid, username, sizeof(username));
format(string, sizeof(string), "PM from %s: %s", username, Message);
format(string2, sizeof(string2), "PM sent to %s: %s", targetName, Message);
SendClientMessage(playerid, COLOR_GOLD, string2);
SendClientMessage(pID, COLOR_GOLD, string);
new timestamp = gettime()
format(query, sizeof(query), "INSERT INTO pms (id, sender, reciever, date, message) VALUES ('', '%s', '%s', '%s', '%s')", playerid, pID, timestamp, Message);
mysql_query(query);
}
return 1;
}
CMD:pm(playerid, params[])
{
if(IsPlayerConnected(playerid)) // Checks if the Player IS connected
{
new pID, Message[60], username[MAX_PLAYER_NAME],
targetName[MAX_PLAYER_NAME], string[128],
query[600];
if(!sscanf(params, "us[60]", pID, Message))
{
if(pID != INVALID_PLAYER_ID)
{
if(PMEnabled == 1)
{
GetPlayerName(pID, targetName, sizeof(targetName));
GetPlayerName(playerid, username, sizeof(username));
format(string, sizeof(string), "PM from %s: %s", username, Message);
format(string2, sizeof(string2), "PM sent to %s: %s", targetName, Message);
SendClientMessage(playerid, COLOR_GOLD, string2);
SendClientMessage(pID, COLOR_GOLD, string);
new timestamp = gettime()
format(query, sizeof(query), "INSERT INTO pms (id, sender, reciever, date, message) VALUES ('', '%s', '%s', '%s', '%s')", playerid, pID, timestamp, Message);
mysql_query(query);
}
else return SendClientMessage(playerid, 0xAFAFAFAA, "PM Is Disabled");
}
else return SendClientMessage(playerid, COLOR_GOLD, "[REDMIN]PM Error: Invalid Player");
}
else return SendClientMessage(playerid, COLOR_GOLD, "[REDMIN] PM Error: /pm <playerID or playername> <message>");
}
return 1;
}
|
Why would you like to check if the player that is executing the command is online?
|
|
Why would you like to check if the player that is executing the command is online?
|

COMMAND:pm(playerid,params[])
{
static id,msg[112],string[128];
if(sscanf(params,"us[112]",id,msg))
{
return SendClientMessage(playerid,COLOR_GREY,"Usage:/pm [Name/ID] [Message]");
}
if(id == playerid)
return SendClientMessage(playerid,COLOR_RED,"/pm>>You cannot send a private message to yourself.");
if (id == INVALID_PLAYER_ID)
return SendClientMessage(playerid,COLOR_RED,"/pm>>Please give a valid player id/name.");
if (PlayerAC[id][Alive])
return SendClientMessage(playerid,COLOR_RED,"/pm>>Player cannot recieve private messages while he isen't spawned.");
if(PlayerData[id][DoNotRecievePMs])
return SendClientMessage(playerid,COLOR_RED,"/pm>>Player has disabled private messages for this session.");
if(PlayerData[playerid][IgnorePM][id>>5] & (1<<(id & 31)))
return SendClientMessage(playerid,COLOR_RED,"/pm>>The player is ignoring you.");
PlayerData[id][LastPMSentBy] = playerid;
format(msg,sizeof(string),"PM from %s(%d):%s",PlayerData[playerid][Name],playerid,msg);
SendClientMessage(id,COLOR_YELLOW,string);
SendClientMessage(id,COLOR_YELLOW,"/reply OR /r for quick reply");
format(msg,sizeof(string),"PM to %s(%d):%s",PlayerData[id][Name],id,msg);
SendClientMessage(playerid,COLOR_YELLOW,string);
return 1;
}
COMMAND:reply(playerid,params[])
{
static id,msg[112];
if(sscanf(params,"s[112]",msg))
{
return SendClientMessage(playerid,COLOR_GREY,"Usage:/reply [Message]");
}
id = PlayerData[id][LastPMSentBy];
if (id == INVALID_PLAYER_ID)
return SendClientMessage(playerid,COLOR_RED,"/reply>>The player has logged out.");
if (PlayerAC[id][Alive])
return SendClientMessage(playerid,COLOR_RED,"/reply>>Player cannot recieve private messages while he hasn't spawned yet.");
if(PlayerData[id][DoNotRecievePMs])
return SendClientMessage(playerid,COLOR_RED,"/reply>>Player has disabled private messages for this session.");
if(PlayerData[playerid][IgnorePM][id>>5] & (1<<(id & 31)))
return SendClientMessage(playerid,COLOR_RED,"/reply>>The player is ignoring you.");
if(PlayerData[id][LastPMSentBy] == -1)
return SendClientMessage(playerid,COLOR_RED,"/r>>You've not recieved any recent private message to use quick reply.");
PlayerData[id][LastPMSentBy] = playerid;
format(msg,sizeof(msg),"PM from %s(%d):%s",PlayerData[playerid][Name],playerid,msg);
SendClientMessage(id,COLOR_YELLOW,msg);
SendClientMessage(id,COLOR_YELLOW,"/reply OR /r for quick reply");
format(msg,sizeof(msg),"PM to %s(%d):%s",PlayerData[id][Name],id,msg);
SendClientMessage(playerid,COLOR_YELLOW,msg);
return 1;
}
COMMAND:r(playerid,params[])
{
static id,msg[112];
if(sscanf(params,"s[112]",msg))
{
return SendClientMessage(playerid,COLOR_GREY,"Usage:/r [Message]");
}
id = PlayerData[id][LastPMSentBy];
if (id == INVALID_PLAYER_ID)
return SendClientMessage(playerid,COLOR_RED,"/r>>The player has logged out.");
if (PlayerAC[id][Alive])
return SendClientMessage(playerid,COLOR_RED,"/r>>Player cannot recieve private messages while he hasn't spawned yet.");
if(PlayerData[id][DoNotRecievePMs])
return SendClientMessage(playerid,COLOR_RED,"/r>>Player has disabled private messages for this session.");
if(PlayerData[playerid][IgnorePM][id>>5] & (1<<(id & 31)))
return SendClientMessage(playerid,COLOR_RED,"/r>>The player is ignoring you.");
if(PlayerData[id][LastPMSentBy] == -1)
return SendClientMessage(playerid,COLOR_RED,"/r>>You've not recieved any recent private message to use quick reply.");
PlayerData[id][LastPMSentBy] = playerid;
format(msg,sizeof(msg),"PM from %s(%d):%s",PlayerData[playerid][Name],playerid,msg);
SendClientMessage(id,COLOR_YELLOW,msg);
SendClientMessage(id,COLOR_YELLOW,"/reply OR /r for quick reply");
format(msg,sizeof(msg),"PM to %s(%d):%s",PlayerData[id][Name],id,msg);
SendClientMessage(playerid,COLOR_YELLOW,msg);
return 1;
}
COMMAND:togglepm(playerid,params[])
{
switch((PlayerData[playerid][DoNotRecievePMs] = !PlayerData[playerid][DoNotRecievePMs]))
{
case true:
{
return SendClientMessage(playerid,COLOR_YELLOW,"You've has disabled private messages./togglepm to enable them.");
}
case false:
{
return SendClientMessage(playerid,COLOR_YELLOW,"You've has enabled private messages./togglepm to disable them.");
}
}
return 1;
}
COMMAND:ignore(playerid,params[])
{
new id,msg[98+MAX_PLAYER_NAME];
if(sscanf(params,"u",id))
{
return SendClientMessage(playerid,COLOR_GREY,"Usage>>/ignore [Name/ID]");
}
if(id == INVALID_PLAYER_ID)
return SendClientMessage(playerid,COLOR_RED,"/ignore:Invalid Player");
if(id == playerid)
return SendClientMessage(playerid,COLOR_RED,"/ignore:You cannot ignore yourself.");
switch(!!(PlayerData[playerid][IgnorePM][id>>5] ^= 1 << (id & 31)))
{
case true:
{
format(msg,sizeof(msg),"You are ignoring %s(%d)'s private messages./ignore [Name/ID] to stop ignoring.",PlayerData[id][Name],id);
return SendClientMessage(playerid,COLOR_YELLOW,msg);
}
case false:
{
format(msg,sizeof(msg),"You are stopped ignoring %s(%d)'s private messages./ignore [Name/ID] to ignore private messages.",PlayerData[id][Name],id);
return SendClientMessage(playerid,COLOR_YELLOW,msg);
}
}
return 1;
}
|
lol yeah!
The player has to be connected if he has to use the command. xD ![]() |
.CMD:pm(playerid, params[])
{
if(IsPlayerConnected(playerid)) // This line
|
No we were talking about IsPlayerConnected(playerid) at the beginning.If a player has to send a command he has to be connected.
Code:
CMD:pm(playerid, params[])
{
if(IsPlayerConnected(playerid)) // This line
|