14.02.2017, 18:02
hey guys i have this ban command everything is ok but if i ban someone for 90 days in DB says he will get unban on 76/03/2017 ... instead of calculating 90 days from 14/02/2017 any idea why :-s ? i searched and didn't find a problem
Command
Callback
check only the "if(days >= 1)" cause if(days == 0)" is permanently so i don't need to get a date on that
Command
Код HTML:
CMD:ban(playerid, params[])
{
new nume[24], giveplayerid, splayer[25], reason[64], days;
if(gLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_ERROR, "Tu nu esti logat si nu poti sa folosesti aceasta comanda!");
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_ERROR, "Nu ai gradul necesar ca sa folosesti aceasta comanda!");
if(sscanf(params,"s[25]is[64]",splayer,days,reason)) return SendClientMessage(playerid, COLOR_SYN, "Sintaxa:{FFFFFF} /ban <Player ID/Name> <days> <reason>");
{
GetPlayerName(playerid, nume, sizeof(nume));
if(GetPlayers(splayer) == INVALID_PLAYER_ID) return InvalidPlayer(playerid);
else if(GetPlayers(splayer) == 1000) return ToManyResults(playerid);
else if(GetPlayers(splayer) == 1001) return ShowResults(playerid, splayer);
else giveplayerid = GetPlayers(splayer);
if(IsManager(giveplayerid)) return SendClientMessage(playerid, COLOR_ERROR, "Tu nu ai acest privilegiu!");
if(days == 0) GivePlayerSanction(playerid, GetSQLID(giveplayerid), "Ban permanent", reason);
if(days > 0) GivePlayerSanction(playerid, GetSQLID(giveplayerid), "Ban temporar", reason);
AddBan(playerid,giveplayerid,days,reason,0);
ClearJob(giveplayerid);
ClearPizzaJob(giveplayerid);
}
return 1;
}
Код HTML:
function AddBan(playerid,targetid,days,reason[],ipban)
{
new nyear, nmonth, nday;
new year, month, day, hour, mins, sec, playerip[16];
if(days < 0) return 1;
if(days == 0)
{//perm
getdate(year, month, day);
gettime(hour, mins, sec);
GetPlayerIp(targetid,playerip,sizeof(playerip));
gQuery[0] = (EOS);
mysql_format(handle, gQuery, sizeof(gQuery) ,"INSERT INTO `bans` (`Name`,`IP`,`Admin`,`Reason`,`BanY`,`BanM`,`BanD`,`BanH`,`UnbanY`,`UnbanM`,`UnbanD`,`UnbanH`,`Days`) VALUES ('%e','%e','%e','%e',%d,%d,%d,%d,%d,%d,%d,%d,%d)",
GetName(targetid),
playerip,
GetName(playerid),
reason,
year,
month,
day,
hour,
nyear,
nmonth,
nday,
hour,
days);
mysql_query(handle ,gQuery);
format(gString, sizeof(gString), "(Td) %s a primit ban de la administratorul %s, motiv: %s.", GetName(targetid), GetName(playerid), reason);
SendClientMessageToAll(COLOR_LIGHTRED, gString);
if(ipban) Ban(targetid);
else Kick(targetid);
// Feed
new feed[128];
format(feed, sizeof(feed), "~%d~ was banned by admin ~%d~, reason: %s", GetSQLID(targetid), GetSQLID(playerid), reason);
mysql_format(handle, gQuery, sizeof(gQuery), "INSERT INTO `feed` (`text`,`time`) VALUES ('%e','%e')", feed, GetDate());
mysql_tquery(handle, gQuery, "", "");
//
}
if(days >= 1)
{//Temp
getdate(year, month, day);
gettime(hour, mins, sec);
CalcDate(nyear, nmonth, nday, days);
//
GetPlayerIp(targetid,playerip,sizeof(playerip));
gQuery[0] = (EOS);
mysql_format(handle, gQuery, sizeof(gQuery) ,"INSERT INTO `bans` (`Name`,`IP`,`Admin`,`Reason`,`BanY`,`BanM`,`BanD`,`BanH`,`UnbanY`,`UnbanM`,`UnbanD`,`UnbanH`,`Days`) VALUES ('%e','%e','%e','%e',%d,%d,%d,%d,%d,%d,%d,%d,%d)",
GetName(targetid),
playerip,
GetName(playerid),
reason,
year,
month,
day,
hour,
nyear,
nmonth,
nday,
hour,
days);
mysql_query(handle ,gQuery);
format(gString, sizeof(gString), "(TP) %s a primit ban de la administratorul %s pentru %d zile, motiv: %s.",GetName(targetid), GetName(playerid), days, reason);
SendClientMessageToAll(COLOR_LIGHTRED, gString);
Kick(targetid);
// Feed
new feed[128];
format(feed, sizeof(feed), "~%d~ was banned by admin ~%d~ for %d days, reason: %s", GetSQLID(targetid), GetSQLID(playerid), days, reason);
mysql_format(handle, gQuery, sizeof(gQuery), "INSERT INTO `feed` (`text`,`time`) VALUES ('%e','%e')", feed, GetDate());
mysql_tquery(handle, gQuery, "", "");
//
}
return 1;
}