Convert Timer [+REP] -
arlindi - 26.04.2015
PHP код:
function BanListCheck(playerid)
{
new count_rows, fields, bField[2][512], Days[4], sebStr[128]; eString[0] = EOS; cache_get_data(count_rows, fields, DB_Connect);
//--------------------------------------------------------------------------
if(count_rows)
{
Days[0] = cache_get_field_content_int(0, "BanExpire", DB_Connect);
//----------------------------------------------------------------------
cache_get_field_content(0, "Reason", bField[0]); cache_get_field_content(0, "Admin", bField[1]);
//----------------------------------------------------------------------
Days[1] = gettime(); Days[2] = Days[0] - Days[1]; Days[3] = floatround(((Days[2]/24)/60)/60);
//----------------------------------------------------------------------
if(Days[0] == -1)
{
for(new i = 0; i < 30; i++) SendClientMessage(playerid, ~1, " ");
SendClientMessage(playerid, COLOR_ABLUE, "==============(Ban Details)================");
format(eString, 512, "You have been Banned by {00A6FF}%s {D1D1D1}!", bField[1]);
SendClientMessage(playerid, COLOR_GREY2, eString);
format(eString, 512, "Reason: {00A6FF}%s", bField[0]);
SendClientMessage(playerid, COLOR_GREY2, eString);
SendClientMessage(playerid, COLOR_GREY2, "Press {FF0000}F8{D1D1D1} to make an Screenshot!");
format(eString, 512, "For UnBan, make a request {FF0000}"SERVER_SITE"{D1D1D1} with name {FF0000}%s {D1D1D1}and IP {00A6FF}%s {D1D1D1}!", PlayerName(playerid), GetPlayerIPEx(playerid));
SendClientMessage(playerid, COLOR_GREY2, eString);
SendClientMessage(playerid, COLOR_ABLUE, "========================================");
KickEx(playerid);
}
else if(gettime() >= Days[0])
{
format(sebStr, 128, "UPDATE `Bans` SET `BanExpire` = '0' WHERE `Name` = '%s'", PlayerName(playerid)),
mysql_tquery(DB_Connect, sebStr, "", "");
}
else if(Days[3] > 0)
{
for(new i = 0; i < 30; i++) SendClientMessage(playerid, ~1, " ");
SendClientMessage(playerid, COLOR_ABLUE, "==============(Ban Details)================");
format(eString, 512, "You have been Banned by {00A6FF}%s {D1D1D1}for {FF0000}%d {D1D1D1}Days!", bField[1], Days[3]);
SendClientMessage(playerid, COLOR_GREY2, eString);
format(eString, 512, "Reason: {00A6FF}%s", bField[0]);
SendClientMessage(playerid, COLOR_GREY2, eString);
SendClientMessage(playerid, COLOR_GREY2, "Press {FF0000}F8{D1D1D1} to make an Screenshot!");
format(eString, 512, "For UnBan, make a request {FF0000}"SERVER_SITE"{D1D1D1} with name {FF0000}%s {D1D1D1}and IP {00A6FF}%s {D1D1D1}!", PlayerName(playerid), GetPlayerIPEx(playerid));
SendClientMessage(playerid, COLOR_GREY2, eString);
SendClientMessage(playerid, COLOR_ABLUE, "========================================");
KickEx(playerid);
}
}
return 1;
}
CONVERT TIME
How to create for this to get the date and hour and minute of expiration DD/MM/YY H/M
Re: Convert Timer [+REP] -
arlindi - 26.04.2015
Hmmm............
Re: Convert Timer [+REP] -
Evocator - 26.04.2015
There are many ways to do this, i also suggest not sending the hours/mins because they usually differ to players. So sending DD/MM/YYYY is fine.
Код:
//Off the internet, no credits found
GetDateStamp(Time = 0, bool:IsUnixTime = true)
{
new hour, minute, sec;
gettime(hour,minute,sec);
new secs;
secs = Time;
if (IsUnixTime) secs -= gettime();
secs += sec;
new mins;
if (secs >= 60)
{
mins = secs / 60;
secs -= mins * 60;
}
mins += minute;
new hours;
if (mins >= 60)
{
hours = mins / 60;
mins -= hours * 60;
}
hours += hour;
new Days;
if (hours >= 24)
{
Days = hours / 24;
hours -= Days * 24;
}
new MonthDays[] = {31,28,31,30,31,30,31,31,30,31,30,31};
new Year;
new Month;
new Day;
getdate(Year,Month,Day);
if ((Year % 4 == 0) && (Year % 100 != 0) || (Year % 400 == 0)) MonthDays[1] = 29;
Days += Day;
new Months;
while (Days > MonthDays[Month - 1])
{
Days -= MonthDays[Month - 1];
Months++;
}
Months += Month;
new Years;
if (Months > 12)
{
Years = Months / 12;
Months -= Years * 12;
}
Years += Year;
new YearDay;
new YearDays[] = {0,31,59,90,120,151,181,212,243,273,304,334};
YearDay = Days + YearDays[Months - 1];
if (Months > 2 && (Year % 4 == 0) && (Year % 100 != 0) || (Year % 400 == 0)) YearDay++;
new string[64];
format(string,sizeof (string),"%i-%02i-%i",Days,Months,Years);
return string;
}
Re: Convert Timer [+REP] -
arlindi - 26.04.2015
Ok but i dont know how to use this in my server
Re: Convert Timer [+REP] -
Evocator - 27.04.2015
Save the ban time using gettime() and compare it when the player connects, if its greater or equal then hes still banned:
Код:
format (string, sizeof(string), "Ban expires on: ", GetDateStamp(time));
SendClientMessage(playerid, -1, string);
if its smaller, then you can remove the ban and allow them to play.
Re: Convert Timer [+REP] -
arlindi - 27.04.2015
Soo
will i get with this and minutes ? of time ?
Re: Convert Timer [+REP] -
Toxik - 27.04.2015
hm...... let me think what can u do
Re: Convert Timer [+REP] -
arlindi - 27.04.2015
Ok tell mee i want it also to get the time with minutes and hours
Also please add it to my first post and repost it
Thanks