PDA

View Full Version : Pm cmd help


Face9000
25/10/2012, 10:30 AM
Hello, i have this /pm command, it works perfectly but there is a problem.

It doesnt show the FULL pm message, i tried increasing string cells size but nothing.

CMD:pm(playerid, params[])
{
new str[300], str2[300], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
new strr[300];
if(sscanf(params, "us", id, str2))
{
SendClientMessage(playerid, -1, "{F70505}Usage: {FFFFFF}/pm <id> <message>");
return 1;
}
new Year, Month, Day, Hour, Minute, Second;
getdate(Year, Month, Day);
gettime(Hour, Minute, Second);
if(PlayerInfo[playerid][pMuted] == 1) return SendClientMessage(playerid,0xFF0000FF,"You are muted, you can't use this command.");
if(PlayerInfo[id][pNopm] == 1) return SendClientMessage(playerid,0xFF0000FF,"This player has /nopm enabled, you can't send him a pm.");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: Player not connected");
if(playerid == id) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot pm yourself!");
if(strlen(params) > 300) return SendClientMessage(playerid,0xFF0000FF, "Your message is too long, reduce it. (Max 128 characters)");
if(GetPVarInt(playerid,"PmTime")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"Please wait before sending a pm again.");
GetPlayerName(playerid, Name1, sizeof(Name1));
GetPlayerName(id, Name2, sizeof(Name2));
format(str, sizeof(str), "{F70505}PM SENT TO: {FFFFFF}%s (%d): %s", Name2, id, str2);
SendClientMessage(playerid, -1, str);
format(str, sizeof(str), "{F70505}PM FROM: {FFFFFF}%s (%d): %s", Name1, playerid, str2);
SendClientMessage(id, -1, strr);
new log[300];
new am[300];
format(log, sizeof(log), "PM from %s (%d) to %s (%d): %s - %02d/%02d/%d - %02d:%02d:%02d",Name1,playerid, Name2, id,str2,Day,Month,Year,Hour,Minute,Second);
format(am, sizeof(am), "PM from %s (%d) to %s (%d): %s",Name1,playerid, Name2, id,str2);
PmLog(log);
SendMessageToAdmins(COLOR_YELLOW,am);

new imsg[300];
format(imsg, sizeof(imsg), "10*PM from %s (%d) to %s (%d): %s", Name1,playerid, Name2, id,str2);
IRC_GroupSay(gGroupID, IRC_CHANNEL, imsg);
IRC_GroupSay(gGroupID, IRC_ACHANNEL, imsg);

SetPVarInt(playerid,"PmTime",GetTickCount()+5000);
return 1;
}

-=Dar[K]Lord=-
25/10/2012, 10:36 AM
Here my pm code it shows whole message

I recommend u instead of putting str2 and all put params[]



CMD:pm(playerid,params[])
{
new player = strval(params);
new text = params[1];
if(sscanf(params,"uc",player,text))return SendClientMessage(playerid,Red,"[Usage]: /pm [playerid] [ Message]");
if(!IsPlayerConnected(player))return SendClientMessage(playerid,Red,"[ERROR]:Player Not Connected");
new string[256];
format(string,sizeof(string),"PM To %s(%d): %s",Playername(player),player,params[1]);
SendClientMessage(playerid,Yellow,string);
format(string,sizeof(string),"PM From %s(%d): %s",Playername(playerid),playerid,params[1]);
SendClientMessage(player,Yellow,string);
return 1;
}

Riddick94
25/10/2012, 10:38 AM
Did you read sscanf plugin topic?
if(sscanf(params, "us", id, str2))
After string specifier in statement you need to tell specifier what is the array size.

-=Dar[K]Lord=-
25/10/2012, 10:39 AM
Did you read sscanf plugin topic?
if(sscanf(params, "us", id, str2))
After string specifier in statement you need to tell specifier what is the array size.
yea otherwise it will show only the first word of ur message

Lordzy
25/10/2012, 10:44 AM
A normal client message's length is 128. There's no way of changing it to 300.
Btw, try executing the PM command with sscanf2.
That might do well.

Face9000
25/10/2012, 10:44 AM
Did you read sscanf plugin topic?
if(sscanf(params, "us", id, str2))
After string specifier in statement you need to tell specifier what is the array size.

Ah, my bad. Thanks.

-=Dar[K]Lord=-
25/10/2012, 10:44 AM
Lord ... i think sccanf2 and sccanf are interrelated .. cuz one shows its natives and other specifies it.

niels44
25/10/2012, 10:45 AM
try it this way:
if(sscanf(params, "us[128]", id, str2))

change the 128 to whatever you want the size to be

EDIT: damn too late xD

Face9000
25/10/2012, 10:47 AM
Already fixed by Riddick94, it's weird when an error can get you in troubles.