Banning by days
#1

Hello, I've been making a ban command, but i wanted it so when you ban a player it bans them for 30 days, on the 30th day, it'll unban them, but I've looked through a lot of tutorials and couldn't find one that i was looking for, and when ever i try scripting one, it just ends up with errors.
If you could help I would be grateful.
Code:
Код:
ACMD:ban(playerid, params[])
{
	if (pInfo[playerid][Adminlevel] < 2)return 1;
	new reason[128], string[250];
	if(sscanf(params, "us[128]",ID, reason))
	return SCM(playerid, red, "--- /ban <ID> <Reason> ---");
    if(ID == IPI)return SCM(playerid, red, "Player is not connected!");
    pInfo[ID][Banned]=1;
    GetPlayerName(ID,pname,MAX_PLAYER_NAME);
    GetPlayerName(playerid,Nam, MAX_PLAYER_NAME);
    format(string, sizeof(string), "%s %s has banned %s for %s", AdminLevelName(playerid),Nam, pname, reason);
   	SCMToAll(red, string);
   	Kick(ID);
   	return 1;
}
Reply
#2

Hello, so can any help me with this please?
Reply
#3

Convert the amount of days into a unix timestamp format, and then when a player tries to connect check if the timestamp has passed.

See,
https://sampforum.blast.hk/showthread.php?tid=164359
https://sampforum.blast.hk/showthread.php?tid=496063
Hint:
This should convert it into a timestamp.
new datestamp = gettime() + date*86400;

For example, if the date is 1 day then it would simply be 86400. And the timestamp would simply be the current timestamp plus a day. To check if the ban has passed you'd do something like this:
pawn Код:
if(unbantime > gettime())
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)