Major PM truncation
#1

My code:

pawn Код:
CMD:pm(playerid, params[])
{
    new str[144];
    new str2[144];
    new id;
    if(sscanf(params, "us", id, str2)) return SendClientMessage(playerid, COLOR_RED, "Syntax: /pm [name/playerid] [message]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "Error: Invalid ID/player name.");
    {

        format(str, sizeof(str), "%s(ID %d): %s", GetName(id), id, str2);
        SendClientMessage(playerid, COLOR_YELLOW, str);
        format(str, sizeof(str), "%s(ID %d): %s", GetName(playerid), playerid, str2);
        SendClientMessage(id, COLOR_ORANGE, str);
    }
    return 1;
}
To me, the script looks fine but it majorly truncates. Here is an example:



(NOTE: This happens to some other commands too, but any help I receive with this, I can apply to the other commands. )

Thanks in advance.
Reply
#2

You should have warnings in your console/server log from sscanf about "destination size". If no size is supplied sscanf will truncate data, likely at a cap of 32 characters.
Reply
#3

Thanks, fixed. Rep will be given.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)