[HELP] File Functions Help
#1

Hello.

I have a file (bans.txt), I'm new to scripting (files at least), I need to remove a value (an IP) from that file, I was wondering how, and what to use?
*The file includes many other lines, so I'm not sure how to make it check, remove then done?

Thanks for any help, truly appreciated
Reply
#2

https://sampwiki.blast.hk/wiki/File_Functions
Reply
#3

I was trying to make an unban command for myself, but I failed:

pawn Код:
dcmd_unban(playerid, params[])
{
    new name[MAX_PLAYER_NAME], string[128], string2[128];
    if (sscanf(params, "s", name))
    {
        SendClientMessage(playerid, COLOR_WHITE, "SYNTAX - /unban [name]");
        SendClientMessage(playerid, COLOR_GREY, "Full name, this includes underscores.");
    }
    else
    {
      format(string, sizeof(string), "CRP_Scriptfiles/Accounts/%s.ini", name);
      if(fexist(string))
      {
        dini_IntSet(string, "Banned", -1);
      string2 = dini_Get(string, "IP");
      fdeleteline("Bans.txt", string2);
      }
      else
      {
        SendClientMessage(playerid, COLOR_WHITE, "Invalid name, the name was not recognized.");
      }
   
    }
}
Errors:
C:\Documents and Settings\Calon\Desktop\SAMP\0.3\gamemodes\crpnew.p wn(20457) : error 047: array sizes do not match, or destination array is too small

Line 20457:

pawn Код:
string2 = dini_Get(string, "IP");
Can someone help me fix this, please?
Reply
#4

Calgon why make a seperate ban file. Use samp.ban. When you do /unban it loads the ip from the account file and sends the rcon command "unbanip ip".
Reply
#5

Quote:
Originally Posted by Calgon
I was trying to make an unban command for myself, but I failed:

pawn Код:
dcmd_unban(playerid, params[])
{
    new name[MAX_PLAYER_NAME], string[128], string2[128];
    if (sscanf(params, "s", name))
    {
        SendClientMessage(playerid, COLOR_WHITE, "SYNTAX - /unban [name]");
        SendClientMessage(playerid, COLOR_GREY, "Full name, this includes underscores.");
    }
    else
    {
      format(string, sizeof(string), "CRP_Scriptfiles/Accounts/%s.ini", name);
      if(fexist(string))
      {
        dini_IntSet(string, "Banned", -1);
      string2 = dini_Get(string, "IP");
      fdeleteline("Bans.txt", string2);
      }
      else
      {
        SendClientMessage(playerid, COLOR_WHITE, "Invalid name, the name was not recognized.");
      }
   
    }
}
Errors:
C:\Documents and Settings\Calon\Desktop\SAMP\0.3\gamemodes\crpnew.p wn(20457) : error 047: array sizes do not match, or destination array is too small

Line 20457:

pawn Код:
string2 = dini_Get(string, "IP");
Can someone help me fix this, please?
Change string2[128] to string2[MAX_STRING]
Reply
#6

Quote:
Originally Posted by TimmehBoy
Calgon why make a seperate ban file. Use samp.ban. When you do /unban it loads the ip from the account file and sends the rcon command "unbanip ip".
I prefer having a seprate file, the samp.ban prevents connecting and I'd rather the server showed a ban reason message.

@ Gappy; I changed it to that then got 4 errors, changed to 256 and it works. Sorry, my bad.
Reply
#7

Quote:
Originally Posted by Calgon
Quote:
Originally Posted by TimmehBoy
Calgon why make a seperate ban file. Use samp.ban. When you do /unban it loads the ip from the account file and sends the rcon command "unbanip ip".
I prefer having a seprate file, the samp.ban prevents connecting and I'd rather the server showed a ban reason message.
I recently made the same thing.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)