Pm cmd help
#1

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.

pawn Код:
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;
}
Reply
#2

Here my pm code it shows whole message

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


PHP код:
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;

Reply
#3

Did you read sscanf plugin topic?
pawn Код:
if(sscanf(params, "us", id, str2))
After string specifier in statement you need to tell specifier what is the array size.
Reply
#4

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
Did you read sscanf plugin topic?
pawn Код:
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
Reply
#5

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.
Reply
#6

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
Did you read sscanf plugin topic?
pawn Код:
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.
Reply
#7

Lord ... i think sccanf2 and sccanf are interrelated .. cuz one shows its natives and other specifies it.
Reply
#8

try it this way:
pawn Код:
if(sscanf(params, "us[128]", id, str2))
change the 128 to whatever you want the size to be

EDIT: damn too late xD
Reply
#9

Already fixed by Riddick94, it's weird when an error can get you in troubles.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)