Anyway to edit ban cmd to be temporary?Ban for few days?
#1

Anyway to edit ban cmd to be temporary?Ban for few days?
Код:
CMD:ban(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] >= 2)
	{
		new string[128], giveplayerid, reason[64];
		if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /ban [player] [reason]");

		if(IsPlayerConnected(giveplayerid))
		{
			if(PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin])
			{
				format(string, sizeof(string), "AdmCmd: %s has been auto-banned, reason: Trying to /ban a higher admin.", GetPlayerNameEx(playerid));
				ABroadCast(COLOR_YELLOW,string,2);
				PlayerInfo[playerid][pBanned] = 1;
				SystemBan(playerid, "[System] (Attempting to ban a higher admin.)");
				Kick(playerid);
				return 1;
			}
			else
			{
				new playerip[32];
				GetPlayerIp(giveplayerid, playerip, sizeof(playerip));
				format(string, sizeof(string), "AdmCmd: %s(IP:%s) was banned by %s, reason: %s", GetPlayerNameEx(giveplayerid), playerip, GetPlayerNameEx(playerid), reason);
				Log("logs/ban.log", string);
				format(string, sizeof(string), "AdmCmd: %s was banned by %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
				SendClientMessageToAllEx(COLOR_LIGHTRED, string);
				PlayerInfo[giveplayerid][pBanned] = 1;
				StaffAccountCheck(giveplayerid, GetPlayerIpEx(giveplayerid));
				new ip[32];
				GetPlayerIp(giveplayerid,ip,sizeof(ip));
    			AddBan(playerid, giveplayerid, reason);
				MySQLBan(GetPlayerSQLId(giveplayerid),ip,reason,1,GetPlayerNameEx(playerid));
				SystemBan(giveplayerid, GetPlayerNameEx(giveplayerid));
				SetTimerEx("KickEx", 1000, 0, "i", giveplayerid);
				return 1;
			}

		}
	}
	else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
	return 1;
}
Reply
#2

This would require a timer maybe (May be a little laggy).

There is an other way to do it by checking the date whenever the player connects.

I'm giving just information here, Maybe you could take care of the rest. (If you need help i'll be here)

- Store the date of the ban in your Data Base alongside the number of days of the ban
- Whenever the player connect, Check if he is banned or no (OnPlayerConnect)
- If he is banned, Check if the currently date is the date of his unban (Or the date has passed), If so, Unban him by changing your values in Data Base
- If he isn't banned, Just deal with him as any other player (A normal login)
Reply
#3

Or more simple unix timestamp
https://sampforum.blast.hk/showthread.php?tid=254915%5D
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)