Offline ban
#1

I've been trying to make an offline ban cmd and it's not working so here's what i did till now i know it's fucked up but i would appreciate any help:
Код:
	CMD:oban(playerid, params[])
	{
    if(IsPlayerConnected(playerid))
	    {
			if(PlayerInfo[playerid][pAdmin] >= 3)
			{
                new name[MAX_PLAYER_NAME],sendername[MAX_PLAYER_NAME], result[60], string[100], logstring[100];
				if(sscanf(params, "s[24]s[32]",name,result)) return SendClientMessage(playerid,RED,"USAGE: /oban [Name] [reason]");
						new year, month, day;
						getdate(year, month, day);
						if(dini_Exists(SERVER_USER_FILE))
						{
						dini_IntSet("lost/accounts/%s.ini","pBanned",1);
						format(string, sizeof(string), "{AA3333}AdmCmd{FFFF00}: %s was offline banned by %s, reason: %s", name, sendername, (result));
						SendClientMessageToAll(RED, string);
	                 	format(logstring, sizeof(logstring), "[%d/%d/%d] Name: %s Banned by: %s Reason: %s (/oban)",day, month, year,name, sendername, (result));
                        SaveIn("BanLog.txt",string);
                        }
                        else
                        {
						SendClientMessage(playerid,RED, "invalid player name");
						}
						return 1;
			}
		}
		return 1;
	}
I want it to ban the player name given and I don't know how to do it i tried things like Playerinfo[name][pBanned] = 1; and it didn't work.
Reply
#2

Try this:

Код:
CMD:oban(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 4)
	{
		SendClientMessage(playerid, COLOR_GRAD1, "You're not authorized to use that command!");
		return 1;
	}
 	if(AdminDuty[playerid] != 1 && PlayerInfo[playerid][pAdmin] < 6)
  	{
   		SendClientMessage(playerid,COLOR_WHITE, "You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
		return 1;
	}

	new string[128], playername[MAX_PLAYER_NAME], reason[64];
	if(sscanf(params, "s[MAX_PLAYER_NAME]s[64]", playername, reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /oban [playername] [reason]");

    new giveplayerid = ReturnUser(playername);
	if(IsPlayerConnected(giveplayerid))
	{
		SendClientMessage(playerid, COLOR_GRAD2, "That player is online, use /ban for online players.");
	}
	else if(doesAccountExist(playername))
	{
		OnPlayerOfflineLogin(playername);
		if(PlayerInfo[MAX_PLAYERS][pPermaBanned] == 1)
		{
			SendClientMessage(playerid, COLOR_WHITE, "That player is already permabanned!");
			return 1;
		}
		if(PlayerInfo[MAX_PLAYERS][pAdmin] >= 1)
		{
			SendClientMessage(playerid, COLOR_WHITE, "You can't ban admin accounts!");
			return 1;
		}
		else
		{
			if(PlayerInfo[MAX_PLAYERS][pBanned] >= 0)
			{
				PlayerInfo[MAX_PLAYERS][pBanned] = 1;
				AddBan(PlayerInfo[MAX_PLAYERS][pIP]);
				OnPlayerOfflineSave(playername);
				format(string, sizeof(string), "AdmCmd: %s (IP:%s) was offline banned by %s, reason: %s", playername, PlayerInfo[MAX_PLAYERS][pIP], GetPlayerNameEx(playerid), reason);
				Log("logs/ban.log", string);
				format(string, 128, "AdmCmd: %s (IP:%s) was offline banned by %s, reason: %s", playername, PlayerInfo[MAX_PLAYERS][pIP], GetPlayerNameEx(playerid), reason);
				ABroadCast(COLOR_LIGHTRED,string,1);
			}
			else
			{
				SendClientMessage(playerid, COLOR_WHITE, "That player is already banned!");
			}
		}
	}
	else
	{
		SendClientMessage(playerid, COLOR_WHITE, "That account doesn't exist.");
	}
	return 1;
}
Reply
#3

Well i need stocks and defines for :
doesAccountExist
OnPlayerOfflineLogin
AddBan
OnPlayerOfflineSave
lol
Reply
#4

Anyone knows how to do it ?
Reply
#5

I can show you how i would do it.

In this Example i use dini and sscanf

Код:
CMD:oban(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 4)
	{
		SendClientMessage(playerid, COLOR_GRAD1, "You're not authorized to use that command!");
		return 1;
	}
 	if(AdminDuty[playerid] != 1 && PlayerInfo[playerid][pAdmin] < 6)
  	{
   		SendClientMessage(playerid,COLOR_WHITE, "You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
		return 1;
	}
	
	new username[24],reason[64],string[128];
	if(sscanf(params,"s[24]s[64]",username,reason)) return SendClientMessage(playerid,COLOR_GRAD1,"Useage: /oban username reason");
	if(doesAccountExist(username))
	{
	    new UserFile[24];
		format(UserFile,sizeof(UserFile),"/Account/%s.ini",username);
		dini_IntSet(UserFile,"Ban",1);
		format(string,sizeof(string),"User %s was banned from this Server",username);
		SendClientMessageToAll(COLOR_WHITE,string);
	}
	
	return 1;
}

stock doesAccountExist(user[])
{
	new UserFile[24];
	format(UserFile,sizeof(UserFile),"/Account/%s.ini",user);
	if(dini_Exists(UserFile)) return 1;
	return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)