SA-MP Forums Archive
Ban command help please. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Ban command help please. (/showthread.php?tid=119166)



Ban command help please. - introzen - 06.01.2010

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 =)


Re: Ban command help please. - pagie1111 - 07.01.2010


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.



Re: Ban command help please. - introzen - 07.01.2010

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.


Re: Ban command help please. - pagie1111 - 07.01.2010

In that code string is equal to nothing.


Re: Ban command help please. - introzen - 07.01.2010

That's why i'm asking for help


Re: Ban command help please. - bogeymanEST - 07.01.2010

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;
}



Re: Ban command help please. - pagie1111 - 07.01.2010

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


Re: Ban command help please. - introzen - 07.01.2010

Arguments doesn't match definition on this line:

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



Re: Ban command help please. - Nakki - 07.01.2010

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


Re: Ban command help please. - introzen - 07.01.2010

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 :..