23.03.2015, 21:51
Just an useful function i had to do today for converting time(in seconds) to date using mysql and unix timestamp, this function iscompatible with BlueG's MySQL plugin R33+:
Example of usage:
PS: you can change the result and add hours, minutes, seconds only by changing the formats and delimiters of the query.
Код:
GetDateFromTime(time, string[32])
{
new query[128];
format(query, 128, "SELECT FROM_UNIXTIME(%d,%s)", timestamp, "'%d/%m/%Y'");
new Cache:result = mysql_query(MySQL, query, true);
cache_get_row(0, 0, string);
return cache_delete(result);
}
Код:
public OnPlayerConnect(playerid)
{
//PlayerInfo[playerid][bantime] holds the time of the player unban date
if(PlayerInfo[playerid][bantime] > gettime())
{
//PlayerInfo[playerid][bantime] has the value of 1429733277 seconds (22/04/2015)
new string[32], msg[128];
GetDateFromTime(PlayerInfo[playerid][bantime], string);
format(msg, 128, "{FF0000}You still banned on this server, your unban date is was set to %s, please come back after this day!", string);
SendClientMessage(playerid, -1, msg);
Kick(playerid);
}
}

