zcmd /pm help -
ricardo178 - 12.03.2011
Hey people, i want a zcmd /pm cmd... It ryed to convert strcmp one to zcmd but jail....
I tryed this:
pawn Код:
COMMAND:pm(playerid, params[])
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp) || strlen(tmp) > 5) {
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /pm (id) (message)");
return 1;
}
new id = strval(tmp);
gMessage = strrest(cmdtext,idx);
if(!strlen(gMessage)) {
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /pm (id) (message)");
return 1;
}
if(!IsPlayerConnected(id)) {
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/pm : Bad player ID");
}
if(playerid != id) {
GetPlayerName(id,iName,sizeof(iName));
GetPlayerName(playerid,pName,sizeof(pName));
format(Message,sizeof(Message),">> %s(%d): %s",iName,id,gMessage);
SendClientMessage(playerid,PM_OUTGOING_COLOR,Message);
format(Message,sizeof(Message),"** %s(%d): %s",pName,playerid,gMessage);
SendClientMessage(id,PM_INCOMING_COLOR,Message);
PlayerPlaySound(id,1085,0.0,0.0,0.0);
printf("PM: %s",Message);
}
else {
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"You cannot PM yourself");
}
return 1;
}
Thanks
Re: zcmd /pm help -
xir - 12.03.2011
pawn Код:
COMMAND:pm(playerid, params[])
{
new str[128], str2[128], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
if(sscanf(params, "ds[128]", id, str2)) return SendClientMessage(playerid, ADMINFS_MESSAGE_COLOR, "Usage: /pm (id) (message)");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, ADMINFS_MESSAGE_COLOR, "/pm : Bad player ID");
if(playerid == id) return SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR, "You cannot PM yourself");
{
GetPlayerName(playerid, Name1, sizeof(Name1));
GetPlayerName(id, Name2, sizeof(Name2));
format(str, sizeof(str), ">> %s(%d): %s", Name2, id, str2);
SendClientMessage(playerid, PM_OUTGOING_COLOR, str);
format(str, sizeof(str), "** %s(%d): %s", Name1, playerid, str2);
SendClientMessage(id, PM_INCOMING_COLOR, str);
PlayerPlaySound(id,1085,0.0,0.0,0.0);
printf("PM: %s",str2);
}
return 1;
}
Try this with sscanf
Re: zcmd /pm help -
iMonk3y - 12.03.2011
Use sscanf.. it's simple and efficient
pawn Код:
CMD:pm(playerid, params[])
{
new targetid;
if(sscanf(params, "us[128]", targetid, str128)) return SendClientMessage(playerid, WHITE, "Use: /pm [player] [text]");
if(targetid != INVALID_PLAYER_ID)
{
if(targetid == playerid) SendClientMessage(playerid, LIME, "You cannot PM yourself.");
else CallLocalFunction("OnPlayerPrivmsg", "dds", playerid, targetid, str128);
}
else SendClientMessage(playerid, LIME, "Player is not connected.");
return 1;
}
pawn Код:
PUBLIC:OnPlayerPrivmsg(playerid, recieverid, text[])
{
format(str128, 128, "PM from %s(ID:%d): %s", PlayerName[playerid], playerid, text);
SendClientMessage(recieverid, YELLOW, str128);
format(str128, 128, "PM to %s(ID:%d): %s", PlayerName[recieverid], recieverid, text);
SendClientMessage(playerid, YELLOW, str128);
printf("[pm] %s PM'ed %s: %s", PlayerName[playerid], PlayerName[recieverid], text);
return 0;
}
Ops, too late ...
Re: zcmd /pm help -
Scrip - 12.03.2011
pawn Код:
COMMAND:pm(playerid, params[])
{
new playerid2;
new mes;
if(sscanf(params, "us", playerid2,mes)) return SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /pm (id) (message)");
if(!IsPlayerConnected(playerid2)) return SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/pm : Bad player ID");
if(playerid != playerid2) return SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"You cannot PM yourself");
GetPlayerName(playerid2,iName,sizeof(iName));
GetPlayerName(playerid,pName,sizeof(pName));
format(Message,sizeof(Message),">> %s(%d): %s",iName,playerid2,mes);
SendClientMessage(playerid,PM_OUTGOING_COLOR,Message);
format(Message,sizeof(Message),"** %s(%d): %s",pName,playerid,mes);
SendClientMessage(playerid2,PM_INCOMING_COLOR,Message);
PlayerPlaySound(playerid2,1085,0.0,0.0,0.0);
printf("PM: %s",Message);
return 1;
}
Re: zcmd /pm help -
ricardo178 - 12.03.2011
Thanks very much