Ban command help please.
#1

Hello, I've made a fully working ban command which makes a line in Bans.ban like this:

[Year/Month/Day - Hour:Minute:Second] ..: Banner_Name BANNED Banned_Name. Reason: Ban_Reason :..


How do I make a stock which checks if Banned_Name is the same as Playername who connected on each line?

Thanks =)
Reply
#2


pawn Код:
stock strcmp_BanName(playerid, bannedname[])
{
if(strcmp(bannedname,ReturnName(playerid),true) == 0) return 1;
else return 0;
}
pawn Код:
stock ReturnName(playerid)
{
new n[MAX_PLAYER_NAME];
GetPlayerName(playerid,n,sizeof(n));
return n;
}
Hmm, maybe I am not sure if it will work.
Reply
#3

Definetly not. I already got this:

pawn Код:
stock BanCheck(playerid)
{
  new pName[MAX_PLAYER_NAME], string[128];
  GetPlayerName(playerid,pName,sizeof(pName));
    new File:check = fopen("CLRP/Bans.ban", io_read);
    while(fread(check, string))
    {
      if(!strcmp(string,pName)) return 1;
        new server[256];
        format(server,sizeof(server),".: Server kicked %s, Account BANNED! :.",pName);
        SendClientMessageToAll(COLOR_DARKRED, server);
        Kick(playerid);
    }
    return 1;
}
But that kicks the one who banned the player aswell when he/she tries to connect...

so if Sarah_Johnson banned Daniel_Jackson,

The server kicks them both when they tries to connect.
Reply
#4

In that code string is equal to nothing.
Reply
#5

That's why i'm asking for help
Reply
#6

Might work:
pawn Код:
stock BanCheck(playerid)
{
    new pName[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid,pName,sizeof(pName));
    format(pName, 128, "BANNED %s", pname);//Because the name always has "BANNED" in front of it
    new File:check = fopen("CLRP/Bans.ban", io_read);
    while(fread(check, string))
    {
      if(!strcmp(string,pName)) return 1;
        new server[256];
        format(server,sizeof(server),".: Server kicked %s, Account BANNED! :.",pName);
        SendClientMessageToAll(COLOR_DARKRED, server);
        Kick(playerid);
    }
    return 1;
}
Reply
#7

pawn Код:
stock BanCheck(playerid)
{
new pName[MAX_PLAYER_NAME], string[128];// defines variables
GetPlayerName(playerid,pName,sizeof(pName));// sizes off the name
format(pName, 128, "BANNED %s", pname);// Why do you change pName to this?
new File:check = fopen("CLRP/Bans.ban", io_read);// opens and reads the file given
while(fread(check, string))// while loop
{
  if(!strcmp(string,pName)) return 1;// if strcmp doesn't find a truth to the statement - return 1
new server[256];// defines a string with a ridiculously large cell ammount
format(server,sizeof(server),".: Server kicked %s, Account BANNED! :.",pName);
SendClientMessageToAll(COLOR_DARKRED, server);
Kick(playerid);
}
return 1;
}
now if you haven't noticed what is wrong, here:

pawn Код:
stock BanCheck(playerid)
{
new pName[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid,pName,sizeof(pName));
format(string, sizeof(string), "BANNED %s", pname);
new File:check = fopen("CLRP/Bans.ban", io_read);
while(fread(check, string))
{
  if(!strfind(string)) return 1;
new server[38 + MAX_PLAYER_NAME];
format(server,sizeof(server),".: Server kicked %s, Account BANNED! :.",pName);
SendClientMessageToAll(COLOR_DARKRED, server);
Kick(playerid);
}
return 1;
}
Hope it works
Reply
#8

Arguments doesn't match definition on this line:

pawn Код:
if(!strfind(string)) return 1;
Reply
#9

Just login RCON and use it

Код:
if(!strcmp(cmdtext, "/ban", true, 5))
{
  if (IsPlayerAdmin(playerid))
  {
    if(!strlen(cmdtext[6]))
    {
      SendClientMessage(playerid, COLOR_ORED, "Usage: /ban [playerid]");
      return 1;
    }
    new ID = strval(cmdtext[6]);
    new strv[170];
    if(IsPlayerConnected(ID))
    {
      format(strv, 170, "~ You have been banned from this server");
      SendClientMessage(ID,COLOR_ORANGE, strv);
      Ban( ID );
    }
  }
  return SendClientMessage(playerid, COLOR_RED, "Your not rcon admin!");
}
OMG .. im stypid xD that normal ban command
Reply
#10

pawn Код:
stock BanCheck(playerid)
{
    new pName[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid,pName,sizeof(pName));
    format(pName, 128, "BANNED %s", pName);//Because the name always has "BANNED" in front of it
    new File:check = fopen("CLRP/Bans.ban", io_read);
    while(fread(check, string))
    {
      if(!strcmp(string,pName)) return 1;
        new server[256];
        format(server,sizeof(server),".: Server kicked %s, Account BANNED! :.",pName);
        SendClientMessageToAll(COLOR_DARKRED, server);
        Kick(playerid);
    }
    return 1;
}
This kicks me when I join...

pawn Код:
stock BanCheck(playerid)
{
    new pName[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid,pName,sizeof(pName));
    format(pName, 128, "BANNED %s", pName);//Because the name always has "BANNED" in front of it
    new File:check = fopen("CLRP/Bans.ban", io_read);
    while(fread(check, string))
    {
      if(strcmp(string,pName)) return 1;
        new server[256];
        format(server,sizeof(server),".: Server kicked %s, Account BANNED! :.",pName);
        SendClientMessageToAll(COLOR_DARKRED, server);
        Kick(playerid);
    }
    return 1;
}
this doesn't kick me =/

Line in the Bans.ban file looks like this:

Код:
[2010/01/07 - 16:28:05] ..: Sarah_Johnson BANNED Daniel_Jackson. Reason: test :..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)