Raised This Month: $ Target: $400
 0% 

Solved [H3LP] Get specific ini line and remove it


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DarthMan
Veteran Member
Join Date: Aug 2011
Old 04-17-2017 , 13:58   [H3LP] Get specific ini line and remove it
Reply With Quote #1

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 !

Last edited by DarthMan; 04-18-2017 at 04:53. Reason: Solved
DarthMan is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-17-2017 , 14:20   Re: [H3LP] Get specific ini line and remove it
Reply With Quote #2

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.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 04-17-2017 , 14:26   Re: [H3LP] Get specific ini line and remove it
Reply With Quote #3

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

Last edited by KiLLeR.; 04-17-2017 at 14:27.
KiLLeR. is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 04-17-2017 , 14:34   Re: [H3LP] Get specific ini line and remove it
Reply With Quote #4

Quote:
Originally Posted by KiLLeR. View Post
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?
DarthMan is offline
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 04-17-2017 , 14:46   Re: [H3LP] Get specific ini line and remove it
Reply With Quote #5

https://www.amxmodx.org/api/file/rename_file
KiLLeR. is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 04-17-2017 , 14:56   Re: [H3LP] Get specific ini line and remove it
Reply With Quote #6

Quote:
Originally Posted by KiLLeR. View Post
And I will be using delete_file to remove the file

Last edited by DarthMan; 04-17-2017 at 14:56.
DarthMan is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-17-2017 , 15:44   Re: [H3LP] Get specific ini line and remove it
Reply With Quote #7

If you have your bans saved in an array, you don't need to rename it. Delete it directly and rewrite it.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
DarthMan
Veteran Member
Join Date: Aug 2011
Old 04-17-2017 , 17:14   Re: [H3LP] Get specific ini line and remove it
Reply With Quote #8

Problem solved, ty guys

Last edited by DarthMan; 04-18-2017 at 04:53.
DarthMan is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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