AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [H3LP] Get specific ini line and remove it (https://forums.alliedmods.net/showthread.php?t=296308)

DarthMan 04-17-2017 13:58

[H3LP] Get specific ini line and remove it
 
Hello. Can anyone show me an example of how I can get a specific line using the new file system? I mean, I am working myself on a brand new and different ban plug-in, and I want when I say max_unban argument1 to look for the line containing argument1 and remove the whole text from it. Thanks !

OciXCrom 04-17-2017 14:20

Re: [H3LP] Get specific ini line and remove it
 
Lol, I'm doing the exact same thing at the moment.
You can't just find a line and delete it. You need to delete the entire file and rewrite it. So store all bans in an array, delete the file, and check whether the ban is in the array when writing it again.

KiLLeR. 04-17-2017 14:26

Re: [H3LP] Get specific ini line and remove it
 
Re-write all lines to another temp file excluding the line, that contains the unbanned player, which you want to remove and then delete the original file and rename the temp file. I have done the same thing a month ago. Lol

DarthMan 04-17-2017 14:34

Re: [H3LP] Get specific ini line and remove it
 
Quote:

Originally Posted by KiLLeR. (Post 2513000)
Re-write all lines to another temp file excluding the line, that contains the unbanned player, which you want to remove and then delete the original file and rename the temp file. I have done the same thing a month ago. Lol

Do I have to use replace to rename the file?

KiLLeR. 04-17-2017 14:46

Re: [H3LP] Get specific ini line and remove it
 
https://www.amxmodx.org/api/file/rename_file

DarthMan 04-17-2017 14:56

Re: [H3LP] Get specific ini line and remove it
 
Quote:

Originally Posted by KiLLeR. (Post 2513009)

And I will be using delete_file to remove the file :)

OciXCrom 04-17-2017 15:44

Re: [H3LP] Get specific ini line and remove it
 
If you have your bans saved in an array, you don't need to rename it. Delete it directly and rewrite it.

DarthMan 04-17-2017 17:14

Re: [H3LP] Get specific ini line and remove it
 
Problem solved, ty guys :)


All times are GMT -4. The time now is 17:56.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.