05.04.2012, 00:38
So for example I have 2 people in game:
John (ID 0)
Kyle (ID 1)
And I'm John. I want to /pm Kyle so I have to type this in: /pm 1 my message to kyle
how can I make it so when I type it in, I can just type in /pm kyle instead of /pm 1 ? Because when I type in /pm kyle my message , in game, it automatically sends a pm to ID 0 because I didn't put the ID in. I want it to be both ways so I can /pm kyle and /pm 1
Here is my code:
John (ID 0)
Kyle (ID 1)
And I'm John. I want to /pm Kyle so I have to type this in: /pm 1 my message to kyle
how can I make it so when I type it in, I can just type in /pm kyle instead of /pm 1 ? Because when I type in /pm kyle my message , in game, it automatically sends a pm to ID 0 because I didn't put the ID in. I want it to be both ways so I can /pm kyle and /pm 1
Here is my code:
Код:
#include <a_samp>
#include "../include/gl_common.inc"
#define COLOR_YELLOW 0xFFFF00AA
//------------------------------------------------
public OnFilterScriptInit()
{
print("Private Message Script Loaded");
return 1;
}
//------------------------------------------------
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new tmp[256];
new Message[256];
new gMessage[256];
new pName[MAX_PLAYER_NAME+1];
new iName[MAX_PLAYER_NAME+1];
new idx;
cmd = strtok(cmdtext, idx);
// PM Command
if(strcmp("/pm", cmd, true) == 0)
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp) || strlen(tmp) > 5) {
SendClientMessage(playerid,COLOR_YELLOW,"Usage: /pm (ID) (message)");
return 1;
}
new id = strval(tmp);
gMessage = strrest(cmdtext,idx);
if(!strlen(gMessage)) {
SendClientMessage(playerid,COLOR_YELLOW,"Usage: /pm (ID) (message)");
return 1;
}
if(!IsPlayerConnected(id)) {
SendClientMessage(playerid,COLOR_YELLOW,"/pm : You Entered a Wrong ID!");
return 1;
}
if(playerid != id) {
GetPlayerName(id,iName,sizeof(iName));
GetPlayerName(playerid,pName,sizeof(pName));
format(Message,sizeof(Message),"PM Sent to %s(%d): %s",iName,id,gMessage);
SendClientMessage(playerid,COLOR_YELLOW,Message);
format(Message,sizeof(Message),"PM From %s(%d): %s",pName,playerid,gMessage);
SendClientMessage(id,COLOR_YELLOW,Message);
PlayerPlaySound(id,1085,0.0,0.0,0.0);
printf("PM: %s",Message);
}
else {
SendClientMessage(playerid,COLOR_YELLOW,"You Cannot Private Message Yourself.");
}
return 1;
}
return 0;
}

