SA-MP Forums Archive
Pm cmd help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Pm cmd help (/showthread.php?tid=387537)



Pm cmd help - Face9000 - 25.10.2012

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;
}



Re: Pm cmd help - -=Dar[K]Lord=- - 25.10.2012

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;




Re: Pm cmd help - Riddick94 - 25.10.2012

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.


Re: Pm cmd help - -=Dar[K]Lord=- - 25.10.2012

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


Re: Pm cmd help - Lordzy - 25.10.2012

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.


Re: Pm cmd help - Face9000 - 25.10.2012

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.


Re: Pm cmd help - -=Dar[K]Lord=- - 25.10.2012

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


Re: Pm cmd help - niels44 - 25.10.2012

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


Re: Pm cmd help - Face9000 - 25.10.2012

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