Weird !pm bug?
#1

Hey

I have this problem that I have been ignoring in the script for now months, and I'm still puzzled about why it's happening.

So basically what's troubling me is that no matter which !pm command I use for IRC, it doesn't work. I've tried my own IRC personal message scripts, those that were working on a different gamemode, and I've also tried like 5 others scripts from the forums. None seem to work.


Actual problem:

The command itself does execute and sends, but it's pretty much limited to like 20-25 characters.
Example
When doing: !pm 0 This is a test to see if the personal message command is working.
Result ingame for id 0: PM From Roperr (IRC): This is a test to see if

The message cuts down at approximately that much of text.

Warnings
Yes my strings are properly defined.
Yes I've tried other commands.
My !msg command is fully working, seems like it cuts off when using a playerid parameter or something?

Code
pawn Код:
IRCCMD:pm(botid, channel[], user[], host[], params[])
{
    if(IRC_IsVoice(botid, channel, user))
    {
        new ID;
        new pname[24];
        new message[128];
        new string[400];

        if(sscanf(params,"ds",ID,message)) return IRC_GroupSay(gGroupID, IRC_CHANNEL, "Usage: !pm <ID> <message>");

        GetPlayerName(ID, pname, 24);

        if(!IsPlayerConnected(ID))
        {
            IRC_GroupSay(gGroupID, IRC_CHANNEL, "Invalid Player ID.");
            return 1;
        }
        format(string, sizeof(string), "%s, IRCPM sent.", user);
        IRC_GroupSay(gGroupID, channel,string);
        format(string, sizeof(string), "[IRC] From User %s: %s", user, message);
        SendClientMessage(ID, COLOR_BLUE, string);
        return 1;
    }
    return 1;
}
Help me solve this silly thing
Reply
#2

Change your message-string for the PM to 128 or 256!

If this didn't work, try it like 'dis:

pawn Код:
new ID, pname[24], message[128], mstring[256];
Reply
#3

I've unfortunately already tried that. No matter what the string size would be, it still fails to send a whole message.
Reply
#4

i have similar command in my gamemode, try this:
pawn Код:
if(sscanf(params,"ds[128]",ID,message))
Reply
#5

I'm giving you mine, just try to combine it with your IRC:

pawn Код:
COMMAND:pm(playerid,params[])
{
        new pid;
        new message[100];
        if(sscanf(params, "us[32]", pid, message))
        {
            return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /pm <playerid> <message>");
        }
         if(!IsPlayerConnected(pid))
                return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected!");
        new pmsg[256];
        new pname[MAX_PLAYER_NAME];
        GetPlayerName(playerid,pname,sizeof(pname));
        format(pmsg,sizeof(pmsg),"PM from %s(%d): %s",pname,playerid,message);
        new pidmsg[256];
        new pidname[MAX_PLAYER_NAME];
        GetPlayerName(pid,pidname,sizeof(pidname));
        format(pidmsg,sizeof(pidmsg),"PM to %s(%d): %s",pidname,pid,message);
        SendClientMessage(pid, COLOR_ORANGE, pmsg);
        PlayerPlaySound(pid,1057,0.0,0.0,0.0);
        SendClientMessage(playerid, COLOR_ORANGE, pidmsg);
       
    return 1;
}
Reply
#6

It should be
pawn Код:
new message [ 128 ];
if( sscanf( params, "rs[128]", ID, message ) ) //continue..
Reply
#7

Quote:
Originally Posted by Dwane
Посмотреть сообщение
It should be
pawn Код:
new message [ 128 ];
if( sscanf( params, "rs[128]", ID, message ) ) //continue..
I can't yet try it out, but seems like that would be the fix to it.

I'm just wondering why the same doesn't happen for !msg, oh well.
Reply
#8

If you declare after the "s" specifier the value the array has, then the command should work.
Also, for Players/Bots the specifier is "u" and for only Players "r". The "d" or "i" is for numbers
Reply
#9

Thank you, I knew about declaring the value while getting parameters but I never used it because it was pointless to me that I would note down the array size once again.
I've ignored this mostly because it worked and I never had to use it.

Thank you, +rep
Reply
#10

Quote:
Originally Posted by Dwane
Посмотреть сообщение
If you declare after the "s" specifier the value the array has, then the command should work.
Also, for Players/Bots the specifier is "u" and for only Players "r". The "d" or "i" is for numbers
Sorry for double post.

Using the specifier "u" when I updated to 0.3d kept returning me id 0 and the command wouldn't work. It's because 0.3d had some changes for sscanf, so I've changed every "u" specifier to "d", which now works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)