PM Command for ZCMD -
Torran - 09.03.2010
Does anyone have a PM command for ZCMD,
I tried making one but i failed
Re: PM Command for ZCMD -
[SF]RobMob - 09.03.2010
here mine i coded for my gm your welcome to edit and use
COMMAND

m(playerid,params[])
{
new tmp[256];
new Message[256];
new gMessage[256];
new pName[MAX_PLAYER_NAME+1];
new iName[MAX_PLAYER_NAME+1];
new idx;
tmp = strtok(params,idx);
if(!strlen(tmp)) return SendClientMessage(playerid,0xFF0000FF,"USAGE: /PM (id) (message)");
new id = strval(tmp);
gMessage = strrest(params,idx);
if(!strlen(gMessage)) return SendClientMessage(playerid,0xFF0000FF,"Usage: /pm (id) (message)");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xFF0000FF,"/pm :Invalid ID");
GetPlayerName(id,iName,sizeof(iName));
GetPlayerName(playerid,pName,sizeof(pName));
format(Message,sizeof(Message),">> %s(%i): %s",iName,id,gMessage);
SendClientMessage(playerid,0xFFD720FF,Message);
format(Message,sizeof(Message),"** %s(%i): %s",pName,playerid,gMessage);
SendClientMessage(id,0xFFD720FF,Message);
new OwnerMessage[256];
format(OwnerMessage,sizeof(OwnerMessage),"[PM]: %s to %s, Message: %s",pName,iName,gMessage);
MessageToOwners(COLOR_GREY, OwnerMessage);
new File:ftw=fopen("logs/pms.txt", io_append);
new string1[256];
format(string1, 150, "%s\r\n", OwnerMessage);
fwrite(ftw, string1);
fclose(ftw);
PlayerPlaySound(id,1085,0.0,0.0,0.0);
return 1;
}
Re: PM Command for ZCMD -
Anwix - 10.03.2010
@[SF]robmob : You should use 128, instead of 256.
Here's a much cleaner version:
pawn Code:
COMMAND:pm(playerid, params[])
{
new string[128], name[MAX_PLAYER_NAME], tmp[128], index;
tmp = strtok(params, index);
new otherid = strval(tmp);
if (strlen(tmp) && strlen(params[2]))
{
if (IsPlayerConnected(otherid))
{
// Message to "otherid"
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "PM from %s: %s", name, params[2]);
SendClientMessage(otherid, YELLOW, string);
//Message to sender
GetPlayerName(otherid, name, sizeof(name));
format(string, sizeof(string), "PM to %s: %s", name, params[2]);
SendClientMessage(playerid, WHITE, string):
}
else
{
SendClientMessage(playerid, WHITE, "Invalid player id.");
}
}
else
{
SendClientMessage(playerid, WHITE, "USAGE: /pm [playerid] [message]");
}
return 1;
}
Untested.
Re: PM Command for ZCMD -
cessil - 10.03.2010
and if you use sscanf
Code:
COMMAND:pm(playerid, params[])
{
new message[128];
new id;
new rname[MAX_PLAYER_NAME+1];
new sname[MAX_PLAYER_NAME+1];
if(!sscanf(params,"us[sizeof(message)]",id,message))
{
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,RED,"invalid user");
GetPlayerName(id,rname,sizeof(rname));
GetPlayerName(playerid,sname,sizeof(sname));
if(playerid != id) {
format(message,sizeof(message),"PM Sent %s(%d): %s",rname,id,message);
SendClientMessage(playerid,PM_OUTGOING_COLOR,message);
format(message,sizeof(message),"PM From %s(%d): %s",sname,playerid,message);
SendClientMessage(id,PM_INCOMING_COLOR,message);
PlayerPlaySound(id,1085,0.0,0.0,0.0);
for(new ia = 0; ia < GetMaxPlayers(); ia++)
{
if (IsPlayerConnected(ia))
{
if (AccountInfo[ia][AdminLevel] > 0 && ViewCmds[ia] == 1 && playerid != ia && id != ia)
{
format(message, sizeof(message),"[VIEWCMDS] [%d]%s: /pm %s(%d) %s",playerid, sname,rname,id,message);
SendClientMessage(ia, PMSPY, message);
}
}
}
return 1;
}
else
{
SendClientMessage(playerid,RED,"You cannot PM yourself");
return 1;
}
}
if(sscanf(params,"us[sizeof(message)]",id,message))
{
return SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /pm (id) (message)");
}
return 1;
}
Re: PM Command for ZCMD -
Torran - 10.03.2010
Quote:
Originally Posted by Anwix
@[SF]robmob : You should use 128, instead of 256.
Here's a much cleaner version:
pawn Code:
COMMAND:pm(playerid, params[]) { new string[128], name[MAX_PLAYER_NAME], tmp[128], index; tmp = strtok(params, index); new otherid = strval(tmp); if (strlen(tmp) && strlen(params[2])) { if (IsPlayerConnected(otherid)) { // Message to "otherid" GetPlayerName(playerid, name, sizeof(name)); format(string, sizeof(string), "PM from %s: %s", name, params[2]); SendClientMessage(otherid, YELLOW, string); //Message to sender GetPlayerName(otherid, name, sizeof(name)); format(string, sizeof(string), "PM to %s: %s", name, params[2]); SendClientMessage(playerid, WHITE, string): } else { SendClientMessage(playerid, WHITE, "Invalid player id."); } } else { SendClientMessage(playerid, WHITE, "USAGE: /pm [playerid] [message]"); } return 1; }
Untested.
|
Do you think you could add a thing stopping the player from sending a PM to himself
Re: PM Command for ZCMD -
[SF]RobMob - 10.03.2010
Quote:
Originally Posted by Joe Torran C
Quote:
Originally Posted by Anwix
@[SF]robmob : You should use 128, instead of 256.
Here's a much cleaner version:
pawn Code:
COMMAND:pm(playerid, params[]) { new string[128], name[MAX_PLAYER_NAME], tmp[128], index; tmp = strtok(params, index); new otherid = strval(tmp); if (strlen(tmp) && strlen(params[2])) { if (IsPlayerConnected(otherid)) { // Message to "otherid" GetPlayerName(playerid, name, sizeof(name)); format(string, sizeof(string), "PM from %s: %s", name, params[2]); SendClientMessage(otherid, YELLOW, string); //Message to sender GetPlayerName(otherid, name, sizeof(name)); format(string, sizeof(string), "PM to %s: %s", name, params[2]); SendClientMessage(playerid, WHITE, string): } else { SendClientMessage(playerid, WHITE, "Invalid player id."); } } else { SendClientMessage(playerid, WHITE, "USAGE: /pm [playerid] [message]"); } return 1; }
Untested.
|
Do you think you could add a thing stopping the player from sending a PM to himself
|
well if your that board you half to pm yourself you got a problem
Re: PM Command for ZCMD -
Torran - 10.03.2010
Dude read my other topic, This ones closed,
Ive made my own from scratch now..
Re: PM Command for ZCMD -
Anwix - 10.03.2010
Quote:
Originally Posted by Joe Torran C
Do you think you could add a thing stopping the player from sending a PM to himself
|
pawn Code:
COMMAND:pm(playerid, params[])
{
new string[128], name[MAX_PLAYER_NAME], tmp[128], index;
tmp = strtok(params, index);
new otherid = strval(tmp);
if (strlen(tmp) && strlen(params[2]))
{
if (IsPlayerConnected(otherid))
{
if (playerid != otherid)
{
// Message to "otherid"
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "PM from %s: %s", name, params[2]);
SendClientMessage(otherid, YELLOW, string);
//Message to sender
GetPlayerName(otherid, name, sizeof(name));
format(string, sizeof(string), "PM to %s: %s", name, params[2]);
SendClientMessage(playerid, WHITE, string);
}
else
{
SendClientMessage(playerid, RED, "You cannot sent a PM to yourself.");
}
}
else
{
SendClientMessage(playerid, WHITE, "Invalid player id.");
}
}
else
{
SendClientMessage(playerid, WHITE, "USAGE: /pm [playerid] [message]");
}
return 1;
}
Should work.