little help with banning
#1

Alright i have now got a rcon attempt in my script and it bans you when you have done 3 bad rcon attempts, but it bans in samp.ban file but i want it to ban in the users file, so it would say
Password: frerghtfgww
Money:
Banned:
Etc...
I have the code here:
Код:
#define MAX_RCON_ATTEMPS 3
Код:
public OnRconLoginAttempt(ip[], password[], success)
{
	if(!success)
	{
		if(!dini_Exists("Logs/Badrcons.txt"))
			dini_Create("Logs/Badrcons.txt");

		new attempts=dini_Int("Logs/Badrcons.txt",ip);
		attempts++;
		if(attempts>=MAX_RCON_ATTEMPS)
		{
			new cmd[32];
			format(cmd,sizeof(cmd),"banip %s",ip);
			SendRconCommand(cmd);
		}
		dini_IntSet("Logs/Badrcons.txt",ip,attempts);

	}
	return 1;
}
I have this as my banned:
Код:
INI_WriteInt(file,"Banned",pInfo[playerid][Banned]);
If you can help me i will be very grateful. thank you

Edit --------------------------------------------------------------
I also have a problem with my ban command, it doesn't ban a player it only shows me the usage of the command, i type /ban ID Reason but it just shows me the usage can someone help me find out why it's not banning

Код:
ACMD:ban(playerid, params[])
{
    if (pInfo[playerid][Adminlevel] < 2) return 0;
    new R[25], string[250];
    if(sscanf(params, "ui", ID, R)) return SendClientMessage(playerid, red, "--- /ban <ID> <Reason> ---");
  	if(ID == IPI) return SCM(playerid, red, "Player is not connected!");
    pInfo[playerid][Banned]=1;
    GetPlayerName(ID,pname,MAX_PLAYER_NAME);
    GetPlayerName(playerid,Nam, MAX_PLAYER_NAME);
    format(string, sizeof(string), "%s %s has banned %s for %s", AdminLevelName(playerid),Nam, pname, R);
	SendClientMessageToAll(red, string);
	Kick(ID);
	return 1;
}
Reply
#2

By using the RCON command "banip {ip}", the same happens when you use Ban or BanEx(). You should remove that (if you don't want the samp.ban).
Then, if you want to ban someone using the value in that userfile; check if the player is banned (by reading the userfile, the "Banned" data), kick the player

EDIT:
You are using sscanf wrong. You must not use "i" (which stands for "integer") for the string, you should use "s". Also, add the max size of that string;

pawn Код:
new ID; //?
new string[25];

sscanf(params, "us[25]", ID, string);
EDIT 2:
I see you're using "AdminLevelName()". I suggest you don't use that (I assume you're using if statements and formats to get the admin level name). Check this out:

pawn Код:
/*
Admin level 0: Player
Admin level 1: Mod
Admin level 2: Admin
Admin level 3: Owner
*/

new AdmLvlName[][] =
{
    "Player", //level 0
    "Mod", //level 1
    "Admin", //level 2
    "Owner" //level 3
};

//Then, to show the admin level;

printf("Name of admin level 0: %s", AdmLvlName[0]);
printf("Player ID %d has admin level: %d", 0, AdmLvlName[pInfo[playerid][AdminLevel]);

//You could eventually use this:
stock AdminLevelName(playerid) return AdmLvlName[pInfo[playerid][AdminLevel]];
//or:
#define AdminLevelName(%0) AdmLvlName[pInfo[%0][AdminLevel]
Reply
#3

I'll have a go at what you're saying when I get home, thanks for the tips and I'll see how I feel with the adminlvlname, I'll tell you how it goes
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)