help, ban command
#1

Код:
//==============================================================================
dcmd_unban(playerid, params[])
{
	if(PlayerInfo[playerid][AdminLevel] >= 2)
	{
		new PlayerFile[50],string[128];
		format(PlayerFile, sizeof(PlayerFile), "Saves/%s.ini", params);
		if(!strlen(params)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /unban [playername]");
		if(!dini_Exists(PlayerFile)){SendClientMessage(playerid, COLOR_GREY, "No such player found in the database.");}
		else
		{
		    if(dini_Int(PlayerFile,"Banned")==0)return SendClientMessage(playerid,-1,"That Player is already unbanned");
			dini_IntSet(PlayerFile, "Banned", 0);
    		SendClientMessage(playerid, COLOR_WHITE, "Account Unbanned");
    		format(string,sizeof(string),"unbanip %s",dini_Get(PlayerFile,"IP"));
	 		SendRconCommand(string);
		}
 	}else return 0;
	return 1;
}
//==============================================================================
dcmd_ban(playerid, params[])
{
	if(PlayerInfo[playerid][AdminLevel] >= 3)
	{
		new PlayerFile[50];
		format(PlayerFile, sizeof(PlayerFile), "Saves/%s.ini", params);
		if(!strlen(params)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /oban [playername]");
		if(!dini_Exists(PlayerFile)) {SendClientMessage(playerid, COLOR_GREY, "No such player found in the database.");}
		else
		{
		    if(dini_Int(PlayerFile,"Banned")==1)return SendClientMessage(playerid,-1,"That Player is already banned");
    		dini_IntSet(PlayerFile, "Banned", 1);
    		SendClientMessage(playerid, COLOR_WHITE, "Account Banned");}
 	}else return 0;
	return 1;
}
/ban feature only set Banned = 1 on their save file...
and they can play on the server until they relog...
i need help with making the command also banning their ip and "closes the connection"

/ban (iD) (reason)
/unban (iD)
Reply
#2

Here you go:
Unban:

pawn Код:
dcmd_unban(playerid, params[])
{
    new name[120], file[126],string[100], string2[100], playerIP[256];
    if(PlayerInfo[playerid][pAdmin] >= 1337 || PlayerInfo[playerid][pBanAppealer] == 1)
    {
        if (sscanf(params, "s", name)) return SendClientMessage(playerid, COLOR_GREY, "** [Usage]: /unban [Account Name]");
        format(file,sizeof(file),"users/%s.ini",name);
        if(!fexist(file))
        {
            SendClientMessage(playerid, COLOR_LIGHTRED, "** [Error]: Invalid player Account");
            return 1;
        }
        else
        {
            format(file, sizeof(file), "users/%s.ini", name);
            new File: hFile = fopen(file, io_append);
            if(hFile)
            {
                new var[32];
                playerIP = dini_Get(file, "IP");
                format(var, 32, "Band=0"); fwrite(hFile, var);
                fclose(hFile);
            }
            format(string, sizeof(string), "unbanip %s", playerIP);
            SendRconCommand(string);
            SendRconCommand("reloadbans");
            SendClientMessage(playerid, COLOR_YELLOW, "** Member unbanned");
            format(string2, 256, "AdmCmd: %s has unbanned account '%s', and IP '%s'",PlayerName(playerid),name,playerIP);
            ABroadCast(COLOR_LIGHTRED, string2, 1);
        }
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "** [Error]: You are NOT an admin");
        return 1;
    }
}
Ban:

pawn Код:
if(strcmp(cmd, "/ban", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ban [playerid/PartOfName] [reason]");
                return 1;
            }
            giveplayerid = ReturnUser(tmp);
            if(IsPlayerNPC(giveplayerid)) return 1;
            if(PlayerInfo[playerid][pAdmin] >= 2)
            {
                if(IsPlayerConnected(giveplayerid))
                {
                    if(giveplayerid != INVALID_PLAYER_ID)
                    {
                        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        new length = strlen(cmdtext);
                        while ((idx < length) && (cmdtext[idx] <= ' '))
                        {
                            idx++;
                        }
                        new offset = idx;
                        new result[96];
                        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                        {
                            result[idx - offset] = cmdtext[idx];
                            idx++;
                        }
                        result[idx - offset] = EOS;
                        if(!strlen(result))
                        {
                            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ban [playerid/PartOfName] [reason]");
                            return 1;
                        }
                        new IP[16];
                        new logstring[256];
                        new banstring[256]; //modified
                        new year, month, day;
                        getdate(year, month, day);
                        if(giveplayerid == playerid)
                        {
                            return SendClientMessage(playerid,COLOR_GREY,"If you're leaving, use /q and stop being an attention whore.");
                        }
                        if(UseAdmCmdTimer[playerid] > 2)
                        {
                            GetPlayerIp(playerid, IP, sizeof(IP));
                            format(logstring, sizeof(logstring), "%s [%d/%d/%d] Name: %s Key: %s Reason: Spam.", IP, day, month, year,sendername,PlayerInfo[playerid][pKey]);
                            BanLog(logstring);
                            format(string, sizeof(string), "AdmCmd: %s was banned, reason: Spam.", sendername);
                            SendClientMessageToAll(COLOR_LIGHTRED, string);
                            PlayerInfo[playerid][pBand] = 3;
                            PlayerInfo[playerid][pPermBand] = 1;
                            format(string, sizeof(string), "Ban Reason: Spam - Banned by: Autoban");
                            strmid(PlayerInfo[playerid][pBanReason], string, 0, strlen(string), 255);
                            BanEx(playerid, "Banned By: Autoban Reason: Spam");
                            return 1;
                        }
                        if(IsGod[giveplayerid] || (PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin]))
                        {
                            GetPlayerIp(playerid, IP, sizeof(IP));
                            format(logstring, sizeof(logstring), "%s [%d/%d/%d] Name: %s Key: %s Reason: Attempting to ban a higher admin.", IP, day, month, year,sendername,PlayerInfo[playerid][pKey]);
                            BanLog(logstring);
                            format(string, sizeof(string), "AdmCmd: %s was banned, reason: Attempting to ban a higher admin.", sendername);
                            SendClientMessageToAll(COLOR_LIGHTRED, string);
                            PlayerInfo[playerid][pBand] = 3;
                            PlayerInfo[playerid][pPermBand] = 1;
                            format(string, sizeof(string), "Ban Reason: Attempting to ban a higher admin - Banned by: Autoban");
                            strmid(PlayerInfo[playerid][pBanReason], string, 0, strlen(string), 255);
                            BanEx(playerid, "Banned By: Autoban Reason: Attempting to ban a higher admin");
                            return 1;
                        }
                        GetPlayerIp(giveplayerid, IP, sizeof(IP));
                        format(logstring, sizeof(logstring), "%s [%d/%d/%d] Name: %s Key: %s Banned by: %s Reason: %s", IP, day, month, year,giveplayer,PlayerInfo[giveplayerid][pKey], sendername, (result));
                        BanLog(logstring);
                        format(string, sizeof(string), "AdmCmd: %s was banned by %s, reason: %s", giveplayer, sendername, (result));
                        SendClientMessageToAll(COLOR_LIGHTRED, string);
                        PlayerInfo[giveplayerid][pBand] = 3;
                        format(banstring, sizeof(banstring), "Banned By: %s Reason: %s", sendername, (result)); //modified
                        format(string, sizeof(string), "Ban Reason: %s - Banned by: %s",result,sendername);
                        strmid(PlayerInfo[giveplayerid][pBanReason], string, 0, strlen(string), 255);
                        PlayerInfo[giveplayerid][pBanDay] = day;
                        PlayerInfo[giveplayerid][pBanMonth] = month;
                        PlayerInfo[giveplayerid][pBanYear] = year;
                        BanEx(giveplayerid, banstring); //modified
                        UseAdmCmdTimer[playerid]++;
                        SetTimerEx("UseAdmCmd",3*1000,0,"i",playerid); //3 seconds
                        return 1;
                    }
                }
                else
                {
                    format(string, sizeof(string), "   %d is not an active player !", giveplayerid);
                    SendClientMessage(playerid, COLOR_GRAD1, string);
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD2, "   You are not authorized to use that command !");
            }
        }
        return 1;
    }
Reply
#3

Will that be compilable with my script you sude pAdmin i use adminlevel
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)