PM Command.
#1

Hey guys

I made this /pm command from a tutorial but the problem is, players can only send a few words. What should I do to make the players able to send longer PMs?

Код:
CMD:pm(playerid, params[])
{
    new str[256], str2[256], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
    if(sscanf(params, "us", id, str2))
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Usage: /pm <id> <message>");
        return 1;
    }
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_YELLOW, "ERROR: Player not connected");
    if(playerid == id) return SendClientMessage(playerid, COLOR_YELLOW, "ERROR: You cannot pm yourself!");
    {
        GetPlayerName(playerid, Name1, sizeof(Name1));
        GetPlayerName(id, Name2, sizeof(Name2));
        format(str, sizeof(str), "(( PM To %s(ID %d): %s ))", Name2, id, str2);
        SendClientMessage(playerid, COLOR_YELLOW, str);
        format(str, sizeof(str), "(( PM From %s(ID %d): %s ))", Name1, playerid, str2);
        SendClientMessage(id, COLOR_YELLOW, str);
    }
    return 1;
}
Thanks for help.
Reply
#2

First of all, max client messages are 128 (or even 144 these days, if I may believe the wiki.. which I actually do). You are wasting your memory using 256 length strings.
Also, in sscanf you must define the string length like this: sscanf(params, "ds[50]", id, str2); -If the max length would be 50. Perhaps that might occur the problem. And aaaalsoo
pawn Код:
if(playerid == id) return SendClientMessage(playerid, COLOR_YELLOW, "ERROR: You cannot pm yourself!"); //That return
    { //And that...
You should really reconsider to just rebuild the whole command.
Reply
#3

I suck on scripting, but well. Can someone try to help me without recreating the command?
Reply
#4

if you suck ,then quit or start learning.

Код:
CMD:pm(playerid, params[])
{
    new str[256], str2[256], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
    if(sscanf(params, "us[256]", id, str2)) //increase the string size here on parameter "s" which is str2
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Usage: /pm <id> <message>");
        return 1;
    }
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_YELLOW, "ERROR: Player not connected");
    if(playerid == id) return SendClientMessage(playerid, COLOR_YELLOW, "ERROR: You cannot pm yourself!");
    {
        GetPlayerName(playerid, Name1, sizeof(Name1));
        GetPlayerName(id, Name2, sizeof(Name2));
        format(str, sizeof(str), "(( PM To %s(ID %d): %s ))", Name2, id, str2);
        SendClientMessage(playerid, COLOR_YELLOW, str);
        format(str, sizeof(str), "(( PM From %s(ID %d): %s ))", Name1, playerid, str2);
        SendClientMessage(id, COLOR_YELLOW, str);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)