Pm command -
Goldino - 18.11.2012
Hey guys,
I'm looking for a pm command for my SA-MP script. I've looked everywhere, but I can't find it. I hope you guys could help me. I want it written in PWN language.
Re: Pm command -
RanSEE - 18.11.2012
This question should be in script request thread anyway.
pawn Код:
new lastpm[MAX_PLAYERS][128];
CMD:pm(playerid, params[]) {
new id, message[1024];
if(sscanf(params,"ds[1024]",id,message))return SendClientMessage(playerid, COLOR_RED, "USAGE: /pm <playerid> <message>");
if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected.");
if(playerid != id) {
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
new ReturnName[MAX_PLAYER_NAME];
GetPlayerName(id, ReturnName, sizeof(ReturnName));
format(szString,sizeof(szString), ">> PM To %s (ID:%d): %s", ReturnName, id, message);
SendClientMessage(playerid, 0xFFCC2299, szString);
format(szString,sizeof(szString),"<< PM From %s (ID:%d): %s",PlayerName, playerid, message);
SendClientMessage(id, 0xFFFF22AA, szString);
PlayerPlaySound(id, 1085, 0.0, 0.0, 0.0);
format(szString, sizeof(szString), "5*** [PM] From %s (ID:%d) To %s (ID:%d): %s",PlayerName,playerid,ReturnName,id,message);
IRC_GroupSay(gGroupID, IRC_CHANNEL2, szString);
lastpm[playerid] = message;
}
else {
SendClientMessage(playerid, COLOR_RED, "ERROR: You cannot PM yourself");
}
return 1;
}
Thats just what i use
Re: Pm command -
[HK]Ryder[AN] - 18.11.2012
Everything of samp is in pwn, except plugins.
can you tell me which cmd processor u r using and also if u r using sscanf
Re: Pm command -
[KHK]Khalid - 18.11.2012
I'm wondering what's your method of searching?!
https://sampforum.blast.hk/showthread.php?tid=300182
https://sampforum.blast.hk/showthread.php?tid=164500
https://sampforum.blast.hk/showthread.php?tid=324192
https://sampforum.blast.hk/showthread.php?tid=106888
Wiki - /pm - Strcmp
Re: Pm command -
Goldino - 18.11.2012
But where do I paste it?
Re: Pm command -
XtremeR - 18.11.2012
in ur server, if ur using ZCMD then any where in middle.. learn scripting first..
Re: Pm command -
Goldino - 18.11.2012
Well I don't use any of ZCMD, sscanf, MySQL.
Can you add the command without any of those stuff? cos I dont have them
Re: Pm command -
Konstantinos - 18.11.2012
Quote:
Originally Posted by HellSphinX
|
^^, lol
I'll agree, only few people search before post something on this forum. ****** has everything!
By the way, for the thousandth time. The language is called Pawn, not pwn.
Re: Pm command -
2KY - 18.11.2012
Quote:
Originally Posted by RanSEE
This question should be in script request thread anyway.
pawn Код:
new lastpm[MAX_PLAYERS][128]; CMD:pm(playerid, params[]) { new id, message[1024]; if(sscanf(params,"ds[1024]",id,message))return SendClientMessage(playerid, COLOR_RED, "USAGE: /pm <playerid> <message>"); if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected."); if(playerid != id) { new PlayerName[MAX_PLAYER_NAME]; GetPlayerName(playerid, PlayerName, sizeof(PlayerName)); new ReturnName[MAX_PLAYER_NAME]; GetPlayerName(id, ReturnName, sizeof(ReturnName)); format(szString,sizeof(szString), ">> PM To %s (ID:%d): %s", ReturnName, id, message); SendClientMessage(playerid, 0xFFCC2299, szString); format(szString,sizeof(szString),"<< PM From %s (ID:%d): %s",PlayerName, playerid, message); SendClientMessage(id, 0xFFFF22AA, szString); PlayerPlaySound(id, 1085, 0.0, 0.0, 0.0); format(szString, sizeof(szString), "5*** [PM] From %s (ID:%d) To %s (ID:%d): %s",PlayerName,playerid,ReturnName,id,message); IRC_GroupSay(gGroupID, IRC_CHANNEL2, szString); lastpm[playerid] = message; } else { SendClientMessage(playerid, COLOR_RED, "ERROR: You cannot PM yourself"); } return 1; }
Thats just what i use
|
Holy mother of fuck. 1024 cells for a string that can only be 128?! You're nuts!
Re: Pm command -
[KHK]Khalid - 18.11.2012
Quote:
Originally Posted by Goldino
Well I don't use any of ZCMD, sscanf, MySQL.
Can you add the command without any of those stuff? cos I dont have them
|
Well, I've already given you one which is done using Strcmp. Here it is:
pawn Код:
if(!strcmp("/pm", cmdtext, true))
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid,0xFF0000FF,"USAGE: /PM (id) (message)");
new id = strval(tmp);
gMessage = strrest(cmdtext,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);
PlayerPlaySound(id,1085,0.0,0.0,0.0);
return 1;
}
Also you will need these functions:
https://sampwiki.blast.hk/wiki/Strtok
https://sampwiki.blast.hk/wiki/Functiontrrest
Read this article about creating commands, I'm sure it's going to help you:
https://sampwiki.blast.hk/wiki/Creating_Commands