ban with amount of days -
Geeboi_Mehdi - 10.06.2013
i have a ban system but it bans perm for every thing should i replace it with day one that has perm and days or what?
here is the cmd i am using now
pawn Код:
if(strcmp(cmd, "/ban", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_SECURITY, "Syntax: /ban (id/name) (reason)");
return 1;
}
new giveplayerid;
giveplayerid = ReturnUser(tmp);
if(IsPlayerNPC(giveplayerid)) return 1;
if(PInfo[playerid][AdminLevel] >= 1)
{
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[156];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_SECURITY, "Syntax: /ban (id/name) (reason)");
return 1;
}
PlaySound(0);
PlayerPlaySound(giveplayerid, 1190, 0, 0, 0); //Send a slap sound to the victim for lulz.
new date,month,year;
getdate(date,month,year);
new hour,minute,second;
gettime(hour,minute,second);
format(string, sizeof(string), "{FFFFFF}Administrator {FF9900}%s(%d){FFFFFF}Permanently Banned banned {FF9900}%s(%d){FFFFFF} • {FF9900}[Reason: %s]", PlayerName(playerid), playerid, PlayerName(giveplayerid), giveplayerid, (result));
SendClientMessageToAll(COLOR_WHITE, string);
PInfo[giveplayerid][Banned] = 1;
GettingBanned[giveplayerid] = 1;
new Name[MAX_PLAYER_NAME];
new plrIP[25];
new query[256];
//new date2[128];
//format(date2, sizeof(date2), "%d/%d/%d", year,month,date);
GetPlayerName(giveplayerid,Name,sizeof(Name));
GetPlayerName(playerid,sendername,sizeof(sendername));
GetPlayerIp(giveplayerid, plrIP, sizeof(plrIP));
mysql_real_escape_string(Name,Name);
mysql_real_escape_string((result),(result));
mysql_real_escape_string(sendername,sendername);
mysql_real_escape_string(plrIP,plrIP);
format(query,sizeof(query),"INSERT INTO `bans` (Username, Reason, Administrator, IP, Date, Time) VALUES ('%s','%s','%s','%s','%d/%d/%d','%d:%d:%d')",Name,(result),sendername,plrIP,year,month,date,hour,minute,second);
mysql_reconnect();
mysql_query(query);
AdminLog(playerid, "/ban", (result), Name);
Kick(giveplayerid);
return 1;
}
}
else
{
format(string, sizeof(string), "Could not find player (%d)", giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, string);
}
}
else
{
SendClientMessage(playerid, COLOR_ERROR, "Unknown command, please type /help for a list of available commands to use.");
}
}
return 1;
}
return SendClientMessage(playerid, COLOR_ERROR, "Unknown command, please type /help for a list of available commands to use.");
}
thanks
Re: ban with amount of days -
Aly - 11.06.2013
Well you should add the date when its ban expires.
Like today is 11.06 and you banned him for 1 day, so on the date you put 12.06 .
So now we he is logging in you will check and compare the current date and the date when the ban expires.
Re: ban with amount of days -
Geeboi_Mehdi - 11.06.2013
yes exactly how i do that
Re: ban with amount of days -
Aly - 11.06.2013
Well you'll need 3 new variables in pInfo enum: BanDay,BanMonth,BanYear
Now in your script you have to check if the current month have 31 or 30 days or 28 etc.
Here is an example:
pawn Код:
if(month == 5 && date+amount > 31)
{
pInfo[giveplayerid][BanDay] = (date+amount) - 31; // amount - number of days you ban the player,date=the current day
pInfo[giveplayerid][BanMonth] = month+1;
pInfo[giveplayerid][BanYear] = year;
}
//Well you have to do this for all cases.
And now when the player is loggin in:
pawn Код:
new day,month,year;
getdate(day,month,year);
if(pInfo[playerid][Banned] == 1)
{
if((pInfo[playerid][BanDay] == day || pInfo[playerid][BanDay] > day)&& pInfo[playerid][BanMonth] == month && pInfo[playerid][BanYear] == year)
{
pInfo[playerid][Banned] = 0;
pInfo[playerid][BanDay] = 0;
pInfo[playerid][BanMonth] = 0;
pInfo[playerid][BanYear] = 0;
}
else if(pInfo[playerid][BanDay] < day && pInfo[playerid][BanMonth] > month && pInfo[playerid][BanYear] == year)
{
pInfo[playerid][Banned] = 0;
pInfo[playerid][BanDay] = 0;
pInfo[playerid][BanMonth] = 0;
pInfo[playerid][BanYear] = 0;
}
else if(pInfo[playerid][BanDay] < day && pInfo[playerid][BanMonth] < month && pInfo[playerid][BanYear] > year)
{
pInfo[playerid][Banned] = 0;
pInfo[playerid][BanDay] = 0;
pInfo[playerid][BanMonth] = 0;
pInfo[playerid][BanYear] = 0;
}
else return SCM(playerid,0xFFFFFFFF,"You are banned from this server.");
}
I hope you get the idea
Re: ban with amount of days -
Geeboi_Mehdi - 11.06.2013
how do i make it support mysql though
Re: ban with amount of days -
MP2 - 11.06.2013
A good idea would be to use gettime(). Work out how many seconds in a day* then add that to the current time value, then store that in mySQL. If a player joins and they're banned and their unban time isn't reached, kick them. Simple.
* To work out seconds in a day:
1 minute = 60 sec
1 hour = 3600 seconds
24 hours = 86400
Set ban time to gettime() + (86400 * days);
Re: ban with amount of days -
zT KiNgKoNg - 11.06.2013
Lets break this down a little for you (One big break down).
pawn Код:
1 minute (60 seconds) is 60 * 1 = 60
2 minutes (120 seconds) is 60 * 2 = 120
1 hour (60 minutes) is 60 * 60 = 3600
2 hours (120 minutes) is 60 * 120 = 7200
1 day (24 hours) is 60 * 60 * 24 = 86400
2 days (48 hours) is 60 * 60 * 48 = 172800
1 week (7 days) is 60 * 60 * 24 * 7 = 604800
2 weeks (14 days) is 60 * 60 * 24 * 14 = 1209600
1 month (30 days) is 60 * 60 * 24 * 30 = 2592000
2 months (60 days) is 60 * 60 * 24 * 60 = 5184000
1 year (365 days) is 60 * 60 * 24 * 365 = 31536000
2 years (730 days) is 60 * 60 * 24 * 730 = 63072000
Just place /* & */ above and below this and place it into your script for future reference, I do!