Little help here.
#1

Hello,
Can anyone help me to script a ban/unban offline command?
Reply
#2

Here you go, I've copied this from my own script, feel free to edit it..
-

pawn Код:
if(strcmp(cmd, "/banaccount", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new string2[256];
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GREY, "USAGE: /banaccount [full name(case sensative)]");
                return 1;
            }
            if(PlayerInfo[playerid][pAdmin] >= 4)
            {
                format(string, sizeof(string), "users/%s.ini",tmp);
                if(dini_Exists(string))
                {
                    if(dini_Int(string, "Band") == 0)
                    {
                        if(dini_Int(string, "AdminLvl") > PlayerInfo[playerid][pAdmin])
                        {
                            SendClientMessage(playerid, COLOR_GREY, "You can't ban higher level Admins !");
                            return 1;
                        }
                        dini_IntSet(string, "Band", 3);
                        string2 = dini_Get(string, "IP");
                        format(string, sizeof(string),"banip %s", string2);
                        SendRconCommand(string);
                        SendRconCommand("reloadbans");
                        format(string, 256, "AdmWarning: %s has banned account '%s' and IP '%s'.",PlayerName(playerid),tmp,string2);
                        ABroadCast(COLOR_LIGHTRED, string, 1);
                        return 1;
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GRAD2, "That player is already account-banned. You have banned their IP.");
                        string2 = dini_Get(string, "IP");
                        format(string, sizeof(string), "banip %s", string2);
                        SendRconCommand(string);
                        SendRconCommand("reloadbans");
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "That player does not exist!");
                }
            }
        }
        return 1;
    }
Reply
#3

And to unban
Код:
	if(strcmp(cmd, "/unban", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SyntaxMessage(playerid, "/unban [full name(case sensitive)]");
				return 1;
			}
			if (PlayerInfo[playerid][pAdmin] >= 1337 || PlayerInfo[playerid][pBanAppealer])
			{
			    new file[128];
				format(file,sizeof(file),"Users/%s.ini",tmp);
 				if(!fexist(file))
				{
	  				SendClientMessage(playerid, GREY, "Invalid player account.");
	    			return 1;
				}
				else
				{
				    new tmpip[20];
					if(INI_Open(file))
					{
                		INI_WriteInt("Band", 0);
                		INI_WriteInt("PermBan", 0);
                		INI_WriteString("BanReason", "None");
						INI_ReadString(tmpip, "IP", 20);
						format(string, sizeof(string), "unbanip %s", tmpip);
						SendRconCommand(string);
						SendRconCommand("reloadbans");
						SendClientMessage(playerid, LIGHTRED, "* Member unbanned.");
						format(string, sizeof(string), "{FF6347}%s has unbanned account '%s', and IP '%s'",PlayerName(playerid),tmp,tmpip);
						ABroadCast(RED, string, 1);
						INI_Save();
						INI_Close();
					}
					return 1;
				}
			}
			else
			{
				SendClientMessage(playerid, GREY, "    You are not authorized to use this command.");
			}
		}
		return 1;
	}
Reply
#4

Hope this helps.
Reply
#5

Thanks guys, I appreciate this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)