Problem with Date
#1

Hello, Im trying to make something in my command that saves the date at the PMLog together with the message

pawn Код:
command(pm, playerid, params[])
{
    new string[128],string1[128],string2[128],string3[128], message[128], id;
    new Year, Month, Day, Date[128];
    new Year1, Month1, Day1, Date1[128];
    if(sscanf(params, "uz", id, message))
    {
        SendClientMessage(playerid, WHITE, "SYNTAX: /pm [playerid] [message]");
    }
    else
    {
        if(IsPlayerConnectedEx(id))
        {
            if(strlen(message) >= 1)
            {
                if(Player[id][PMsEnabled] == 1)
                {
                    getdate(Year, Month, Day);
                    format(string1, sizeof(string1), "[%02d/%02d/%d] ", Day, Month, Year);
                    format(string, sizeof(string), "((PM to %s(ID: %d): %s)) ", GetName(id), id, message);
                    SendClientMessage(playerid, YELLOW, string);
                    Date[128] = strcat(string1, string);
                    PMsLog(Date);
                   
                    getdate(Year1, Month1, Day1);
                    format(string2, sizeof(string2), "[%02d/%02d/%d] ", Day, Month, Year);
                    format(string3, sizeof(string3), "((PM to %s(ID: %d): %s)) ", GetName(playerid), playerid, message);
                    SendClientMessage(id, YELLOW, string);
                    Date1[128] = strcat(string2, string3);
                    PMsLog(Date1);
                }
                else
                {
                    SendClientMessage(playerid, WHITE, "That player has disabled PMs!");
                }
            }
            else
            {
                SendClientMessage(playerid, WHITE, "SYNTAX: /pm [playerid] [message]");
            }
        }
        else
        {
            SendClientMessage(playerid, WHITE, "That player is not connected or isn't logged in.");
        }
    }
    return 1;
}
Код:
C:\Users\Stefan Dorst\Desktop\Scratch RolePlay\gamemodes\RP.pwn(979) : error 032: array index out of bounds (variable "Date")
C:\Users\Stefan Dorst\Desktop\Scratch RolePlay\gamemodes\RP.pwn(986) : error 032: array index out of bounds (variable "Date1")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#2

you have to format Date1(like string1, etc), not set the value like you would for variables.
pawn Код:
format(Date, sizeof(Date), "%s", strcat(string, string1););
pawn Код:
format(Date1, sizeof(Date1), "%s", strcat(string2, string3););
Reply
#3

Try this:
pawn Код:
command(pm, playerid, params[])
{
    new id, message[128];
    if(sscanf(params, "us", id, message)) return SendClientMessage(playerid, WHITE, "SYNTAX: /pm [playerid] [message]");
    if(!IsPlayerConnectedEx(id)) return SendClientMessage(playerid, WHITE, "That player is not connected or isn't logged in.");
    if(Player[id][PMsEnabled] == 0) return SendClientMessage(playerid, WHITE, "That player has disabled PMs!");
    new Year, Month, Day;
    getdate(Year, Month, Day);
    format(string, sizeof(string), "[%02d/%02d/%d] ((PM From %s (ID: %d) To: %s (ID: %d) | %s))", Day, Month, Year, GetName(playerid), playerid, GetName(id), id, message);
    PMsLog(string);
    format(string, sizeof(string), "((PM to %s(ID: %d): %s)) ", GetName(id), id, message);
    SendClientMessage(playerid, YELLOW, string);
    format(string, sizeof(string), "((PM from %s(ID: %d): %s)) ", GetName(playerid), playerid, message);
    SendClientMessage(id, YELLOW, string1);
    return 1;
}
EDIT: 800th Post
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)