Ban and Rban
#1

Pls help with my ban and rban cmd. In game I have ban myself with these cmd. But after banning myself i can enter in the game with a different name. These cmds are not banning the ip pls help here are my codes
Код:
CMD:ban(playerid,params[])
{
	if(PlayerInfo[playerid][LoggedIn] == 1)
	{
		if(PlayerInfo[playerid][Level] >= 2)
		{
			new Index;
		    new tmp[256];  tmp  = strtok(params,Index);
			new tmp2[256]; tmp2 = strtok(params,Index);

		    if(!strlen(params)) return
			SendClientMessage(playerid, red, "Usage: /ban [PlayerID] [Reason]");
			if(!strlen(tmp2))
			return SendClientMessage(playerid, red, "ERROR: You must give a reason");
			new player1;
	    	new string[128];
			new playername[MAX_PLAYER_NAME];
		 	new adminname [MAX_PLAYER_NAME];
			player1 = strval(tmp);

		 	if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && (PlayerInfo[player1][Level] != ServerInfo[MaxAdminLevel]))
			{
				GetPlayerName(player1, playername, sizeof(playername));
				GetPlayerName(playerid, adminname, sizeof(adminname));
				new year,month,day; getdate(year, month, day);
				new hour,minuite,second; gettime(hour,minuite,second);
			    CMDMessageToAdmins(playerid,"BAN");
				format(string,sizeof(string),"|- %s has been Banned by Administrator %s | Reason: %s [Date: %d/%d/%d] [Time: %d:%d]",playername,adminname,params[2],day,month,year,hour,minuite);
				SendClientMessageToAll(red,string);
    			new str[128];
				format(str,sizeof(str),"%s has been Banned by Administrator %s | Reason: %s",playername,adminname,params[2]);
				SaveIn("BanLog",str);
				print(string);
				if(udb_Exists(PlayerName2(player1)) && PlayerInfo[player1][LoggedIn] == 1)
				dUserSetINT(PlayerName2(player1)).("Banned",1);
				format(string,sizeof(string),"Banned by Administrator %s. | Reason: %s",adminname,params[2]);
				return BanEx(player1, string);
			}
			else return SendClientMessage(playerid, red, "ERRPR: Player is not connected or is yourself or is the highest level admin");
		}
		else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
	}
	else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
CMD:rban(playerid,params[]) {
	if(PlayerInfo[playerid][LoggedIn] == 1) {
		if(PlayerInfo[playerid][Level] >= 4) {
		    new ip[128], Index;
			new tmp[256];  tmp = strtok(params,Index);
			new tmp2[256]; tmp2 = strtok(params,Index);
		    if(!strlen(params)) return SendClientMessage(playerid, red, "USAGE: /rban [playerid] [reason]");
			if(!strlen(tmp2)) return SendClientMessage(playerid, red, "ERROR: You must give a reason");
	    	new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
			player1 = strval(tmp);

		 	if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && (PlayerInfo[player1][Level] != ServerInfo[MaxAdminLevel]) ) {
				GetPlayerName(player1, playername, sizeof(playername));
				GetPlayerName(playerid, adminname, sizeof(adminname));
				new year,month,day,hour,minuite,second; getdate(year, month, day); gettime(hour,minuite,second);
				CMDMessageToAdmins(playerid,"RBAN");
				format(string,sizeof(string),"%s has been range banned by Administrator %s [Reason: %s] [Date: %d/%d/%d] [Time: %d:%d]",playername,adminname,params[2],day,month,year,hour,minuite);
				SendClientMessageToAll(COLOR_RED,string);
				SaveToFile("BanLog",string);
				print(string);
				if(udb_Exists(PlayerName2(player1)) && PlayerInfo[player1][LoggedIn] == 1)
				dUserSetINT(PlayerName2(player1)).("banned",1);
				GetPlayerIp(player1,ip,sizeof(ip));
	            strdel(ip,strlen(ip)-2,strlen(ip));
    	        format(ip,sizeof(ip),"%s**",ip);
				format(ip,sizeof(ip),"banip %s",ip);
            	SendRconCommand(ip);
            	Ban(player1);
				return 1;
			} else return SendClientMessage(playerid, red, "Player is not connected or is yourself or is the highest level admin");
		} else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
	} else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
Reply
#2

try this dude (its not my)

Код:
COMMAND:rangeban(playerid, params[])
{
            new Target;
            new Reason[100];
            if(!sscanf(params, "us[100]", Target,Reason))
            {
                if(Target == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"ERROR: Wrong player ID");
                if(Target == playerid) return SendClientMessage(playerid,-1,"ERROR: You cant ban yourself!");
                new tname[MAX_PLAYER_NAME];
                GetPlayerName(Target,tname,sizeof(tname));
                new pname[MAX_PLAYER_NAME];
                GetPlayerName(playerid,pname,sizeof(pname));
                new MyString[256];
                new TargetString[256];
                new rbandate[3];
                getdate(rbandate[0], rbandate[1], rbandate[2]);
                format(MyString,sizeof(MyString),"You have range banned %s(%d)! (Reason: %s)",tname, Target, Reason);
                format(TargetString,sizeof(TargetString),"{FF002B}Range banned by: {FFFFFF}%s\n\n{FF002B}Reason: {FFFFFF}%s\n\n{FF002B}Date: {FFFFFF}%02d/%02d/%04d\n\n{FFFFFF}Press F8 to take a screenshot and use this in unban appeal!", pname, playerid,Reason, rbandate[2], rbandate[1], rbandate[0]);
                ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "{FF002B}RANGE BANNED!", TargetString, "OK", "");
                SendClientMessage(playerid,-1,MyString);
                new AllString[256];
                format(AllString,sizeof(AllString),"Administrator %s range banned player %s(%d)! (Reason: %s)",pname,tname,Target,Reason);
                SendClientMessageToAll(-1,AllString);
                new ip[50];
                GetPlayerIp(Target,ip,sizeof(ip));
                strdel(ip,strlen(ip)-4,strlen(ip));
                format(ip,sizeof(ip),"%s**.**",ip);
                format(ip,sizeof(ip),"banip %s",ip);
                SendRconCommand(ip);
                Kick(Target);
            }
            else SendClientMessage(playerid, -1, "USAGE: /rangeban <playerid> <reason>");
            return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)