AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Extern file] (https://forums.alliedmods.net/showthread.php?t=102353)

Mxnn 09-01-2009 09:50

[Extern file]
 
Yeah, again.
I'm trying to modifie a extern file created by me.
I used fopen to open the file, fprintf to wrote in the file and then i used fclose to close the file.

But my questin is, how to delete a part of the file?
:/

SnoW 09-01-2009 10:00

Re: [Extern file]
 
Something like:
PHP Code:

write_filesFileName""iLine ); 


Mxnn 09-01-2009 10:10

Re: [Extern file]
 
If i want to delete the var "name" i must to put something like this:
PHP Code:

write_filesFileName"%s",name iLine ); 

It's right?

SnoW 09-01-2009 10:14

Re: [Extern file]
 
No, that wouldn't work. First you can't format like that inside of the native. That native actually replaces the line you specify, and when you set the replacing string to "", the line is obviously emptyed. Somehow if you want to delete/change some specific string istead of some line, you should read the file, then delete everything you want and after that write it back to the file.

Mxnn 09-01-2009 10:20

Re: [Extern file]
 
But if i want to delete "pedrito" i have to put this:
PHP Code:

write_filesFileName"pedrito"iLine ); 

But if have to write a name write by a admin in her console i what i have to do?
How must to put a string to delete it?
</span></span>

SnoW 09-01-2009 10:24

Re: [Extern file]
 
I don't really understand you, but I already said that that doesn't work at all. What I were trying to say was that write_file replaces the line you specify with the text you pass.

Mxnn 09-01-2009 10:31

Re: [Extern file]
 
But how can i specify the line?
In the "" i must write the text that i want to replace or the text that i put in replace of the other?
I don't understand.. if you can put an example it would better.

EX: If i wan't to delete "pedrito" how can i put?
And then, if i want to delete the variable "name".. =(!

SnoW 09-01-2009 10:41

Re: [Extern file]
 
To empty a specific line, use stock:
PHP Code:

empty_linefile_name[ ], line )
     
write_filefile_name""line ); 

If you want to remove some word from the file:
1. Read the file to memory.
2. Empty things you want. Natives for that exist already.
3. Write the modified text to the file.

Mxnn 09-01-2009 10:49

Re: [Extern file]
 
AAAAAAAAAAAAAAA i don't understand!.

I'm stupid sorry, jajaja,.
Look, i have to delete the word "pedro".
I have to put:
PHP Code:

empty_linefile_name[ ], line )
     
write_filefile_name"pedrito"line ); 

?

Or
PHP Code:

empty_linefile_name[ ], pedrito )
     
write_filefile_name""pedrito ); 

?

And if i have to delete the var "name" how i have to put?

Alucard^ 09-01-2009 11:55

Re: [Extern file]
 
I don't know about reading files, write files, etc... but, no... that is wrong...

PHP Code:

write_filefile_name"pedrito"line ); 

With this, you are writing the file to pedrito.... You should READ the file first, to search "pedrito" and then use like Snow said, the write_file:

PHP Code:

write_filefile_name""pedrito ); 

To read the file i dont know but maybe you have to use this read_file


All times are GMT -4. The time now is 15:07.

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