25.07.2014, 09:25
You're storing 4 values in one array... Technically that should work but have you tried storing them in seperate arrays?
new temp[4], hour, minute; TimestampToDate(pData[playerid][last_session], temp[0], temp[1], temp[2], hour, minute, temp[3], 1); printf("%02d:%02d", hour, minute);
new year, month, day, hour, minute, second;
TimestampToDate(timestamp, year, month, day, hour, minute, second, 0);
I have one small problem. I have this code:
pawn Код:
Is there any way to fix this? EDIT: by the way, timestamp is set to 1418418196. |
CMD:payrent(playerid, params[])
{
new id = PlayerInfo[playerid][HotelRoom];
if(!IsPlayerConnected(playerid)) return 1;
if(id == -1) return SendClientMessage(playerid, -1, "You don't own a hotel room.");
//new year, month, day, minute, hour, second;
new year, month, day, hour, minute, second;
new string[128];
if(HotelInfo[id][Paid] == true)
{
printf("id: %d | timestamp: %d", id, HotelInfo[id][PayDate]);
TimestampToDate(HotelInfo[id][PayDate], year, month, day, hour, minute, second, 2);
SendClientMessage(playerid, -1, "You have already paid the rent.");
format(string, sizeof(string), "Your rent will expire on %d.%d.%d %d:%d", day, month, year, minute, hour);
SendClientMessage(playerid, -1, string);
return 1;
}
// from now on this isn't so important I think
switch(HotelInfo[id][Level])
{
case 1:
{
PlayerMoney(playerid, -LEVEL_1_RENT);
}
case 2:
{
PlayerMoney(playerid, -LEVEL_2_RENT);
}
case 3:
{
PlayerMoney(playerid, -LEVEL_3_RENT);
}
}
HotelInfo[id][PayDate] = gettime() + RENT_DAYS * 86400;
HotelInfo[id][Paid] = true;
TimestampToDate(HotelInfo[id][PayDate], year, month, day, hour, minute, second, 2);
SendClientMessage(playerid, -1, "You have paid your rent.");
format(string, sizeof(string), "You rent will expire in %d days, which is on:", RENT_DAYS);
SendClientMessage(playerid, -1, string);
format(string, sizeof(string), "%d.%d.%d %d:%d", day, month, year, minute, hour);
SendClientMessage(playerid, -1, string);
return 1;
}
enum hInfo
{
Owner[MAX_PLAYER_NAME],
bool:Paid,
PayDate // timestamp is stored here
};
new HotelInfo[MAX_HOTEL_ROOMS][hInfo];
CMD:stamp(playerid)
{
new time = gettime() + 2629743;
printf("timestamp: %d", time);
new year, month, day, hour, minute, second;
TimestampToDate(time, year, month, day, hour, minute, second, 0);
return 1;
// Timestamp: 1420616454
}
new year,
month,
day,
hour,
minute,
second,
Timestamp = gettime();
printf("new");
TimestampToDate(Timestamp, year, month, day, hour, minute, second, 1);
printf("Date: %d/%d/%d %d:%d:%d", day, month, year, hour, minute, second);
printf("Date: %d/%d/%d %d:%d:%d", day, month, year, hour, minute, second);
printf("new");
COMMAND:test(playerid, params[])
{
new date[6],
string[144],
Timestamp = gettime();
TimestampToDate(Timestamp, date[0], date[1], date[2], date[3], date[4], date[5], 1);
format(string, sizeof(string), "Date: %d/%d/%d %d:%d:%d", date[0], date[1], date[2], date[3], date[4], date[5]);
return SendClientMessage(playerid, -1, string);
}
pawn Код:
|
if(DonateLevel[playerid] > 0) { new str[128]; dex[playerid] = DateToTimestamp("%d",DonateExpire[playerid]); // i want to format the // date to timestamp thing, but the stock is supporting only 1 string parameter if(DonateExpire[playerid] != 0) { if(gettime() < dex[playerid]) { switch(Sprache[playerid]) { case 0: format(str,sizeof(str),"DONOR: Spende Level %d bis: %s.",DonateLevel[playerid],DonateExpire[playerid]); case 1: format(str,sizeof(str),"DONOR: Donator Level %d until: %s.",DonateLevel[playerid],DonateExpire[playerid]); case 2: format(str,sizeof(str),"DONOR: Nivel de donante %d hasta: %s.",DonateLevel[playerid],DonateExpire[playerid]); } SendClientMessage(playerid,0x2641FEFF,str); SendLangMessage(playerid,_COLOR_WHITE,"DONOR: Schreibe /donorcmds um deine Commands zu sehen","Type /donorcmds to see your commands.","Escribe /donorcmds para ver tus comandos."); } else { switch(Sprache[playerid]) { case 0: format(str,sizeof(str),"DONOR: Dein Spende Level (%d) ist am %s abgelaufen.",DonateLevel[playerid],DonateExpire[playerid]); case 1: format(str,sizeof(str),"DONOR: Your Donator Level (%d) expired on %s.",DonateLevel[playerid],DonateExpire[playerid]); case 2:format(str,sizeof(str),"DONOR: Tu nivel de donante (%d) expirу el %s.",DonateLevel[playerid],DonateExpire[playerid]); } SendClientMessage(playerid,0x2641FEFF,str); DonateLevel[playerid] = 0; DonateExpire[playerid] = 0; } } else { switch(Sprache[playerid]) { case 0: format(str,sizeof(str),"DONOR: Spende Level: %d bis: Unbefristet",DonateLevel[playerid]); case 1: format(str,sizeof(str),"DONOR: Donator Level: %d until: Permanent",DonateLevel[playerid]); case 2: format(str,sizeof(str),"DONOR: Nivel de donante: %d hasta: Permanente",DonateLevel[playerid]); } SendClientMessage(playerid,0x2641FEFF,str); SendLangMessage(playerid,_COLOR_WHITE,"DONOR: Schreibe /donorcmds um deine Commands zu sehen","Type /donorcmds to see your commands.","Escribe /donorcmds para ver tus comandos."); } }
// Want to change the params.... stock DateToTimestamp(str[11]) // here want to change the params { new date[3]; // date[0] = day date[1] = month date[2] = year if(!sscanf(str,"p<"#SPLITTER">ddd",date[0],date[1],date[2])) { new total = 0, tmp = 0; total += date[0] * 86400; if(date[1] == 2 && date[0] < 29) tmp = ((date[2] - 1968) / 4 - 2); else tmp = ((date[2] - 1968) / 4 - 1); total += tmp * 31622400; total += (date[2] - 1970 - tmp) * 31536000; for(new i = 1; i < date[1]; i ++) total += MonthTimes1[i][0 + IsLeapYear(date[2])] * 86400; return total; } else return -1; }
I want to format the donate expire to Datetotimestamp but it supports only 1 string parmater.
how do i do this, help me thanks |
DateToTimestamp("26.03.2019");
Yeah. I think it's related to the month being December. It starts with month 1 and adds one for every full month if can substract from the timestamp, ending up in 13 where the max is 12. I will take a closer look later.
|
17:24:34] [debug] Run time error 4: "Array index out of bounds" [17:24:34] [debug] Accessing element at index 12 past array upper bound 11 [17:24:34] [debug] AMX backtrace: [17:24:34] [debug] #0 0000ab54 in TimestampToDate (Timestamp=1474, &year=@00076298 2015, &month=@00076294 12, &day=@00076290 2, &hour=@0007628c 16, &minute=@00076284 24, &second=@00076288 34, HourGMT=0, MinuteGMT=0) at C:\Users\Redirect Left\Desktop\Sumo\SC2\maps\include\datetime.inc:90 [17:24:34] [debug] #1 0003753c in public BanPlayerIRC (playerid=0, Reason[]=@00072748 "prior failed bans [Speed/Airbreak]", IRCName[]=@00072730 "Timid", bantime=1449073474) at C:\Users\Redirect Left\Desktop\Sumo\SC2\script\SumoCore2_upd3.inc:3731
TimestampToDate(bantime,year,month,day,hour,minute,second,0); format(string,sizeof(string),"Date of Unban: %d/%d/%d at %d:%d:%d (DD/MM/YY at HH:MM:SS UTC+1)",day,month,year,hour,minute,second);