[HELP] File Functions Help - 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: [HELP] File Functions Help (
/showthread.php?tid=97140)
[HELP] File Functions Help -
Marclang - 12.09.2009
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
Re: [HELP] File Functions Help -
Correlli - 12.09.2009
https://sampwiki.blast.hk/wiki/File_Functions
Re: [HELP] File Functions Help -
Calgon - 12.09.2009
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?
Re: [HELP] File Functions Help -
[eLg]Timmy - 12.09.2009
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".
Re: [HELP] File Functions Help -
Gappy - 12.09.2009
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]
Re: [HELP] File Functions Help -
Calgon - 12.09.2009
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.
Re: [HELP] File Functions Help -
Gappy - 12.09.2009
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.